summaryrefslogtreecommitdiff
path: root/locks
diff options
context:
space:
mode:
authorJim Jagielski <jim@apache.org>2017-04-05 17:10:04 +0000
committerJim Jagielski <jim@apache.org>2017-04-05 17:10:04 +0000
commitb6b9736ccb532b4b741d7ef2db404c67cd6512c1 (patch)
tree96cb85a2d16f7d38023f9fb89b0be30df2935117 /locks
parent4ca6e8f64ecd5854fd68637a904473593f31ed1f (diff)
downloadapr-b6b9736ccb532b4b741d7ef2db404c67cd6512c1.tar.gz
semtimedop() takes a delta time, so accept what is given as the "time remaining"
rr1790301 git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1790302 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'locks')
-rw-r--r--locks/unix/misc.c26
1 files changed, 4 insertions, 22 deletions
diff --git a/locks/unix/misc.c b/locks/unix/misc.c
index b3bc21828..d7018fc3a 100644
--- a/locks/unix/misc.c
+++ b/locks/unix/misc.c
@@ -146,41 +146,23 @@ int sem_timedwait(sem_t * sem, const struct timespec *abs_timeout)
#if APR_HAS_SYSVSEM_SERIALIZE
#if !HAVE_SEMTIMEDOP
extern int semtimedop(int semid, struct sembuf *sops, unsigned nsops,
- const struct timespec *abs_timeout);
+ const struct timespec *timeout);
/*
* A semtimedop() impl for OSX/macOS, which lacks the
* real thing.
*/
int semtimedop(int semid, struct sembuf *sops, unsigned nsops,
- const struct timespec *abs_timeout)
+ const struct timespec *timeout)
{
int rv;
- struct timespec remaining, ts, tod;
- apr_time_t now;
+ struct timespec remaining, ts;
struct sembuf proc_mutex_op_try;
proc_mutex_op_try.sem_num = 0;
proc_mutex_op_try.sem_op = -1;
proc_mutex_op_try.sem_flg = SEM_UNDO | IPC_NOWAIT;
- remaining = *abs_timeout;
- now = apr_time_now();
- tod.tv_sec = apr_time_sec(now);
- tod.tv_nsec = apr_time_usec(now) * 1000; /* nanoseconds */
-
- remaining.tv_sec -= tod.tv_sec;
- if (tod.tv_nsec <= remaining.tv_nsec) {
- remaining.tv_nsec -= tod.tv_nsec;
- }
- else {
- remaining.tv_sec--;
- remaining.tv_nsec =
- (NANOSECS_PER_SEC - (tod.tv_nsec - remaining.tv_nsec));
- }
- /* If we had a REALLY small timeout ;) */
- if (remaining.tv_sec < 0) {
- return ETIMEDOUT;
- }
+ remaining = *timeout;
errno = 0;
while (((rv = semop(semid, &proc_mutex_op_try, nsops)) != 0)
&& (errno == EAGAIN)) {