diff options
author | Volker Lendecke <vl@samba.org> | 2019-08-23 18:11:57 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2019-09-10 23:14:31 +0000 |
commit | 4204ed2b82fd8e9f6faf6e05a009d0ad7742c649 (patch) | |
tree | 5b4c4f55213ea560a7a00a142b016794a3abc2f3 /source3/locking | |
parent | 92c2a723b278fb0338248bfb1fd1c1f4b90dce2b (diff) | |
download | samba-4204ed2b82fd8e9f6faf6e05a009d0ad7742c649.tar.gz |
smbd: Use dbwrap_do_locked() in add_fd_to_close_entry()
Less explicit talloc. Right now dbwrap_rbt behind the scenes does a
dbwrap_fetch_locked(), but that will eventually change.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/locking')
-rw-r--r-- | source3/locking/posix.c | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/source3/locking/posix.c b/source3/locking/posix.c index a7bb5519bb4..5b5fc229d33 100644 --- a/source3/locking/posix.c +++ b/source3/locking/posix.c @@ -508,44 +508,46 @@ static void delete_lock_ref_count(const files_struct *fsp) ref count is non zero. ****************************************************************************/ -/**************************************************************************** - Add an fd to the pending close db. -****************************************************************************/ +struct add_fd_to_close_entry_state { + const struct files_struct *fsp; +}; -static void add_fd_to_close_entry(const files_struct *fsp) +static void add_fd_to_close_entry_fn( + struct db_record *rec, void *private_data) { - struct db_record *rec; - int *fds; - size_t num_fds; + struct add_fd_to_close_entry_state *state = private_data; + TDB_DATA values[] = { + dbwrap_record_get_value(rec), + { .dptr = (uint8_t *)&(state->fsp->fh->fd), + .dsize = sizeof(state->fsp->fh->fd) }, + }; NTSTATUS status; - TDB_DATA value; - - rec = dbwrap_fetch_locked( - posix_pending_close_db, talloc_tos(), - fd_array_key_fsp(fsp)); - - SMB_ASSERT(rec != NULL); - value = dbwrap_record_get_value(rec); - SMB_ASSERT((value.dsize % sizeof(int)) == 0); + SMB_ASSERT((values[0].dsize % sizeof(int)) == 0); - num_fds = value.dsize / sizeof(int); - fds = talloc_array(rec, int, num_fds+1); - - SMB_ASSERT(fds != NULL); + status = dbwrap_record_storev(rec, values, ARRAY_SIZE(values), 0); + SMB_ASSERT(NT_STATUS_IS_OK(status)); +} - memcpy(fds, value.dptr, value.dsize); - fds[num_fds] = fsp->fh->fd; +/**************************************************************************** + Add an fd to the pending close db. +****************************************************************************/ - status = dbwrap_record_store( - rec, make_tdb_data((uint8_t *)fds, talloc_get_size(fds)), 0); +static void add_fd_to_close_entry(const files_struct *fsp) +{ + struct add_fd_to_close_entry_state state = { .fsp = fsp }; + NTSTATUS status; + status = dbwrap_do_locked( + posix_pending_close_db, + fd_array_key_fsp(fsp), + add_fd_to_close_entry_fn, + &state); SMB_ASSERT(NT_STATUS_IS_OK(status)); - TALLOC_FREE(rec); - - DEBUG(10,("add_fd_to_close_entry: added fd %d file %s\n", - fsp->fh->fd, fsp_str_dbg(fsp))); + DBG_DEBUG("added fd %d file %s\n", + fsp->fh->fd, + fsp_str_dbg(fsp)); } /**************************************************************************** |