client handle connection fail at second phase properly
authorAndy Green <andy@warmcat.com>
Sun, 8 May 2016 09:10:38 +0000 (17:10 +0800)
committerAndy Green <andy@warmcat.com>
Sun, 8 May 2016 09:10:38 +0000 (17:10 +0800)
Signed-off-by: Andy Green <andy@warmcat.com>
lib/parsers.c

index 95257e70a4a1e316e1a23feec10080595e19d901..8af5079d1485de42ae54bf15d5f61c4d0a98a5d5 100644 (file)
@@ -187,7 +187,11 @@ reset:
 
 #ifndef LWS_NO_CLIENT
        if (wsi->state == LWSS_CLIENT_UNCONNECTED)
-               lws_client_connect_via_info2(wsi);
+               if (!lws_client_connect_via_info2(wsi))
+                       /* our client connect has failed, the wsi
+                        * has been closed
+                        */
+                       return -1;
 #endif
 
        return 0;
@@ -300,7 +304,14 @@ int lws_header_table_detach(struct lws *wsi, int autoservice)
 
 #ifndef LWS_NO_CLIENT
        if (wsi->state == LWSS_CLIENT_UNCONNECTED)
-               lws_client_connect_via_info2(wsi);
+               if (!lws_client_connect_via_info2(wsi)) {
+                       /* our client connect has failed, the wsi
+                        * has been closed
+                        */
+                       lws_pt_unlock(pt);
+
+                       return -1;
+               }
 #endif
 
        assert(!!pt->ah_wait_list_length == !!(int)(long)pt->ah_wait_list);