From 1ba4672ee909251d41d2edb9af957549a72a1a36 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 3 Dec 2020 17:12:20 +0100 Subject: [PATCH] smbd: Simplify share_mode_entry_do() Rely on the truth in locking.tdb wrt existence of share entries Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- source3/locking/share_mode_lock.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c index 98fa9f019a5..cfce43beabe 100644 --- a/source3/locking/share_mode_lock.c +++ b/source3/locking/share_mode_lock.c @@ -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; } -- 2.47.3