1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-12-21 15:46:48 +00:00

Enforce HW_BUFFER_SIZE inside h1::dispatcher (#1550)

This commit is contained in:
Andrew 2020-06-17 00:58:23 -07:00 committed by GitHub
parent 4f9a1ac3b7
commit e72ee28232
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View file

@ -1,5 +1,11 @@
# Changes
## [Unreleased]
### Changed
* Fix actix_http::h1::dispatcher so it returns when HW_BUFFER_SIZE is reached. Should reduce peak memory consumption during large uploads. [#1550]
## [3.0.0-alpha.3] - 2020-05-21
### Added

View file

@ -861,7 +861,14 @@ where
T: AsyncRead + Unpin,
{
let mut read_some = false;
loop {
// If buf is full return but do not disconnect since
// there is more reading to be done
if buf.len() >= HW_BUFFER_SIZE {
return Ok(Some(false));
}
let remaining = buf.capacity() - buf.len();
if remaining < LW_BUFFER_SIZE {
buf.reserve(HW_BUFFER_SIZE - remaining);