mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
smp: hold pt lock for lws_client_reset removing fds
https://github.com/warmcat/libwebsockets/issues/2268
This commit is contained in:
parent
eeed0c07d0
commit
b28b03eee1
2 changed files with 7 additions and 0 deletions
|
@ -351,6 +351,8 @@ __insert_wsi_socket_into_fds(struct lws_context *context, struct lws *wsi)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* requires pt lock */
|
||||
|
||||
int
|
||||
__remove_wsi_socket_from_fds(struct lws *wsi)
|
||||
{
|
||||
|
|
|
@ -1525,6 +1525,7 @@ struct lws *
|
|||
lws_client_reset(struct lws **pwsi, int ssl, const char *address, int port,
|
||||
const char *path, const char *host, char weak)
|
||||
{
|
||||
struct lws_context_per_thread *pt;
|
||||
#if defined(LWS_ROLE_WS)
|
||||
struct _lws_websocket_related *ws;
|
||||
#endif
|
||||
|
@ -1537,6 +1538,7 @@ lws_client_reset(struct lws **pwsi, int ssl, const char *address, int port,
|
|||
return NULL;
|
||||
|
||||
wsi = *pwsi;
|
||||
pt = &wsi->a.context->pt[(int)wsi->tsi];
|
||||
|
||||
lwsl_debug("%s: %s: redir %d: %s\n", __func__, lws_wsi_tag(wsi),
|
||||
wsi->redirects, address);
|
||||
|
@ -1608,7 +1610,10 @@ lws_client_reset(struct lws **pwsi, int ssl, const char *address, int port,
|
|||
lwsl_info("redirect ads='%s', port=%d, path='%s', ssl = %d, pifds %d\n",
|
||||
address, port, path, ssl, wsi->position_in_fds_table);
|
||||
|
||||
lws_pt_lock(pt, __func__);
|
||||
__remove_wsi_socket_from_fds(wsi);
|
||||
lws_pt_unlock(pt);
|
||||
|
||||
#if defined(LWS_ROLE_WS)
|
||||
if (weak) {
|
||||
ws = wsi->ws;
|
||||
|
|
Loading…
Add table
Reference in a new issue