impl From<ConnectionError> for Event

This commit is contained in:
Benjamin Saunders
2018-12-08 18:31:46 -08:00
parent 62d78c6662
commit 6286698dd1
2 changed files with 15 additions and 24 deletions
+6 -18
View File
@@ -778,9 +778,7 @@ impl Connection {
mux.timer_stop(Timer::LossDetection);
mux.timer_stop(Timer::Close);
mux.timer_stop(Timer::Idle);
mux.emit(Event::ConnectionLost {
reason: ConnectionError::Reset,
});
mux.emit(ConnectionError::Reset.into());
self.state = Some(State::Drained);
}
return;
@@ -824,9 +822,7 @@ impl Connection {
let state = match result {
Ok(state) => state,
Err(conn_err) => {
mux.emit(Event::ConnectionLost {
reason: conn_err.clone(),
});
mux.emit(conn_err.clone().into());
match conn_err {
ConnectionError::ApplicationClosed { reason } => State::closed(reason),
@@ -937,15 +933,11 @@ impl Connection {
"peer aborted the handshake: {error}",
error = reason.error_code
);
mux.emit(Event::ConnectionLost {
reason: ConnectionError::ConnectionClosed { reason },
});
mux.emit(ConnectionError::ConnectionClosed { reason }.into());
return Ok(State::Draining);
}
Frame::ApplicationClose(reason) => {
mux.emit(Event::ConnectionLost {
reason: ConnectionError::ApplicationClosed { reason },
});
mux.emit(ConnectionError::ApplicationClosed { reason }.into());
return Ok(State::Draining);
}
Frame::PathChallenge(value) => {
@@ -1209,15 +1201,11 @@ impl Connection {
}
Frame::Padding | Frame::Ping => {}
Frame::ConnectionClose(reason) => {
mux.emit(Event::ConnectionLost {
reason: ConnectionError::ConnectionClosed { reason },
});
mux.emit(ConnectionError::ConnectionClosed { reason }.into());
return Ok(true);
}
Frame::ApplicationClose(reason) => {
mux.emit(Event::ConnectionLost {
reason: ConnectionError::ApplicationClosed { reason },
});
mux.emit(ConnectionError::ApplicationClosed { reason }.into());
return Ok(true);
}
Frame::PathChallenge(x) => {
+9 -6
View File
@@ -690,12 +690,9 @@ impl Endpoint {
let mut mux = EndpointMux::new(&mut self.ctx, conn, self.connections[conn.0].side);
self.connections[conn.0].close_common(&mut mux, now);
self.connections[conn.0].state = Some(State::Draining);
self.ctx.events.push_back((
conn,
Event::ConnectionLost {
reason: ConnectionError::TimedOut,
},
));
self.ctx
.events
.push_back((conn, ConnectionError::TimedOut.into()));
self.dirty_conns.insert(conn); // Ensure the loss detection timer cancellation
// goes through
}
@@ -920,6 +917,12 @@ pub enum Event {
},
}
impl From<ConnectionError> for Event {
fn from(x: ConnectionError) -> Self {
Event::ConnectionLost { reason: x }
}
}
/// I/O operations to be immediately executed the backend.
#[derive(Debug)]
pub enum Io {