From 51407b90d9363341252acdf3663886b22d1ee4c7 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 23 May 2018 09:41:29 +0200 Subject: [PATCH] smbd: split out a fsp_flush_write_time_update() function from update_write_time_handler() It's confusing to call update_write_time_handler() from anywhere, it should only be called from within the event loop when the timer expires. This makes it more obvious that fsp_flush_write_time_update() doesn't really need an tevent context argument. Signed-off-by: Stefan Metzmacher Reviewed-by: Jeremy Allison --- source3/smbd/close.c | 5 +---- source3/smbd/durable.c | 5 +---- source3/smbd/fileio.c | 19 ++++++++++++++----- source3/smbd/proto.h | 5 +---- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/source3/smbd/close.c b/source3/smbd/close.c index 3324d3ec4e0..8581b04e8aa 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -255,10 +255,7 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp, /* Ensure any pending write time updates are done. */ if (fsp->update_write_time_event) { - update_write_time_handler(fsp->conn->sconn->ev_ctx, - fsp->update_write_time_event, - timeval_current(), - (void *)fsp); + fsp_flush_write_time_update(fsp); } /* diff --git a/source3/smbd/durable.c b/source3/smbd/durable.c index 602a96e1fe5..7d7a1b21751 100644 --- a/source3/smbd/durable.c +++ b/source3/smbd/durable.c @@ -194,10 +194,7 @@ NTSTATUS vfs_default_durable_disconnect(struct files_struct *fsp, /* Ensure any pending write time updates are done. */ if (fsp->update_write_time_event) { - update_write_time_handler(fsp->conn->sconn->ev_ctx, - fsp->update_write_time_event, - timeval_current(), - (void *)fsp); + fsp_flush_write_time_update(fsp); } /* diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c index 1c8bb41620c..cde6a057ccd 100644 --- a/source3/smbd/fileio.c +++ b/source3/smbd/fileio.c @@ -160,12 +160,12 @@ static int wcp_file_size_change(files_struct *fsp) return ret; } -void update_write_time_handler(struct tevent_context *ctx, - struct tevent_timer *te, - struct timeval now, - void *private_data) +void fsp_flush_write_time_update(struct files_struct *fsp) { - files_struct *fsp = (files_struct *)private_data; + /* + * Note this won't expect any impersonation! + * So don't call any SMB_VFS operations here! + */ DEBUG(5, ("Update write time on %s\n", fsp_str_dbg(fsp))); @@ -180,6 +180,15 @@ void update_write_time_handler(struct tevent_context *ctx, TALLOC_FREE(fsp->update_write_time_event); } +static void update_write_time_handler(struct tevent_context *ctx, + struct tevent_timer *te, + struct timeval now, + void *private_data) +{ + files_struct *fsp = (files_struct *)private_data; + fsp_flush_write_time_update(fsp); +} + /********************************************************* Schedule a write time update for WRITE_TIME_UPDATE_USEC_DELAY in the future. diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index aacdeb44daf..2851d6d5f7d 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -320,10 +320,7 @@ NTSTATUS can_set_delete_on_close(files_struct *fsp, uint32_t dosmode); /* The following definitions come from smbd/fileio.c */ ssize_t read_file(files_struct *fsp,char *data,off_t pos,size_t n); -void update_write_time_handler(struct tevent_context *ctx, - struct tevent_timer *te, - struct timeval now, - void *private_data); +void fsp_flush_write_time_update(struct files_struct *fsp); void trigger_write_time_update(struct files_struct *fsp); void trigger_write_time_update_immediate(struct files_struct *fsp); void mark_file_modified(files_struct *fsp); -- 2.34.1