From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: cypherpunks Date: Tue, 21 Jun 2016 13:03:38 +0000 Subject: [PATCH] Use the return value for choosing intervals --- src/or/main.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/or/main.c b/src/or/main.c index 4de2e70..d1a9178 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -2015,14 +2015,19 @@ heartbeat_callback(time_t now, const or_options_t *options) return PERIODIC_EVENT_NO_UPDATE; } - /* Write the heartbeat message */ + /* Skip the first one. */ if (first) { - first = 0; /* Skip the first one. */ - } else { - log_heartbeat(now); + first = 0; + return options->HeartbeatPeriod; } - return options->HeartbeatPeriod; + /* Write the heartbeat message */ + int r = log_heartbeat(now); + if (r == 0) { + return options->HeartbeatPeriod; + } + + return PERIODIC_EVENT_NO_UPDATE; } /** Timer: used to invoke second_elapsed_callback() once per second. */