Rework rep_hist_log_link_protocol_counts()

This commit is contained in:
rl1987 2018-12-23 20:55:14 +02:00 committed by Nick Mathewson
parent efd765a948
commit 9d9e71824c
2 changed files with 23 additions and 18 deletions

6
changes/bug28920 Normal file
View File

@ -0,0 +1,6 @@
o Minor bugfixes (logging):
- Rework rep_hist_log_link_protocol_counts() to iterate through all link
protocol versions when logging incoming/outgoing connection counts. Tor
no longer skips version 5 and we don't have to remember to update this
function when new link protocol version is developed. Fixes bug 28920;
bugfix on 0.2.6.10.

View File

@ -2874,24 +2874,23 @@ rep_hist_get_padding_count_lines(void)
void void
rep_hist_log_link_protocol_counts(void) rep_hist_log_link_protocol_counts(void)
{ {
log_notice(LD_HEARTBEAT, smartlist_t *lines = smartlist_new();
"Since startup, we have initiated "
"%"PRIu64" v1 connections, " for (int i = 1; i <= MAX_LINK_PROTO; i++) {
"%"PRIu64" v2 connections, " char *line = NULL;
"%"PRIu64" v3 connections, and " tor_asprintf(&line, "initiated %"PRIu64" and received "
"%"PRIu64" v4 connections; and received " "%"PRIu64" v%d connections", link_proto_count[i][1],
"%"PRIu64" v1 connections, " link_proto_count[i][0], i);
"%"PRIu64" v2 connections, " smartlist_add(lines, line);
"%"PRIu64" v3 connections, and " }
"%"PRIu64" v4 connections.",
(link_proto_count[1][1]), char *log_line = smartlist_join_strings(lines, "; ", 0, NULL);
(link_proto_count[2][1]),
(link_proto_count[3][1]), log_notice(LD_HEARTBEAT, "Since startup we %s.", log_line);
(link_proto_count[4][1]),
(link_proto_count[1][0]), SMARTLIST_FOREACH(lines, char *, s, tor_free(s));
(link_proto_count[2][0]), smartlist_free(lines);
(link_proto_count[3][0]), tor_free(log_line);
(link_proto_count[4][0]));
} }
/** Free all storage held by the OR/link history caches, by the /** Free all storage held by the OR/link history caches, by the