mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
lws_vhost_bind_wsi: avoid if already bound to same wsi
if wsi->vhost == vhost then it is already bound to that vhost. doubling binding causes a problem during shutdown by trashing the reference counting.
This commit is contained in:
parent
991241905c
commit
7019b56ec9
2 changed files with 8 additions and 5 deletions
|
@ -87,9 +87,12 @@ lws_client_connect_via_info(const struct lws_client_connect_info *i)
|
|||
wsi->pending_timeout = NO_PENDING_TIMEOUT;
|
||||
wsi->position_in_fds_table = LWS_NO_FDS_POS;
|
||||
wsi->c_port = i->port;
|
||||
wsi->vhost = i->vhost;
|
||||
if (!wsi->vhost)
|
||||
wsi->vhost = i->context->vhost_list;
|
||||
|
||||
wsi->vhost = NULL;
|
||||
if (!i->vhost)
|
||||
lws_vhost_bind_wsi(i->context->vhost_list, wsi);
|
||||
else
|
||||
lws_vhost_bind_wsi(i->vhost, wsi);
|
||||
|
||||
if (!wsi->vhost) {
|
||||
lwsl_err("%s: No vhost in the context\n", __func__);
|
||||
|
@ -97,8 +100,6 @@ lws_client_connect_via_info(const struct lws_client_connect_info *i)
|
|||
goto bail;
|
||||
}
|
||||
|
||||
lws_vhost_bind_wsi(wsi->vhost, wsi);
|
||||
|
||||
wsi->protocol = &wsi->vhost->protocols[0];
|
||||
wsi->client_pipeline = !!(i->ssl_connection & LCCSCF_PIPELINE);
|
||||
|
||||
|
|
|
@ -113,6 +113,8 @@ int lws_open(const char *__file, int __oflag, ...)
|
|||
void
|
||||
lws_vhost_bind_wsi(struct lws_vhost *vh, struct lws *wsi)
|
||||
{
|
||||
if (wsi->vhost == vh)
|
||||
return;
|
||||
wsi->vhost = vh;
|
||||
vh->count_bound_wsi++;
|
||||
lwsl_info("%s: vh %s: count_bound_wsi %d\n",
|
||||
|
|
Loading…
Add table
Reference in a new issue