Skip to content

fix timebase used in _dispatch_semaphore_wait_slow leading to infinit… #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 29, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/semaphore.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ _dispatch_semaphore_wait_slow(dispatch_semaphore_t dsema,
}
#elif USE_FUTEX_SEM
do {
uint64_t nsec = _dispatch_time_to_nanoseconds(timeout);
uint64_t nsec = _dispatch_timeout(timeout);
_timeout.tv_sec = (typeof(_timeout.tv_sec))(nsec / NSEC_PER_SEC);
_timeout.tv_nsec = (typeof(_timeout.tv_nsec))(nsec % NSEC_PER_SEC);
ret = slowpath(_dispatch_futex_wait(&dsema->dsema_futex, &_timeout));
Expand Down Expand Up @@ -645,10 +645,9 @@ _dispatch_group_wait_slow(dispatch_semaphore_t dsema, dispatch_time_t timeout)
}
#elif USE_FUTEX_SEM
do {
// HF: check whether we need same timer as POSIX_SEM
uint64_t nsec = _dispatch_timeout(timeout);
_timeout.tv_sec = nsec / NSEC_PER_SEC;
_timeout.tv_nsec = nsec % NSEC_PER_SEC;
_timeout.tv_sec = (typeof(_timeout.tv_sec))(nsec / NSEC_PER_SEC);
_timeout.tv_nsec = (typeof(_timeout.tv_nsec))(nsec % NSEC_PER_SEC);
ret = slowpath(_dispatch_futex_wait(&dsema->dsema_futex, &_timeout));
} while (ret == false && errno == EINTR);

Expand Down