[Libwebsockets] libwebsockets loses an event in the poll loop if another FD is closed during that iteration of the poll loop

Bruce Perens bruce at perens.com
Sat May 30 22:35:00 CEST 2015

I also see a call to libwebsocket_service_timeout_check() followed by
polldf->revents = 0;
That can cause the same problem. There may be others.

On Sat, May 30, 2015 at 1:14 PM, Bruce Perens <bruce at perens.com> wrote:

> Libwebsockets can lose an event in a poll loop, if another of the FDs in
> the poll FD array is closed during that iteration of the poll loop.
> At the end of* libsocket_service_fd()*,
> *libwebsocket_close_and_free_session()* causes a callback to the
> application with *LWS_CALLBACK_DEL_POLL_FD*. After that, it sets *pollfd->revents
> = 0;*
> But the application has changed the poll fd array in response to
> *LWS_CALLBACK_DEL_POLL_FD*, and *pollfd* now points to different data
> than it previously did. Thus, *revents* is zeroed for the wrong FD.
> The symptom of this is that poll() returns a positive integer, and the
> number of FDs with revents set is less than the value poll() returned.
>     Thanks
>     Bruce
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20150530/1686ca12/attachment-0001.html>

More information about the Libwebsockets mailing list