Return NULL if the handshake failed to complete,

libwebsocket_service_fd closes and frees the websocket in that case.
This commit is contained in:
David Galeano 2013-01-09 16:17:04 +08:00 committed by Andy Green
parent a3a97d1acc
commit 36750b84fd

View file

@ -138,9 +138,15 @@ struct libwebsocket *__libwebsocket_client_connect_2(
wsi->mode = LWS_CONNMODE_WS_CLIENT_ISSUE_HANDSHAKE;
pfd.fd = wsi->sock;
pfd.revents = POLLIN;
if (libwebsocket_service_fd(context, &pfd) < 0)
n = libwebsocket_service_fd(context, &pfd);
if (n < 0)
goto oom4;
if (n) /* returns 1 on failure after closing wsi */
return NULL;
return wsi;
oom4: