summaryrefslogtreecommitdiff
path: root/src/or/rephist.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/or/rephist.c')
-rw-r--r--src/or/rephist.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/or/rephist.c b/src/or/rephist.c
index 76f3165235..8019be7257 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -462,6 +462,14 @@ get_weighted_fractional_uptime(or_history_t *hist, time_t when)
} else if (hist->start_of_downtime) {
total += (when - hist->start_of_downtime);
}
+
+ if (!total) {
+ /* Avoid calling anybody's uptime infinity (which should be impossible if
+ * the code is working), or NaN (which can happen for any router we haven't
+ * observed up or down yet). */
+ return 0.0;
+ }
+
return ((double) up) / total;
}