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
This commit is contained in:
Andy Green 2016-12-15 08:33:53 +08:00
parent 023ac896e9
commit ad99232f8c

View file

@ -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 */