aboutsummaryrefslogtreecommitdiff
path: root/src/backend/port/win32_latch.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/port/win32_latch.c')
-rw-r--r--src/backend/port/win32_latch.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/backend/port/win32_latch.c b/src/backend/port/win32_latch.c
index ee9526245fd..0e3aaeec69e 100644
--- a/src/backend/port/win32_latch.c
+++ b/src/backend/port/win32_latch.c
@@ -265,13 +265,16 @@ WaitLatchOrSocket(volatile Latch *latch, int wakeEvents, pgsocket sock,
elog(ERROR, "unexpected return code from WaitForMultipleObjects(): %lu", rc);
/* If we're not done, update cur_timeout for next iteration */
- if (result == 0 && cur_timeout != INFINITE)
+ if (result == 0 && (wakeEvents & WL_TIMEOUT))
{
INSTR_TIME_SET_CURRENT(cur_time);
INSTR_TIME_SUBTRACT(cur_time, start_time);
cur_timeout = timeout - (long) INSTR_TIME_GET_MILLISEC(cur_time);
- if (cur_timeout < 0)
- cur_timeout = 0;
+ if (cur_timeout <= 0)
+ {
+ /* Timeout has expired, no need to continue looping */
+ result |= WL_TIMEOUT;
+ }
}
} while (result == 0);