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:
1 parent
a6618790bb
commit
e9bb1a9e2d
3 files changed
+25
-12
No files matched your search
@@ -276,10 +276,14 @@ Send cadence:
|
|||||||
- **Edge-triggered** on local-state changes that affect the set: client
|
- **Edge-triggered** on local-state changes that affect the set: client
|
||||||
connect / disconnect, `MsgSelectTG`, `MsgTgMonitor`, and trunk hello
|
connect / disconnect, `MsgSelectTG`, `MsgTgMonitor`, and trunk hello
|
||||||
completion. Coalesced with a 500 ms debounce so a client toggling its
|
completion. Coalesced with a 500 ms debounce so a client toggling its
|
||||||
monitor list one TG at a time sends one update, not many.
|
monitor list one TG at a time sends one update, not many. This path
|
||||||
- **Periodic refresh** every 60 s as a safety net against lost deltas.
|
skips the actual send when the outgoing set is unchanged.
|
||||||
Both timers skip the actual send when the outgoing set is unchanged
|
- **Periodic refresh** every 60 s — *always sends*, even when the
|
||||||
since the last transmission, so an idle reflector generates no traffic.
|
outgoing set is unchanged. The heartbeat is what keeps the receiver's
|
||||||
|
`m_peer_interested_tgs` entries from expiring at the 600 s TTL: every
|
||||||
|
receipt rewrites the timestamp, so an idle monitor stays known to its
|
||||||
|
peer indefinitely. Without this the monitor would go deaf 10 minutes
|
||||||
|
after the last edge-triggered change.
|
||||||
|
|
||||||
Multi-hop propagation: when a reflector receives `MsgPeerTgInterest` from
|
Multi-hop propagation: when a reflector receives `MsgPeerTgInterest` from
|
||||||
a peer P, it triggers a refresh on its other trunk links. Each other
|
a peer P, it triggers a refresh on its other trunk links. Each other
|
||||||
|
|||||||
@@ -1826,14 +1826,22 @@ void TrunkLink::handleMsgPeerTgInterest(std::istream& is)
|
|||||||
|
|
||||||
void TrunkLink::onTgInterestTimer(Async::Timer*)
|
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 */
|
} /* TrunkLink::onTgInterestTimer */
|
||||||
|
|
||||||
|
|
||||||
void TrunkLink::onTgInterestDebounce(Async::Timer* t)
|
void TrunkLink::onTgInterestDebounce(Async::Timer* t)
|
||||||
{
|
{
|
||||||
t->setEnable(false);
|
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 */
|
} /* TrunkLink::onTgInterestDebounce */
|
||||||
|
|
||||||
|
|
||||||
@@ -1872,16 +1880,15 @@ std::set<uint32_t> TrunkLink::buildOutgoingTgInterest(void) const
|
|||||||
} /* TrunkLink::buildOutgoingTgInterest */
|
} /* TrunkLink::buildOutgoingTgInterest */
|
||||||
|
|
||||||
|
|
||||||
void TrunkLink::sendTgInterest(void)
|
void TrunkLink::sendTgInterest(bool force)
|
||||||
{
|
{
|
||||||
if (!isActive()) return;
|
if (!isActive()) return;
|
||||||
|
|
||||||
std::set<uint32_t> outgoing = buildOutgoingTgInterest();
|
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
|
// Edge-triggered debounce path with nothing changed: skip. The 60 s
|
||||||
// ride on the previous send. Keeps the heartbeat refresh from generating
|
// heartbeat (force=true) will refresh the receiver's TTL.
|
||||||
// idle traffic when the monitored set is stable.
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -294,7 +294,9 @@ class TrunkLink : public sigc::trackable
|
|||||||
void handleMsgPeerNodeList(std::istream& is);
|
void handleMsgPeerNodeList(std::istream& is);
|
||||||
void handleMsgPeerTgInterest(std::istream& is);
|
void handleMsgPeerTgInterest(std::istream& is);
|
||||||
|
|
||||||
void sendTgInterest(void);
|
// force=true bypasses skip-when-unchanged so the periodic 60 s
|
||||||
|
// heartbeat refreshes the receiver's m_peer_interested_tgs TTL.
|
||||||
|
void sendTgInterest(bool force = false);
|
||||||
void onTgInterestTimer(Async::Timer* t);
|
void onTgInterestTimer(Async::Timer* t);
|
||||||
void onTgInterestDebounce(Async::Timer* t);
|
void onTgInterestDebounce(Async::Timer* t);
|
||||||
// Build the set we should advertise to this peer: local interest, plus
|
// Build the set we should advertise to this peer: local interest, plus
|
||||||
|
|||||||
Reference in new issue
Block a user