]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Simplify share_mode_entry_do()
authorVolker Lendecke <vl@samba.org>
Thu, 3 Dec 2020 16:12:20 +0000 (17:12 +0100)
committerJeremy Allison <jra@samba.org>
Fri, 4 Dec 2020 21:08:39 +0000 (21:08 +0000)
Rely on the truth in locking.tdb wrt existence of share entries

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/locking/share_mode_lock.c

index 98fa9f019a5bc77caef16eadfed30a950dcd464c..cfce43beabe953c80bb4c2a52bdb8767e196a664 100644 (file)
@@ -2160,7 +2160,7 @@ static bool share_mode_entry_do(
        bool modified;
        struct share_mode_entry e;
        uint8_t *e_ptr = NULL;
-       bool have_share_modes;
+       bool had_share_entries, have_share_entries;
        NTSTATUS status;
        bool ret = false;
 
@@ -2172,6 +2172,8 @@ static bool share_mode_entry_do(
        }
        DBG_DEBUG("num_share_modes=%zu\n", ltdb->num_share_entries);
 
+       had_share_entries = (ltdb->num_share_entries != 0);
+
        idx = share_mode_entry_find(
                ltdb->share_entries,
                ltdb->num_share_entries,
@@ -2248,9 +2250,12 @@ static bool share_mode_entry_do(
                goto done;
        }
 
-       have_share_modes = (ltdb->num_share_entries != 0);
-       if (d->have_share_modes != have_share_modes) {
-               d->have_share_modes = have_share_modes;
+       have_share_entries = (ltdb->num_share_entries != 0);
+       if (had_share_entries != have_share_entries) {
+               /*
+                * Make share_mode_data_store do the right thing wrt
+                * possibly deleting the locking.tdb record
+                */
                d->modified = true;
        }