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.
This commit is contained in:
Elena Frank
2023-02-19 22:18:54 +01:00
committed by GitHub
parent 0f4930f92b
commit 79b7cef070
2 changed files with 8 additions and 2 deletions

View File

@ -7,7 +7,10 @@
- Update to `libp2p-swarm` `v0.42.0`. - 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 3208]: https://github.com/libp2p/rust-libp2p/pull/3208
[PR 3344]: https://github.com/libp2p/rust-libp2p/pull/3344
# 0.41.1 # 0.41.1

View File

@ -189,11 +189,14 @@ where
Ok(()) Ok(())
} }
async fn recv<T>(mut socket: T) -> Result<Info, UpgradeError> async fn recv<T>(socket: T) -> Result<Info, UpgradeError>
where where
T: AsyncRead + AsyncWrite + Unpin, 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( let info = FramedRead::new(
socket, socket,