node: Match error by value
There wasn't a good reason to use a reference. This also allows us to explicitly drop the session.
This commit is contained in:
parent
17651e259d
commit
18616a16bd
|
|
@ -633,7 +633,7 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
err: reactor::Error<NetAccept<WireSession<G>>, NetTransport<WireSession<G>>>,
|
err: reactor::Error<NetAccept<WireSession<G>>, NetTransport<WireSession<G>>>,
|
||||||
) {
|
) {
|
||||||
match &err {
|
match err {
|
||||||
reactor::Error::ListenerUnknown(id) => {
|
reactor::Error::ListenerUnknown(id) => {
|
||||||
// TODO: What are we supposed to do here? Remove this error.
|
// TODO: What are we supposed to do here? Remove this error.
|
||||||
log::error!(target: "wire", "Received error: unknown listener {}", id);
|
log::error!(target: "wire", "Received error: unknown listener {}", id);
|
||||||
|
|
@ -649,7 +649,7 @@ where
|
||||||
reactor::Error::ListenerPollError(id, _) => {
|
reactor::Error::ListenerPollError(id, _) => {
|
||||||
// TODO: This should be a fatal error, there's nothing we can do here.
|
// TODO: This should be a fatal error, there's nothing we can do here.
|
||||||
log::error!(target: "wire", "Received error: listener {} disconnected", id);
|
log::error!(target: "wire", "Received error: listener {} disconnected", id);
|
||||||
self.actions.push_back(Action::UnregisterListener(*id));
|
self.actions.push_back(Action::UnregisterListener(id));
|
||||||
}
|
}
|
||||||
reactor::Error::ListenerDisconnect(id, _, _) => {
|
reactor::Error::ListenerDisconnect(id, _, _) => {
|
||||||
// TODO: This should be a fatal error, there's nothing we can do here.
|
// TODO: This should be a fatal error, there's nothing we can do here.
|
||||||
|
|
@ -659,17 +659,20 @@ where
|
||||||
log::error!(target: "wire", "Received error: peer (fd={fd}) poll error");
|
log::error!(target: "wire", "Received error: peer (fd={fd}) poll error");
|
||||||
|
|
||||||
self.disconnect(
|
self.disconnect(
|
||||||
*fd,
|
fd,
|
||||||
DisconnectReason::Connection(Arc::new(io::Error::from(io::ErrorKind::Other))),
|
DisconnectReason::Connection(Arc::new(io::Error::from(io::ErrorKind::Other))),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
reactor::Error::TransportDisconnect(fd, _, _) => {
|
reactor::Error::TransportDisconnect(fd, session, _) => {
|
||||||
log::error!(target: "wire", "Received error: peer (fd={fd}) disconnected");
|
log::error!(target: "wire", "Received error: peer (fd={fd}) disconnected");
|
||||||
|
|
||||||
|
// We're dropping the TCP connection here.
|
||||||
|
drop(session);
|
||||||
|
|
||||||
// The peer transport is already disconnected and removed from the reactor;
|
// The peer transport is already disconnected and removed from the reactor;
|
||||||
// therefore there is no need to initiate a disconnection. We simply remove
|
// therefore there is no need to initiate a disconnection. We simply remove
|
||||||
// the peer from the map.
|
// the peer from the map.
|
||||||
match self.peers.remove(fd) {
|
match self.peers.remove(&fd) {
|
||||||
Some(peer) => {
|
Some(peer) => {
|
||||||
let reason = DisconnectReason::Connection(Arc::new(io::Error::from(
|
let reason = DisconnectReason::Connection(Arc::new(io::Error::from(
|
||||||
io::ErrorKind::ConnectionReset,
|
io::ErrorKind::ConnectionReset,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue