diff options
author | jim <jim@13f79535-47bb-0310-9956-ffa450edef68> | 2017-04-04 13:42:09 +0000 |
---|---|---|
committer | jim <jim@13f79535-47bb-0310-9956-ffa450edef68> | 2017-04-04 13:42:09 +0000 |
commit | 3dc057d7bf7f3f089d9560af1ffaa5e1eb274ad6 (patch) | |
tree | a4d9d2045973e2b09a6683dc372c783be7d0292d /locks | |
parent | 09150ab33fd6a29bb1acc131cc72da114115e244 (diff) | |
download | libapr-3dc057d7bf7f3f089d9560af1ffaa5e1eb274ad6.tar.gz |
backport r1790111
git-svn-id: http://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 : |