浏览代码

Merge remote-tracking branch 'isis/bug19476'

Nick Mathewson 6 年之前
父节点
当前提交
62d241ad22
共有 4 个文件被更改,包括 21 次插入9 次删除
  1. 3 0
      changes/bug19476
  2. 0 4
      src/or/config.c
  3. 4 0
      src/or/config.h
  4. 14 5
      src/or/main.c

+ 3 - 0
changes/bug19476

@@ -0,0 +1,3 @@
+ o Minor changes:
+   - If we fail to write a heartbeat message, schedule a retry for the minimum
+     heartbeat interval number of seconds in the future. Fixes bug 19476.

+ 0 - 4
src/or/config.c

@@ -2805,10 +2805,6 @@ compute_publishserverdescriptor(or_options_t *options)
  * will generate too many circuits and potentially overload the network. */
 #define MIN_CIRCUIT_STREAM_TIMEOUT 10
 
-/** Lowest allowable value for HeartbeatPeriod; if this is too low, we might
- * expose more information than we're comfortable with. */
-#define MIN_HEARTBEAT_PERIOD (30*60)
-
 /** Lowest recommended value for CircuitBuildTimeout; if it is set too low
  * and LearnCircuitBuildTimeout is off, the failure rate for circuit
  * construction may be very high.  In that case, if it is set below this

+ 4 - 0
src/or/config.h

@@ -18,6 +18,10 @@
 #define KERNEL_MAY_SUPPORT_IPFW
 #endif
 
+/** Lowest allowable value for HeartbeatPeriod; if this is too low, we might
+ * expose more information than we're comfortable with. */
+#define MIN_HEARTBEAT_PERIOD (30*60)
+
 MOCK_DECL(const char*, get_dirportfrontpage, (void));
 MOCK_DECL(const or_options_t *, get_options, (void));
 MOCK_DECL(or_options_t *, get_options_mutable, (void));

+ 14 - 5
src/or/main.c

@@ -2060,6 +2060,9 @@ check_fw_helper_app_callback(time_t now, const or_options_t *options)
 
 /**
  * Periodic callback: write the heartbeat message in the logs.
+ *
+ * If writing the heartbeat message to the logs fails for some reason, retry
+ * again after <b>MIN_HEARTBEAT_PERIOD</b> seconds.
  */
 static int
 heartbeat_callback(time_t now, const or_options_t *options)
@@ -2071,14 +2074,20 @@ 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 */
+  if (log_heartbeat(now) == 0) {
+    return options->HeartbeatPeriod;
+  } else {
+    /* If we couldn't write the heartbeat log message, try again in the minimum
+     * interval of time. */
+    return MIN_HEARTBEAT_PERIOD;
+  }
 }
 
 #define CDM_CLEAN_CALLBACK_INTERVAL 600