From 9c0cc42707b16eb67e1719d52c15246526a80a91 Mon Sep 17 00:00:00 2001
From: Andy Green <andy@warmcat.com>
Date: Fri, 13 May 2016 10:59:44 +0800
Subject: [PATCH] asserts log which

Signed-off-by: Andy Green <andy@warmcat.com>
---
 lib/handshake.c |  6 ++++--
 lib/libuv.c     |  7 +++++--
 lib/server.c    | 18 +++++++++++++++---
 lib/service.c   |  5 ++++-
 4 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/lib/handshake.c b/lib/handshake.c
index 2bda5174..e109d6f6 100644
--- a/lib/handshake.c
+++ b/lib/handshake.c
@@ -107,8 +107,10 @@ lws_read(struct lws *wsi, unsigned char *buf, size_t len)
 		wsi->u.hdr.lextable_pos = 0;
 		/* fallthru */
 	case LWSS_HTTP_HEADERS:
-		
-		assert(wsi->u.hdr.ah);
+		if (!wsi->u.hdr.ah) {
+			lwsl_err("%s: LWSS_HTTP_HEADERS: NULL ah\n", __func__);
+			assert(0);
+		}
 		lwsl_parser("issuing %d bytes to parser\n", (int)len);
 
 		if (lws_handshake_client(wsi, &buf, len))
diff --git a/lib/libuv.c b/lib/libuv.c
index 7216078e..64e5a7ed 100644
--- a/lib/libuv.c
+++ b/lib/libuv.c
@@ -308,8 +308,11 @@ lws_libuv_io(struct lws *wsi, int flags)
 		return;
 	}
 
-	assert((flags & (LWS_EV_START | LWS_EV_STOP)) &&
-	       (flags & (LWS_EV_READ | LWS_EV_WRITE)));
+	if (!((flags & (LWS_EV_START | LWS_EV_STOP)) &&
+	      (flags & (LWS_EV_READ | LWS_EV_WRITE)))) {
+		lwsl_err("%s: assert: flags %d", __func__, flags);
+		assert(0);
+	}
 
 	if (flags & LWS_EV_START) {
 		if (flags & LWS_EV_WRITE)
diff --git a/lib/server.c b/lib/server.c
index 6cd3e676..82ebc2de 100644
--- a/lib/server.c
+++ b/lib/server.c
@@ -753,8 +753,15 @@ lws_handshake_server(struct lws *wsi, unsigned char **buf, size_t len)
 	char protocol_name[32];
 	char *p;
 
-	assert(len < 10000000);
-	assert(wsi->u.hdr.ah);
+	if (len >= 10000000) {
+		lwsl_err("%s: assert: len %ld\n", __func__, (long)len);
+		assert(0);
+	}
+
+	if (!wsi->u.hdr.ah) {
+		lwsl_err("%s: assert: NULL ah\n", __func__);
+		assert(0);
+	}
 
 	while (len--) {
 		wsi->more_rx_waiting = !!len;
@@ -1504,7 +1511,12 @@ lws_server_socket_service(struct lws_context *context, struct lws *wsi,
 					goto try_pollout;
 				}
 			}
-			assert(ah->rxpos != ah->rxlen && ah->rxlen);
+			if (!(ah->rxpos != ah->rxlen && ah->rxlen)) {
+				lwsl_err("%s: assert: rxpos %d, rxlen %d\n",
+					 __func__, ah->rxpos, ah->rxlen);
+
+				assert(0);
+			}
 			/* just ignore incoming if waiting for close */
 			if (wsi->state != LWSS_FLUSHING_STORED_SEND_BEFORE_CLOSE) {
 				n = lws_read(wsi, ah->rx + ah->rxpos,
diff --git a/lib/service.c b/lib/service.c
index 03d2f5aa..f6ad73a2 100644
--- a/lib/service.c
+++ b/lib/service.c
@@ -408,7 +408,10 @@ lws_service_adjust_timeout(struct lws_context *context, int timeout_ms, int tsi)
 	for (n = 0; n < context->max_http_header_pool; n++)
 		if (pt->ah_pool[n].rxpos != pt->ah_pool[n].rxlen) {
 			/* any ah with pending rx must be attached to someone */
-			assert(pt->ah_pool[n].wsi);
+			if (!pt->ah_pool[n].wsi) {
+				lwsl_err("%s: assert: no wsi attached to ah\n", __func__);
+				assert(0);
+			}
 			return 0;
 		}
 
-- 
GitLab