quinn-rs / quinn

Async-friendly QUIC implementation in Rust
Apache License 2.0
3.57k stars 364 forks source link

Add Connection::is_closed method #1780

Closed jean-airoldie closed 3 months ago

jean-airoldie commented 3 months ago

Problem

Multiple threads are using the same connection when the connection dies. All the threads race to restore the connection, potentially, reconnecting multiple times.

Solution

Put the connection behind a RwLock, acquire the writer lock, check if the connection is closed via is_closed method, if it is, reconnect. This way the reconnection happens at most once.

Ralith commented 3 months ago

See Connection::close_reason.