diff --git a/lib/core-net/private-lib-core-net.h b/lib/core-net/private-lib-core-net.h index 3a3a19942..635d0d125 100644 --- a/lib/core-net/private-lib-core-net.h +++ b/lib/core-net/private-lib-core-net.h @@ -1102,7 +1102,7 @@ lws_client_connect_2_dnsreq(struct lws *wsi); LWS_VISIBLE struct lws * LWS_WARN_UNUSED_RESULT lws_client_reset(struct lws **wsi, int ssl, const char *address, int port, - const char *path, const char *host); + const char *path, const char *host, char weak); LWS_EXTERN struct lws * LWS_WARN_UNUSED_RESULT lws_create_new_server_wsi(struct lws_vhost *vhost, int fixed_tsi); diff --git a/lib/roles/http/client/client-handshake.c b/lib/roles/http/client/client-handshake.c index 15c8a6596..de50c34c8 100644 --- a/lib/roles/http/client/client-handshake.c +++ b/lib/roles/http/client/client-handshake.c @@ -959,8 +959,11 @@ static uint8_t hnames2[] = { */ struct lws * lws_client_reset(struct lws **pwsi, int ssl, const char *address, int port, - const char *path, const char *host) + const char *path, const char *host, char weak) { +#if defined(LWS_ROLE_WS) + struct _lws_websocket_related *ws; +#endif char *stash, *p; struct lws *wsi; size_t size = 0; @@ -1041,7 +1044,17 @@ lws_client_reset(struct lws **pwsi, int ssl, const char *address, int port, address, port, path, ssl, wsi->position_in_fds_table); __remove_wsi_socket_from_fds(wsi); +#if defined(LWS_ROLE_WS) + if (weak) { + ws = wsi->ws; + wsi->ws = NULL; + } +#endif __lws_reset_wsi(wsi); /* detaches ah here */ +#if defined(LWS_ROLE_WS) + if (weak) + wsi->ws = ws; +#endif wsi->client_pipeline = 1; /* close the connection by hand */ diff --git a/lib/roles/http/client/client-http.c b/lib/roles/http/client/client-http.c index d5192f4b7..84dc42eb7 100644 --- a/lib/roles/http/client/client-http.c +++ b/lib/roles/http/client/client-http.c @@ -893,7 +893,7 @@ lws_client_interpret_server_handshake(struct lws *wsi) goto bail3; } - if (!lws_client_reset(&wsi, ssl, ads, port, path, ads)) { + if (!lws_client_reset(&wsi, ssl, ads, port, path, ads, 1)) { /* * There are two ways to fail out with NULL return... * simple, early problem where the wsi is intact, or