From 8cc3d05949b9c2750a5460488cac58c82174e85c Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 16 Apr 2014 08:21:45 -0700 Subject: Fix some almtx_ return values --- Alc/threads.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'Alc/threads.c') diff --git a/Alc/threads.c b/Alc/threads.c index 5361e649..1dece664 100644 --- a/Alc/threads.c +++ b/Alc/threads.c @@ -184,7 +184,10 @@ int almtx_timedlock(almtx_t *mtx, const struct timespec *ts) { DWORD now = timeGetTime(); if(now-start >= timelen) + { + ret = althrd_timedout; break; + } SwitchToThread(); } @@ -331,12 +334,20 @@ void almtx_destroy(almtx_t *mtx) int almtx_timedlock(almtx_t *mtx, const struct timespec *ts) { + int ret; + if(!mtx || !ts) return althrd_error; - if(pthread_mutex_timedlock(mtx, ts) != 0) - return althrd_busy; - return althrd_success; + ret = pthread_mutex_timedlock(mtx, ts); + switch(ret) + { + case 0: return althrd_success; + case ETIMEDOUT: return althrd_timedout; + case EAGAIN: + case EBUSY: return althrd_busy; + } + return althrd_error; } #endif -- cgit v1.2.3