diff options
author | Jeremy Allison <jra@samba.org> | 2014-07-02 20:18:42 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2014-07-03 21:41:12 +0200 |
commit | 12be57ef3b2d1b670be7a83f29cd580938030015 (patch) | |
tree | 483a31fe0a2b4b6558b4fd58c97112c2dfa75368 /source3/smbd/blocking.c | |
parent | 517fa80bd385c6adcfee03ea6b25599013ad88f5 (diff) | |
download | samba-12be57ef3b2d1b670be7a83f29cd580938030015.tar.gz samba-12be57ef3b2d1b670be7a83f29cd580938030015.tar.xz samba-12be57ef3b2d1b670be7a83f29cd580938030015.zip |
s3: smbd: Locking - add and use utility function lock_timed_out().
Bug #10684 - SMB1 blocking locks can fail notification on unlock, causing client timeout.
https://bugzilla.samba.org/show_bug.cgi?id=10684
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <Volker.Lendecke@SerNet.DE>
Diffstat (limited to 'source3/smbd/blocking.c')
-rw-r--r-- | source3/smbd/blocking.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/source3/smbd/blocking.c b/source3/smbd/blocking.c index b7445008d1..b8d3f1d4fb 100644 --- a/source3/smbd/blocking.c +++ b/source3/smbd/blocking.c @@ -430,6 +430,25 @@ static void blocking_lock_reply_error(struct blocking_lock_record *blr, NTSTATUS } /**************************************************************************** + Utility function that returns true if a lock timed out. +*****************************************************************************/ + +static bool lock_timed_out(const struct blocking_lock_record *blr) +{ + struct timeval tv_curr; + + if (timeval_is_zero(&blr->expire_time)) { + return false; /* Never times out. */ + } + + tv_curr = timeval_current(); + if (timeval_compare(&blr->expire_time, &tv_curr) <= 0) { + return true; + } + return false; +} + +/**************************************************************************** Attempt to finish off getting all pending blocking locks for a lockingX call. Returns True if we want to be removed from the list. *****************************************************************************/ @@ -734,11 +753,10 @@ static void received_unlock_msg(struct messaging_context *msg, void process_blocking_lock_queue(struct smbd_server_connection *sconn) { - struct timeval tv_curr = timeval_current(); struct blocking_lock_record *blr, *next = NULL; if (sconn->using_smb2) { - process_blocking_lock_queue_smb2(sconn, tv_curr); + process_blocking_lock_queue_smb2(sconn, timeval_current()); return; } @@ -794,7 +812,7 @@ void process_blocking_lock_queue(struct smbd_server_connection *sconn) * If the time has expired, return a lock error. */ - if (!timeval_is_zero(&blr->expire_time) && timeval_compare(&blr->expire_time, &tv_curr) <= 0) { + if (lock_timed_out(blr)) { struct byte_range_lock *br_lck = brl_get_locks( talloc_tos(), blr->fsp); |