[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/maint-0.2.8] Fix bug when disabling heartbeats.



commit f038e9cb00b9324b24a100d7cd3576410a7ae7f3
Author: George Kadianakis <desnacked@xxxxxxxxxx>
Date:   Tue Jun 21 15:05:59 2016 +0300

    Fix bug when disabling heartbeats.
    
    Callbacks can't return 0.
---
 changes/bug19454 |  3 +++
 src/or/main.c    | 12 +++++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/changes/bug19454 b/changes/bug19454
new file mode 100644
index 0000000..05650b5
--- /dev/null
+++ b/changes/bug19454
@@ -0,0 +1,3 @@
+  o Minor bugfixes (heartbeat):
+    - Fix regression that crashes Tor when disabling heartbeats. Fixes bug
+      19454; bugfix on tor-0.2.8.1-alpha. Reported by "kubaku".
diff --git a/src/or/main.c b/src/or/main.c
index b9fee1d..f585f0b 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -2004,18 +2004,24 @@ check_fw_helper_app_callback(time_t now, const or_options_t *options)
   return PORT_FORWARDING_CHECK_INTERVAL;
 }
 
+/** Callback to write heartbeat message in the logs. */
 static int
 heartbeat_callback(time_t now, const or_options_t *options)
 {
   static int first = 1;
-  /* 12. write the heartbeat message */
+
+  /* Check if heartbeat is disabled */
+  if (!options->HeartbeatPeriod) {
+    return PERIODIC_EVENT_NO_UPDATE;
+  }
+
+  /* Write the heartbeat message */
   if (first) {
     first = 0; /* Skip the first one. */
   } else {
     log_heartbeat(now);
   }
-  /* XXXX This isn't such a good way to handle possible changes in the
-   * callback event */
+
   return options->HeartbeatPeriod;
 }
 

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits