File tree 2 files changed +23
-18
lines changed
src/backend/access/transam 2 files changed +23
-18
lines changed Original file line number Diff line number Diff line change @@ -460,15 +460,18 @@ timestamp_t MtmGetCurrentTime(void)
460
460
461
461
void MtmSleep (timestamp_t interval )
462
462
{
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 () ;
467
467
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 ;
472
475
}
473
476
}
474
477
Original file line number Diff line number Diff line change @@ -152,17 +152,19 @@ dtm_get_current_time()
152
152
static void
153
153
dtm_sleep (timestamp_t interval )
154
154
{
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
+ for (;;)
162
157
{
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 ;
166
168
}
167
169
}
168
170
You can’t perform that action at this time.
0 commit comments