Skip to content

Commit

Permalink
fix(identify): don't close stream in protocol::recv
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
elenaf9 authored Feb 19, 2023
1 parent 0f4930f commit 79b7cef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions protocols/identify/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 5 additions & 2 deletions protocols/identify/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,14 @@ where
Ok(())
}

async fn recv<T>(mut socket: T) -> Result<Info, UpgradeError>
async fn recv<T>(socket: T) -> Result<Info, UpgradeError>
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,
Expand Down

0 comments on commit 79b7cef

Please sign in to comment.