]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:locking: split out put_share_mode_lock_internal()
authorStefan Metzmacher <metze@samba.org>
Sun, 28 Aug 2022 07:58:51 +0000 (09:58 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 20 Sep 2022 00:34:35 +0000 (00:34 +0000)
This pairs with get_share_mode_lock_internal() and will allow us
to use a struct share_mode_lock stack variable in future,
which will be much cheaper.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/locking/share_mode_lock.c

index d192dfdce876917b59a8456bc74149850df1b454..3fcd2843023dd4fa2db7efac7cefee877b49f9d9 100644 (file)
@@ -950,7 +950,7 @@ fail:
        return status;
 }
 
-static int share_mode_lock_destructor(struct share_mode_lock *lck)
+static NTSTATUS put_share_mode_lock_internal(struct share_mode_lock *lck)
 {
        NTSTATUS status;
 
@@ -958,21 +958,21 @@ static int share_mode_lock_destructor(struct share_mode_lock *lck)
        share_mode_lock_key_refcount -= 1;
 
        if (share_mode_lock_key_refcount > 0) {
-               return 0;
+               return NT_STATUS_OK;
        }
 
        status = share_mode_data_store(static_share_mode_data);
        if (!NT_STATUS_IS_OK(status)) {
                DBG_ERR("share_mode_data_store failed: %s\n",
                        nt_errstr(status));
-               smb_panic("Could not store share mode data\n");
+               return status;
        }
 
        status = g_lock_unlock(lock_ctx, share_mode_lock_key);
        if (!NT_STATUS_IS_OK(status)) {
                DBG_ERR("g_lock_unlock failed: %s\n",
                        nt_errstr(status));
-               smb_panic("Could not unlock share mode\n");
+               return status;
        }
 
        if (!static_share_mode_data->not_stored) {
@@ -986,6 +986,20 @@ static int share_mode_lock_destructor(struct share_mode_lock *lck)
        }
 
        TALLOC_FREE(static_share_mode_data);
+       return NT_STATUS_OK;
+}
+
+static int share_mode_lock_destructor(struct share_mode_lock *lck)
+{
+       NTSTATUS status;
+
+       status = put_share_mode_lock_internal(lck);
+       if (!NT_STATUS_IS_OK(status)) {
+               DBG_ERR("put_share_mode_lock_internal failed: %s\n",
+                       nt_errstr(status));
+               smb_panic("put_share_mode_lock_internal failed\n");
+       }
+
        return 0;
 }