Skip to content

Commit 3e2dc99

Browse files
authored
Merge pull request #878 from etcwilde/ewilde/wake-me-up
POSIX: Keep original timeout from sleep call
2 parents 96ac07d + 322ba68 commit 3e2dc99

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/shims/lock.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,10 @@ _dispatch_sema4_timedwait(_dispatch_sema4_t *sema, dispatch_time_t timeout)
231231
struct timespec _timeout;
232232
int ret;
233233

234+
uint64_t nsec = _dispatch_time_nanoseconds_since_epoch(timeout);
235+
_timeout.tv_sec = (__typeof__(_timeout.tv_sec))(nsec / NSEC_PER_SEC);
236+
_timeout.tv_nsec = (__typeof__(_timeout.tv_nsec))(nsec % NSEC_PER_SEC);
234237
do {
235-
uint64_t nsec = _dispatch_time_nanoseconds_since_epoch(timeout);
236-
_timeout.tv_sec = (__typeof__(_timeout.tv_sec))(nsec / NSEC_PER_SEC);
237-
_timeout.tv_nsec = (__typeof__(_timeout.tv_nsec))(nsec % NSEC_PER_SEC);
238238
ret = sem_timedwait(sema, &_timeout);
239239
} while (unlikely(ret == -1 && errno == EINTR));
240240

0 commit comments

Comments
 (0)