[Libwebsockets] lws_cancel_service() and libev
andy at warmcat.com
Sun Feb 16 05:21:34 CET 2020
On February 15, 2020 10:58:57 PM GMT, Olivier Langlois <olivier at olivierlanglois.net> wrote:
>thx, for the prompt replies. I got a bad flu which basically forced me
>to rest for pretty much the whole sleep.
According to the news lately this was a good warmup for ncov-19...
>> ... I don't understand what you think is broken that this
>> 'fixes'. We already evidently cancelled the event loop wait since we
>> woke up and did the callback.
>If what I am saying isn't clear then maybe it is that the contract
>proposed by lws_service() isn't really understood by me and clarifying
>documentation about that could be useful.
>lws_service() never returns when a foreign loop is used. My
>expectation, and tell me if it is unreasonable, is that by calling
>lws_cancel_service() would wake up my service thread and make it return
>If calling lws_cancel_service() doesn't cancel the service, IMHO,
>something is wrong with that.
No nothing is wrong with it... the name is confusing you... if it was called lws_cancel_sleep() it would be clearer.
Its only goal is to wake from sleep ASAP and do the callback, then resume sleeping. When using a foreign event loop, lws is just an 'extra', he's not running any service loop he's just joining somebody else's one as a guest. He can't start making assumptions about what will happen if he actually breaks the shared event loop... it's not his code that would handle it.
By contrast all event libs including poll(), foreign or lws-owned loop, windows or osx or linux or rtos plat, get the same action from lws_cancel_service() as described, without affecting the event loop beyond creating an event on it.
More information about the Libwebsockets