From 97164368dddd478bc3ee6be127c78613cccd4e67 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Fri, 13 May 2016 10:27:48 +0800 Subject: [PATCH] asserts log which Signed-off-by: Andy Green --- 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 2bda517..e109d6f 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 7216078..64e5a7e 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 6a921a3..a3b512a 100644 --- a/lib/server.c +++ b/lib/server.c @@ -810,8 +810,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; @@ -1562,7 +1569,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 03d2f5a..f6ad73a 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; } -- 2.7.4