mirror of
https://github.com/n0-computer/noq.git
synced 2026-09-23 11:45:25 +00:00
impl From<ConnectionError> for Event
This commit is contained in:
@@ -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) => {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user