prevent a leak of 'active streams' if client request has user error (#266)

This commit is contained in:
Sean McArthur
2018-04-26 18:20:32 -07:00
committed by GitHub
parent 279dd93354
commit fadec67fdf
2 changed files with 17 additions and 4 deletions

View File

@@ -607,13 +607,21 @@ where
let mut stream = me.store.insert(stream.id, stream); let mut stream = me.store.insert(stream.id, stream);
me.actions.send.send_headers( let sent = me.actions.send.send_headers(
headers, headers,
send_buffer, send_buffer,
&mut stream, &mut stream,
&mut me.counts, &mut me.counts,
&mut me.actions.task, &mut me.actions.task,
)?; );
// send_headers can return a UserError, if it does,
// we should forget about this stream.
if let Err(err) = sent {
stream.unlink();
stream.remove();
return Err(err.into());
}
// Given that the stream has been initialized, it should not be in the // Given that the stream has been initialized, it should not be in the
// closed state. // closed state.

View File

@@ -440,9 +440,14 @@ fn request_with_connection_headers() {
let _ = ::env_logger::try_init(); let _ = ::env_logger::try_init();
let (io, srv) = mock::new(); let (io, srv) = mock::new();
let srv = srv.assert_client_handshake() // can't assert full handshake, since client never sends a request, and
// thus never bothers to ack the settings...
let srv = srv.read_preface()
.unwrap() .unwrap()
.recv_settings() .recv_frame(frames::settings())
// goaway is required to make sure the connection closes because
// of no active streams
.recv_frame(frames::go_away(0))
.close(); .close();
let headers = vec![ let headers = vec![