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

Steve Lhomme robux4 at gmail.com
Thu Nov 26 16:43:15 CET 2015

I still have issues. With both codes...

The current git fails to see that a (non-blocking) socket can be
written to after a few calls (maybe when the TCP window becomes full
?). httpd just gets blocked after that point.

With the libcurl version (which uses plain select()) it works fine.
But then it's not alertable, so if for some reason there's an issue
with the receiver (I have a case I can reproduce) when closing VLC, we
get stuck in an infinite select(). 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

In fact the Microsoft doc says it
"When issuing a blocking Winsock call such as select with the timeout
parameter set to NULL, Winsock may need to wait for a network event
before the call can complete. Winsock performs an alertable wait in
this situation, which can be interrupted by an asynchronous procedure
call (APC) scheduled on the same thread. Issuing another blocking
Winsock call inside an APC that interrupted an ongoing blocking
Winsock call on the same thread will lead to undefined behavior, and
must never be attempted by Winsock clients. "

I can tell the APC is called in the right thread, but the select
doesn't gets out afterwards. But that means it could be possible to
push/pop some code to execute in vlc_cancel_self, a bit like

Is there a reason we mix select() and WSAEventSelect() in the current
master ? They seem to do the same. Although when I disable the code
using select() and rely only on WSAEventSelect and
WSAWaitForMultipleEvents the connection with the Chromecast doesn't go
far. It stops after the second read, waiting infinitely.

These issues are on Windows 10. I haven't tested on other versions of Windows.

On Tue, Oct 6, 2015 at 5:29 PM, Steve Lhomme <robux4 at gmail.com> wrote:
> On Tue, Oct 6, 2015 at 5:09 PM, Rémi Denis-Courmont <remi at remlab.net> wrote:
>> Le 2015-10-06 17:13, Steve Lhomme a écrit :
>>> the current code was occasionally not seeing some sockets available
>>> for reading
>> This looks like before 74337dd2 but with bugs added.
> What bugs ? It's exactly the libcurl code with unused code removed and
> style adapted. And it works way better than the previous code.
>> --
>> 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