mirror of
https://github.com/actix/actix-web.git
synced 2025-01-02 21:38:46 +00:00
Enforce HW_BUFFER_SIZE inside h1::dispatcher (#1550)
This commit is contained in:
parent
4f9a1ac3b7
commit
e72ee28232
2 changed files with 13 additions and 0 deletions
|
@ -1,5 +1,11 @@
|
||||||
# Changes
|
# 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
|
## [3.0.0-alpha.3] - 2020-05-21
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -861,7 +861,14 @@ where
|
||||||
T: AsyncRead + Unpin,
|
T: AsyncRead + Unpin,
|
||||||
{
|
{
|
||||||
let mut read_some = false;
|
let mut read_some = false;
|
||||||
|
|
||||||
loop {
|
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();
|
let remaining = buf.capacity() - buf.len();
|
||||||
if remaining < LW_BUFFER_SIZE {
|
if remaining < LW_BUFFER_SIZE {
|
||||||
buf.reserve(HW_BUFFER_SIZE - remaining);
|
buf.reserve(HW_BUFFER_SIZE - remaining);
|
||||||
|
|
Loading…
Reference in a new issue