fix(peer): heartbeat MsgPeerTgInterest re-sends to keep TTL alive

The 60 s heartbeat path was inheriting the skip-when-unchanged gate
from the 500 ms debounce path. Result: after the initial
edge-triggered advertisement, an idle reflector with a stable monitor
list would silently no-op every 60 s, the receiver's
m_peer_interested_tgs[tg] timestamp never got refreshed, and its
600 s TTL elapsed. A passive monitor would go deaf 10 minutes after
adding a foreign TG to monitoredTGs.

Split the two call sites: heartbeat passes force=true (always send),
debounce keeps force=false (skip when unchanged). The steady-state
heartbeat is one frame per trunk per minute, which is what the
receiver TTL needs.

Doc note in PEER_PROTOCOL.md was wrong (claimed both timers skipped
unchanged sends); corrected.

Affects v1.3.9; ship as v1.3.10.
This commit is contained in:
Audric authored and Audric IW1GEU committed 2026-05-08 21:03:41 +02:00
1 parent a6618790bb
commit e9bb1a9e2d
3 files changed
+25 -12

No files matched your search

+14 -7
View File
@@ -1826,14 +1826,22 @@ void TrunkLink::handleMsgPeerTgInterest(std::istream& is)
void TrunkLink::onTgInterestTimer(Async::Timer*)
{
sendTgInterest();
// Periodic refresh: always re-send (force=true) so the receiver's
// m_peer_interested_tgs entries get their timestamp refreshed and the
// 600 s TTL stays alive even when the local set hasn't changed since
// the last debounce send. Without this, a passive monitor would go
// deaf after 600 s of no-op heartbeats.
sendTgInterest(/*force=*/true);
} /* TrunkLink::onTgInterestTimer */
void TrunkLink::onTgInterestDebounce(Async::Timer* t)
{
t->setEnable(false);
sendTgInterest();
// Edge-triggered: skip when the outgoing set is unchanged. The 60 s
// heartbeat above takes care of receiver-TTL upkeep, so this path can
// safely no-op on idle changes.
sendTgInterest(/*force=*/false);
} /* TrunkLink::onTgInterestDebounce */
@@ -1872,16 +1880,15 @@ std::set<uint32_t> TrunkLink::buildOutgoingTgInterest(void) const
} /* TrunkLink::buildOutgoingTgInterest */
void TrunkLink::sendTgInterest(void)
void TrunkLink::sendTgInterest(bool force)
{
if (!isActive()) return;
std::set<uint32_t> outgoing = buildOutgoingTgInterest();
if (outgoing == m_last_sent_tg_interest)
if (!force && outgoing == m_last_sent_tg_interest)
{
// Nothing changed since the last advertisement — let the receiver's TTL
// ride on the previous send. Keeps the heartbeat refresh from generating
// idle traffic when the monitored set is stable.
// Edge-triggered debounce path with nothing changed: skip. The 60 s
// heartbeat (force=true) will refresh the receiver's TTL.
return;
}