update override. use write_ready state for detecting disconnect

This commit is contained in:
fakeshadow 2021-03-23 17:59:33 +08:00
parent 4b9401efbb
commit 1048d7df70
2 changed files with 8 additions and 7 deletions

View File

@ -135,8 +135,8 @@ actix-multipart = { path = "actix-multipart" }
actix-files = { path = "actix-files" } actix-files = { path = "actix-files" }
awc = { path = "awc" } awc = { path = "awc" }
actix-rt = { git = "https://github.com/actix/actix-net.git", branch = "feat/net_poll_ready" } actix-rt = { git = "https://github.com/actix/actix-net.git" }
tokio = { git = "https://github.com/fakeshadow/tokio", branch = "feature/net_poll_ready" } actix-tls = { git = "https://github.com/actix/actix-net.git" }
[[bench]] [[bench]]
name = "server" name = "server"

View File

@ -695,14 +695,15 @@ where
if timer.as_mut().poll(cx).is_ready() { if timer.as_mut().poll(cx).is_ready() {
// payload is pending and it's time to check the ready state of io. // payload is pending and it's time to check the ready state of io.
if this.flags.contains(Flags::PAYLOAD_PENDING) { if this.flags.contains(Flags::PAYLOAD_PENDING) {
match Pin::new(this.io.as_mut().unwrap()).poll_read_ready(cx)? { match Pin::new(this.io.as_mut().unwrap()).poll_write_ready(cx)? {
// if io is ready and already closed resolve with dispatcher error. // if io is ready and already closed resolve with dispatcher error.
Poll::Ready(ready) if ready.is_read_closed() => { Poll::Ready(ready) if ready.is_write_closed() => {
trace!("Response payload pending check determine remote connection is dropped"); trace!("Response payload pending check determine remote connection is closed");
return Err(DispatchError::DisconnectTimeout); this.flags
.insert(Flags::SHUTDOWN | Flags::WRITE_DISCONNECT);
} }
// otherwise reset the interval and check again after 1 second.
_ => { _ => {
// reset the interval and check again after 1 second.
timer timer
.as_mut() .as_mut()
.reset(Instant::now() + Duration::from_secs(1)); .reset(Instant::now() + Duration::from_secs(1));