Fixed handshake leak

This commit is contained in:
arkpar 2016-03-14 13:54:06 +01:00
parent 42499addc8
commit c8b65c769b

View File

@ -687,6 +687,8 @@ impl<Message> Host<Message> where Message: Send + Sync + Clone {
if h.expired {
return;
}
io.deregister_stream(token).expect("Error deleting handshake registration");
h.set_expired();
let originated = h.originated;
let mut session = match Session::new(&mut h, &self.info.read().unwrap()) {
Ok(s) => s,
@ -705,8 +707,6 @@ impl<Message> Host<Message> where Message: Send + Sync + Clone {
}
let result = sessions.insert_with(move |session_token| {
session.set_token(session_token);
io.deregister_stream(token).expect("Error deleting handshake registration");
h.set_expired();
io.register_stream(session_token).expect("Error creating session registration");
self.stats.inc_sessions();
trace!(target: "network", "Creating session {} -> {}", token, session_token);