From 3c650ca194ffe3fa58652b57325436be1681e744 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sun, 7 Apr 2019 10:40:45 -0700 Subject: [PATCH] remove buffer capacity for payload --- actix-http/Cargo.toml | 1 + actix-http/src/h1/payload.rs | 14 ++------------ actix-http/src/message.rs | 3 ++- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/actix-http/Cargo.toml b/actix-http/Cargo.toml index fe9b62d14..528ab617c 100644 --- a/actix-http/Cargo.toml +++ b/actix-http/Cargo.toml @@ -59,6 +59,7 @@ base64 = "0.10" bitflags = "1.0" bytes = "0.4" byteorder = "1.2" +copyless = "0.1.2" derive_more = "0.14" either = "1.5.2" encoding = "0.2" diff --git a/actix-http/src/h1/payload.rs b/actix-http/src/h1/payload.rs index e880d46ab..28acb64bb 100644 --- a/actix-http/src/h1/payload.rs +++ b/actix-http/src/h1/payload.rs @@ -77,14 +77,6 @@ impl Payload { pub fn unread_data(&mut self, data: Bytes) { self.inner.borrow_mut().unread_data(data); } - - #[inline] - /// Set read buffer capacity - /// - /// Default buffer capacity is 32Kb. - pub fn set_read_buffer_capacity(&mut self, cap: usize) { - self.inner.borrow_mut().capacity = cap; - } } impl Stream for Payload { @@ -153,7 +145,6 @@ struct Inner { err: Option, need_read: bool, items: VecDeque, - capacity: usize, task: Option, io_task: Option, } @@ -166,7 +157,6 @@ impl Inner { err: None, items: VecDeque::new(), need_read: true, - capacity: MAX_BUFFER_SIZE, task: None, io_task: None, } @@ -186,7 +176,7 @@ impl Inner { fn feed_data(&mut self, data: Bytes) { self.len += data.len(); self.items.push_back(data); - self.need_read = self.len < self.capacity; + self.need_read = self.len < MAX_BUFFER_SIZE; if let Some(task) = self.task.take() { task.notify() } @@ -200,7 +190,7 @@ impl Inner { fn readany(&mut self) -> Poll, PayloadError> { if let Some(data) = self.items.pop_front() { self.len -= data.len(); - self.need_read = self.len < self.capacity; + self.need_read = self.len < MAX_BUFFER_SIZE; if self.need_read && self.task.is_none() && !self.eof { self.task = Some(current_task()); diff --git a/actix-http/src/message.rs b/actix-http/src/message.rs index 25bc55baf..e1fb3a111 100644 --- a/actix-http/src/message.rs +++ b/actix-http/src/message.rs @@ -3,6 +3,7 @@ use std::collections::VecDeque; use std::rc::Rc; use bitflags::bitflags; +use copyless::BoxHelper; use crate::extensions::Extensions; use crate::header::HeaderMap; @@ -417,7 +418,7 @@ impl BoxedResponsePool { BoxedResponseHead { head: Some(head) } } else { BoxedResponseHead { - head: Some(Box::new(ResponseHead::default())), + head: Some(Box::alloc().init(ResponseHead::default())), } } }