From: Stefan Metzmacher Date: Sun, 28 Aug 2022 07:58:51 +0000 (+0200) Subject: s3:locking: split out put_share_mode_lock_internal() X-Git-Tag: talloc-2.4.0~861 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a2f6f96ac74b25e99c9765bff341bfc9060a7bbf;p=thirdparty%2Fsamba.git s3:locking: split out put_share_mode_lock_internal() 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 Reviewed-by: Jeremy Allison --- diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c index d192dfdce87..3fcd2843023 100644 --- a/source3/locking/share_mode_lock.c +++ b/source3/locking/share_mode_lock.c @@ -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; }