From 5e156be97a37b9bd42b18a78cf6ab541271971e7 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 13 Aug 2019 16:39:41 +0200 Subject: s3:smb2_lock: split smbd_smb2_lock_retry() into _try() and _retry() This makes it possible to reuse _try() in the _send() function in the next commits. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113 Signed-off-by: Stefan Metzmacher Reviewed-by: Volker Lendecke (cherry picked from commit d096742da1a045357f52ccd5b28d499c30e96152) --- source3/smbd/smb2_lock.c | 49 +++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/source3/smbd/smb2_lock.c b/source3/smbd/smb2_lock.c index 4cf735ff48d..c2b4603f3e1 100644 --- a/source3/smbd/smb2_lock.c +++ b/source3/smbd/smb2_lock.c @@ -189,6 +189,7 @@ static void smbd_smb2_request_lock_done(struct tevent_req *subreq) } } +static void smbd_smb2_lock_try(struct tevent_req *req); static void smbd_smb2_lock_retry(struct tevent_req *subreq); static bool smbd_smb2_lock_cancel(struct tevent_req *req); @@ -410,10 +411,8 @@ static struct tevent_req *smbd_smb2_lock_send(TALLOC_CTX *mem_ctx, return tevent_req_post(req, ev); } -static void smbd_smb2_lock_retry(struct tevent_req *subreq) +static void smbd_smb2_lock_try(struct tevent_req *req) { - struct tevent_req *req = tevent_req_callback_data( - subreq, struct tevent_req); struct smbd_smb2_lock_state *state = tevent_req_data( req, struct smbd_smb2_lock_state); struct share_mode_lock *lck = NULL; @@ -421,22 +420,7 @@ static void smbd_smb2_lock_retry(struct tevent_req *subreq) struct server_id blocking_pid = { 0 }; uint64_t blocking_smblctx; NTSTATUS status; - bool ok; - - /* - * Make sure we run as the user again - */ - ok = change_to_user_by_fsp(state->fsp); - if (!ok) { - tevent_req_nterror(req, NT_STATUS_ACCESS_DENIED); - return; - } - - status = dbwrap_watched_watch_recv(subreq, NULL, NULL); - TALLOC_FREE(subreq); - if (tevent_req_nterror(req, status)) { - return; - } + struct tevent_req *subreq = NULL; lck = get_existing_share_mode_lock( talloc_tos(), state->fsp->file_id); @@ -467,6 +451,33 @@ static void smbd_smb2_lock_retry(struct tevent_req *subreq) tevent_req_set_callback(subreq, smbd_smb2_lock_retry, req); } +static void smbd_smb2_lock_retry(struct tevent_req *subreq) +{ + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct smbd_smb2_lock_state *state = tevent_req_data( + req, struct smbd_smb2_lock_state); + NTSTATUS status; + bool ok; + + /* + * Make sure we run as the user again + */ + ok = change_to_user_by_fsp(state->fsp); + if (!ok) { + tevent_req_nterror(req, NT_STATUS_ACCESS_DENIED); + return; + } + + status = dbwrap_watched_watch_recv(subreq, NULL, NULL); + TALLOC_FREE(subreq); + if (tevent_req_nterror(req, status)) { + return; + } + + smbd_smb2_lock_try(req); +} + static NTSTATUS smbd_smb2_lock_recv(struct tevent_req *req) { return tevent_req_simple_recv_ntstatus(req); -- cgit v1.2.1