diff --git a/actix-codec/CHANGES.md b/actix-codec/CHANGES.md index ae76143a..8959d057 100644 --- a/actix-codec/CHANGES.md +++ b/actix-codec/CHANGES.md @@ -1,5 +1,9 @@ # Changes +## [0.2.0-alpha.4] + +* Fix buffer remaining capacity calcualtion + ## [0.2.0-alpha.3] * Use tokio 0.2 diff --git a/actix-codec/Cargo.toml b/actix-codec/Cargo.toml index 67744c41..9f2f64b9 100644 --- a/actix-codec/Cargo.toml +++ b/actix-codec/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-codec" -version = "0.2.0-alpha.3" +version = "0.2.0-alpha.4" authors = ["Nikolay Kim "] description = "Utilities for encoding and decoding frames" keywords = ["network", "framework", "async", "futures"] diff --git a/actix-codec/src/framed.rs b/actix-codec/src/framed.rs index f4be2792..ed1ce7a1 100644 --- a/actix-codec/src/framed.rs +++ b/actix-codec/src/framed.rs @@ -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 Framed { 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 Framed { 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) }