Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid possibility of dispatcher getting stuck while backpressuring io #2369

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion actix-http/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
* Remove slice creation pointing to potential uninitialized data on h1 encoder. [#2364]
* Remove `Into<Error>` bound on `Encoder` body types. [#2375]
* Fix quality parse error in Accept-Encoding header. [#2344]
* Avoid possibility of dispatcher getting stuck while backpressuring io. [#2369]

[#2364]: https://github.com/actix/actix-web/pull/2364
[#2375]: https://github.com/actix/actix-web/pull/2375
[#2344]: https://github.com/actix/actix-web/pull/2344
[#2377]: https://github.com/actix/actix-web/pull/2377

[#2369]: https://github.com/actix/actix-web/pull/2369

## 3.0.0-beta.8 - 2021-08-09
### Fixed
Expand Down
9 changes: 6 additions & 3 deletions actix-http/src/h1/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -842,10 +842,13 @@ where
A Request head too large to parse is only checked on
httparse::Status::Partial condition.
*/
if this.payload.is_none() {
match this.payload {
/*
When dispatcher has a payload the responsibility of
wake up it would be shift to h1::payload::Payload.
Unless the payload is ready to read, in which case
it might not have access to the waker and could
result in the dispatcher getting stuck until timeout.

Reason:
Self wake up when there is payload would waste poll
Expand All @@ -857,9 +860,9 @@ where
At this case read_buf could always remain beyond
MAX_BUFFER_SIZE and self wake up would be busy poll
dispatcher and waste resource.

*/
cx.waker().wake_by_ref();
Some(ref p) if p.need_read(cx) != PayloadStatus::Read => {}
_ => cx.waker().wake_by_ref(),
}

return Ok(false);
Expand Down