mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-30 00:00:16 +01:00
vhost: listen: protect listen port transfer between
...vhosts from vh destroy on zero refcount https://github.com/warmcat/libwebsockets/issues/2343
This commit is contained in:
parent
041baf93cf
commit
e90f005a10
1 changed files with 15 additions and 0 deletions
|
@ -1272,8 +1272,23 @@ lws_vhost_destroy1(struct lws_vhost *vh)
|
||||||
|
|
||||||
if (v->lserv_wsi) {
|
if (v->lserv_wsi) {
|
||||||
/* req cx + vh lock */
|
/* req cx + vh lock */
|
||||||
|
/*
|
||||||
|
* If the vhost sees it's being destroyed and
|
||||||
|
* in the unbind the number of wsis bound to
|
||||||
|
* it falls to zero, it will destroy the
|
||||||
|
* vhost opportunistically before we can
|
||||||
|
* complete the transfer. Add a fake wsi
|
||||||
|
* bind temporarily to disallow this...
|
||||||
|
*/
|
||||||
|
v->count_bound_wsi++;
|
||||||
__lws_vhost_unbind_wsi(vh->lserv_wsi);
|
__lws_vhost_unbind_wsi(vh->lserv_wsi);
|
||||||
lws_vhost_bind_wsi(v, v->lserv_wsi);
|
lws_vhost_bind_wsi(v, v->lserv_wsi);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ... remove the fake wsi bind
|
||||||
|
*/
|
||||||
|
v->count_bound_wsi--;
|
||||||
|
|
||||||
vh->lserv_wsi = NULL;
|
vh->lserv_wsi = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue