From b5cf69fdb57c4025572cde1007e0ff16108d4f80 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Sun, 18 Oct 2015 18:47:37 +0800 Subject: [PATCH] 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 --- lib/client-handshake.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/client-handshake.c b/lib/client-handshake.c index 7293a410..0623f519 100644 --- a/lib/client-handshake.c +++ b/lib/client-handshake.c @@ -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;