Commit c9c39ac14db0cfe5224bbb150eb979e4701236af

Con Kolivas 2013-10-14T11:44:13

Give correct return code in cgsem_mswait

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
diff --git a/util.c b/util.c
index 4c53df2..8235b1c 100644
--- a/util.c
+++ b/util.c
@@ -2472,9 +2472,12 @@ 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 && !sock_timeout()))
+	if (ret) {
+		if (likely(sock_timeout()))
+			return ETIMEDOUT;
 		quitfrom(1, file, func, line, "Failed to sem_timedwait errno=%d cgsem=0x%p", errno, cgsem);
-	return ret;
+	}
+	return 0;
 }
 
 void _cgsem_destroy(cgsem_t *cgsem)