[Libwebsockets] Possible bug, ping/pong with polling on Windows seems to send pings too late

Casey Banner kcbanner at gmail.com
Thu Oct 8 20:43:01 CEST 2020

Thanks for such a quick response Andy!

I can confirm your latest changes indeed fix the issue! In my use case
we only open one socket at a time, so the fds aren't an issue for us.


On Thu, Oct 8, 2020 at 10:16 AM Andy Green <andy at warmcat.com> wrote:
> On 10/8/20 4:18 AM, Casey Banner wrote:
> > Perhaps this is a problem specifically on windows with this polling model?
> > I could also just use the scheduler to wake up and send pings (without
> > using the retry functionality at all). Also, if I've misunderstood how
> > the system is supposed to work, let me know.
> No you seem to have the right ideas.
> The fd event handling for windows platform is wrong, I pushed a patch
> aligning it to how events are used in the ms examples about it.  That
> has a lot of history, originally it was contributed and various people
> hacked on it, since then I have my own windows VM and run lws-based CI
> locally on it, so over the last 6 months or so windows support has
> improved a lot, since I use it myself.  It's just the event reporting
> causing wakes impacted, since there were hacks to make everything else
> work if something else was waking it.
> WSA needs an event per fd, I added this, but it's limited to 64 events
> with one reserved for lws_cancel_service(), so 63 fds.  WSA basically
> does not know how to do POSIX POLLOUT, it reports an event when
> "blocking for write is no longer the case", not when you may write.  I
> added support for that with detection of blocking each time in the
> service code, since if we waited until we did the work to do the write,
> it's too late.
> I confirmed the changes work with the minimal examples,
> lws_cancel_service etc, please give current lws master a try.  And it
> fixes a recent lws_cancel_service() related problem for
> lws-api-test-lws_smd on windows so CI is back to green again.
> If you need more fds, look to libuv which is also supported and no doubt
> does a better job than the default roll-your-own implementation.
> -Andy

More information about the Libwebsockets mailing list