Get receiving data working

This commit is contained in:
Carl Lerche
2017-08-07 12:48:50 -07:00
parent 71acfe3961
commit 6053ee059d
5 changed files with 86 additions and 39 deletions

View File

@@ -236,8 +236,12 @@ impl<P, B> Recv<P, B>
.take_while(&mut self.buffer, |frame| frame.is_data());
if frames.is_empty() {
stream.recv_task = Some(task::current());
Ok(Async::NotReady)
if stream.state.is_recv_closed() {
Ok(None.into())
} else {
stream.recv_task = Some(task::current());
Ok(Async::NotReady)
}
} else {
Ok(Some(Chunk {
pending_recv: frames,

View File

@@ -203,6 +203,13 @@ impl State {
}
}
pub fn is_recv_closed(&self) -> bool {
match self.inner {
Closed(..) | HalfClosedRemote(..) => true,
_ => false,
}
}
pub fn recv_flow_control(&mut self) -> Option<&mut FlowControl> {
match self.inner {
Open { ref mut remote, .. } |

View File

@@ -368,6 +368,19 @@ impl<P, B> Clone for StreamRef<P, B> {
// ===== impl Chunk =====
impl<P, B> Chunk<P, B>
where P: Peer,
B: Buf,
{
// TODO: Come up w/ a better API
pub fn pop_bytes(&mut self) -> Option<Bytes> {
let mut me = self.inner.lock().unwrap();
let me = &mut *me;
me.actions.recv.pop_bytes(&mut self.recv)
}
}
impl<P, B> Drop for Chunk<P, B>
where P: Peer,
B: Buf,