correct error handling path in client handshake

After Vikas Gahlan

http://ml.libwebsockets.org/pipermail/libwebsockets/2015-October/001955.html

Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
Andy Green 2015-10-18 18:47:37 +08:00
parent 74a54e8b94
commit b5cf69fdb5

View file

@ -155,6 +155,11 @@ struct libwebsocket *libwebsocket_client_connect_2(
if (insert_wsi_socket_into_fds(context, wsi))
goto oom4;
/*
* past here, we can't simply free the structs as error
* handling as oom4 does. We have to run the whole close flow.
*/
libwebsocket_set_timeout(wsi,
PENDING_TIMEOUT_AWAITING_CONNECT_RESPONSE,
AWAITING_TIMEOUT);
@ -219,7 +224,7 @@ struct libwebsocket *libwebsocket_client_connect_2(
* about the connect completion
*/
if (lws_change_pollfd(wsi, 0, LWS_POLLOUT))
goto oom4;
goto failed;
lws_libev_io(context, wsi, LWS_EV_START | LWS_EV_WRITE);
return wsi;