]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-mutex: Test the lock by locking a 2nd byte range
authorMartin Schwenke <martin@meltin.net>
Tue, 8 Feb 2022 01:23:42 +0000 (12:23 +1100)
committerMartin Schwenke <martins@samba.org>
Thu, 28 Jul 2022 10:09:34 +0000 (10:09 +0000)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_mutex_fcntl_helper.c

index 07f111a0d6b692cef071b23b965860bcf30b5582..84d3790db57cc5518739d52b071a237ef0ceae04 100644 (file)
@@ -265,6 +265,23 @@ static void lock_io_check_loop(struct tevent_req *subreq)
                goto done;
        }
 
+       /*
+        * Attempt to lock a 2nd byte range.  Using a blocking lock
+        * encourages ping timeouts if the cluster filesystem is in a
+        * bad state.  It also makes testing easier.
+        */
+       ret = fcntl_lock_fd(fd, true, 1);
+       if (ret != 0) {
+               fprintf(stderr,
+                       "%s: "
+                       "lock fail - lock file \"%s\" test lock error (%d)\n",
+                       progname,
+                       state->lock_file,
+                       ret);
+               goto done;
+       }
+
+       /* Unlock occurs on close */
        close(fd);
 
        subreq = tevent_wakeup_send(