[vlc-devel] [PATCH 1/2] win32: add cancel functions to be called in the APC
Steve Lhomme
robux4 at gmail.com
Mon Jan 18 09:50:14 CET 2016
On Mon, Jan 18, 2016 at 9:28 AM, Steve Lhomme <robux4 at gmail.com> wrote:
> On Sun, Jan 17, 2016 at 2:36 PM, Rémi Denis-Courmont <remi at remlab.net> wrote:
>> On Sunday 17 January 2016 14:17:47 Steve Lhomme wrote:
>>> On Sat, Jan 16, 2016 at 6:34 PM, Rémi Denis-Courmont <remi at remlab.net>
>> wrote:
>>> > On Friday 15 January 2016 17:16:21 Steve Lhomme wrote:
>>> >> --
>>> >> this is going to be useful to cancel socket tasks that are not alertable
>>> >
>>> > That makes no sense. If the waiting function cannot be alerted, the
>>> > asynchronous procedure callback won´t be invoked. We already have
>>> > cancellation cleanup handlers then.
>>>
>>> Maybe I did not use the right term. select() does let the cancel APC
>>> run. But unlike WSAWaitForMultipleEvents(), it doesn't exit (with
>>> WSA_WAIT_IO_COMPLETION) when after the APC is run. So the infinite
>>> wait just sits there.
>>>
>>> That's why in patch 2/2 I use an extra UDP socket that is canceled
>>> during the APC, thus making select() exit as we want.
>>
>> Winsock is not supposed to be re-entrant, so this is undefined.
>
> I tried to find information on this and found nothing. But since such
> information may be bogus I tested the code and it works on XP SP3 and
> W10. I assume it should also work in the versions in between.
>
>> Besides, INET sockets bring a variety of failure cases that make them
>> unsuitable as a reliable intra-process wake-up mechanism.
>>
>>> This seems to be
>>> a common solution:
>>> http://stackoverflow.com/questions/3333361/how-to-cancel-waiting-in-select-o
>>> n-windows
>>
>> Just FYI, stackoverflow.com is not exactly what I would call a reliable source
>> of information. Regardless, that page suggests calling send() from *another*
>> thread. Big deal.
>
> I can also try that.
The problem is that the cleaners we already have are executed once the
thread is canceled. So we would need hooks to call when calling
vlc_cancel() and it needs to be thread safe. That's a lot more complex
than what I propose and works.
>> --
>> 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