mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
smbd: Factor out unlocking from smbd_do_locking
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
27ef395771
commit
f93ae07679
@ -120,11 +120,13 @@ NTSTATUS smbd_do_locking(struct smb_request *req,
|
||||
files_struct *fsp,
|
||||
uint8_t type,
|
||||
int32_t timeout,
|
||||
uint16_t num_ulocks,
|
||||
struct smbd_lock_element *ulocks,
|
||||
uint16_t num_locks,
|
||||
struct smbd_lock_element *locks,
|
||||
bool *async);
|
||||
NTSTATUS smbd_do_unlocking(struct smb_request *req,
|
||||
files_struct *fsp,
|
||||
uint16_t num_ulocks,
|
||||
struct smbd_lock_element *ulocks);
|
||||
|
||||
NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
|
||||
TALLOC_CTX *mem_ctx,
|
||||
|
@ -7697,8 +7697,6 @@ NTSTATUS smbd_do_locking(struct smb_request *req,
|
||||
files_struct *fsp,
|
||||
uint8_t type,
|
||||
int32_t timeout,
|
||||
uint16_t num_ulocks,
|
||||
struct smbd_lock_element *ulocks,
|
||||
uint16_t num_locks,
|
||||
struct smbd_lock_element *locks,
|
||||
bool *async)
|
||||
@ -7709,38 +7707,6 @@ NTSTATUS smbd_do_locking(struct smb_request *req,
|
||||
|
||||
*async = false;
|
||||
|
||||
/* Data now points at the beginning of the list
|
||||
of smb_unlkrng structs */
|
||||
for(i = 0; i < (int)num_ulocks; i++) {
|
||||
struct smbd_lock_element *e = &ulocks[i];
|
||||
|
||||
DEBUG(10,("smbd_do_locking: unlock start=%.0f, len=%.0f for "
|
||||
"pid %u, file %s\n",
|
||||
(double)e->offset,
|
||||
(double)e->count,
|
||||
(unsigned int)e->smblctx,
|
||||
fsp_str_dbg(fsp)));
|
||||
|
||||
if (e->brltype != UNLOCK_LOCK) {
|
||||
/* this can only happen with SMB2 */
|
||||
return NT_STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
status = do_unlock(req->sconn->msg_ctx,
|
||||
fsp,
|
||||
e->smblctx,
|
||||
e->count,
|
||||
e->offset,
|
||||
WINDOWS_LOCK);
|
||||
|
||||
DEBUG(10, ("smbd_do_locking: unlock returned %s\n",
|
||||
nt_errstr(status)));
|
||||
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
/* Setup the timeout in seconds. */
|
||||
|
||||
if (!lp_blocking_locks(SNUM(conn))) {
|
||||
@ -7920,8 +7886,54 @@ NTSTATUS smbd_do_locking(struct smb_request *req,
|
||||
return status;
|
||||
}
|
||||
|
||||
DEBUG(3, ("smbd_do_locking: %s type=%d num_locks=%d num_ulocks=%d\n",
|
||||
fsp_fnum_dbg(fsp), (unsigned int)type, num_locks, num_ulocks));
|
||||
DEBUG(3, ("smbd_do_locking: %s type=%d num_locks=%d\n",
|
||||
fsp_fnum_dbg(fsp), (unsigned int)type, num_locks));
|
||||
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
NTSTATUS smbd_do_unlocking(struct smb_request *req,
|
||||
files_struct *fsp,
|
||||
uint16_t num_ulocks,
|
||||
struct smbd_lock_element *ulocks)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Data now points at the beginning of the list
|
||||
of smb_unlkrng structs */
|
||||
for(i = 0; i < (int)num_ulocks; i++) {
|
||||
struct smbd_lock_element *e = &ulocks[i];
|
||||
NTSTATUS status;
|
||||
|
||||
DEBUG(10,("%s: unlock start=%.0f, len=%.0f for "
|
||||
"pid %u, file %s\n", __func__,
|
||||
(double)e->offset,
|
||||
(double)e->count,
|
||||
(unsigned int)e->smblctx,
|
||||
fsp_str_dbg(fsp)));
|
||||
|
||||
if (e->brltype != UNLOCK_LOCK) {
|
||||
/* this can only happen with SMB2 */
|
||||
return NT_STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
status = do_unlock(req->sconn->msg_ctx,
|
||||
fsp,
|
||||
e->smblctx,
|
||||
e->count,
|
||||
e->offset,
|
||||
WINDOWS_LOCK);
|
||||
|
||||
DEBUG(10, ("%s: unlock returned %s\n", __func__,
|
||||
nt_errstr(status)));
|
||||
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG(3, ("%s: %s num_ulocks=%d\n", __func__, fsp_fnum_dbg(fsp),
|
||||
num_ulocks));
|
||||
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
@ -8125,9 +8137,15 @@ void reply_lockingX(struct smb_request *req)
|
||||
}
|
||||
}
|
||||
|
||||
status = smbd_do_unlocking(req, fsp, num_ulocks, ulocks);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
END_PROFILE(SMBlockingX);
|
||||
reply_nterror(req, status);
|
||||
return;
|
||||
}
|
||||
|
||||
status = smbd_do_locking(req, fsp,
|
||||
locktype, lock_timeout,
|
||||
num_ulocks, ulocks,
|
||||
num_locks, locks,
|
||||
&async);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
|
@ -328,20 +328,13 @@ static struct tevent_req *smbd_smb2_lock_send(TALLOC_CTX *mem_ctx,
|
||||
state->lock_count = in_lock_count;
|
||||
|
||||
if (isunlock) {
|
||||
status = smbd_do_locking(smb1req, fsp,
|
||||
0,
|
||||
timeout,
|
||||
in_lock_count,
|
||||
locks,
|
||||
0,
|
||||
NULL,
|
||||
&async);
|
||||
status = smbd_do_unlocking(smb1req, fsp,
|
||||
in_lock_count, locks);
|
||||
async = false;
|
||||
} else {
|
||||
status = smbd_do_locking(smb1req, fsp,
|
||||
0,
|
||||
timeout,
|
||||
0,
|
||||
NULL,
|
||||
in_lock_count,
|
||||
locks,
|
||||
&async);
|
||||
|
Loading…
Reference in New Issue
Block a user