[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:14:20 CEST 2015


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: <http://libwebsockets.org/pipermail/libwebsockets/attachments/20150530/43650f2d/attachment.html>


More information about the Libwebsockets mailing list