From ffe4933c776bc89ab8a6bb09f74288b8bf7b1310 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 17 Nov 2019 14:50:51 +0100 Subject: [PATCH] locking: Remove a call to dbwrap_record_get_value() This makes a copy of the record values TDB_DATA. In this case, it is okay: We only do a dbwrap_record_storev modifying the value that we retrieved from the share_mode_lock destructor. This patch is necessary because the next commit will make the "value" argument to the dbwrap_do_locked() callback the only source of the record value. Thus for a nested share_mode_do_locked() call we have to maintain the record value explicitly. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- source3/locking/share_mode_lock.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c index a4e52d6a5b0..ecc410c6598 100644 --- a/source3/locking/share_mode_lock.c +++ b/source3/locking/share_mode_lock.c @@ -528,6 +528,7 @@ static size_t static_share_mode_data_refcount = 0; * need to share with a nested get_share_mode_lock call. */ static struct db_record *static_share_mode_record = NULL; +static TDB_DATA static_share_mode_record_value = {0}; static bool static_share_mode_record_talloced = false; /******************************************************************* @@ -611,6 +612,8 @@ struct share_mode_lock *get_share_mode_lock( goto fail; } static_share_mode_record_talloced = true; + static_share_mode_record_value = dbwrap_record_get_value( + static_share_mode_record); status = get_static_share_mode_data( static_share_mode_record, @@ -731,6 +734,7 @@ static void share_mode_do_locked_fn( if (static_share_mode_record == NULL) { static_share_mode_record = rec; + static_share_mode_record_value = value; static_share_mode_record_talloced = false; reset_static_share_mode_record = true; } else { @@ -760,7 +764,7 @@ NTSTATUS share_mode_do_locked( if (static_share_mode_record != NULL) { bool modified_dependent = false; - TDB_DATA static_key, static_value; + TDB_DATA static_key; int cmp; static_key = dbwrap_record_get_key(static_share_mode_record); @@ -772,9 +776,9 @@ NTSTATUS share_mode_do_locked( return NT_STATUS_INVALID_LOCK_SEQUENCE; } - static_value = dbwrap_record_get_value(static_share_mode_record); - - fn(static_value, &modified_dependent, private_data); + fn(static_share_mode_record_value, + &modified_dependent, + private_data); if (modified_dependent) { dbwrap_watched_wakeup(static_share_mode_record); -- 2.47.3