From cf8b922df52730efadfbc794239ca214f2c9afba Mon Sep 17 00:00:00 2001 From: Andy Green Date: Thu, 15 Dec 2016 08:38:35 +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 6af36c8f..7d91c1f8 100755 --- a/lib/client.c +++ b/lib/client.c @@ -608,6 +608,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; } @@ -652,7 +653,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 @@ -676,7 +677,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 */