summaryrefslogtreecommitdiff
path: root/src/or/status.c
diff options
context:
space:
mode:
authorAlexander Færøy <ahf@torproject.org>2017-12-16 02:41:21 +0100
committerAlexander Færøy <ahf@torproject.org>2017-12-16 02:41:21 +0100
commitd4f4108601fe7e2614f30055ff5abe00460f6a12 (patch)
treef8c926dc04c1c476561fff41b6d7fb25eed3dd20 /src/or/status.c
parente44662a7f9af990753a89b0a831d3439a509c8ae (diff)
downloadtor-d4f4108601fe7e2614f30055ff5abe00460f6a12.tar.gz
tor-d4f4108601fe7e2614f30055ff5abe00460f6a12.zip
Add MainloopStats option.
This patch adds support for MainloopStats that allow developers to get main event loop statistics via Tor's heartbeat status messages. The new status log message will show how many succesful, erroneous, and idle event loop iterations we have had. See: https://bugs.torproject.org/24605
Diffstat (limited to 'src/or/status.c')
-rw-r--r--src/or/status.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/or/status.c b/src/or/status.c
index f7be41e412..1a8885e83e 100644
--- a/src/or/status.c
+++ b/src/or/status.c
@@ -157,6 +157,20 @@ log_heartbeat(time_t now)
tor_free(msg);
}
+ if (options->MainloopStats) {
+ const uint64_t main_loop_success_count = get_main_loop_success_count();
+ const uint64_t main_loop_error_count = get_main_loop_error_count();
+ const uint64_t main_loop_idle_count = get_main_loop_idle_count();
+
+ log_fn(LOG_NOTICE, LD_HEARTBEAT, "Main event loop statistics: "
+ U64_FORMAT " succesful returns, "
+ U64_FORMAT " erroneous returns, and "
+ U64_FORMAT " idle returns.",
+ U64_PRINTF_ARG(main_loop_success_count),
+ U64_PRINTF_ARG(main_loop_error_count),
+ U64_PRINTF_ARG(main_loop_idle_count));
+ }
+
tor_free(uptime);
tor_free(bw_sent);
tor_free(bw_rcvd);