s3:smb2_lock: let smbd_smb2_lock_try() explicitly check for the retry condition
authorStefan Metzmacher <metze@samba.org>
Tue, 13 Aug 2019 14:39:41 +0000 (16:39 +0200)
committerStefan Metzmacher <metze@samba.org>
Mon, 9 Sep 2019 14:23:40 +0000 (14:23 +0000)
This makes it possible to reuse _try() in the _send() function in the
next commit.

We should not retry forever on a hard error.

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>
source3/smbd/smb2_lock.c

index c049c33ebbcb8ccd8643280d792c843cd85d4286..153705b26a161c64d6e4911eabc4b31cb9be219d 100644 (file)
@@ -457,6 +457,32 @@ static void smbd_smb2_lock_try(struct tevent_req *req)
                tevent_req_done(req);
                return;
        }
+       if (NT_STATUS_EQUAL(status, NT_STATUS_FILE_LOCK_CONFLICT)) {
+               /*
+                * This is a bug and will be changed into an assert
+                * in 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);
+               return;
+       }
+
+       if (!state->blocking) {
+               TALLOC_FREE(lck);
+               tevent_req_nterror(req, status);
+               return;
+       }
+
+       DBG_DEBUG("Watching share mode lock\n");
 
        subreq = dbwrap_watched_watch_send(
                state, state->ev, lck->data->record, blocking_pid);