[request-response] Close substream after writing request/response. (#1660)

* Close substream after writing request/response.

* Update protocols/request-response/src/handler/protocol.rs

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
This commit is contained in:
Roman Borschel 2020-07-13 12:35:32 +02:00 committed by GitHub
parent e61ccd22df
commit c8b426005f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 2 deletions

View File

@ -1,3 +1,11 @@
# 0.1.1
- Always properly `close()` the substream after sending requests and
responses in the `InboundUpgrade` and `OutboundUpgrade`. Otherwise this is
left to `RequestResponseCodec::write_request` and `RequestResponseCodec::write_response`,
which can be a pitfall and lead to subtle problems (see e.g.
https://github.com/libp2p/rust-libp2p/pull/1606).
# 0.1.0
- Initial release.

View File

@ -2,7 +2,7 @@
name = "libp2p-request-response"
edition = "2018"
description = "Generic Request/Response Protocols"
version = "0.1.0"
version = "0.1.1"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"

View File

@ -113,6 +113,7 @@ where
write.await?;
}
}
io.close().await?;
Ok(())
}.boxed()
}
@ -156,10 +157,10 @@ where
async move {
let write = self.codec.write_request(&protocol, &mut io, self.request);
write.await?;
io.close().await?;
let read = self.codec.read_response(&protocol, &mut io);
let response = read.await?;
Ok(response)
}.boxed()
}
}