TrunkLink: accept multiple inbound connections when PAIRED=1

Add PairedInboundState struct (parallel to PairedClientState) and
m_ib_states vector to track per-inbound heartbeat/hello state.
acceptInboundConnection branches on m_paired: in paired mode, push
each new inbound into m_ib_cons/m_ib_states, wire a lambda frameReceived
handler to onPairedInboundFrame, and send the hello reply immediately.
Non-paired path is unchanged.

Add onPairedInboundFrame (mirrors onPairedOutboundFrame: resets hb_rx_cnt,
dispatches data messages to shared handlers), onPairedInboundDisconnected
(removes by index from both vectors without deleting — Reflector owns the
object), pairedInboundIndex (linear scan), and sendMsgOnPairedInbound
(mirrors sendMsgOnPairedOutbound).

Route onInboundDisconnected through the paired handler when m_paired.
Update sendMsg paired fallback to iterate m_ib_cons instead of calling
the legacy sendMsgOnInbound. Update heartbeatTick paired branch to iterate
m_ib_cons/m_ib_states instead of m_inbound_con scalars. Update
isInboundReady to check m_ib_states in paired mode. Destructor clears
m_ib_cons/m_ib_states without deleting connections.
This commit is contained in:
Audric committed 2026-04-15 22:08:55 +02:00
1 parent 70195e10c3
commit 17bed97d1c
2 files changed
+205 -21

No files matched your search

+17
View File
@@ -277,6 +277,14 @@ class TrunkLink : public sigc::trackable
size_t pairedClientIndex(FramedTcpClient* client) const;
void sendMsgOnPairedOutbound(size_t idx, const ReflectorMsg& msg);
// PAIRED mode: per-host inbound connection handlers (D3)
void onPairedInboundFrame(Async::FramedTcpConnection* con,
std::vector<uint8_t>& data);
void onPairedInboundDisconnected(Async::FramedTcpConnection* con,
Async::FramedTcpConnection::DisconnectReason reason);
size_t pairedInboundIndex(Async::FramedTcpConnection* con) const;
void sendMsgOnPairedInbound(size_t idx, const ReflectorMsg& msg);
// Per-client handshake/heartbeat state for paired outbound connections
struct PairedClientState
{
@@ -286,6 +294,15 @@ class TrunkLink : public sigc::trackable
};
std::vector<PairedClientState> m_ob_states; // parallel to m_ob_cons
// Per-inbound handshake/heartbeat state for paired inbound connections
struct PairedInboundState
{
bool hello_received = false;
unsigned hb_tx_cnt = 0;
unsigned hb_rx_cnt = 0;
};
std::vector<PairedInboundState> m_ib_states; // parallel to m_ib_cons
}; /* class TrunkLink */