diff options
author | Jeremy Allison <jra@samba.org> | 2007-05-19 20:57:12 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:22:15 -0500 |
commit | fa18fc25a50cf13c687ae88e7e5e2dda1120e017 (patch) | |
tree | e4092079b40c62cb7ed0e898a3d1ab838f3ac021 /source/smbd | |
parent | 94b0997ef1bd993587dfeef4e0a8d366c5371e9f (diff) | |
download | samba-fa18fc25a50cf13c687ae88e7e5e2dda1120e017.tar.gz samba-fa18fc25a50cf13c687ae88e7e5e2dda1120e017.tar.xz samba-fa18fc25a50cf13c687ae88e7e5e2dda1120e017.zip |
r23014: For all branches, ensure that if we're blocked on a POSIX
lock we know nothing about that we retry the lock every
10 seconds instead of waiting for the standard select
timeout. This is how we used to (and are supposed to)
work.
Jeremy.
Diffstat (limited to 'source/smbd')
-rw-r--r-- | source/smbd/blocking.c | 25 | ||||
-rw-r--r-- | source/smbd/reply.c | 13 | ||||
-rw-r--r-- | source/smbd/trans2.c | 8 |
3 files changed, 36 insertions, 10 deletions
diff --git a/source/smbd/blocking.c b/source/smbd/blocking.c index ae7b861f2b0..43b2633b9af 100644 --- a/source/smbd/blocking.c +++ b/source/smbd/blocking.c @@ -39,6 +39,7 @@ typedef struct _blocking_lock_record { SMB_BIG_UINT offset; SMB_BIG_UINT count; uint32 lock_pid; + uint32 blocking_pid; /* PID that blocks us. */ enum brl_flavour lock_flav; enum brl_type lock_type; char *inbuf; @@ -108,6 +109,16 @@ static BOOL recalc_brl_timeout(void) for (brl = blocking_lock_queue; brl; brl = brl->next) { if (timeval_is_zero(&brl->expire_time)) { + /* + * If we're blocked on pid 0xFFFFFFFF this is + * a POSIX lock, so calculate a timeout of + * 10 seconds into the future. + */ + if (brl->blocking_pid == 0xFFFFFFFF) { + struct timeval psx_to = timeval_current_ofs(10, 0); + next_timeout = timeval_min(&next_timeout, &psx_to); + } + continue; } @@ -146,7 +157,9 @@ BOOL push_blocking_lock_request( struct byte_range_lock *br_lck, uint32 lock_pid, enum brl_type lock_type, enum brl_flavour lock_flav, - SMB_BIG_UINT offset, SMB_BIG_UINT count) + SMB_BIG_UINT offset, + SMB_BIG_UINT count, + uint32 blocking_pid) { static BOOL set_lock_msg; blocking_lock_record *blr; @@ -187,6 +200,7 @@ BOOL push_blocking_lock_request( struct byte_range_lock *br_lck, } blr->lock_num = lock_num; blr->lock_pid = lock_pid; + blr->blocking_pid = blocking_pid; blr->lock_flav = lock_flav; blr->lock_type = lock_type; blr->offset = offset; @@ -202,7 +216,8 @@ BOOL push_blocking_lock_request( struct byte_range_lock *br_lck, count, lock_type == READ_LOCK ? PENDING_READ_LOCK : PENDING_WRITE_LOCK, blr->lock_flav, - lock_timeout ? True : False); /* blocking_lock. */ + lock_timeout ? True : False, /* blocking_lock. */ + NULL); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("push_blocking_lock_request: failed to add PENDING_LOCK record.\n")); @@ -445,7 +460,8 @@ static BOOL process_lockingX(blocking_lock_record *blr) READ_LOCK : WRITE_LOCK), WINDOWS_LOCK, True, - &status); + &status, + &blr->blocking_pid); TALLOC_FREE(br_lck); @@ -506,7 +522,8 @@ static BOOL process_trans2(blocking_lock_record *blr) blr->lock_type, blr->lock_flav, True, - &status); + &status, + &blr->blocking_pid); TALLOC_FREE(br_lck); if (!NT_STATUS_IS_OK(status)) { diff --git a/source/smbd/reply.c b/source/smbd/reply.c index c71c7b8beae..ec110e7b213 100644 --- a/source/smbd/reply.c +++ b/source/smbd/reply.c @@ -2426,7 +2426,8 @@ int reply_lockread(connection_struct *conn, char *inbuf,char *outbuf, int length WRITE_LOCK, WINDOWS_LOCK, False, /* Non-blocking lock. */ - &status); + &status, + NULL); TALLOC_FREE(br_lck); if (NT_STATUS_V(status)) { @@ -3474,7 +3475,8 @@ int reply_lock(connection_struct *conn, WRITE_LOCK, WINDOWS_LOCK, False, /* Non-blocking lock. */ - &status); + &status, + NULL); TALLOC_FREE(br_lck); @@ -5575,6 +5577,7 @@ int reply_lockingX(connection_struct *conn, char *inbuf, char *outbuf, BOOL blocking_lock = lock_timeout ? True : False; BOOL defer_lock = False; struct byte_range_lock *br_lck; + uint32 block_smbpid; br_lck = do_lock(smbd_messaging_context(), fsp, @@ -5584,7 +5587,8 @@ int reply_lockingX(connection_struct *conn, char *inbuf, char *outbuf, lock_type, WINDOWS_LOCK, blocking_lock, - &status); + &status, + &block_smbpid); if (br_lck && blocking_lock && ERROR_WAS_LOCK_DENIED(status)) { /* Windows internal resolution for blocking locks seems @@ -5621,7 +5625,8 @@ int reply_lockingX(connection_struct *conn, char *inbuf, char *outbuf, lock_type, WINDOWS_LOCK, offset, - count)) { + count, + block_smbpid)) { TALLOC_FREE(br_lck); END_PROFILE(SMBlockingX); return -1; diff --git a/source/smbd/trans2.c b/source/smbd/trans2.c index 0730041899f..63fd414e16f 100644 --- a/source/smbd/trans2.c +++ b/source/smbd/trans2.c @@ -4815,6 +4815,8 @@ static NTSTATUS smb_set_posix_lock(connection_struct *conn, offset, POSIX_LOCK); } else { + uint32 block_smbpid; + struct byte_range_lock *br_lck = do_lock(smbd_messaging_context(), fsp, lock_pid, @@ -4823,7 +4825,8 @@ static NTSTATUS smb_set_posix_lock(connection_struct *conn, lock_type, POSIX_LOCK, blocking_lock, - &status); + &status, + &block_smbpid); if (br_lck && blocking_lock && ERROR_WAS_LOCK_DENIED(status)) { /* @@ -4840,7 +4843,8 @@ static NTSTATUS smb_set_posix_lock(connection_struct *conn, lock_type, POSIX_LOCK, offset, - count)) { + count, + block_smbpid)) { TALLOC_FREE(br_lck); return status; } |