[Libwebsockets] libuv loops from within lwsws plugins
andy at warmcat.com
Fri Jul 29 18:54:04 CEST 2016
On July 29, 2016 10:09:21 PM GMT+08:00, Dan White <dwhite at cafedemocracy.org> wrote:
>I've installed version 2.0.2 and created a test external plugin which
>creates it's own (default) libuv event loop, and seems to work with a
>simple libcurl test.
>Is this recommended from within the lwsws server or should I be using
>multiple loops and coordinating with lwsws's default loop?
What the provided plugins do (eg, dumb increment timer)
is use the lws loop from the public api lws_uv_getloop(), that's definitely the best way.
That way there's no locking issues when using lws apis from your handlers, lws events and your plugin events are all serialized together properly.
In addition lws allows its own loop to be passed in from other code already using libuv, so it can integrate directly, ie a foreign loop. If you use the lws loop your plugin will work under those conditions with the foreign loop, also without locking for lws apis or the foreign code.
Neither building the plugin out-of-tree, nor it being a plugin at all, makes any trouble for coming in on the lws loop.
>Libwebsockets mailing list
>Libwebsockets at ml.libwebsockets.org
More information about the Libwebsockets