summaryrefslogtreecommitdiffstats
path: root/source3/smbd/blocking.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2002-08-18 20:09:02 +0000
committerAndrew Tridgell <tridge@samba.org>2002-08-18 20:09:02 +0000
commitf18c3c757a84734e45b8da8af2bc576c1ded73d2 (patch)
tree8e0e1ee121319992b25a38f30adef3ddc7c63bcf /source3/smbd/blocking.c
parentdb9a33fd38c1ac445e5edc1c80499ac3300a4824 (diff)
downloadsamba-f18c3c757a84734e45b8da8af2bc576c1ded73d2.tar.gz
samba-f18c3c757a84734e45b8da8af2bc576c1ded73d2.tar.xz
samba-f18c3c757a84734e45b8da8af2bc576c1ded73d2.zip
added exact timing semantics on blocking locks
(This used to be commit aed32eb412cab7f6d0959f9faaaebdb320b2b6a8)
Diffstat (limited to 'source3/smbd/blocking.c')
-rw-r--r--source3/smbd/blocking.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/source3/smbd/blocking.c b/source3/smbd/blocking.c
index 72cf3e59b6b..9d411711cb9 100644
--- a/source3/smbd/blocking.c
+++ b/source3/smbd/blocking.c
@@ -531,13 +531,33 @@ file %s fnum = %d\n", blr->com_type, fsp->fsp_name, fsp->fnum ));
}
/****************************************************************************
- Return True if the blocking lock queue has entries.
+ Return the number of seconds to the next blocking locks timeout, or default_timeout
*****************************************************************************/
-
-BOOL blocking_locks_pending(void)
+unsigned blocking_locks_timeout(unsigned default_timeout)
{
- blocking_lock_record *blr = (blocking_lock_record *)ubi_slFirst( &blocking_lock_queue );
- return (blr == NULL ? False : True);
+ unsigned timeout = default_timeout;
+ time_t t;
+ blocking_lock_record *blr = (blocking_lock_record *)ubi_slFirst(&blocking_lock_queue);
+
+ /* note that we avoid the time() syscall if there are no blocking locks */
+ if (!blr) {
+ return timeout;
+ }
+
+ t = time(NULL);
+
+ while (blr) {
+ if (timeout > (blr->expire_time - t)) {
+ timeout = blr->expire_time - t;
+ }
+ blr = (blocking_lock_record *)ubi_slNext(blr);
+ }
+
+ if (timeout < 1) {
+ timeout = 1;
+ }
+
+ return timeout;
}
/****************************************************************************