Description
In both unix_domain_socket.rs and tcp_socket.rs, the send_to_connection method acquires the connections mutex and holds it for the entire duration of write_message().await. This blocks all other connection operations for the duration of the write.
Similarly, get_active_connections() returns an empty vec when the mutex is contended (via try_lock), which makes it appear as if there are no active connections.
Impact
- Multi-client throughput is reduced as writes serialize on the mutex
get_active_connections() returns misleading empty results under contention
- Potential for deadlocks under high contention
Suggested Fix
Clone or take the stream out of the map, release the lock, then perform the async write. For get_active_connections, use .lock().await instead of try_lock or document the fallible nature.
Found during release polish review
Description
In both
unix_domain_socket.rsandtcp_socket.rs, thesend_to_connectionmethod acquires the connections mutex and holds it for the entire duration ofwrite_message().await. This blocks all other connection operations for the duration of the write.Similarly,
get_active_connections()returns an empty vec when the mutex is contended (viatry_lock), which makes it appear as if there are no active connections.Impact
get_active_connections()returns misleading empty results under contentionSuggested Fix
Clone or take the stream out of the map, release the lock, then perform the async write. For
get_active_connections, use.lock().awaitinstead oftry_lockor document the fallible nature.Found during release polish review