]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Make share_mode_do_locked() pass TDB_DATA instead of a record
authorVolker Lendecke <vl@samba.org>
Fri, 1 Nov 2019 11:33:23 +0000 (12:33 +0100)
committerJeremy Allison <jra@samba.org>
Wed, 13 Nov 2019 21:41:09 +0000 (21:41 +0000)
No callback used (and should not use) the record directly, this is all
handled within share_mode_lock.c

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Nov 13 21:41:09 UTC 2019 on sn-devel-184

source3/locking/locking.c
source3/locking/proto.h
source3/locking/share_mode_lock.c

index 52309e5fc81661592411a77c764ba1a68ab51578..7822c2b3665844c16b5e87c47a0d1d99c9cf5e35 100644 (file)
@@ -247,7 +247,7 @@ struct do_lock_state {
 };
 
 static void do_lock_fn(
-       struct db_record *rec,
+       TDB_DATA value,
        bool *modified_dependent,
        void *private_data)
 {
index fe171ea501244c05d2d2d0e773bb18ddc954d690..fc11ef8863c66d5d84bb6f60de4feb7484487ab5 100644 (file)
@@ -23,6 +23,8 @@
 #ifndef _LOCKING_PROTO_H_
 #define _LOCKING_PROTO_H_
 
+#include <tdb.h>
+
 /* The following definitions come from locking/brlock.c  */
 
 void brl_init(bool read_only);
@@ -142,7 +144,7 @@ bool file_has_read_lease(struct files_struct *fsp);
 struct db_record;
 NTSTATUS share_mode_do_locked(
        struct file_id id,
-       void (*fn)(struct db_record *rec,
+       void (*fn)(TDB_DATA value,
                   bool *modified_dependent,
                   void *private_data),
        void *private_data);
index 4fcca861e4810f7b39a7226de60576aa4be49b58..234dd90c1d0a94e98f12cc654e908d54dfa11c41 100644 (file)
@@ -225,10 +225,9 @@ struct fsp_update_share_mode_flags_state {
 };
 
 static void fsp_update_share_mode_flags_fn(
-       struct db_record *rec, bool *modified_dependent, void *private_data)
+       TDB_DATA value, bool *modified_dependent, void *private_data)
 {
        struct fsp_update_share_mode_flags_state *state = private_data;
-       TDB_DATA value = dbwrap_record_get_value(rec);
        DATA_BLOB blob = { .data = value.dptr, .length = value.dsize };
        uint64_t seq;
 
@@ -715,7 +714,7 @@ static int share_mode_lock_destructor(struct share_mode_lock *lck)
 }
 
 struct share_mode_do_locked_state {
-       void (*fn)(struct db_record *rec,
+       void (*fn)(TDB_DATA value,
                   bool *modified_dependent,
                   void *private_data);
        void *private_data;
@@ -727,6 +726,7 @@ static void share_mode_do_locked_fn(struct db_record *rec,
        struct share_mode_do_locked_state *state = private_data;
        bool modified_dependent = false;
        bool reset_static_share_mode_record = false;
+       TDB_DATA value = dbwrap_record_get_value(rec);
 
        if (static_share_mode_record == NULL) {
                static_share_mode_record = rec;
@@ -736,7 +736,7 @@ static void share_mode_do_locked_fn(struct db_record *rec,
                SMB_ASSERT(static_share_mode_record == rec);
        }
 
-       state->fn(rec, &modified_dependent, state->private_data);
+       state->fn(value, &modified_dependent, state->private_data);
 
        if (modified_dependent) {
                dbwrap_watched_wakeup(rec);
@@ -749,7 +749,7 @@ static void share_mode_do_locked_fn(struct db_record *rec,
 
 NTSTATUS share_mode_do_locked(
        struct file_id id,
-       void (*fn)(struct db_record *rec,
+       void (*fn)(TDB_DATA value,
                   bool *modified_dependent,
                   void *private_data),
        void *private_data)
@@ -759,7 +759,7 @@ NTSTATUS share_mode_do_locked(
 
        if (static_share_mode_record != NULL) {
                bool modified_dependent = false;
-               TDB_DATA static_key;
+               TDB_DATA static_key, static_value;
                int cmp;
 
                static_key = dbwrap_record_get_key(static_share_mode_record);
@@ -771,9 +771,9 @@ NTSTATUS share_mode_do_locked(
                        return NT_STATUS_INVALID_LOCK_SEQUENCE;
                }
 
-               fn(static_share_mode_record,
-                  &modified_dependent,
-                  private_data);
+               static_value = dbwrap_record_get_value(static_share_mode_record);
+
+               fn(static_value, &modified_dependent, private_data);
 
                if (modified_dependent) {
                        dbwrap_watched_wakeup(static_share_mode_record);
@@ -798,7 +798,7 @@ NTSTATUS share_mode_do_locked(
        return NT_STATUS_OK;
 }
 
-static void share_mode_wakeup_waiters_fn(struct db_record *rec,
+static void share_mode_wakeup_waiters_fn(TDB_DATA value,
                                         bool *modified_dependent,
                                         void *private_data)
 {