From 00fc583960f0983c84f960408c8cc92c25c0a928 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 13 Aug 2019 16:39:41 +0200 Subject: s3:smb2_lock: make use of smbd_smb2_lock_try() in smbd_smb2_lock_send() We only need the logic to call smbd_do_locks_try() and a possible retry once in smbd_smb2_lock_try(). BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113 Signed-off-by: Stefan Metzmacher (cherry picked from commit 359e9992be713bbecfdb19998d69e1d3f020c5e9) --- source3/smbd/smb2_lock.c | 68 +++++------------------------------------------- 1 file changed, 6 insertions(+), 62 deletions(-) diff --git a/source3/smbd/smb2_lock.c b/source3/smbd/smb2_lock.c index 153705b26a1..a8ccf21cc20 100644 --- a/source3/smbd/smb2_lock.c +++ b/source3/smbd/smb2_lock.c @@ -205,10 +205,6 @@ static struct tevent_req *smbd_smb2_lock_send(TALLOC_CTX *mem_ctx, bool isunlock = false; uint16_t i; struct smbd_lock_element *locks; - struct share_mode_lock *lck = NULL; - uint16_t blocker_idx; - struct server_id blocking_pid = { 0 }; - uint64_t blocking_smblctx; NTSTATUS status; req = tevent_req_create(mem_ctx, &state, @@ -363,68 +359,16 @@ static struct tevent_req *smbd_smb2_lock_send(TALLOC_CTX *mem_ctx, return tevent_req_post(req, ev); } - lck = get_existing_share_mode_lock( - talloc_tos(), state->fsp->file_id); - if (tevent_req_nomem(lck, req)) { - return tevent_req_post(req, ev); - } - - status = smbd_do_locks_try( - state->fsp, - WINDOWS_LOCK, - state->lock_count, - state->locks, - &blocker_idx, - &blocking_pid, - &blocking_smblctx); - - if (NT_STATUS_IS_OK(status)) { - TALLOC_FREE(lck); - tevent_req_done(req); - return tevent_req_post(req, ev); - } - if (NT_STATUS_EQUAL(status, NT_STATUS_FILE_LOCK_CONFLICT)) { - /* - * This is a bug and will be changed into an assert - * in a future version. We should only - * ever get NT_STATUS_LOCK_NOT_GRANTED here! - */ - static uint64_t _bug_count; - int _level = (_bug_count++ == 0) ? DBGLVL_ERR: DBGLVL_DEBUG; - DBG_PREFIX(_level, ("BUG: Got %s mapping to " - "NT_STATUS_LOCK_NOT_GRANTED\n", - nt_errstr(status))); - status = NT_STATUS_LOCK_NOT_GRANTED; - } - if (!NT_STATUS_EQUAL(status, NT_STATUS_LOCK_NOT_GRANTED)) { - TALLOC_FREE(lck); - tevent_req_nterror(req, status); + smbd_smb2_lock_try(req); + if (!tevent_req_is_in_progress(req)) { return tevent_req_post(req, ev); } - if (state->blocking) { - struct tevent_req *subreq; - - DBG_DEBUG("Watching share mode lock\n"); - - subreq = dbwrap_watched_watch_send( - state, state->ev, lck->data->record, blocking_pid); - TALLOC_FREE(lck); - if (tevent_req_nomem(subreq, req)) { - return tevent_req_post(req, ev); - } - tevent_req_set_callback(subreq, smbd_smb2_lock_retry, req); - - tevent_req_defer_callback(req, smb2req->sconn->ev_ctx); - aio_add_req_to_fsp(state->fsp, req); - tevent_req_set_cancel_fn(req, smbd_smb2_lock_cancel); + tevent_req_defer_callback(req, smb2req->sconn->ev_ctx); + aio_add_req_to_fsp(state->fsp, req); + tevent_req_set_cancel_fn(req, smbd_smb2_lock_cancel); - return req; - } - - TALLOC_FREE(lck); - tevent_req_nterror(req, status); - return tevent_req_post(req, ev); + return req; } static void smbd_smb2_lock_try(struct tevent_req *req) -- cgit v1.2.1