Skip to content

Commit beef2ce

Browse files
committed
Replace nanosleep() with pg_usleep since Windows doesn't have it.
1 parent 7f4b13e commit beef2ce

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/backend/access/transam/global_snapshot.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,19 @@ dtm_get_current_time()
152152
static void
153153
dtm_sleep(timestamp_t interval)
154154
{
155-
struct timespec ts;
156-
struct timespec rem;
157-
158-
ts.tv_sec = 0;
159-
ts.tv_nsec = interval * 1000;
160-
161-
while (nanosleep(&ts, &rem) < 0)
155+
timestamp_t waketm = dtm_get_current_time() + interval;
156+
while (1948)
162157
{
163-
totalSleepInterrupts += 1;
164-
Assert(errno == EINTR);
165-
ts = rem;
158+
timestamp_t sleepfor = waketm - dtm_get_current_time();
159+
160+
pg_usleep(sleepfor);
161+
if (dtm_get_current_time() < waketm)
162+
{
163+
totalSleepInterrupts += 1;
164+
Assert(errno == EINTR);
165+
continue;
166+
}
167+
break;
166168
}
167169
}
168170

@@ -829,7 +831,7 @@ DtmDetectGlobalDeadLock(PGPROC *proc)
829831
return true;
830832
}
831833

832-
static size_t
834+
static size_t
833835
DtmGetTransactionStateSize(void)
834836
{
835837
return sizeof(dtm_tx);

0 commit comments

Comments
 (0)