[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Add update_current_time() calls to periodic and event-driven callbacks



commit 83137275a77eedbf177fbdb298c89a346abe2243
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Thu May 3 10:56:49 2018 -0400

    Add update_current_time() calls to periodic and event-driven callbacks
    
    This is part of 26009, where we're going to keep track of the
    current time and its jumps without having to do so in
    second_elapsed_callback.
---
 src/or/connection.c | 3 ++-
 src/or/main.c       | 1 +
 src/or/periodic.c   | 2 ++
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/or/connection.c b/src/or/connection.c
index c2673ade1..df36d4211 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -3439,7 +3439,7 @@ int
 connection_handle_read(connection_t *conn)
 {
   int res;
-
+  update_current_time(time(NULL));
   res = connection_handle_read_impl(conn);
   return res;
 }
@@ -3982,6 +3982,7 @@ int
 connection_handle_write(connection_t *conn, int force)
 {
     int res;
+    update_current_time(time(NULL));
     conn->in_connection_handle_write = 1;
     res = connection_handle_write_impl(conn, force);
     conn->in_connection_handle_write = 0;
diff --git a/src/or/main.c b/src/or/main.c
index 6ecc340a9..d773c8e29 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -3047,6 +3047,7 @@ signal_callback(evutil_socket_t fd, short events, void *arg)
   (void)fd;
   (void)events;
 
+  update_current_time(time(NULL));
   process_signal(sig);
 }
 
diff --git a/src/or/periodic.c b/src/or/periodic.c
index 76aa418b3..92fa677f8 100644
--- a/src/or/periodic.c
+++ b/src/or/periodic.c
@@ -14,6 +14,7 @@
 #include "or.h"
 #include "compat_libevent.h"
 #include "config.h"
+#include "main.h"
 #include "periodic.h"
 
 /** We disable any interval greater than this number of seconds, on the
@@ -48,6 +49,7 @@ periodic_event_dispatch(mainloop_event_t *ev, void *data)
   }
 
   time_t now = time(NULL);
+  update_current_time(now);
   const or_options_t *options = get_options();
 //  log_debug(LD_GENERAL, "Dispatching %s", event->name);
   int r = event->fn(now, options);



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits