Skip to content

Commit e5bbbe1

Browse files
PaulOlteanuflub
andauthored
fix(iroh-relay): fix client actors not closing (#3134)
## Description When a client actor closes, it awaits `Clients::unregister`, which then awaits for the actor task to close, so almost every actor task was being leaked. Since the only place `Clients::unregister` is called is from when the actor is already closing, I chose to break the cycle by not have it call `Client::shutdown`. I also added a timeout to the tls handshake because that also gets stuck forever if the client goes away. I didn't add it to the `LetsEncrypt` acceptor because I wasn't sure where exactly it belonged, but that should probably have one too. I can move this to a separate PR if preferred. Maybe the timeout should be configurable as well? ## Notes & open questions <!-- Any notes, remarks or open questions you have to make about the PR. --> ## Change checklist - [ ] Self-review. - [ ] Documentation updates following the [style guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text), if relevant. - [ ] Tests if relevant. - [ ] All breaking changes documented. --------- Co-authored-by: Floris Bruynooghe <[email protected]>
1 parent 08bd2a1 commit e5bbbe1

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

iroh-relay/src/server/client.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,7 @@ impl Actor {
221221
}
222222
}
223223

224-
self.clients
225-
.unregister(self.connection_id, self.node_id)
226-
.await;
224+
self.clients.unregister(self.connection_id, self.node_id);
227225
}
228226

229227
async fn run_inner(&mut self, done: CancellationToken) -> Result<()> {

iroh-relay/src/server/clients.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl Clients {
7171
/// peer is gone from the network.
7272
///
7373
/// Must be passed a matching connection_id.
74-
pub(super) async fn unregister(&self, connection_id: u64, node_id: NodeId) {
74+
pub(super) fn unregister(&self, connection_id: u64, node_id: NodeId) {
7575
trace!(
7676
node_id = node_id.fmt_short(),
7777
connection_id,
@@ -102,7 +102,6 @@ impl Clients {
102102
}
103103
}
104104
}
105-
client.shutdown().await;
106105
}
107106
}
108107

iroh-relay/src/server/http_server.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,11 @@ impl RelayService {
644644
},
645645
TlsAcceptor::Manual(a) => {
646646
debug!("TLS[manual]: accept");
647-
let tls_stream = a.accept(stream).await.context("TLS[manual] accept")?;
647+
let tls_stream = tokio::time::timeout(Duration::from_secs(30), a.accept(stream))
648+
.await
649+
.context("TLS[manual] timeout")?
650+
.context("TLS[manual] accept")?;
651+
648652
self.serve_connection(MaybeTlsStream::Tls(tls_stream))
649653
.await
650654
.context("TLS[manual] serve connection")?;

0 commit comments

Comments
 (0)