diff options
author | Marc Hoersken <info@marc-hoersken.de> | 2020-06-01 08:32:21 +0200 |
---|---|---|
committer | Marc Hoersken <info@marc-hoersken.de> | 2020-06-01 08:32:21 +0200 |
commit | 5325b92a0a3c2b29a4be03ed88c14972114774af (patch) | |
tree | 3fb1b3c289c07b6a04e64d32ef0d79e167766d7f /lib/select.c | |
parent | 8346c90b789e249e42cd1e9f4542f5c55a1cc917 (diff) | |
download | curl-5325b92a0a3c2b29a4be03ed88c14972114774af.tar.gz |
select: always use Sleep in Curl_wait_ms on Win32
Since Win32 almost always will also have USE_WINSOCK,
we can reduce complexity and always use Sleep there.
Assisted-by: Jay Satiro
Reviewed-by: Daniel Stenberg
Follow up to #5343
Closes #5489
Diffstat (limited to 'lib/select.c')
-rw-r--r-- | lib/select.c | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/lib/select.c b/lib/select.c index 08468216f..ca0e24fb1 100644 --- a/lib/select.c +++ b/lib/select.c @@ -86,16 +86,12 @@ int Curl_wait_ms(timediff_t timeout_ms) } #if defined(MSDOS) delay(timeout_ms); -#elif defined(USE_WINSOCK) +#elif defined(WIN32) /* prevent overflow, timeout_ms is typecast to ULONG/DWORD. */ -#if TIMEDIFF_T_MAX > ULONG_MAX - if(timeout_ms > ULONG_MAX) -#if ULONG_MAX < INFINITE - timeout_ms = ULONG_MAX; -#else +#if TIMEDIFF_T_MAX >= ULONG_MAX + if(timeout_ms >= ULONG_MAX) timeout_ms = ULONG_MAX-1; - /* avoid waiting forever */ -#endif + /* don't use ULONG_MAX, because that is equal to INFINITE */ #endif Sleep((ULONG)timeout_ms); #else @@ -119,14 +115,6 @@ int Curl_wait_ms(timediff_t timeout_ms) #endif pending_tv.tv_sec = (time_t)tv_sec; pending_tv.tv_usec = (suseconds_t)tv_usec; -#elif defined(WIN32) /* maybe also others in the future */ -#if TIMEDIFF_T_MAX > LONG_MAX - /* tv_sec overflow check on Windows there we know it is long */ - if(tv_sec > LONG_MAX) - tv_sec = LONG_MAX; -#endif - pending_tv.tv_sec = (long)tv_sec; - pending_tv.tv_usec = (long)tv_usec; #else #if TIMEDIFF_T_MAX > INT_MAX /* tv_sec overflow check in case time_t is signed */ |