From 6e948d8750b7f038d485234d24005f56b8197e71 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 14 Oct 2013 11:34:08 +1100 Subject: [PATCH] Check for correct timeout error in cgsem_mswait --- util.c | 2 +- util.h | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/util.c b/util.c index 2de5c1ca..4c53df29 100644 --- a/util.c +++ b/util.c @@ -2472,7 +2472,7 @@ int _cgsem_mswait(cgsem_t *cgsem, int ms, const char *file, const char *func, co timeraddspec(&abs_timeout, &ts_now); ret = sem_timedwait(cgsem, &abs_timeout); - if (unlikely(ret && ret != ETIMEDOUT)) + if (unlikely(ret && !sock_timeout())) quitfrom(1, file, func, line, "Failed to sem_timedwait errno=%d cgsem=0x%p", errno, cgsem); return ret; } diff --git a/util.h b/util.h index 07860659..8127e784 100644 --- a/util.h +++ b/util.h @@ -20,6 +20,10 @@ { return (errno == EAGAIN || errno == EWOULDBLOCK); } + static inline bool sock_timeout(void) + { + return (errno == ETIMEDOUT); + } #elif defined WIN32 #include #include @@ -37,6 +41,10 @@ { return (WSAGetLastError() == WSAEWOULDBLOCK); } + static inline bool sock_timeout(void) + { + return (WSAGetLastError() == WSAETIMEDOUT); + } #ifndef SHUT_RDWR #define SHUT_RDWR SD_BOTH #endif