[vlc-devel] [PATCH] win32: use the same poll code as libcurl

Rémi Denis-Courmont remi at remlab.net
Sat Nov 28 15:16:36 CET 2015


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.

-- 
Rémi Denis-Courmont
http://www.remlab.net/



More information about the vlc-devel mailing list