If writing a heartbeat message fails, retry after MIN_HEARTBEAT_PERIOD.

* FIXES #19476.
This commit is contained in:
Isis Lovecruft 2017-07-12 02:40:24 +00:00
parent f516c9ca99
commit 9de12397cf
No known key found for this signature in database
GPG Key ID: C8E8B1AA4CF3844E
3 changed files with 12 additions and 8 deletions

View File

@ -2804,10 +2804,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

View File

@ -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));

View File

@ -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)
@ -2078,12 +2081,13 @@ heartbeat_callback(time_t now, const or_options_t *options)
}
/* Write the heartbeat message */
int r = log_heartbeat(now);
if (r == 0) {
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;
}
return PERIODIC_EVENT_NO_UPDATE;
}
#define CDM_CLEAN_CALLBACK_INTERVAL 600