smbd: split out a fsp_flush_write_time_update() function from update_write_time_handler()
authorStefan Metzmacher <metze@samba.org>
Wed, 23 May 2018 07:41:29 +0000 (09:41 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 14 Jun 2018 18:52:23 +0000 (20:52 +0200)
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 <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/close.c
source3/smbd/durable.c
source3/smbd/fileio.c
source3/smbd/proto.h

index 3324d3ec4e03fd06ba404015eed9d6b4719af563..8581b04e8aaf43710e959e530dc41fcf9004d073 100644 (file)
@@ -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);
        }
 
        /*
index 602a96e1fe56bc874f738893685046a931b101ce..7d7a1b2175146cc689d18e8abd3c2718ef732ae8 100644 (file)
@@ -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);
        }
 
        /*
index 1c8bb41620c869b196587ba7815941563209b2d8..cde6a057ccdafc65f1148a4a43976330421c6a64 100644 (file)
@@ -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.
index aacdeb44daf9aac28f5f1b4cf259368be98729be..2851d6d5f7df623eb51c575bf02c3f5c621c983b 100644 (file)
@@ -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);