Use conditional intervals in heartbeat_callback

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