Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
node: Don't panic on connection logic error
cloudhead committed 1 year ago
commit bbb292c8e65ec68428fae285b02751ef2ffcc363
parent 0be7453e764e26dcc2a3a4f4ad903b1b236cc753
3 files changed +8 -2
modified radicle-node/src/service.rs
@@ -1335,6 +1335,12 @@ where
                    // In this scenario, it's possible that our peer is persistent, and
                    // disconnected. We get an inbound connection before we attempt a re-connection,
                    // and therefore we treat it as a regular inbound connection.
+
                    //
+
                    // It's also possible that a disconnection hasn't gone through yet and our
+
                    // peer is still in connected state here, while a new inbound connection from
+
                    // that same peer is made. This results in a new connection from a peer that is
+
                    // already connected from the perspective of the service. This appears to be
+
                    // a bug in the underlying networking library.
                    let peer = e.get_mut();
                    debug!(
                        target: "service",
modified radicle-node/src/service/session.rs
@@ -231,7 +231,7 @@ impl Session {
        self.last_active = since;

        if let State::Connected { .. } = &self.state {
-
            panic!("Session::to_connected: session is already in 'connected' state");
+
            log::error!(target: "service", "Session {} is already in 'connected' state, resetting..", self.id);
        };
        self.state = State::Connected {
            since,
modified radicle-node/src/wire/protocol.rs
@@ -491,7 +491,7 @@ where
                &DisconnectReason::connection(),
            );
        } else {
-
            log::warn!(target: "wire", "Tried to cleanup unknown peer with id={id} (fd={fd})");
+
            log::debug!(target: "wire", "Tried to cleanup unknown peer with id={id} (fd={fd})");
        }
    }
}