[core] Gate publisher sends by active connection layer - #2680
Conversation
| mutable std::mutex m_connection_map_mutex; | ||
| SSubscriptionMapT m_connection_map; | ||
| std::atomic<size_t> m_connection_count{ 0 }; | ||
| std::atomic<bool> m_udp_send_enabled{ false }; |
There was a problem hiding this comment.
instead of an std::atomic we should use connection counters, as we can increase / decrease them upon registration / unregistration which eliminates the need to iterate over the map every time.
|
This is already better than what we had previously. However we still have a problem. With this PR, we currently won't send out data for pending connections, which is a different behavior than previously. Anyways the logic is brittle, and what we need is a true handshake, as we get e.g. in TCP, instead of a heuristic via the monitoring. |
Track the selected transport layer per subscriber connection and derive per-layer send_enabled state so stale writer objects no longer emit data after their last matching subscriber disconnects.
2f26a1c to
faf3636
Compare
| // get payload buffer size (one time, to avoid multiple computations) | ||
| const size_t payload_buf_size(payload_.GetSize()); | ||
|
|
||
| const bool udp_send_enabled = m_send_layer_connection_counters.UdpEnabled(); |
There was a problem hiding this comment.
already && with udp_writer.
…subscribers. (#2680) Co-authored-by: Kerstin Keller <13848742+KerstinKeller@users.noreply.github.com>
This change tracks publisher connections and selected transport layers using atomic counters and explicit connection states. Writes now skip transport layers without active subscribers, reducing unnecessary data copies and network traffic while preserving zero-copy SHM where possible. Connection counts are updated incrementally instead of recalculated from the connection map. Transport counters are reset when writers are destroyed.