From c3e4b12e7f0cc123114d60222c1cb4a47a85551f Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 18 Dec 2008 17:19:23 +0000 Subject: [PATCH] Why were we using gettimeofday() in second_elapsed_callback? We were only ever looking at the tv_sec field. svn:r17691 --- src/or/main.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/or/main.c b/src/or/main.c index 17cd6d2676..28a33480d9 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -1173,7 +1173,7 @@ second_elapsed_callback(int fd, short event, void *args) * time against a bunch of timeouts every second. */ static struct timeval one_second; static long current_second = 0; - struct timeval now; + time_t now; size_t bytes_written; size_t bytes_read; int seconds_elapsed; @@ -1191,13 +1191,13 @@ second_elapsed_callback(int fd, short event, void *args) n_libevent_errors = 0; /* log_fn(LOG_NOTICE, "Tick."); */ - tor_gettimeofday(&now); - update_approx_time(now.tv_sec); + now = time(NULL); + update_approx_time(now); /* the second has rolled over. check more stuff. */ bytes_written = stats_prev_global_write_bucket - global_write_bucket; bytes_read = stats_prev_global_read_bucket - global_read_bucket; - seconds_elapsed = current_second ? (int)(now.tv_sec - current_second) : 0; + seconds_elapsed = current_second ? (int)(now - current_second) : 0; stats_n_bytes_read += bytes_read; stats_n_bytes_written += bytes_written; if (accounting_is_enabled(options) && seconds_elapsed >= 0) @@ -1206,7 +1206,7 @@ second_elapsed_callback(int fd, short event, void *args) control_event_stream_bandwidth_used(); if (seconds_elapsed > 0) - connection_bucket_refill(seconds_elapsed, now.tv_sec); + connection_bucket_refill(seconds_elapsed, now); stats_prev_global_read_bucket = global_read_bucket; stats_prev_global_write_bucket = global_write_bucket; @@ -1243,9 +1243,9 @@ second_elapsed_callback(int fd, short event, void *args) } else if (seconds_elapsed > 0) stats_n_seconds_working += seconds_elapsed; - run_scheduled_events(now.tv_sec); + run_scheduled_events(now); - current_second = now.tv_sec; /* remember which second it is, for next time */ + current_second = now; /* remember which second it is, for next time */ #if 0 if (current_second % 300 == 0) {