summaryrefslogtreecommitdiff
path: root/locks
diff options
context:
space:
mode:
authorJim Jagielski <jim@apache.org>2017-04-04 13:40:53 +0000
committerJim Jagielski <jim@apache.org>2017-04-04 13:40:53 +0000
commite79e7f28dd4ff42546228dfead08d392c6177f93 (patch)
treeff922a9edafa58ec76c76d98f65a227ce918e576 /locks
parent288882b198de154e0fa38cec3704cae374ec41dc (diff)
downloadapr-e79e7f28dd4ff42546228dfead08d392c6177f93.tar.gz
Be safe... if we had a super small timeout then by the time we
call us, we could have blown past it... in that case, just try the lock git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1790111 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'locks')
-rw-r--r--locks/unix/misc.c4
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 :