From ad99232f8c007178a2916a08cb2b6f8ce010a384 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Thu, 15 Dec 2016 08:33:53 +0800 Subject: [PATCH] client: if NULL protocol vhost same linked list entry Lws maintains a linked-list of wsi that are on the same vhost protocol... it walks it to perform ..._all_protocol() type apis. Client connections also participate in this list, but in the case the selected protocol is not given during negotation (a legal case where the server default protocol is selected) we missed adding the new ws negotiated client wsi to the list. This patch makes sure we add the wsi to the vhost protocols[0] list in that case. https://github.com/warmcat/libwebsockets/issues/716 --- lib/client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/client.c b/lib/client.c index 53c39292..045d87b2 100755 --- a/lib/client.c +++ b/lib/client.c @@ -621,6 +621,7 @@ lws_client_interpret_server_handshake(struct lws *wsi) * no protocol name to work from, * default to first protocol */ + n = 0; wsi->protocol = &wsi->vhost->protocols[0]; goto check_extensions; } @@ -665,7 +666,7 @@ lws_client_interpret_server_handshake(struct lws *wsi) goto bail2; } - +check_extensions: /* * stitch protocol choice into the vh protocol linked list * We always insert ourselves at the start of the list @@ -689,7 +690,6 @@ lws_client_interpret_server_handshake(struct lws *wsi) wsi->same_vh_protocol_next->same_vh_protocol_prev = &wsi->same_vh_protocol_next; -check_extensions: #ifndef LWS_NO_EXTENSIONS /* instantiate the accepted extensions */