From 851cadba51b00b326c5f040f23f95932aec53105 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 1 Apr 2008 11:40:23 +0200 Subject: locking: combine get_delete_on_close_flag() and get_write_time() into get_file_infos() This means we need to fetch the record only once. metze (This used to be commit 4130b873291d39e363184fe4e38dc1f24ebe5056) --- source3/locking/locking.c | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'source3/locking') diff --git a/source3/locking/locking.c b/source3/locking/locking.c index 8d8c0347a5..5faebef1fe 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -940,37 +940,40 @@ bool rename_share_filename(struct messaging_context *msg_ctx, return True; } -struct timespec get_write_time(struct file_id id) +void get_file_infos(struct file_id id, + bool *delete_on_close, + struct timespec *write_time) { - struct timespec result; struct share_mode_lock *lck; - ZERO_STRUCT(result); + if (delete_on_close) { + *delete_on_close = false; + } + + if (write_time) { + ZERO_STRUCTP(write_time); + } if (!(lck = fetch_share_mode_unlocked(talloc_tos(), id, NULL, NULL))) { - return result; + return; } - result = lck->changed_write_time; - if (null_timespec(result)) { - result = lck->old_write_time; + if (delete_on_close) { + *delete_on_close = lck->delete_on_close; } - TALLOC_FREE(lck); - return result; -} + if (write_time) { + struct timespec wt; -bool get_delete_on_close_flag(struct file_id id) -{ - bool result; - struct share_mode_lock *lck; - - if (!(lck = fetch_share_mode_unlocked(talloc_tos(), id, NULL, NULL))) { - return False; + wt = lck->changed_write_time; + if (null_timespec(wt)) { + wt = lck->old_write_time; + } + + *write_time = wt; } - result = lck->delete_on_close; + TALLOC_FREE(lck); - return result; } bool is_valid_share_mode_entry(const struct share_mode_entry *e) -- cgit