hooray! we don't have to track data_len on its own
This commit is contained in:
		| @@ -1,4 +1,4 @@ | ||||
| use {ConnectionError, Frame, FrameSize}; | ||||
| use {ConnectionError, Frame}; | ||||
| use client::Client; | ||||
| use error; | ||||
| use frame::{self, SettingSet, StreamId}; | ||||
| @@ -91,7 +91,6 @@ impl<T, P> Connection<T, P, Bytes> | ||||
|     { | ||||
|         self.send(Frame::Data { | ||||
|             id, | ||||
|             data_len: data.len() as FrameSize, | ||||
|             data, | ||||
|             end_of_stream, | ||||
|         }) | ||||
| @@ -176,7 +175,6 @@ impl<T, P, B> Stream for Connection<T, P, B> | ||||
|                 Some(Data(v)) => Frame::Data { | ||||
|                     id: v.stream_id(), | ||||
|                     end_of_stream: v.is_end_stream(), | ||||
|                     //data_len: v.len(), | ||||
|                     data: v.into_payload(), | ||||
|                 }, | ||||
|  | ||||
|   | ||||
| @@ -1,5 +1,4 @@ | ||||
| use ConnectionError; | ||||
| use error; | ||||
| use {error, ConnectionError, FrameSize}; | ||||
| use frame::{self, Frame}; | ||||
| use proto::*; | ||||
|  | ||||
| @@ -8,8 +7,8 @@ use std::collections::VecDeque; | ||||
| #[derive(Debug)] | ||||
| pub struct FlowControl<T>  { | ||||
|     inner: T, | ||||
|     initial_local_window_size: u32, | ||||
|     initial_remote_window_size: u32, | ||||
|     initial_local_window_size: WindowSize, | ||||
|     initial_remote_window_size: WindowSize, | ||||
|  | ||||
|     /// Tracks the connection-level flow control window for receiving data from the | ||||
|     /// remote. | ||||
| @@ -37,8 +36,8 @@ impl<T, U> FlowControl<T> | ||||
|           T: Sink<SinkItem = Frame<U>, SinkError = ConnectionError>, | ||||
|           T: ControlStreams | ||||
| { | ||||
|     pub fn new(initial_local_window_size: u32, | ||||
|                initial_remote_window_size: u32, | ||||
|     pub fn new(initial_local_window_size: WindowSize, | ||||
|                initial_remote_window_size: WindowSize, | ||||
|                inner: T) | ||||
|         -> FlowControl<T> | ||||
|     { | ||||
| @@ -250,11 +249,12 @@ impl<T> Stream for FlowControl<T> | ||||
|                 } | ||||
|  | ||||
|                 Some(Data(v)) => { | ||||
|                     if self.connection_local_flow_controller.claim_window(v.len()).is_err() { | ||||
|                     let sz = v.payload().len() as FrameSize; | ||||
|                     if self.connection_local_flow_controller.claim_window(sz).is_err() { | ||||
|                         return Err(error::Reason::FlowControlError.into()) | ||||
|                     } | ||||
|                     if let Some(fc) = self.local_flow_controller(v.stream_id()) { | ||||
|                         if fc.claim_window(v.len()).is_err() { | ||||
|                         if fc.claim_window(sz).is_err() { | ||||
|                             return Err(error::Reason::FlowControlError.into()) | ||||
|                         } | ||||
|                     } | ||||
| @@ -271,6 +271,7 @@ impl<T, U> Sink for FlowControl<T> | ||||
|     where T: Sink<SinkItem = Frame<U>, SinkError = ConnectionError>, | ||||
|           T: ReadySink, | ||||
|           T: ControlStreams, | ||||
|           U: Buf, | ||||
|  { | ||||
|     type SinkItem = T::SinkItem; | ||||
|     type SinkError = T::SinkError; | ||||
| @@ -289,11 +290,12 @@ impl<T, U> Sink for FlowControl<T> | ||||
|                     return Ok(AsyncSink::NotReady(Data(v))); | ||||
|                 } | ||||
|  | ||||
|                 if self.connection_remote_flow_controller.claim_window(v.len()).is_err() { | ||||
|                 let sz = v.payload().remaining() as FrameSize; | ||||
|                 if self.connection_remote_flow_controller.claim_window(sz).is_err() { | ||||
|                     return Err(error::User::FlowControlViolation.into()); | ||||
|                 } | ||||
|                 if let Some(fc) = self.remote_flow_controller(v.stream_id()) { | ||||
|                     if fc.claim_window(v.len()).is_err() { | ||||
|                     if fc.claim_window(sz).is_err() { | ||||
|                         return Err(error::User::FlowControlViolation.into()) | ||||
|                     } | ||||
|                 } | ||||
| @@ -318,6 +320,7 @@ impl<T, U> ReadySink for FlowControl<T> | ||||
|           T: Sink<SinkItem = Frame<U>, SinkError = ConnectionError>, | ||||
|           T: ReadySink, | ||||
|           T: ControlStreams, | ||||
|           U: Buf, | ||||
| { | ||||
|     fn poll_ready(&mut self) -> Poll<(), ConnectionError> { | ||||
|         try_ready!(self.inner.poll_ready()); | ||||
|   | ||||
| @@ -74,7 +74,7 @@ impl<T, B> FramedWrite<T, B> | ||||
|     } | ||||
|  | ||||
|     fn frame_len(&self, data: &frame::Data<B>) -> usize { | ||||
|         cmp::min(self.max_frame_size, data.len()) as usize | ||||
|         cmp::min(self.max_frame_size as usize, data.payload().remaining()) | ||||
|     } | ||||
| } | ||||
|  | ||||
| @@ -104,7 +104,7 @@ impl<T, B> Sink for FramedWrite<T, B> | ||||
|  | ||||
|         match item { | ||||
|             Frame::Data(mut v) => { | ||||
|                 if v.len() >= (CHAIN_THRESHOLD as FrameSize) { | ||||
|                 if v.payload().remaining() >= CHAIN_THRESHOLD { | ||||
|                     let head = v.head(); | ||||
|                     let len = self.frame_len(&v); | ||||
|  | ||||
| @@ -121,7 +121,7 @@ impl<T, B> Sink for FramedWrite<T, B> | ||||
|  | ||||
|                     // The chunk has been fully encoded, so there is no need to | ||||
|                     // keep it around | ||||
|                     assert_eq!(v.len(), 0, "chunk not fully encoded"); | ||||
|                     assert_eq!(v.payload().remaining(), 0, "chunk not fully encoded"); | ||||
|                 } | ||||
|             } | ||||
|             Frame::Headers(v) => { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user