Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c2db0d4

Browse files
committed
Use sleep by Arseny
1 parent d737c5d commit c2db0d4

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

multimaster.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -460,15 +460,18 @@ timestamp_t MtmGetCurrentTime(void)
460460

461461
void MtmSleep(timestamp_t interval)
462462
{
463-
struct timespec ts;
464-
struct timespec rem;
465-
ts.tv_sec = interval/USECS_PER_SEC;
466-
ts.tv_nsec = interval%USECS_PER_SEC*1000;
463+
timestamp_t waketm = MtmGetCurrentTime() + interval;
464+
for (;;)
465+
{
466+
timestamp_t sleepfor = waketm - MtmGetCurrentTime();
467467

468-
while (nanosleep(&ts, &rem) < 0) {
469-
Assert(errno == EINTR);
470-
CHECK_FOR_INTERRUPTS();
471-
ts = rem;
468+
pg_usleep(sleepfor);
469+
if (MtmGetCurrentTime() < waketm)
470+
{
471+
Assert(errno == EINTR);
472+
continue;
473+
}
474+
break;
472475
}
473476
}
474477

0 commit comments

Comments
 (0)