From 0312eb9cb5d8595317717af8159fa85a11622ef4 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Wed, 9 Sep 2026 08:03:30 +0800 Subject: [PATCH] review: cover Terminal in the displacement test, correct the ipc comment Terminal is a kind the rule accepts and the test did not exercise. It stays in the main select loop, so nothing but the assertion was missing. `Displaced` ends one connection, not the session - the session is precisely what continues, on the connection that replaced it. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_019aokqJuhjvB3kijXtAg5Ns --- src/ipc.rs | 7 ++++--- src/server/connection.rs | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ipc.rs b/src/ipc.rs index d6de78bba..56664b9d2 100644 --- a/src/ipc.rs +++ b/src/ipc.rs @@ -355,9 +355,10 @@ pub enum Data { MouseMoveTime(i64), Authorize, Close, - // A newer authorized connection has taken this one's place. Ends the session like `Close` - // but sends the peer nothing: the peer that owned this one has already moved on, and the - // link it would be sent over is the very one that stopped working. + // A newer authorized connection has taken this one's place. Ends the superseded connection + // like `Close` - the session itself continues on the newer one - and sends the peer nothing: + // the peer has already moved on, and the link it would be sent over is the very one that + // stopped working. Displaced, #[cfg(windows)] SAS, diff --git a/src/server/connection.rs b/src/server/connection.rs index 81401d72b..f5e6066dd 100644 --- a/src/server/connection.rs +++ b/src/server/connection.rs @@ -7635,12 +7635,13 @@ mod test { let mine = key(7, "peer"); // Every kind displaces its own: a stale remote control or camera view keeps the capture - // loop waiting on it, and a stale transfer or tunnel holds its own resources. + // loop waiting on it, and a stale transfer, tunnel or terminal holds its own resources. for kind in [ AuthConnType::Remote, AuthConnType::ViewCamera, AuthConnType::FileTransfer, AuthConnType::PortForward, + AuthConnType::Terminal, ] { assert!( AuthedConnID::is_displaced(&conn(1, kind, mine.clone()), 2, kind, &mine), @@ -7661,6 +7662,7 @@ mod test { AuthConnType::FileTransfer, AuthConnType::PortForward, AuthConnType::ViewCamera, + AuthConnType::Terminal, ] { assert!( !AuthedConnID::is_displaced(