summaryrefslogtreecommitdiff
path: root/source3/smbd/blocking.c
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2019-08-13 18:34:36 +0200
committerStefan Metzmacher <metze@samba.org>2019-09-09 14:23:39 +0000
commite79fcfaaf2ecfca6c3747f6fe4be51f332ebf10d (patch)
tree0ff59f5301ff02a05657406908f3c14f6081ca67 /source3/smbd/blocking.c
parent2ec9e93a7aac2706b4a5931495d56a7b64f8d894 (diff)
downloadsamba-e79fcfaaf2ecfca6c3747f6fe4be51f332ebf10d.tar.gz
s3:blocking: split smbd_smb1_do_locks_retry() into _try() and _retry()
This will make it possible to have just one caller to smbd_do_locks_try() later and use smbd_smb1_do_locks_try() from within smbd_smb1_do_locks_send(). BUG: https://bugzilla.samba.org/show_bug.cgi?id=14113 Reviewed-by: Volker Lendecke <vl@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source3/smbd/blocking.c')
-rw-r--r--source3/smbd/blocking.c72
1 files changed, 42 insertions, 30 deletions
diff --git a/source3/smbd/blocking.c b/source3/smbd/blocking.c
index 91438fe4486..0fa39ae58ab 100644
--- a/source3/smbd/blocking.c
+++ b/source3/smbd/blocking.c
@@ -109,6 +109,7 @@ struct smbd_smb1_do_locks_state {
uint16_t blocker;
};
+static void smbd_smb1_do_locks_try(struct tevent_req *req);
static void smbd_smb1_do_locks_retry(struct tevent_req *subreq);
static void smbd_smb1_blocked_locks_cleanup(
struct tevent_req *req, enum tevent_req_state req_state);
@@ -300,10 +301,8 @@ static void smbd_smb1_blocked_locks_cleanup(
fsp, blocked, struct tevent_req *, num_blocked-1);
}
-static void smbd_smb1_do_locks_retry(struct tevent_req *subreq)
+static void smbd_smb1_do_locks_try(struct tevent_req *req)
{
- struct tevent_req *req = tevent_req_callback_data(
- subreq, struct tevent_req);
struct smbd_smb1_do_locks_state *state = tevent_req_data(
req, struct smbd_smb1_do_locks_state);
struct files_struct *fsp = state->fsp;
@@ -315,36 +314,10 @@ static void smbd_smb1_do_locks_retry(struct tevent_req *subreq)
struct timeval endtime;
struct server_id blocking_pid = { 0 };
uint64_t blocking_smblctx = 0;
+ struct tevent_req *subreq = NULL;
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);
-
- DBG_DEBUG("dbwrap_watched_watch_recv returned %s\n",
- nt_errstr(status));
-
- if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
- double elapsed = timeval_elapsed(&state->endtime);
- if (elapsed > 0) {
- smbd_smb1_brl_finish_by_req(
- req, NT_STATUS_FILE_LOCK_CONFLICT);
- return;
- }
- /*
- * This is a posix lock retry. Just retry.
- */
- }
-
lck = get_existing_share_mode_lock(state, fsp->file_id);
if (tevent_req_nomem(lck, req)) {
DBG_DEBUG("Could not get share mode lock\n");
@@ -396,6 +369,45 @@ done:
smbd_smb1_brl_finish_by_req(req, status);
}
+static void smbd_smb1_do_locks_retry(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(
+ subreq, struct tevent_req);
+ struct smbd_smb1_do_locks_state *state = tevent_req_data(
+ req, struct smbd_smb1_do_locks_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);
+
+ DBG_DEBUG("dbwrap_watched_watch_recv returned %s\n",
+ nt_errstr(status));
+
+ if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
+ double elapsed = timeval_elapsed(&state->endtime);
+ if (elapsed > 0) {
+ smbd_smb1_brl_finish_by_req(
+ req, NT_STATUS_FILE_LOCK_CONFLICT);
+ return;
+ }
+ /*
+ * This is a posix lock retry. Just retry.
+ */
+ }
+
+ smbd_smb1_do_locks_try(req);
+}
+
NTSTATUS smbd_smb1_do_locks_recv(struct tevent_req *req)
{
struct smbd_smb1_do_locks_state *state = tevent_req_data(