From 792713f2c13192012db8d23320e11f127c919162 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Sun, 8 May 2016 17:10:38 +0800 Subject: [PATCH] client handle connection fail at second phase properly Signed-off-by: Andy Green --- lib/parsers.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/parsers.c b/lib/parsers.c index 95257e7..8af5079 100644 --- a/lib/parsers.c +++ b/lib/parsers.c @@ -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); -- 2.7.4