1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-22 22:04:08 +03:00

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 <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Stefan Metzmacher 2022-08-28 09:58:51 +02:00 committed by Jeremy Allison
parent 977498d3eb
commit a2f6f96ac7

View 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;
}