[tor-bugs] #19476 [Core Tor/Tor]: Use conditional intervals in heartbeat_callback

Tor Bug Tracker & Wiki blackhole at torproject.org
Fri Jul 7 18:06:25 UTC 2017


#19476: Use conditional intervals in heartbeat_callback
-------------------------------------------------+-------------------------
 Reporter:  cypherpunks                          |          Owner:
     Type:  defect                               |         Status:
                                                 |  needs_review
 Priority:  Medium                               |      Milestone:  Tor:
                                                 |  0.3.2.x-final
Component:  Core Tor/Tor                         |        Version:
 Severity:  Normal                               |     Resolution:
 Keywords:  tor-relay, heartbeat, usability,     |  Actual Points:
  review-group-20                                |
Parent ID:                                       |         Points:
 Reviewer:                                       |        Sponsor:
-------------------------------------------------+-------------------------

Comment (by cypherpunks):

 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     else
 108       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.

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/19476#comment:9>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list