aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/support/sync_posix.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/support/sync_posix.c')
-rw-r--r--src/core/support/sync_posix.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/core/support/sync_posix.c b/src/core/support/sync_posix.c
index 7f0e4a95a4..a28a4c6bf4 100644
--- a/src/core/support/sync_posix.c
+++ b/src/core/support/sync_posix.c
@@ -33,11 +33,17 @@
/* Posix gpr synchroization support code. */
+#if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 199309L
+#undef _POSIX_C_SOURCE
+#define _POSIX_C_SOURCE 199309L
+#endif
+
#include <grpc/support/port_platform.h>
#ifdef GPR_POSIX_SYNC
#include <errno.h>
+#include <time.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
@@ -67,7 +73,10 @@ int gpr_cv_wait(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline) {
if (gpr_time_cmp(abs_deadline, gpr_inf_future) == 0) {
err = pthread_cond_wait(cv, mu);
} else {
- err = pthread_cond_timedwait(cv, mu, &abs_deadline);
+ struct timespec abs_deadline_ts;
+ abs_deadline_ts.tv_sec = abs_deadline.tv_sec;
+ abs_deadline_ts.tv_nsec = abs_deadline.tv_nsec;
+ err = pthread_cond_timedwait(cv, mu, &abs_deadline_ts);
}
GPR_ASSERT(err == 0 || err == ETIMEDOUT || err == EAGAIN);
return err == ETIMEDOUT;