diff options
author | Jim Jagielski <jim@apache.org> | 2017-04-04 13:42:09 +0000 |
---|---|---|
committer | Jim Jagielski <jim@apache.org> | 2017-04-04 13:42:09 +0000 |
commit | 0f7dd0856674b610f0873ff46a5a6d2225a31c01 (patch) | |
tree | a4d9d2045973e2b09a6683dc372c783be7d0292d /locks | |
parent | 7fe0bd8b03005eca29aff9fa4a7ea49c96050409 (diff) | |
download | apr-0f7dd0856674b610f0873ff46a5a6d2225a31c01.tar.gz |
backport r1790111
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.6.x@1790112 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'locks')
-rw-r--r-- | locks/unix/misc.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/locks/unix/misc.c b/locks/unix/misc.c index 3aacfe71d..84a4a073a 100644 --- a/locks/unix/misc.c +++ b/locks/unix/misc.c @@ -50,6 +50,10 @@ int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *abs_t 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 pthread_mutex_trylock(mutex); + } while ((rv = pthread_mutex_trylock(mutex)) == EBUSY) { ts.tv_sec = 0; ts.tv_nsec = (remaining.tv_sec > 0 ? SLEEP_TIME_NS : |