Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

Commit

Permalink
assert streams are not overwritten
Browse files Browse the repository at this point in the history
  • Loading branch information
stepancheg committed Dec 20, 2016
1 parent 45e3dc9 commit 7e2ec88
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ struct ClientInner {
impl ClientInner {
fn insert_stream(&mut self, stream: GrpcHttpClientStream) -> StreamId {
let id = self.session_state.next_stream_id;
self.common.streams.insert(id, stream);
if let Some(..) = self.common.streams.insert(id, stream) {
panic!("inserted stream that already existed");
}
self.session_state.next_stream_id += 2;
id
}
Expand Down
4 changes: 3 additions & 1 deletion src/http_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ impl<F : HttpService> ServerInner<F> {
request_handler: Some(req_tx),
_marker: marker::PhantomData,
};
self.common.streams.insert(stream_id, stream);
if let Some(..) = self.common.streams.insert(stream_id, stream) {
panic!("inserted stream that already existed");
}
self.common.streams.get_mut(&stream_id).unwrap()
}

Expand Down

0 comments on commit 7e2ec88

Please sign in to comment.