summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-07-17 21:09:02 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:38:11 -0500
commite1da1fcf12164f50f3462c90f0bb785d18c59b0b (patch)
tree8df81a6c947a609249d67188c3a5dbebbdee0984 /source3/smbd
parent4c713703d046f756989e7eb901e884829825593c (diff)
downloadsamba-e1da1fcf12164f50f3462c90f0bb785d18c59b0b.tar.gz
samba-e1da1fcf12164f50f3462c90f0bb785d18c59b0b.tar.bz2
samba-e1da1fcf12164f50f3462c90f0bb785d18c59b0b.zip
r17098: Samba3 now cleanly passes Samba4 RAW-LOCK torture
test. Phew - that was painful :-). But what it means is that we now implement lock cancels and I can add lock cancels into POSIX lock handling which will fix the fast/slow system call issue with cifsfs ! Jeremy. (This used to be commit f1a9cf075b87c76c032d19da0168424c90f6cb3c)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/blocking.c204
-rw-r--r--source3/smbd/close.c2
-rw-r--r--source3/smbd/reply.c123
-rw-r--r--source3/smbd/trans2.c4
4 files changed, 243 insertions, 90 deletions
diff --git a/source3/smbd/blocking.c b/source3/smbd/blocking.c
index 04ab01eb66..941e87d3ad 100644
--- a/source3/smbd/blocking.c
+++ b/source3/smbd/blocking.c
@@ -19,6 +19,8 @@
*/
#include "includes.h"
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_LOCKING
/****************************************************************************
This is the structure to queue to implement blocking locks.
@@ -41,15 +43,18 @@ typedef struct _blocking_lock_record {
int length;
} blocking_lock_record;
+/* dlink list we store pending lock records on. */
static blocking_lock_record *blocking_lock_queue;
+/* dlink list we move cancelled lock records onto. */
+static blocking_lock_record *blocking_lock_cancelled_queue;
+
/****************************************************************************
Destructor for the above structure.
****************************************************************************/
static void free_blocking_lock_record(blocking_lock_record *blr)
{
- DLIST_REMOVE(blocking_lock_queue, blr);
SAFE_FREE(blr->inbuf);
SAFE_FREE(blr);
}
@@ -81,7 +86,6 @@ BOOL push_blocking_lock_request( char *inbuf, int length,
{
static BOOL set_lock_msg;
blocking_lock_record *blr, *tmp;
- BOOL my_lock_ctx = False;
struct byte_range_lock *br_lck = NULL;
NTSTATUS status;
@@ -123,6 +127,7 @@ BOOL push_blocking_lock_request( char *inbuf, int length,
br_lck = brl_get_locks(NULL, blr->fsp);
if (!br_lck) {
+ DLIST_REMOVE(blocking_lock_queue, blr);
free_blocking_lock_record(blr);
return False;
}
@@ -135,11 +140,12 @@ BOOL push_blocking_lock_request( char *inbuf, int length,
count,
PENDING_LOCK,
blr->lock_flav,
- &my_lock_ctx);
+ lock_timeout);
TALLOC_FREE(br_lck);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("push_blocking_lock_request: failed to add PENDING_LOCK record.\n"));
+ DLIST_REMOVE(blocking_lock_queue, blr);
free_blocking_lock_record(blr);
return False;
}
@@ -220,9 +226,24 @@ static void generic_blocking_lock_error(blocking_lock_record *blr, NTSTATUS stat
status = NT_STATUS_FILE_LOCK_CONFLICT;
}
+ if (NT_STATUS_EQUAL(status, NT_STATUS_FILE_LOCK_CONFLICT)) {
+ /* Store the last lock error. */
+ files_struct *fsp = blr->fsp;
+
+ fsp->last_lock_failure.context.smbpid = blr->lock_pid;
+ fsp->last_lock_failure.context.tid = fsp->conn->cnum;
+ fsp->last_lock_failure.context.pid = procid_self();
+ fsp->last_lock_failure.start = blr->offset;
+ fsp->last_lock_failure.size = blr->count;
+ fsp->last_lock_failure.fnum = fsp->fnum;
+ fsp->last_lock_failure.lock_type = READ_LOCK; /* Don't care. */
+ fsp->last_lock_failure.lock_flav = blr->lock_flav;
+ }
+
ERROR_NT(status);
- if (!send_smb(smbd_server_fd(),outbuf))
+ if (!send_smb(smbd_server_fd(),outbuf)) {
exit_server("generic_blocking_lock_error: send_smb failed.");
+ }
}
/****************************************************************************
@@ -335,7 +356,6 @@ static BOOL process_lockread(blocking_lock_record *blr)
size_t numtoread;
NTSTATUS status;
files_struct *fsp = blr->fsp;
- BOOL my_lock_ctx = False;
numtoread = SVAL(inbuf,smb_vwv1);
startpos = (SMB_BIG_UINT)IVAL(inbuf,smb_vwv2);
@@ -343,13 +363,13 @@ static BOOL process_lockread(blocking_lock_record *blr)
numtoread = MIN(BUFFER_SIZE-outsize,numtoread);
data = smb_buf(outbuf) + 3;
- status = do_lock_spin(fsp,
- (uint32)SVAL(inbuf,smb_pid),
- (SMB_BIG_UINT)numtoread,
- startpos,
- READ_LOCK,
- WINDOWS_LOCK,
- &my_lock_ctx);
+ status = do_lock(fsp,
+ (uint32)SVAL(inbuf,smb_pid),
+ (SMB_BIG_UINT)numtoread,
+ startpos,
+ READ_LOCK,
+ WINDOWS_LOCK,
+ (int32)-1);
if (NT_STATUS_V(status)) {
if (!NT_STATUS_EQUAL(status,NT_STATUS_LOCK_NOT_GRANTED) &&
@@ -410,19 +430,18 @@ static BOOL process_lock(blocking_lock_record *blr)
SMB_BIG_UINT count = (SMB_BIG_UINT)0, offset = (SMB_BIG_UINT)0;
NTSTATUS status;
files_struct *fsp = blr->fsp;
- BOOL my_lock_ctx = False;
count = IVAL_TO_SMB_OFF_T(inbuf,smb_vwv1);
offset = IVAL_TO_SMB_OFF_T(inbuf,smb_vwv3);
errno = 0;
- status = do_lock_spin(fsp,
- (uint32)SVAL(inbuf,smb_pid),
- count,
- offset,
- WRITE_LOCK,
- WINDOWS_LOCK,
- &my_lock_ctx);
+ status = do_lock(fsp,
+ (uint32)SVAL(inbuf,smb_pid),
+ count,
+ offset,
+ WRITE_LOCK,
+ WINDOWS_LOCK,
+ (int32)-1);
if (NT_STATUS_IS_ERR(status)) {
if (!NT_STATUS_EQUAL(status,NT_STATUS_LOCK_NOT_GRANTED) &&
@@ -474,7 +493,6 @@ static BOOL process_lockingX(blocking_lock_record *blr)
uint32 lock_pid;
BOOL large_file_format = (locktype & LOCKING_ANDX_LARGE_FILES);
char *data;
- BOOL my_lock_ctx = False;
NTSTATUS status = NT_STATUS_OK;
data = smb_buf(inbuf) + ((large_file_format ? 20 : 10)*num_ulocks);
@@ -496,13 +514,14 @@ static BOOL process_lockingX(blocking_lock_record *blr)
* request would never have been queued. JRA.
*/
errno = 0;
- status = do_lock_spin(fsp,
+ status = do_lock(fsp,
lock_pid,
count,
offset,
- ((locktype & 1) ? READ_LOCK : WRITE_LOCK),
+ ((locktype & LOCKING_ANDX_SHARED_LOCK) ?
+ READ_LOCK : WRITE_LOCK),
WINDOWS_LOCK,
- &my_lock_ctx);
+ (int32)-1);
if (NT_STATUS_IS_ERR(status)) {
break;
@@ -552,7 +571,6 @@ static BOOL process_trans2(blocking_lock_record *blr)
extern int max_send;
char *inbuf = blr->inbuf;
char *outbuf;
- BOOL my_lock_ctx = False;
char params[2];
NTSTATUS status;
@@ -562,7 +580,7 @@ static BOOL process_trans2(blocking_lock_record *blr)
blr->offset,
blr->lock_type,
blr->lock_flav,
- &my_lock_ctx);
+ (int32)-1);
if (!NT_STATUS_IS_OK(status)) {
if (ERROR_WAS_LOCK_DENIED(status)) {
@@ -615,33 +633,41 @@ static BOOL blocking_lock_record_process(blocking_lock_record *blr)
}
/****************************************************************************
- Delete entries by fnum from the blocking lock pending queue.
+ Cancel entries by fnum from the blocking lock pending queue.
*****************************************************************************/
-void remove_pending_lock_requests_by_fid(files_struct *fsp)
+void cancel_pending_lock_requests_by_fid(files_struct *fsp, struct byte_range_lock *br_lck)
{
blocking_lock_record *blr, *next = NULL;
for(blr = blocking_lock_queue; blr; blr = next) {
next = blr->next;
if(blr->fsp->fnum == fsp->fnum) {
- struct byte_range_lock *br_lck = brl_get_locks(NULL, fsp);
+ unsigned char locktype = 0;
+
+ if (blr->com_type == SMBlockingX) {
+ locktype = CVAL(blr->inbuf,smb_vwv3);
+ }
if (br_lck) {
DEBUG(10,("remove_pending_lock_requests_by_fid - removing request type %d for \
file %s fnum = %d\n", blr->com_type, fsp->fsp_name, fsp->fnum ));
- brl_remove_pending_lock(br_lck,
+ brl_lock_cancel(br_lck,
blr->lock_pid,
procid_self(),
blr->offset,
blr->count,
blr->lock_flav);
- TALLOC_FREE(br_lck);
+ blocking_lock_cancel(fsp,
+ blr->lock_pid,
+ blr->offset,
+ blr->count,
+ blr->lock_flav,
+ locktype,
+ NT_STATUS_RANGE_NOT_LOCKED);
}
-
- free_blocking_lock_record(blr);
}
}
}
@@ -664,7 +690,7 @@ void remove_pending_lock_requests_by_mid(int mid)
DEBUG(10,("remove_pending_lock_requests_by_mid - removing request type %d for \
file %s fnum = %d\n", blr->com_type, fsp->fsp_name, fsp->fnum ));
- brl_remove_pending_lock(br_lck,
+ brl_lock_cancel(br_lck,
blr->lock_pid,
procid_self(),
blr->offset,
@@ -674,6 +700,7 @@ file %s fnum = %d\n", blr->com_type, fsp->fsp_name, fsp->fnum ));
}
blocking_lock_reply_error(blr,NT_STATUS_FILE_LOCK_CONFLICT);
+ DLIST_REMOVE(blocking_lock_queue, blr);
free_blocking_lock_record(blr);
}
}
@@ -765,7 +792,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 ));
- brl_remove_pending_lock(br_lck,
+ brl_lock_cancel(br_lck,
blr->lock_pid,
procid_self(),
blr->offset,
@@ -775,6 +802,7 @@ void process_blocking_lock_queue(time_t t)
}
blocking_lock_reply_error(blr,NT_STATUS_FILE_LOCK_CONFLICT);
+ DLIST_REMOVE(blocking_lock_queue, blr);
free_blocking_lock_record(blr);
continue;
}
@@ -787,7 +815,7 @@ void process_blocking_lock_queue(time_t t)
*/
if (br_lck) {
- brl_remove_pending_lock(br_lck,
+ brl_lock_cancel(br_lck,
blr->lock_pid,
procid_self(),
blr->offset,
@@ -799,6 +827,7 @@ void process_blocking_lock_queue(time_t t)
DEBUG(0,("process_blocking_lock_queue: Unable to become user vuid=%d.\n",
vuid ));
blocking_lock_reply_error(blr,NT_STATUS_ACCESS_DENIED);
+ DLIST_REMOVE(blocking_lock_queue, blr);
free_blocking_lock_record(blr);
continue;
}
@@ -811,7 +840,7 @@ void process_blocking_lock_queue(time_t t)
*/
if (br_lck) {
- brl_remove_pending_lock(br_lck,
+ brl_lock_cancel(br_lck,
blr->lock_pid,
procid_self(),
blr->offset,
@@ -822,6 +851,7 @@ void process_blocking_lock_queue(time_t t)
DEBUG(0,("process_blocking_lock_queue: Unable to become service Error was %s.\n", strerror(errno) ));
blocking_lock_reply_error(blr,NT_STATUS_ACCESS_DENIED);
+ DLIST_REMOVE(blocking_lock_queue, blr);
free_blocking_lock_record(blr);
change_to_root_user();
continue;
@@ -837,7 +867,7 @@ void process_blocking_lock_queue(time_t t)
struct byte_range_lock *br_lck = brl_get_locks(NULL, fsp);
if (br_lck) {
- brl_remove_pending_lock(br_lck,
+ brl_lock_cancel(br_lck,
blr->lock_pid,
procid_self(),
blr->offset,
@@ -846,8 +876,106 @@ void process_blocking_lock_queue(time_t t)
TALLOC_FREE(br_lck);
}
+ DLIST_REMOVE(blocking_lock_queue, blr);
free_blocking_lock_record(blr);
}
change_to_root_user();
}
}
+
+/****************************************************************************
+ Handle a cancel message. Lock already moved onto the cancel queue.
+*****************************************************************************/
+
+#define MSG_BLOCKING_LOCK_CANCEL_SIZE (sizeof(blocking_lock_record *) + sizeof(NTSTATUS))
+
+static void process_blocking_lock_cancel_message(int msg_type, struct process_id src,
+ void *buf, size_t len)
+{
+ NTSTATUS err;
+ const char *msg = (const char *)buf;
+ blocking_lock_record *blr;
+
+ if (buf == NULL) {
+ smb_panic("process_blocking_lock_cancel_message: null msg\n");
+ }
+
+ if (len != MSG_BLOCKING_LOCK_CANCEL_SIZE) {
+ DEBUG(0, ("process_blocking_lock_cancel_message: "
+ "Got invalid msg len %d\n", (int)len));
+ smb_panic("process_blocking_lock_cancel_message: bad msg\n");
+ }
+
+ memcpy(&blr, msg, sizeof(blr));
+ memcpy(&err, &msg[sizeof(blr)], sizeof(NTSTATUS));
+
+ DEBUG(10,("process_blocking_lock_cancel_message: returning error %s\n",
+ nt_errstr(err) ));
+
+ blocking_lock_reply_error(blr, err);
+ DLIST_REMOVE(blocking_lock_cancelled_queue, blr);
+ free_blocking_lock_record(blr);
+}
+
+/****************************************************************************
+ Send ourselves a blocking lock cancelled message. Handled asynchronously above.
+*****************************************************************************/
+
+BOOL blocking_lock_cancel(files_struct *fsp,
+ uint32 lock_pid,
+ SMB_BIG_UINT offset,
+ SMB_BIG_UINT count,
+ enum brl_flavour lock_flav,
+ unsigned char locktype,
+ NTSTATUS err)
+{
+ static BOOL initialized;
+ char msg[MSG_BLOCKING_LOCK_CANCEL_SIZE];
+ blocking_lock_record *blr;
+
+ if (!initialized) {
+ /* Register our message. */
+ message_register(MSG_SMB_BLOCKING_LOCK_CANCEL,
+ process_blocking_lock_cancel_message);
+
+ initialized = True;
+ }
+
+ for (blr = blocking_lock_queue; blr; blr = blr->next) {
+ if (fsp == blr->fsp &&
+ lock_pid == blr->lock_pid &&
+ offset == blr->offset &&
+ count == blr->count &&
+ lock_flav == blr->lock_flav) {
+ break;
+ }
+ }
+
+ if (!blr) {
+ return False;
+ }
+
+ /* Check the flags are right. */
+ if (blr->com_type == SMBlockingX &&
+ (locktype & LOCKING_ANDX_LARGE_FILES) !=
+ (CVAL(blr->inbuf,smb_vwv3) & LOCKING_ANDX_LARGE_FILES)) {
+ return False;
+ }
+
+ /* Move to cancelled queue. */
+ DLIST_REMOVE(blocking_lock_queue, blr);
+ DLIST_ADD(blocking_lock_cancelled_queue, blr);
+
+ /* Create the message. */
+ memcpy(msg, &blr, sizeof(blr));
+ memcpy(&msg[sizeof(blr)], &err, sizeof(NTSTATUS));
+
+ /* Don't need to be root here as we're only ever
+ sending to ourselves. */
+
+ message_send_pid(pid_to_procid(sys_getpid()),
+ MSG_SMB_BLOCKING_LOCK_CANCEL,
+ &msg, sizeof(msg), True);
+
+ return True;
+}
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index 8a63d3b227..08e4a24a56 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -268,8 +268,6 @@ static int close_normal_file(files_struct *fsp, enum file_close_type close_type)
int err = 0;
int err1 = 0;
- remove_pending_lock_requests_by_fid(fsp);
-
if (fsp->aio_write_behind) {
/*
* If we're finishing write behind on a close we can get a write
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index ff3c6832e4..ec618db3f8 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -2371,7 +2371,6 @@ int reply_lockread(connection_struct *conn, char *inbuf,char *outbuf, int length
size_t numtoread;
NTSTATUS status;
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
- BOOL my_lock_ctx = False;
START_PROFILE(SMBlockread);
CHECK_FSP(fsp,conn);
@@ -2396,13 +2395,13 @@ int reply_lockread(connection_struct *conn, char *inbuf,char *outbuf, int length
* Note that the requested lock size is unaffected by max_recv.
*/
- status = do_lock_spin(fsp,
- (uint32)SVAL(inbuf,smb_pid),
- (SMB_BIG_UINT)numtoread,
- (SMB_BIG_UINT)startpos,
- WRITE_LOCK,
- WINDOWS_LOCK,
- &my_lock_ctx);
+ status = do_lock(fsp,
+ (uint32)SVAL(inbuf,smb_pid),
+ (SMB_BIG_UINT)numtoread,
+ (SMB_BIG_UINT)startpos,
+ WRITE_LOCK,
+ WINDOWS_LOCK,
+ 0 /* zero timeout. */);
if (NT_STATUS_V(status)) {
#if 0
@@ -2412,7 +2411,7 @@ int reply_lockread(connection_struct *conn, char *inbuf,char *outbuf, int length
* tester. JRA.
*/
- if (lp_blocking_locks(SNUM(conn)) && !my_lock_ctx && ERROR_WAS_LOCK_DENIED(status)) {
+ if (lp_blocking_locks(SNUM(conn)) && ERROR_WAS_LOCK_DENIED(status)) {
/*
* A blocking lock was requested. Package up
* this smb into a queued request and push it
@@ -3418,7 +3417,6 @@ int reply_lock(connection_struct *conn,
SMB_BIG_UINT count,offset;
NTSTATUS status;
files_struct *fsp = file_fsp(inbuf,smb_vwv0);
- BOOL my_lock_ctx = False;
START_PROFILE(SMBlock);
@@ -3432,17 +3430,18 @@ int reply_lock(connection_struct *conn,
DEBUG(3,("lock fd=%d fnum=%d offset=%.0f count=%.0f\n",
fsp->fh->fd, fsp->fnum, (double)offset, (double)count));
- status = do_lock_spin(fsp,
- (uint32)SVAL(inbuf,smb_pid),
- count,
- offset,
- WRITE_LOCK,
- WINDOWS_LOCK,
- &my_lock_ctx);
+ status = do_lock(fsp,
+ (uint32)SVAL(inbuf,smb_pid),
+ count,
+ offset,
+ WRITE_LOCK,
+ WINDOWS_LOCK,
+ 0 /* zero timeout. */);
+
if (NT_STATUS_V(status)) {
#if 0
/* Tests using Samba4 against W2K show this call never creates a blocking lock. */
- if (lp_blocking_locks(SNUM(conn)) && !my_lock_ctx && ERROR_WAS_LOCK_DENIED(status)) {
+ if (lp_blocking_locks(SNUM(conn)) && ERROR_WAS_LOCK_DENIED(status)) {
/*
* A blocking lock was requested. Package up
* this smb into a queued request and push it
@@ -5228,7 +5227,6 @@ int reply_lockingX(connection_struct *conn, char *inbuf, char *outbuf,
BOOL large_file_format =
(locktype & LOCKING_ANDX_LARGE_FILES)?True:False;
BOOL err;
- BOOL my_lock_ctx = False;
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
START_PROFILE(SMBlockingX);
@@ -5244,11 +5242,6 @@ int reply_lockingX(connection_struct *conn, char *inbuf, char *outbuf,
return ERROR_NT(NT_STATUS_DOS(ERRDOS, ERRnoatomiclocks));
}
- if (locktype & LOCKING_ANDX_CANCEL_LOCK) {
- /* Need to make this like a cancel.... JRA. */
- return ERROR_NT(NT_STATUS_UNSUCCESSFUL);
- }
-
/* Check if this is an oplock break on a file
we have granted an oplock on.
*/
@@ -5360,7 +5353,11 @@ int reply_lockingX(connection_struct *conn, char *inbuf, char *outbuf,
/* Setup the timeout in seconds. */
- lock_timeout = ((lock_timeout == -1) ? -1 : (lock_timeout+999)/1000);
+ if (lp_blocking_locks(SNUM(conn))) {
+ lock_timeout = ((lock_timeout == -1) ? -1 : (lock_timeout+999)/1000);
+ } else {
+ lock_timeout = 0;
+ }
/* Now do any requested locks */
data += ((large_file_format ? 20 : 10)*num_ulocks);
@@ -5369,7 +5366,8 @@ int reply_lockingX(connection_struct *conn, char *inbuf, char *outbuf,
of smb_lkrng structs */
for(i = 0; i < (int)num_locks; i++) {
- enum brl_type lock_type = ((locktype & 1) ? READ_LOCK:WRITE_LOCK);
+ enum brl_type lock_type = ((locktype & LOCKING_ANDX_SHARED_LOCK) ?
+ READ_LOCK:WRITE_LOCK);
lock_pid = get_lock_pid( data, i, large_file_format);
count = get_lock_count( data, i, large_file_format);
offset = get_lock_offset( data, i, large_file_format, &err);
@@ -5387,31 +5385,54 @@ int reply_lockingX(connection_struct *conn, char *inbuf, char *outbuf,
(double)count, (unsigned int)lock_pid,
fsp->fsp_name, (int)lock_timeout ));
- status = do_lock_spin(fsp,
+ if (locktype & LOCKING_ANDX_CANCEL_LOCK) {
+ if (lp_blocking_locks(SNUM(conn))) {
+
+ /* Schedule a message to ourselves to
+ remove the blocking lock record and
+ return the right error. */
+
+ if (!blocking_lock_cancel(fsp,
+ lock_pid,
+ offset,
+ count,
+ WINDOWS_LOCK,
+ locktype,
+ NT_STATUS_FILE_LOCK_CONFLICT)) {
+ END_PROFILE(SMBlockingX);
+ return ERROR_NT(NT_STATUS_DOS(ERRDOS, ERRcancelviolation));
+ }
+ }
+ /* Remove a matching pending lock. */
+ status = do_lock_cancel(fsp,
+ lock_pid,
+ count,
+ offset,
+ WINDOWS_LOCK);
+ } else {
+ status = do_lock(fsp,
lock_pid,
count,
offset,
lock_type,
WINDOWS_LOCK,
- &my_lock_ctx);
+ lock_timeout);
- if (NT_STATUS_V(status)) {
- /*
- * Interesting fact found by IFSTEST /t
- * LockOverlappedTest... Even if it's our own lock
- * context, we need to wait here as there may be an
- * unlock on the way. So I removed a "&&
- * !my_lock_ctx" from the following if statement. JRA.
- */
- if ((lock_timeout != 0) &&
- lp_blocking_locks(SNUM(conn)) &&
- ERROR_WAS_LOCK_DENIED(status)) {
+ if (NT_STATUS_V(status)) {
/*
- * A blocking lock was requested. Package up
- * this smb into a queued request and push it
- * onto the blocking lock queue.
+ * Interesting fact found by IFSTEST /t
+ * LockOverlappedTest... Even if it's our own lock
+ * context, we need to wait here as there may be an
+ * unlock on the way. JRA.
*/
- if(push_blocking_lock_request(inbuf, length,
+ if ((lock_timeout != 0) &&
+ ERROR_WAS_LOCK_DENIED(status)) {
+ /*
+ * A blocking lock was requested. Package up
+ * this smb into a queued request and push it
+ * onto the blocking lock queue.
+ */
+ if(push_blocking_lock_request(inbuf, length,
fsp,
lock_timeout,
i,
@@ -5420,17 +5441,25 @@ int reply_lockingX(connection_struct *conn, char *inbuf, char *outbuf,
WINDOWS_LOCK,
offset,
count)) {
- END_PROFILE(SMBlockingX);
- return -1;
+ END_PROFILE(SMBlockingX);
+ return -1;
+ }
}
}
- break;
+ }
+
+ if (NT_STATUS_V(status)) {
+ END_PROFILE(SMBlockingX);
+ return ERROR_NT(status);
}
}
/* If any of the above locks failed, then we must unlock
all of the previous locks (X/Open spec). */
- if (i != num_locks && num_locks != 0) {
+
+ if (!(locktype & LOCKING_ANDX_CANCEL_LOCK) &&
+ (i != num_locks) &&
+ (num_locks != 0)) {
/*
* Ensure we don't do a remove on the lock that just failed,
* as under POSIX rules, if we have a lock already there, we
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 43437469d7..329d5bb0a5 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -4505,7 +4505,6 @@ size = %.0f, uid = %u, gid = %u, raw perms = 0%o\n",
uint32 lock_pid;
BOOL lock_blocking;
enum brl_type lock_type;
- BOOL my_lock_ctx;
if (fsp == NULL || fsp->fh->fd == -1) {
return ERROR_NT(NT_STATUS_INVALID_HANDLE);
@@ -4564,8 +4563,7 @@ size = %.0f, uid = %u, gid = %u, raw perms = 0%o\n",
count,
offset,
lock_type,
- POSIX_LOCK,
- &my_lock_ctx);
+ POSIX_LOCK);
if (lock_blocking && lp_blocking_locks(SNUM(conn)) && ERROR_WAS_LOCK_DENIED(status)) {
/*