notify stream refs when the connection receives EOF (#176)
This commit is contained in:
@@ -277,8 +277,8 @@ where
|
||||
// TODO: handle
|
||||
},
|
||||
None => {
|
||||
// TODO: Is this correct?
|
||||
trace!("codec closed");
|
||||
self.streams.recv_eof();
|
||||
return Ok(Async::Ready(()));
|
||||
},
|
||||
}
|
||||
|
||||
@@ -497,6 +497,11 @@ impl Recv {
|
||||
stream.notify_recv();
|
||||
}
|
||||
|
||||
pub fn recv_eof(&mut self, stream: &mut Stream) {
|
||||
stream.state.recv_eof();
|
||||
stream.notify_recv();
|
||||
}
|
||||
|
||||
fn next_stream_id(&self) -> Result<StreamId, RecvError> {
|
||||
if let Ok(id) = self.next_stream_id {
|
||||
Ok(id)
|
||||
|
||||
@@ -223,6 +223,16 @@ impl State {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn recv_eof(&mut self) {
|
||||
match self.inner {
|
||||
Closed(..) => {},
|
||||
s => {
|
||||
trace!("recv_eof; state={:?}", s);
|
||||
self.inner = Closed(Some(Cause::Io));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Indicates that the local side will not send more data to the local.
|
||||
pub fn send_close(&mut self) {
|
||||
match self.inner {
|
||||
|
||||
@@ -272,6 +272,23 @@ where
|
||||
actions.conn_error = Some(err);
|
||||
}
|
||||
|
||||
pub fn recv_eof(&mut self) {
|
||||
let mut me = self.inner.lock().unwrap();
|
||||
let me = &mut *me;
|
||||
|
||||
let actions = &mut me.actions;
|
||||
let counts = &mut me.counts;
|
||||
|
||||
me.store
|
||||
.for_each(|stream| {
|
||||
counts.transition(stream, |_, stream| {
|
||||
actions.recv.recv_eof(stream);
|
||||
Ok::<_, ()>(())
|
||||
})
|
||||
})
|
||||
.expect("recv_eof");
|
||||
}
|
||||
|
||||
pub fn last_processed_id(&self) -> StreamId {
|
||||
self.inner.lock().unwrap().actions.recv.last_processed_id()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user