aboutsummaryrefslogtreecommitdiff
path: root/src/unix/thread.c
diff options
context:
space:
mode:
authorJohn Barboza <jbarboza@ca.ibm.com>2018-01-17 10:30:48 -0500
committerBen Noordhuis <info@bnoordhuis.nl>2018-02-15 16:15:23 +0100
commit1ded66908dba4fbd11e68471afbba17ac18361cd (patch)
tree2608c5bc3ba18a4c3962f16c40ff8351b1a3d89c /src/unix/thread.c
parent95e44dd46e5e2ae146a367759a6830eb51d49fc7 (diff)
downloadlibuv-1ded66908dba4fbd11e68471afbba17ac18361cd.tar.gz
libuv-1ded66908dba4fbd11e68471afbba17ac18361cd.zip
zos: fix timeout for condition variable
The pthread_cond_timedwait requires a timeout relative to the Epoch. So don't use uv__hrtime to set the timeout because it is relative to an arbitrary time in the past. Use gettimeofday instead. PR-URL: https://github.com/libuv/libuv/pull/1711 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Jamie Davis <davisjam@vt.edu>
Diffstat (limited to 'src/unix/thread.c')
-rw-r--r--src/unix/thread.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/unix/thread.c b/src/unix/thread.c
index 8229c275..3def2945 100644
--- a/src/unix/thread.c
+++ b/src/unix/thread.c
@@ -646,13 +646,22 @@ void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex) {
int uv_cond_timedwait(uv_cond_t* cond, uv_mutex_t* mutex, uint64_t timeout) {
int r;
struct timespec ts;
+#if defined(__MVS__)
+ struct timeval tv;
+#endif
#if defined(__APPLE__) && defined(__MACH__)
ts.tv_sec = timeout / NANOSEC;
ts.tv_nsec = timeout % NANOSEC;
r = pthread_cond_timedwait_relative_np(cond, mutex, &ts);
#else
+#if defined(__MVS__)
+ if (gettimeofday(&tv, NULL))
+ abort();
+ timeout += tv.tv_sec * NANOSEC + tv.tv_usec * 1e3;
+#else
timeout += uv__hrtime(UV_CLOCK_PRECISE);
+#endif
ts.tv_sec = timeout / NANOSEC;
ts.tv_nsec = timeout % NANOSEC;
#if defined(__ANDROID_API__) && __ANDROID_API__ < 21