1
0
mirror of https://github.com/fafhrd91/actix-net synced 2024-11-23 21:51:06 +01:00

Fix buffer remaining capacity calcualtion

This commit is contained in:
Nikolay Kim 2019-12-09 21:50:36 +06:00
parent 35218a4df1
commit 8b3062cd6e
3 changed files with 8 additions and 4 deletions

View File

@ -1,5 +1,9 @@
# Changes
## [0.2.0-alpha.4]
* Fix buffer remaining capacity calcualtion
## [0.2.0-alpha.3]
* Use tokio 0.2

View File

@ -1,6 +1,6 @@
[package]
name = "actix-codec"
version = "0.2.0-alpha.3"
version = "0.2.0-alpha.4"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Utilities for encoding and decoding frames"
keywords = ["network", "framework", "async", "futures"]

View File

@ -2,7 +2,7 @@ use std::pin::Pin;
use std::task::{Context, Poll};
use std::{fmt, io};
use bytes::{BufMut, BytesMut};
use bytes::BytesMut;
use futures::{ready, Sink, Stream};
use crate::{AsyncRead, AsyncWrite, Decoder, Encoder};
@ -208,7 +208,7 @@ impl<T, U> Framed<T, U> {
T: AsyncWrite,
U: Encoder,
{
let remaining = self.write_buf.remaining_mut();
let remaining = self.write_buf.capacity() - self.write_buf.len();
if remaining < LW {
self.write_buf.reserve(HW - remaining);
}
@ -262,7 +262,7 @@ impl<T, U> Framed<T, U> {
debug_assert!(!self.flags.contains(Flags::EOF));
// Otherwise, try to read more data and try again. Make sure we've got room
let remaining = self.read_buf.remaining_mut();
let remaining = self.read_buf.capacity() - self.read_buf.len();
if remaining < LW {
self.read_buf.reserve(HW - remaining)
}