asserts log which
authorAndy Green <andy@warmcat.com>
Fri, 13 May 2016 02:59:44 +0000 (10:59 +0800)
committerAndy Green <andy@warmcat.com>
Fri, 13 May 2016 02:59:44 +0000 (10:59 +0800)
Signed-off-by: Andy Green <andy@warmcat.com>
lib/handshake.c
lib/libuv.c
lib/server.c
lib/service.c

index 2bda517..e109d6f 100644 (file)
@@ -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))
index 7216078..64e5a7e 100644 (file)
@@ -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)
index 6cd3e67..82ebc2d 100644 (file)
@@ -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,
index 03d2f5a..f6ad73a 100644 (file)
@@ -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;
                }