TrunkLink: open one outbound per host when PAIRED=1

For each host in m_peer_hosts, create a FramedTcpClient with its own
connected/disconnected/frameReceived signal wiring and per-client
PairedClientState (hello_received, hb_tx_cnt, hb_rx_cnt).

- onPairedOutboundConnected: resets per-client state, enables heartbeat
  timer, sends MsgTrunkHello on that client
- onPairedOutboundDisconnected: resets per-client state; TcpPrioClient
  auto-reconnects
- onPairedOutboundFrame: per-client RX counter reset; dispatches
  MsgTrunkHello (HMAC verify, sets hello_received) and MsgTrunkHeartbeat
  inline; all other message types forwarded to shared handlers via ss
  (already positioned past header)
- sendMsgOnPairedOutbound(idx): serialises and writes on m_ob_cons[idx]
- pairedClientIndex: linear scan returning SIZE_MAX on miss
- sendMsg: paired branch iterates m_ob_cons in order, picks first with
  connected+hello_received (D4 will make this sticky); falls back to
  inbound
- heartbeatTick: paired branch iterates per-client counters; legacy OB
  block untouched; "disable timer" check uses any_ob_connected flag
- isOutboundReady: returns true if any paired client is ready
- ~TrunkLink: disconnects and deletes all m_ob_cons entries

Single-host path is unchanged; all new code is inside m_paired branches.
This commit is contained in:
Audric committed 2026-04-15 21:54:25 +02:00
1 parent adfe04e8b1
commit 70195e10c3
2 files changed
+349 -4

No files matched your search

+20
View File
@@ -266,6 +266,26 @@ class TrunkLink : public sigc::trackable
void heartbeatTick(Async::Timer* t);
void clearPeerTalkerState(void);
// PAIRED mode: per-host outbound client handlers (D2)
void onPairedOutboundConnected(FramedTcpClient* client);
void onPairedOutboundDisconnected(FramedTcpClient* client,
Async::TcpConnection* con,
Async::TcpConnection::DisconnectReason reason);
void onPairedOutboundFrame(FramedTcpClient* client,
Async::FramedTcpConnection* con,
std::vector<uint8_t>& data);
size_t pairedClientIndex(FramedTcpClient* client) const;
void sendMsgOnPairedOutbound(size_t idx, const ReflectorMsg& msg);
// Per-client handshake/heartbeat state for paired outbound connections
struct PairedClientState
{
bool hello_received = false;
unsigned hb_tx_cnt = 0;
unsigned hb_rx_cnt = 0;
};
std::vector<PairedClientState> m_ob_states; // parallel to m_ob_cons
}; /* class TrunkLink */