[vlc-devel] [PATCH] win32/thread: avoid waking up every 50ms to see if the thread is canceled

Steve Lhomme robux4 at videolabs.io
Mon Jul 20 15:44:17 CEST 2015


On Mon, Jul 20, 2015 at 3:33 PM, Rémi Denis-Courmont <remi at remlab.net> wrote:
> Le 2015-07-20 16:23, Steve Lhomme a écrit :
>>
>> From: Steve Lhomme <robUx4 at gmail.com>
>>
>>
>> set the killEvent when we cancel the thread, which will wake up
>> vlc_WaitForMultipleObjects()
>> ---
>>  src/win32/thread.c | 41 ++++++++++++++++++++++++++---------------
>>  1 file changed, 26 insertions(+), 15 deletions(-)
>>
>> diff --git a/src/win32/thread.c b/src/win32/thread.c
>> index 39711b4..ed9fc72 100644
>> --- a/src/win32/thread.c
>> +++ b/src/win32/thread.c
>> @@ -49,10 +49,10 @@ static vlc_cond_t  super_variable;
>>  static bool isCancelled(void);
>>  #endif
>>
>> -static DWORD vlc_WaitForMultipleObjects (DWORD count, const HANDLE
>> *handles,
>> +static DWORD vlc_WaitForMultipleObjects (DWORD count, HANDLE handle,
>>                                           DWORD delay)
>>  {
>> -    DWORD ret;
>> +    DWORD ret = WAIT_FAILED;
>>      if (count == 0)
>>      {
>>  #if VLC_WINSTORE_APP
>> @@ -73,20 +73,16 @@ static DWORD vlc_WaitForMultipleObjects (DWORD
>> count, const HANDLE *handles,
>>          if (ret == 0)
>>              ret = WAIT_TIMEOUT;
>>      }
>> -    else {
>> +    else if (count == 1 && handle != NULL)
>
>
> What if count is not one?
> What is "handle != NULL" for?

`ret` is initialized to WAIT_FAILED so at the end of the `else` it
will consider there's an invalid call and crash.

> What if poll() is used?

I don't know what poll does.

> More importantly, this fix is likely in vain given that vlc_cond_broadcast()
> is broken on Windows (not only WinRT).

Well, it works better than the old patch we had in place which was deadlocking.


On Mon, Jul 20, 2015 at 3:33 PM, Rémi Denis-Courmont <remi at remlab.net> wrote:
> Le 2015-07-20 16:23, Steve Lhomme a écrit :
>>
>> From: Steve Lhomme <robUx4 at gmail.com>
>>
>>
>> set the killEvent when we cancel the thread, which will wake up
>> vlc_WaitForMultipleObjects()
>> ---
>>  src/win32/thread.c | 41 ++++++++++++++++++++++++++---------------
>>  1 file changed, 26 insertions(+), 15 deletions(-)
>>
>> diff --git a/src/win32/thread.c b/src/win32/thread.c
>> index 39711b4..ed9fc72 100644
>> --- a/src/win32/thread.c
>> +++ b/src/win32/thread.c
>> @@ -49,10 +49,10 @@ static vlc_cond_t  super_variable;
>>  static bool isCancelled(void);
>>  #endif
>>
>> -static DWORD vlc_WaitForMultipleObjects (DWORD count, const HANDLE
>> *handles,
>> +static DWORD vlc_WaitForMultipleObjects (DWORD count, HANDLE handle,
>>                                           DWORD delay)
>>  {
>> -    DWORD ret;
>> +    DWORD ret = WAIT_FAILED;
>>      if (count == 0)
>>      {
>>  #if VLC_WINSTORE_APP
>> @@ -73,20 +73,16 @@ static DWORD vlc_WaitForMultipleObjects (DWORD
>> count, const HANDLE *handles,
>>          if (ret == 0)
>>              ret = WAIT_TIMEOUT;
>>      }
>> -    else {
>> +    else if (count == 1 && handle != NULL)
>
>
> What if count is not one?
> What is "handle != NULL" for?
> What if poll() is used?
>
> More importantly, this fix is likely in vain given that vlc_cond_broadcast()
> is broken on Windows (not only WinRT).
>
> --
> 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