[vlc-devel] [PATCH 2/2] win32: thread: don't call WaitOnAddress if the deadline is reached

Steve Lhomme robux4 at ycbcr.xyz
Thu Aug 13 14:11:00 CEST 2020


Just return ETIMEDOUT directly.
---
 src/win32/thread.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/win32/thread.c b/src/win32/thread.c
index 77e4b27d4f5..255946913c6 100644
--- a/src/win32/thread.c
+++ b/src/win32/thread.c
@@ -289,8 +289,8 @@ int vlc_atomic_timedwait(void *addr, unsigned val, vlc_tick_t deadline)
         delay = deadline - vlc_tick_now();
 
         if (delay < 0)
-            ms = 0;
-        else if (delay >= VLC_TICK_FROM_MS(LONG_MAX))
+            break; // deadline passed
+        if (delay >= VLC_TICK_FROM_MS(LONG_MAX))
             ms = LONG_MAX;
         else
             ms = MS_FROM_VLC_TICK(delay);
@@ -314,8 +314,8 @@ int vlc_atomic_timedwait_daytime(void *addr, unsigned val, time_t deadline)
         delay = deadline - time(NULL);
 
         if (delay < 0)
-            ms = 0;
-        else if (delay >= (LONG_MAX / 1000))
+            break; // deadline passed
+        if (delay >= (LONG_MAX / 1000))
             ms = LONG_MAX;
         else
             ms = delay * 1000;
-- 
2.26.2



More information about the vlc-devel mailing list