summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2009-10-20 18:17:19 -0700
committerKarolin Seeger <kseeger@samba.org>2010-01-13 14:00:52 +0100
commitb516f88218b83f3ed222ae78f6546aeab0960ea5 (patch)
treebc4eb38a1df099f71a746daf4cef058fc5c0842d
parentd935ac91bce2d46f3dd9f9297e1fa1045d5b4b79 (diff)
downloadsamba-b516f88218b83f3ed222ae78f6546aeab0960ea5.tar.gz
samba-b516f88218b83f3ed222ae78f6546aeab0960ea5.tar.xz
samba-b516f88218b83f3ed222ae78f6546aeab0960ea5.zip
Fix bug 6828 - infinite timeout occurs when byte lock held outside of samba Jeremy.
(cherry picked from commit 4fce98ce2578f4bc5063a766fdacbdd5f840e446)
-rw-r--r--source/smbd/blocking.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/source/smbd/blocking.c b/source/smbd/blocking.c
index 2c37fea496d..f4adc0d047d 100644
--- a/source/smbd/blocking.c
+++ b/source/smbd/blocking.c
@@ -94,6 +94,22 @@ static void brl_timeout_fn(struct event_context *event_ctx,
}
/****************************************************************************
+ We need a version of timeval_min that treats zero timval as infinite.
+****************************************************************************/
+
+static struct timeval timeval_brl_min(const struct timeval *tv1,
+ const struct timeval *tv2)
+{
+ if (timeval_is_zero(tv1)) {
+ return *tv2;
+ }
+ if (timeval_is_zero(tv2)) {
+ return *tv1;
+ }
+ return timeval_min(tv1, tv2);
+}
+
+/****************************************************************************
After a change to blocking_lock_queue, recalculate the timed_event for the
next processing.
****************************************************************************/
@@ -116,19 +132,13 @@ static bool recalc_brl_timeout(void)
*/
if (brl->blocking_pid == 0xFFFFFFFF) {
struct timeval psx_to = timeval_current_ofs(10, 0);
- next_timeout = timeval_min(&next_timeout, &psx_to);
+ next_timeout = timeval_brl_min(&next_timeout, &psx_to);
}
continue;
}
- if (timeval_is_zero(&next_timeout)) {
- next_timeout = brl->expire_time;
- }
- else {
- next_timeout = timeval_min(&next_timeout,
- &brl->expire_time);
- }
+ next_timeout = timeval_brl_min(&next_timeout, &brl->expire_time);
}
if (timeval_is_zero(&next_timeout)) {