aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/support
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/support')
-rw-r--r--src/core/support/sync_win32.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/core/support/sync_win32.c b/src/core/support/sync_win32.c
index eadaa970c9..b2e922565f 100644
--- a/src/core/support/sync_win32.c
+++ b/src/core/support/sync_win32.c
@@ -83,6 +83,7 @@ void gpr_cv_destroy(gpr_cv *cv) {
int gpr_cv_wait(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline) {
int timeout = 0;
+ DWORD timeout_max_ms;
if (gpr_time_cmp(abs_deadline, gpr_inf_future) == 0) {
SleepConditionVariableCS(cv, &mu->cs, INFINITE);
} else {
@@ -93,9 +94,9 @@ int gpr_cv_wait(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline) {
if (now_ms >= deadline_ms) {
timeout = 1;
} else {
- timeout =
- (SleepConditionVariableCS(cv, &mu->cs, deadline_ms - now_ms) == 0 &&
- GetLastError() == ERROR_TIMEOUT);
+ timeout_max_ms = (DWORD)min(deadline_ms - now_ms, INFINITE - 1);
+ timeout = (SleepConditionVariableCS(cv, &mu->cs, timeout_max_ms) == 0 &&
+ GetLastError() == ERROR_TIMEOUT);
}
}
return timeout;