/* 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);
}
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,
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);
}
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));
/* 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. */
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 */
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 */
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
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. */
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. */
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. */
* 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);
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);
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);