1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-23 16:21:06 +01: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);