summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/feature/stats/rephist.c8
-rw-r--r--src/test/test_stats.c20
2 files changed, 14 insertions, 14 deletions
diff --git a/src/feature/stats/rephist.c b/src/feature/stats/rephist.c
index 7c0c28804c..4ad5d46b0c 100644
--- a/src/feature/stats/rephist.c
+++ b/src/feature/stats/rephist.c
@@ -233,7 +233,7 @@ rep_hist_get_overload_stats_lines(void)
/* First encode the general overload */
if (overload_happened_recently(overload_stats.overload_general_time, 72)) {
format_iso_time(tbuf, overload_stats.overload_general_time);
- smartlist_add_asprintf(chunks, "overload-general %d %s",
+ smartlist_add_asprintf(chunks, "overload-general %d %s\n",
OVERLOAD_STATS_VERSION, tbuf);
}
@@ -243,7 +243,7 @@ rep_hist_get_overload_stats_lines(void)
format_iso_time(tbuf, overload_stats.overload_ratelimits_time);
smartlist_add_asprintf(chunks,
"overload-ratelimits %d %s %" PRIu64 " %" PRIu64
- " %" PRIu64 " %" PRIu64,
+ " %" PRIu64 " %" PRIu64 "\n",
OVERLOAD_STATS_VERSION, tbuf,
options->BandwidthRate, options->BandwidthBurst,
overload_stats.overload_read_count,
@@ -254,7 +254,7 @@ rep_hist_get_overload_stats_lines(void)
if (overload_happened_recently(
overload_stats.overload_fd_exhausted_time, 72)) {
format_iso_time(tbuf, overload_stats.overload_fd_exhausted_time);
- smartlist_add_asprintf(chunks, "overload-fd-exhausted %d %s",
+ smartlist_add_asprintf(chunks, "overload-fd-exhausted %d %s\n",
OVERLOAD_STATS_VERSION, tbuf);
}
@@ -263,7 +263,7 @@ rep_hist_get_overload_stats_lines(void)
goto done;
}
- result = smartlist_join_strings(chunks, "\n", 0, NULL);
+ result = smartlist_join_strings(chunks, "", 0, NULL);
done:
SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
diff --git a/src/test/test_stats.c b/src/test/test_stats.c
index a34713b650..465256a1e1 100644
--- a/src/test/test_stats.c
+++ b/src/test/test_stats.c
@@ -728,7 +728,7 @@ test_overload_stats(void *arg)
/* Now check the string */
stats_str = rep_hist_get_overload_stats_lines();
- tt_str_op("overload-general 1 2002-01-03 23:00:00", OP_EQ, stats_str);
+ tt_str_op("overload-general 1 2002-01-03 23:00:00\n", OP_EQ, stats_str);
tor_free(stats_str);
/* Move the time forward 72 hours: see that the line has disappeared. */
@@ -744,7 +744,7 @@ test_overload_stats(void *arg)
rep_hist_note_overload(OVERLOAD_GENERAL);
stats_str = rep_hist_get_overload_stats_lines();
- tt_str_op("overload-general 1 2002-01-07 00:00:00", OP_EQ, stats_str);
+ tt_str_op("overload-general 1 2002-01-07 00:00:00\n", OP_EQ, stats_str);
tor_free(stats_str);
/* Also note an fd exhaustion event */
@@ -752,7 +752,7 @@ test_overload_stats(void *arg)
stats_str = rep_hist_get_overload_stats_lines();
tt_str_op("overload-general 1 2002-01-07 00:00:00\n"
- "overload-fd-exhausted 1 2002-01-07 00:00:00", OP_EQ, stats_str);
+ "overload-fd-exhausted 1 2002-01-07 00:00:00\n", OP_EQ, stats_str);
tor_free(stats_str);
/* Move the time forward. Register DNS overload. See that the time changed */
@@ -763,7 +763,7 @@ test_overload_stats(void *arg)
stats_str = rep_hist_get_overload_stats_lines();
tt_str_op("overload-general 1 2002-01-07 02:00:00\n"
- "overload-fd-exhausted 1 2002-01-07 00:00:00", OP_EQ, stats_str);
+ "overload-fd-exhausted 1 2002-01-07 00:00:00\n", OP_EQ, stats_str);
tor_free(stats_str);
/* Move the time forward. Register a bandwidth ratelimit event. See that the
@@ -780,7 +780,7 @@ test_overload_stats(void *arg)
stats_str = rep_hist_get_overload_stats_lines();
tt_str_op("overload-general 1 2002-01-07 02:00:00\n"
"overload-ratelimits 1 2002-01-07 04:00:00 1000 2000 1 0\n"
- "overload-fd-exhausted 1 2002-01-07 00:00:00", OP_EQ, stats_str);
+ "overload-fd-exhausted 1 2002-01-07 00:00:00\n", OP_EQ, stats_str);
tor_free(stats_str);
/* Move the time forward 24 hours: no rate limit line anymore. */
@@ -789,7 +789,7 @@ test_overload_stats(void *arg)
stats_str = rep_hist_get_overload_stats_lines();
tt_str_op("overload-general 1 2002-01-07 02:00:00\n"
- "overload-fd-exhausted 1 2002-01-07 00:00:00", OP_EQ, stats_str);
+ "overload-fd-exhausted 1 2002-01-07 00:00:00\n", OP_EQ, stats_str);
tor_free(stats_str);
/* Move the time forward 44 hours: no fd exhausted line anymore. */
@@ -797,7 +797,7 @@ test_overload_stats(void *arg)
update_approx_time(current_time);
stats_str = rep_hist_get_overload_stats_lines();
- tt_str_op("overload-general 1 2002-01-07 02:00:00", OP_EQ, stats_str);
+ tt_str_op("overload-general 1 2002-01-07 02:00:00\n", OP_EQ, stats_str);
tor_free(stats_str);
/* Move the time forward 2 hours: there is nothing left. */
@@ -815,7 +815,7 @@ test_overload_stats(void *arg)
* registered ten more overload events, but only one should have been counted
* because of the rate limiter */
stats_str = rep_hist_get_overload_stats_lines();
- tt_str_op("overload-ratelimits 1 2002-01-10 02:00:00 1000 2000 2 0",
+ tt_str_op("overload-ratelimits 1 2002-01-10 02:00:00 1000 2000 2 0\n",
OP_EQ, stats_str);
tor_free(stats_str);
@@ -828,7 +828,7 @@ test_overload_stats(void *arg)
rep_hist_note_overload(OVERLOAD_READ);
}
stats_str = rep_hist_get_overload_stats_lines();
- tt_str_op("overload-ratelimits 1 2002-01-10 02:00:00 1000 2000 2 0",
+ tt_str_op("overload-ratelimits 1 2002-01-10 02:00:00 1000 2000 2 0\n",
OP_EQ, stats_str);
tor_free(stats_str);
@@ -842,7 +842,7 @@ test_overload_stats(void *arg)
rep_hist_note_overload(OVERLOAD_WRITE);
}
stats_str = rep_hist_get_overload_stats_lines();
- tt_str_op("overload-ratelimits 1 2002-01-10 02:00:00 1000 2000 3 1",
+ tt_str_op("overload-ratelimits 1 2002-01-10 02:00:00 1000 2000 3 1\n",
OP_EQ, stats_str);
tor_free(stats_str);