In ticket:19454#comment:4 i suggested some rationale about the (now removed) comment in the heartbeat callback function.
The attached patch uses the return value of log_heartbeat to choose between calling the callback after HeartbeatPeriod number of seconds or on the next second.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items ...
Show closed items
Linked items 0
Link issues together to show that they're related.
Learn more.
The current behavior is to always call the heartbeat callback every HeartbeatPeriod seconds even if logging of the heartbeat has failed.
The patch ensures the heartbeat callback is only called every HeartbeatPeriod seconds if logging of the heartbeat message was successful. Otherwise it will report to the scheduler that the callback should be called again in the next second.
The only case where log_heartbeat returns != 0 is
103 if (public_server_mode(options) && !hibernating) {104 /* Let's check if we are in the current cached consensus. */105 if (!(me = router_get_my_routerinfo()))106 return -1; /* Something stinks, we won't even attempt this. */107 else108 if (!node_get_by_id(me->cache_info.identity_digest))109 log_fn(LOG_NOTICE, LD_HEARTBEAT, "Heartbeat: It seems like we are not "110 "in the cached consensus.");111 }
So in the case when 'something stinks' the patch reschedules calling the callback in the next second instead of after HeartbeartPeriod seconds.
Hi! I applied cypherpunks' patch in my bug19476branch. It mostly LGTM.
I made the following small changes in that branch:
Instead of rescheduling for the next second—if the writing the heartbeat log message failed, retry MIN_HEARTBEAT_PERIOD seconds later. (The documentation for MIN_HEARTBEAT_PERIOD states that it is the "Lowest allowable value for HeartbeatPeriod; if this is too low, we might expose more information than we're comfortable with.")
Documented this behaviour in the heartbeat_callback() docstring.