summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2019-08-13 16:39:41 +0200
committerStefan Metzmacher <metze@samba.org>2019-09-09 16:04:29 +0000
commit5e156be97a37b9bd42b18a78cf6ab541271971e7 (patch)
treee369d0105aa107fee96e1ef3c7c511a982ae38bc
parente5385142987202a67fc3667506ee233f2c726107 (diff)
downloadsamba-5e156be97a37b9bd42b18a78cf6ab541271971e7.tar.gz
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 <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> (cherry picked from commit d096742da1a045357f52ccd5b28d499c30e96152)
-rw-r--r--source3/smbd/smb2_lock.c49
1 files 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);