summaryrefslogtreecommitdiff
path: root/src/or/main.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-05-07 17:41:54 -0400
committerNick Mathewson <nickm@torproject.org>2018-05-09 12:06:52 -0400
commit0c19ce7bdece5906e035e71d3fb682632c8bb9cb (patch)
treee96b97b0ddaff1acc149da9f64f0649c1e67b6d2 /src/or/main.c
parent79b38081e985d65cfd08236d2eb42a87cc59a786 (diff)
downloadtor-0c19ce7bdece5906e035e71d3fb682632c8bb9cb.tar.gz
tor-0c19ce7bdece5906e035e71d3fb682632c8bb9cb.zip
Give control.c responsibility for its own once-a-second events
Now it has a function that can tell the rest of Tor whether any once-a-second controller item should fire, and a function to fire all the once-a-second events.
Diffstat (limited to 'src/or/main.c')
-rw-r--r--src/or/main.c19
1 files changed, 2 insertions, 17 deletions
diff --git a/src/or/main.c b/src/or/main.c
index c3505a2d91..8929931eb8 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -163,11 +163,6 @@ token_bucket_rw_t global_bucket;
/* Token bucket for relayed traffic. */
token_bucket_rw_t global_relayed_bucket;
-/* DOCDOC stats_prev_n_read */
-static uint64_t stats_prev_n_read = 0;
-/* DOCDOC stats_prev_n_written */
-static uint64_t stats_prev_n_written = 0;
-
/* XXX we might want to keep stats about global_relayed_*_bucket too. Or not.*/
/** How many bytes have we read since we started the process? */
static uint64_t stats_n_bytes_read = 0;
@@ -2508,8 +2503,6 @@ second_elapsed_callback(periodic_timer_t *timer, void *arg)
* could use Libevent's timers for this rather than checking the current
* time against a bunch of timeouts every second. */
time_t now;
- size_t bytes_written;
- size_t bytes_read;
int seconds_elapsed;
(void)timer;
(void)arg;
@@ -2522,16 +2515,9 @@ second_elapsed_callback(periodic_timer_t *timer, void *arg)
/* the second has rolled over. check more stuff. */
seconds_elapsed = current_second ? (int)(now - current_second) : 0;
- bytes_read = (size_t)(stats_n_bytes_read - stats_prev_n_read);
- bytes_written = (size_t)(stats_n_bytes_written - stats_prev_n_written);
- stats_prev_n_read = stats_n_bytes_read;
- stats_prev_n_written = stats_n_bytes_written;
- control_event_bandwidth_used((uint32_t)bytes_read,(uint32_t)bytes_written);
- control_event_stream_bandwidth_used();
- control_event_conn_bandwidth_used();
- control_event_circ_bandwidth_used();
- control_event_circuit_cell_stats();
+ /* Maybe some controller events are ready to fire */
+ control_per_second_events();
/** If more than this many seconds have elapsed, probably the clock
* jumped: doesn't count. */
@@ -3651,7 +3637,6 @@ tor_free_all(int postfork)
memset(&global_bucket, 0, sizeof(global_bucket));
memset(&global_relayed_bucket, 0, sizeof(global_relayed_bucket));
- stats_prev_n_read = stats_prev_n_written = 0;
stats_n_bytes_read = stats_n_bytes_written = 0;
time_of_process_start = 0;
time_of_last_signewnym = 0;