Get large body writes working

This commit is contained in:
Carl Lerche
2017-08-12 11:02:50 -07:00
parent 570962353b
commit 150c3160be
5 changed files with 30 additions and 18 deletions

View File

@@ -2,7 +2,7 @@ use super::*;
use bytes::buf::Take;
use std::cmp;
use std::{fmt, cmp};
#[derive(Debug)]
pub(super) struct Prioritize<B> {
@@ -26,7 +26,6 @@ pub(super) struct Prioritize<B> {
conn_task: Option<task::Task>,
}
#[derive(Debug)]
pub(crate) struct Prioritized<B> {
// The buffer
inner: Take<B>,
@@ -253,18 +252,23 @@ impl<B> Prioritize<B>
store: &mut Store<B>,
dst: &mut Codec<T, Prioritized<B>>) -> bool
{
trace!("try reclaim frame");
// First check if there are any data chunks to take back
if let Some(frame) = dst.take_last_data_frame() {
trace!(" -> reclaimed; frame={:?}", frame);
let mut eos = false;
let key = frame.payload().stream;
let mut frame = frame.map(|prioritized| {
// TODO: Ensure fully written
eos = prioritized.end_of_stream;
prioritized.inner.into_inner()
});
if frame.payload().has_remaining() {
let mut stream = store.resolve(frame.payload().stream);
let mut eos = false;
let mut frame = frame.map(|prioritized| {
// TODO: Ensure fully written
eos = prioritized.end_of_stream;
prioritized.inner.into_inner()
});
let mut stream = store.resolve(key);
if eos {
frame.set_end_stream();
@@ -312,3 +316,13 @@ impl<B> Buf for Prioritized<B>
self.inner.advance(cnt)
}
}
impl<B: Buf> fmt::Debug for Prioritized<B> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.debug_struct("Prioritized")
.field("remaining", &self.inner.get_ref().remaining())
.field("end_of_stream", &self.end_of_stream)
.field("stream", &self.stream)
.finish()
}
}