Skip to content
Snippets Groups Projects
Commit b84f3e50 authored by Diana Ren's avatar Diana Ren Committed by Andy Green
Browse files

Backport e02a9998 into v2.4 with dependent changes included

parent 5ebc982c
Branches
No related tags found
No related merge requests found
...@@ -424,6 +424,7 @@ oom4: ...@@ -424,6 +424,7 @@ oom4:
goto failed1; goto failed1;
lws_remove_from_timeout_list(wsi); lws_remove_from_timeout_list(wsi);
lws_header_table_detach(wsi, 0); lws_header_table_detach(wsi, 0);
lws_client_stash_destroy(wsi);
lws_free(wsi); lws_free(wsi);
return NULL; return NULL;
...@@ -683,6 +684,15 @@ html_parser_cb(const hubbub_token *token, void *pw) ...@@ -683,6 +684,15 @@ html_parser_cb(const hubbub_token *token, void *pw)
} }
#endif #endif
void
lws_client_stash_destroy(struct lws *wsi)
{
if (!wsi || !wsi->u.hdr.stash)
return;
lws_free_set_NULL(wsi->u.hdr.stash);
}
LWS_VISIBLE struct lws * LWS_VISIBLE struct lws *
lws_client_connect_via_info(struct lws_client_connect_info *i) lws_client_connect_via_info(struct lws_client_connect_info *i)
{ {
...@@ -763,7 +773,7 @@ lws_client_connect_via_info(struct lws_client_connect_info *i) ...@@ -763,7 +773,7 @@ lws_client_connect_via_info(struct lws_client_connect_info *i)
wsi->u.hdr.stash = lws_malloc(sizeof(*wsi->u.hdr.stash), "client stash"); wsi->u.hdr.stash = lws_malloc(sizeof(*wsi->u.hdr.stash), "client stash");
if (!wsi->u.hdr.stash) { if (!wsi->u.hdr.stash) {
lwsl_err("%s: OOM\n", __func__); lwsl_err("%s: OOM\n", __func__);
goto bail; goto bail1;
} }
wsi->u.hdr.stash->origin[0] = '\0'; wsi->u.hdr.stash->origin[0] = '\0';
...@@ -777,6 +787,7 @@ lws_client_connect_via_info(struct lws_client_connect_info *i) ...@@ -777,6 +787,7 @@ lws_client_connect_via_info(struct lws_client_connect_info *i)
sizeof(wsi->u.hdr.stash->path) - 1); sizeof(wsi->u.hdr.stash->path) - 1);
strncpy(wsi->u.hdr.stash->host, i->host, strncpy(wsi->u.hdr.stash->host, i->host,
sizeof(wsi->u.hdr.stash->host) - 1); sizeof(wsi->u.hdr.stash->host) - 1);
if (i->origin) if (i->origin)
strncpy(wsi->u.hdr.stash->origin, i->origin, strncpy(wsi->u.hdr.stash->origin, i->origin,
sizeof(wsi->u.hdr.stash->origin) - 1); sizeof(wsi->u.hdr.stash->origin) - 1);
...@@ -810,7 +821,7 @@ lws_client_connect_via_info(struct lws_client_connect_info *i) ...@@ -810,7 +821,7 @@ lws_client_connect_via_info(struct lws_client_connect_info *i)
* if we failed here, the connection is already closed * if we failed here, the connection is already closed
* and freed. * and freed.
*/ */
goto bail1; goto bail2;
} }
if (i->parent_wsi) { if (i->parent_wsi) {
...@@ -829,10 +840,13 @@ lws_client_connect_via_info(struct lws_client_connect_info *i) ...@@ -829,10 +840,13 @@ lws_client_connect_via_info(struct lws_client_connect_info *i)
return wsi; return wsi;
bail1:
lws_client_stash_destroy(wsi);
bail: bail:
lws_free(wsi); lws_free(wsi);
bail1: bail2:
if (i->pwsi) if (i->pwsi)
*i->pwsi = NULL; *i->pwsi = NULL;
...@@ -886,7 +900,7 @@ lws_client_connect_via_info2(struct lws *wsi) ...@@ -886,7 +900,7 @@ lws_client_connect_via_info2(struct lws *wsi)
#if defined(LWS_WITH_SOCKS5) #if defined(LWS_WITH_SOCKS5)
if (!wsi->vhost->socks_proxy_port) if (!wsi->vhost->socks_proxy_port)
lws_free_set_NULL(wsi->u.hdr.stash); lws_client_stash_destroy(wsi);
#endif #endif
/* /*
... ...
......
...@@ -2113,6 +2113,9 @@ lws_handle_POLLOUT_event(struct lws *wsi, struct lws_pollfd *pollfd); ...@@ -2113,6 +2113,9 @@ lws_handle_POLLOUT_event(struct lws *wsi, struct lws_pollfd *pollfd);
LWS_EXTERN struct lws * LWS_EXTERN struct lws *
lws_client_connect_via_info2(struct lws *wsi); lws_client_connect_via_info2(struct lws *wsi);
LWS_EXTERN void
lws_client_stash_destroy(struct lws *wsi);
LWS_EXTERN int LWS_EXTERN int
_lws_destroy_ah(struct lws_context_per_thread *pt, struct allocated_headers *ah); _lws_destroy_ah(struct lws_context_per_thread *pt, struct allocated_headers *ah);
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment