[Libwebsockets] Bug? LWS-native poll() amidst custom polls

andy at warmcat.com andy at warmcat.com
Thu Jun 24 03:52:44 CEST 2021



On June 24, 2021 12:07:24 AM UTC, Felipe Gasper <felipe at felipegasper.com> wrote:
>Hello,
>
>	I’m working on a Perl binding to LWS
>(https://github.com/FGasper/p5-Net-Libwebsockets … very much under
>construction still!) and am seeing some weirdness where LWS still runs
>its native poll() even though there is a custom event loop configured.
>
>	I’m attaching a Linux strace: you can see poll() amidst _newselect()
>calls. Note the last in particular, where it waits 30 seconds … this is
>the retry.secs_since_valid_hangup.
>
>	I’m inclined to think this is a LWS bug since “mixed” polling seems
>like it shouldn’t happen, but just in case … is it possible I’m
>“holding it wrong”?

strace is a bit circumstantial... put an assert() on lws default poll() usage and see if that is actually involved.

Strace is oblique enough that you might be seeing eg, libc blocking getaddrinfo() internal implementation or something else.  30s wait is what you might get on misconfigured dns resolver lookup.

So good idea to remove this ambiguity before specifically pointing at default poll loop.

Also these newselects seem to be spinning rather than idling, if it's just reflects development didn't address it yet then no problem, but a real implementation should pick a big timeout number and ask lws to shrink it before entering the wait as shown in the minimal example.

-Andy



More information about the Libwebsockets mailing list