1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-16 00:00:07 +01:00
libwebsockets/lib/core
Andy Green ac3bd36c60 vhost_destroy: use vhost wsi reference counting to trigger destroy
This changes the vhost destroy flow to only hand off the listen
socket if another vhost sharing it, and mark the vhost as
being_destroyed.

Each tsi calls lws_check_deferred_free() once a second, if it sees
any vhost being_destroyed there, it closes all wsi on its tsi on
the same vhost, one time.

As the wsi on the vhost complete close (ie, after libuv async close
if on libuv event loop), they decrement a reference count for all
wsi open on the vhost.  The tsi who closes the last one then
completes the destroy flow for the vhost itself... it's random
which tsi completes the vhost destroy but since there are no
wsi left on the vhost, and it holds the context lock, nothing
can conflict.

The advantage of this is that owning tsi do the close for wsi
that are bound to the vhost under destruction, at a time when
they are guaranteed to be idle for service, and they do it with
both vhost and context locks owned, so no other service thread
can conflict for stuff protected by those either.

For the situation the user code may have allocations attached to
the vhost, this adds args to lws_vhost_destroy() to allow destroying
the user allocations just before the vhost is freed.
2018-06-18 09:11:46 +08:00
..
adopt.c vhost_destroy: use vhost wsi reference counting to trigger destroy 2018-06-18 09:11:46 +08:00
alloc.c refactor: core code in lib/core and private-libwebsockets.h to core/private.h 2018-05-03 10:49:36 +08:00
connect.c vhost_destroy: use vhost wsi reference counting to trigger destroy 2018-06-18 09:11:46 +08:00
context.c vhost_destroy: use vhost wsi reference counting to trigger destroy 2018-06-18 09:11:46 +08:00
libwebsockets.c vhost_destroy: use vhost wsi reference counting to trigger destroy 2018-06-18 09:11:46 +08:00
output.c udp: cast sendto payload to be compatible with windows perversions 2018-05-16 08:13:59 +08:00
pollfd.c refactor: split out adoption and client apis to core 2018-05-11 10:29:08 +08:00
private.h vhost_destroy: use vhost wsi reference counting to trigger destroy 2018-06-18 09:11:46 +08:00
service.c vhost_destroy: use vhost wsi reference counting to trigger destroy 2018-06-18 09:11:46 +08:00