mirror of
https://github.com/ntex-rs/ntex-extras.git
synced 2025-04-07 06:47:40 +03:00
Fix buffer remaining capacity calcualtion
This commit is contained in:
parent
0c1f5f9edc
commit
5132257b0d
3 changed files with 12 additions and 7 deletions
|
@ -8,7 +8,7 @@ use actix_codec::{AsyncRead, AsyncWrite, Decoder, Encoder, Framed, FramedParts};
|
|||
use actix_rt::time::{delay_until, Delay, Instant};
|
||||
use actix_service::Service;
|
||||
use bitflags::bitflags;
|
||||
use bytes::{BufMut, BytesMut};
|
||||
use bytes::BytesMut;
|
||||
use log::{error, trace};
|
||||
|
||||
use crate::body::{Body, BodySize, MessageBody, ResponseBody};
|
||||
|
@ -751,8 +751,10 @@ where
|
|||
};
|
||||
|
||||
loop {
|
||||
if inner.write_buf.remaining_mut() < LW_BUFFER_SIZE {
|
||||
inner.write_buf.reserve(HW_BUFFER_SIZE);
|
||||
let remaining =
|
||||
inner.write_buf.capacity() - inner.write_buf.len();
|
||||
if remaining < LW_BUFFER_SIZE {
|
||||
inner.write_buf.reserve(HW_BUFFER_SIZE - remaining);
|
||||
}
|
||||
let result = inner.poll_response(cx)?;
|
||||
let drain = result == PollResponse::DrainWriteBuf;
|
||||
|
@ -863,8 +865,9 @@ where
|
|||
{
|
||||
let mut read_some = false;
|
||||
loop {
|
||||
if buf.remaining_mut() < LW_BUFFER_SIZE {
|
||||
buf.reserve(HW_BUFFER_SIZE);
|
||||
let remaining = buf.capacity() - buf.len();
|
||||
if remaining < LW_BUFFER_SIZE {
|
||||
buf.reserve(HW_BUFFER_SIZE - remaining);
|
||||
}
|
||||
|
||||
match read(cx, io, buf) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue