Skip to content

Mutex held across await in async multi-client send_to_connection #126

Description

@mcurrier2

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions