summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2021-06-11 02:07:36 +0200
committerGravatar Nikias Bassen2021-06-11 02:07:36 +0200
commitef9d674a4812cf1e39b140a9937c0d07886c4275 (patch)
treeddcba51936eb5ec0a3b08617aa20b29e7f4d7978 /src
parent93bb30c682bdc984b9acced58e9a1268eefade15 (diff)
downloadlibimobiledevice-glue-ef9d674a4812cf1e39b140a9937c0d07886c4275.tar.gz
libimobiledevice-glue-ef9d674a4812cf1e39b140a9937c0d07886c4275.tar.bz2
thread(win32): Make sure cond_wait and cond_wait_timeout return a value
Diffstat (limited to 'src')
-rw-r--r--src/thread.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/thread.c b/src/thread.c
index dbe93c8..7dc968c 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -177,7 +177,13 @@ int cond_wait(cond_t* cond, mutex_t* mutex)
{
#ifdef WIN32
mutex_unlock(mutex);
- WaitForSingleObject(cond->sem, INFINITE);
+ DWORD res = WaitForSingleObject(cond->sem, INFINITE);
+ switch (res) {
+ case WAIT_OBJECT_0:
+ return 0;
+ default:
+ return -1;
+ }
#else
return pthread_cond_wait(cond, mutex);
#endif
@@ -187,7 +193,14 @@ int cond_wait_timeout(cond_t* cond, mutex_t* mutex, unsigned int timeout_ms)
{
#ifdef WIN32
mutex_unlock(mutex);
- WaitForSingleObject(cond->sem, timeout_ms);
+ DWORD res = WaitForSingleObject(cond->sem, timeout_ms);
+ switch (res) {
+ case WAIT_OBJECT_0:
+ case WAIT_TIMEOUT:
+ return 0;
+ default:
+ return -1;
+ }
#else
struct timespec ts;
struct timeval now;