Return error for Io::poll_read_ready() if io is closed (#433)

This commit is contained in:
Nikolay Kim 2024-10-07 21:43:43 +02:00 committed by GitHub
parent 3a7477004f
commit c670b51983
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 16 additions and 6 deletions

View file

@ -1,5 +1,9 @@
# Changes
## [2.6.1] - 2024-10-17
* Return error for Io::poll_read_ready() if io is closed.
## [2.6.0] - 2024-10-17
* Return error for IoRef::write(), IoRef::with_write_buf(), Io::poll_flush() if io is closed.

View file

@ -1,6 +1,6 @@
[package]
name = "ntex-io"
version = "2.6.0"
version = "2.6.1"
authors = ["ntex contributors <team@ntex.rs>"]
description = "Utilities for encoding and decoding frames"
keywords = ["network", "framework", "async", "futures"]

View file

@ -262,6 +262,14 @@ impl<F> Io<F> {
fn error(&self) -> Option<io::Error> {
self.st().error.take()
}
/// Get current io error
fn error_or_disconnected(&self) -> io::Error {
self.st()
.error
.take()
.unwrap_or_else(|| io::Error::new(io::ErrorKind::Other, "Disconnected"))
}
}
impl<F: FilterLayer, T: Filter> Io<Layer<F, T>> {
@ -415,7 +423,7 @@ impl<F> Io<F> {
let mut flags = st.flags.get();
if flags.is_stopped() {
Poll::Ready(self.error().map(Err).unwrap_or(Ok(None)))
Poll::Ready(Err(self.error_or_disconnected()))
} else {
st.dispatch_task.register(cx.waker());
@ -540,9 +548,7 @@ impl<F> Io<F> {
let flags = self.flags();
if flags.is_stopped() {
Poll::Ready(self.error().map(Err).unwrap_or_else(|| {
Err(io::Error::new(io::ErrorKind::Other, "Disconnected"))
}))
Poll::Ready(Err(self.error_or_disconnected()))
} else {
let st = self.st();
let len = st.buffer.write_destination_size();

View file

@ -71,7 +71,7 @@ ntex-bytes = "0.1.27"
ntex-server = "2.4"
ntex-h2 = "1.1"
ntex-rt = "0.4.18"
ntex-io = "2.5"
ntex-io = "2.6"
ntex-net = "2.4"
ntex-tls = "2.1"