From: Volker Lendecke Date: Tue, 10 Dec 2019 17:15:40 +0000 (+0100) Subject: smbd: Use share_mode_data->num_share_modes as a boolean X-Git-Tag: ldb-2.1.0~235 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9734bad37b8bc4b2815f2bff4c0f48d33fb76c4d;p=thirdparty%2Fsamba.git smbd: Use share_mode_data->num_share_modes as a boolean This is a micro-commit showing that we don't actually need share_mode_data->num_share_modes as a number *counting* the share mode entries in share_entries.tdb anymore. Instead, we are only using it as an indication for share_mode_lock_destructor() to see whether share entries are around or not, i.e. whether it's worth keeping or deleting the record in locking.tdb. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c index 66132e5d3bb..4b4faa6220b 100644 --- a/source3/locking/share_mode_lock.c +++ b/source3/locking/share_mode_lock.c @@ -1508,7 +1508,7 @@ static size_t share_mode_entry_find( struct set_share_mode_state { struct share_mode_entry e; - uint32_t num_share_modes; + bool created_share_mode_record; NTSTATUS status; }; @@ -1588,7 +1588,7 @@ static void set_share_mode_fn( } } - state->num_share_modes = num_share_modes+1; + state->created_share_mode_record = (num_share_modes == 0); state->status = dbwrap_record_storev(rec, dbufs, num_dbufs, 0); } @@ -1641,8 +1641,10 @@ bool set_share_mode(struct share_mode_lock *lck, return false; } - d->num_share_modes = state.num_share_modes; - d->modified = true; + if (state.created_share_mode_record) { + d->num_share_modes = 1; + d->modified = true; + } return true; } @@ -1653,7 +1655,6 @@ struct share_mode_forall_entries_state { bool *modified, void *private_data); void *private_data; - size_t num_share_modes; bool ok; }; @@ -1788,12 +1789,11 @@ static void share_mode_forall_entries_fn( return; } - if (num_share_modes != d->num_share_modes) { - d->num_share_modes = num_share_modes; - d->modified = true; - } - if (num_share_modes == 0) { + if (data.dsize != 0) { + d->num_share_modes = 0; + d->modified = true; + } status = dbwrap_record_delete(rec); } else { TDB_DATA value = { @@ -2298,9 +2298,7 @@ bool reset_share_mode_entry( nt_errstr(state.status)); return false; } - - d->num_share_modes = state.num_share_modes; - d->modified = true; + d->num_share_modes = 1; return true; }