mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-04-25 19:02:13 +00:00
[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:
parent
e61ccd22df
commit
c8b426005f
@ -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
|
# 0.1.0
|
||||||
|
|
||||||
- Initial release.
|
- Initial release.
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
name = "libp2p-request-response"
|
name = "libp2p-request-response"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
description = "Generic Request/Response Protocols"
|
description = "Generic Request/Response Protocols"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
authors = ["Parity Technologies <admin@parity.io>"]
|
authors = ["Parity Technologies <admin@parity.io>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
repository = "https://github.com/libp2p/rust-libp2p"
|
repository = "https://github.com/libp2p/rust-libp2p"
|
||||||
|
@ -113,6 +113,7 @@ where
|
|||||||
write.await?;
|
write.await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
io.close().await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}.boxed()
|
}.boxed()
|
||||||
}
|
}
|
||||||
@ -156,10 +157,10 @@ where
|
|||||||
async move {
|
async move {
|
||||||
let write = self.codec.write_request(&protocol, &mut io, self.request);
|
let write = self.codec.write_request(&protocol, &mut io, self.request);
|
||||||
write.await?;
|
write.await?;
|
||||||
|
io.close().await?;
|
||||||
let read = self.codec.read_response(&protocol, &mut io);
|
let read = self.codec.read_response(&protocol, &mut io);
|
||||||
let response = read.await?;
|
let response = read.await?;
|
||||||
Ok(response)
|
Ok(response)
|
||||||
}.boxed()
|
}.boxed()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user