summaryrefslogtreecommitdiff
path: root/source3/smbd/blocking.c
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2002-09-25 15:19:00 +0000
committerGerald Carter <jerry@samba.org>2002-09-25 15:19:00 +0000
commita834a73e341059be154426390304a42e4a011f72 (patch)
tree7f53b0f7819238e0ee0396daccf5d924cb9b8d29 /source3/smbd/blocking.c
parent115a39775cb923d026dde58633b6ba6aef3a1943 (diff)
downloadsamba-a834a73e341059be154426390304a42e4a011f72.tar.gz
samba-a834a73e341059be154426390304a42e4a011f72.tar.bz2
samba-a834a73e341059be154426390304a42e4a011f72.zip
sync'ing up for 3.0alpha20 release
(This used to be commit 65e7b5273bb58802bf0c389b77f7fcae0a1f6139)
Diffstat (limited to 'source3/smbd/blocking.c')
-rw-r--r--source3/smbd/blocking.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/source3/smbd/blocking.c b/source3/smbd/blocking.c
index 6623c6df64..9d411711cb 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;
}
/****************************************************************************
@@ -576,7 +596,7 @@ void process_blocking_lock_queue(time_t t)
DEBUG(5,("process_blocking_lock_queue: examining pending lock fnum = %d for file %s\n",
fsp->fnum, fsp->fsp_name ));
- if((blr->expire_time != -1) && (blr->expire_time > t)) {
+ if((blr->expire_time != -1) && (blr->expire_time <= t)) {
/*
* Lock expired - throw away all previously
* obtained locks and return lock error.
@@ -584,7 +604,7 @@ void process_blocking_lock_queue(time_t t)
DEBUG(5,("process_blocking_lock_queue: pending lock fnum = %d for file %s timed out.\n",
fsp->fnum, fsp->fsp_name ));
- blocking_lock_reply_error(blr,NT_STATUS_ACCESS_DENIED);
+ blocking_lock_reply_error(blr,NT_STATUS_FILE_LOCK_CONFLICT);
free_blocking_lock_record((blocking_lock_record *)ubi_slRemNext( &blocking_lock_queue, prev));
blr = (blocking_lock_record *)(prev ? ubi_slNext(prev) : ubi_slFirst(&blocking_lock_queue));
continue;