From 79b7cef07033aa55c18cb786ff5bf99100e20943 Mon Sep 17 00:00:00 2001 From: Elena Frank Date: Sun, 19 Feb 2023 22:18:54 +0100 Subject: [PATCH] fix(identify): don't close stream in `protocol::recv` Don't close the stream `protocol::recv`. This is a short-term fix for #3298. The issue behind this is a general one on the QUIC transport when closing streams, as described in #3343. This PR only circumvents the issue for identify. A proper solution for our QUIC transport still needs more thought. Pull-Request: #3344. --- protocols/identify/CHANGELOG.md | 3 +++ protocols/identify/src/protocol.rs | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/protocols/identify/CHANGELOG.md b/protocols/identify/CHANGELOG.md index e4ce7498f32..f7f5a7ef818 100644 --- a/protocols/identify/CHANGELOG.md +++ b/protocols/identify/CHANGELOG.md @@ -7,7 +7,10 @@ - Update to `libp2p-swarm` `v0.42.0`. +- Don't close the stream when reading the identify info in `protocol::recv`. See [PR 3344]. + [PR 3208]: https://github.com/libp2p/rust-libp2p/pull/3208 +[PR 3344]: https://github.com/libp2p/rust-libp2p/pull/3344 # 0.41.1 diff --git a/protocols/identify/src/protocol.rs b/protocols/identify/src/protocol.rs index 9ef1067a49a..4da9cc0b977 100644 --- a/protocols/identify/src/protocol.rs +++ b/protocols/identify/src/protocol.rs @@ -189,11 +189,14 @@ where Ok(()) } -async fn recv(mut socket: T) -> Result +async fn recv(socket: T) -> Result where T: AsyncRead + AsyncWrite + Unpin, { - socket.close().await?; + // Even though we won't write to the stream anymore we don't close it here. + // The reason for this is that the `close` call on some transport's require the + // remote's ACK, but it could be that the remote already dropped the stream + // after finishing their write. let info = FramedRead::new( socket,