summaryrefslogtreecommitdiff
path: root/src/feature/stats/rephist.c
diff options
context:
space:
mode:
authorAlexander Færøy <ahf@torproject.org>2021-04-12 18:36:05 +0000
committerDavid Goulet <dgoulet@torproject.org>2021-04-13 15:11:03 -0400
commit705ea32c6e832ab2f063dc9802a03f53e4371b9a (patch)
treef5d16b823e6790c194118f496fc661608f82d238 /src/feature/stats/rephist.c
parent1b48a28a7476d8c29cb505ad53daa3c4fe275500 (diff)
downloadtor-705ea32c6e832ab2f063dc9802a03f53e4371b9a.tar.gz
tor-705ea32c6e832ab2f063dc9802a03f53e4371b9a.zip
relay: Move "overload-general" from extra-info to server descriptor.
Fixes #40364 Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/feature/stats/rephist.c')
-rw-r--r--src/feature/stats/rephist.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/feature/stats/rephist.c b/src/feature/stats/rephist.c
index 4ad5d46b0c..e25c01331d 100644
--- a/src/feature/stats/rephist.c
+++ b/src/feature/stats/rephist.c
@@ -221,23 +221,34 @@ overload_happened_recently(time_t overload_time, int n_hours)
/* The current version of the overload stats version */
#define OVERLOAD_STATS_VERSION 1
-/** Returns an allocated string for extra-info documents for publishing
- * overload statistics. */
+/** Returns an allocated string for server descriptor for publising information
+ * on whether we are overloaded or not. */
char *
-rep_hist_get_overload_stats_lines(void)
+rep_hist_get_overload_general_line(void)
{
char *result = NULL;
- smartlist_t *chunks = smartlist_new();
char tbuf[ISO_TIME_LEN+1];
- /* First encode the general overload */
+ /* 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\n",
- OVERLOAD_STATS_VERSION, tbuf);
+ tor_asprintf(&result, "overload-general %d %s\n",
+ OVERLOAD_STATS_VERSION, tbuf);
}
- /* Now do bandwidth-related overloads */
+ return result;
+}
+
+/** Returns an allocated string for extra-info documents for publishing
+ * overload statistics. */
+char *
+rep_hist_get_overload_stats_lines(void)
+{
+ char *result = NULL;
+ smartlist_t *chunks = smartlist_new();
+ char tbuf[ISO_TIME_LEN+1];
+
+ /* Add bandwidth-related overloads */
if (overload_happened_recently(overload_stats.overload_ratelimits_time,24)) {
const or_options_t *options = get_options();
format_iso_time(tbuf, overload_stats.overload_ratelimits_time);