[vlc-devel] [PATCH] win32: use the same poll code as libcurl
Steve Lhomme
robux4 at gmail.com
Mon Nov 30 10:44:39 CET 2015
On Sat, Nov 28, 2015 at 3:16 PM, Rémi Denis-Courmont <remi at remlab.net> wrote:
> On Thursday 26 November 2015 16:43:15 Steve Lhomme wrote:
>> A workaround is to close the httpd
>> connection before joining the thread that's doing the listening. But
>> that should be done in other places too that assume select() is
>> alertable.
>
> No. Closing a file descriptor in use by another thread is not portable, and it
> is intrinsically racy:
>
> - Owner thread calls closesocket().
> - Polling thread calls select().
> -> gets EBADF.
>
> Or worse:
>
> - Owner thread calls closesocket().
> - Unrelated thread create a new socket, gets the same handle.
> - Owner thread calls join().
> - Polling thread calls select().
> -> Polling thread waits on an innocent socket.
> -> Owner thread jams.
>
>> Is there a reason we mix select() and WSAEventSelect() in the current
>> master ?
>
> AFAIR without the select() call, the poll() level-triggered semantics are not
> abode by so events sometimes can get lost depending on the call site.
I understand the code better now. I wonder if there's a race issue
between the moment we call select() and the moment we call
WSAEnumNetworkEvents() or some of the further WSA calls. If I add
enough logs in poll(), effectively extending the time between calls, I
do not get the issue I'm having anymore. Otherwise I get the issue
100% of the time.
> --
> Rémi Denis-Courmont
> http://www.remlab.net/
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list