Skip to content

Commit 9c9e9b5

Browse files
committed
Merge pull request #57 from frankeh/master
fix timebase used in _dispatch_semaphore_wait_slow leading to infinit…
2 parents a650657 + c265aa0 commit 9c9e9b5

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/semaphore.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ _dispatch_semaphore_wait_slow(dispatch_semaphore_t dsema,
380380
}
381381
#elif USE_FUTEX_SEM
382382
do {
383-
uint64_t nsec = _dispatch_time_to_nanoseconds(timeout);
383+
uint64_t nsec = _dispatch_timeout(timeout);
384384
_timeout.tv_sec = (typeof(_timeout.tv_sec))(nsec / NSEC_PER_SEC);
385385
_timeout.tv_nsec = (typeof(_timeout.tv_nsec))(nsec % NSEC_PER_SEC);
386386
ret = slowpath(_dispatch_futex_wait(&dsema->dsema_futex, &_timeout));
@@ -645,10 +645,9 @@ _dispatch_group_wait_slow(dispatch_semaphore_t dsema, dispatch_time_t timeout)
645645
}
646646
#elif USE_FUTEX_SEM
647647
do {
648-
// HF: check whether we need same timer as POSIX_SEM
649648
uint64_t nsec = _dispatch_timeout(timeout);
650-
_timeout.tv_sec = nsec / NSEC_PER_SEC;
651-
_timeout.tv_nsec = nsec % NSEC_PER_SEC;
649+
_timeout.tv_sec = (typeof(_timeout.tv_sec))(nsec / NSEC_PER_SEC);
650+
_timeout.tv_nsec = (typeof(_timeout.tv_nsec))(nsec % NSEC_PER_SEC);
652651
ret = slowpath(_dispatch_futex_wait(&dsema->dsema_futex, &_timeout));
653652
} while (ret == false && errno == EINTR);
654653

0 commit comments

Comments
 (0)