fix stop failed when changing system time
This commit is contained in:
@ -423,6 +423,8 @@ int WaitLatchOrSocket(volatile Latch* latch, int wakeEvents, pgsocket sock, long
|
||||
cur_timeout = timeout - (long)INSTR_TIME_GET_MILLISEC(cur_time);
|
||||
if (cur_timeout < 0) {
|
||||
cur_timeout = 0;
|
||||
} else if (cur_timeout > timeout) {
|
||||
cur_timeout = timeout;
|
||||
}
|
||||
|
||||
#ifndef HAVE_POLL
|
||||
|
||||
@ -238,7 +238,7 @@ void WalWriterAuxiliaryMain(void)
|
||||
}
|
||||
}
|
||||
|
||||
rc = WaitLatch(&t_thrd.proc->procLatch, WL_TIMEOUT | WL_POSTMASTER_DEATH, cur_timeout);
|
||||
rc = WaitLatch(&t_thrd.proc->procLatch, WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH, cur_timeout);
|
||||
|
||||
if (rc & WL_POSTMASTER_DEATH) {
|
||||
gs_thread_exit(1);
|
||||
|
||||
@ -174,11 +174,12 @@ static void delay_control(TimestampTz last_send_time)
|
||||
TimestampTz now = GetCurrentTimestamp();
|
||||
TimestampTz timeout = TimestampTzPlusMilliseconds(last_send_time, u_sess->attr.attr_common.dn_heartbeat_interval);
|
||||
TimestampDifference(now, timeout, &secs, µsecs);
|
||||
Assert(secs <= u_sess->attr.attr_common.dn_heartbeat_interval);
|
||||
|
||||
/* If has exceeded send_interval, don't delay. */
|
||||
if (secs == 0 && microsecs == 0) {
|
||||
return;
|
||||
} else if (secs > u_sess->attr.attr_common.dn_heartbeat_interval) {
|
||||
secs = u_sess->attr.attr_common.dn_heartbeat_interval;
|
||||
}
|
||||
|
||||
pg_usleep(secs * USECS_PER_SEC + microsecs);
|
||||
|
||||
Reference in New Issue
Block a user