From 846aec701f4688d3d78a08c8eae1f13f5c3621ba Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Tue, 5 Nov 2024 22:16:38 -0700 Subject: [PATCH] Remoting: Fix opening multiple folders on one server (#20281) Release Notes: - Remoting: Fix opening multiple folders on one server --- crates/recent_projects/src/remote_servers.rs | 4 ++-- crates/remote/src/ssh_session.rs | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/crates/recent_projects/src/remote_servers.rs b/crates/recent_projects/src/remote_servers.rs index fdf40ecae3..49d870f56b 100644 --- a/crates/recent_projects/src/remote_servers.rs +++ b/crates/recent_projects/src/remote_servers.rs @@ -386,7 +386,7 @@ impl RemoteServerProjects { let ssh_prompt = cx.new_view(|cx| SshPrompt::new(&connection_options, cx)); let connection = connect_over_ssh( - ConnectionIdentifier::Setup, + ConnectionIdentifier::setup(), connection_options.clone(), ssh_prompt.clone(), cx, @@ -477,7 +477,7 @@ impl RemoteServerProjects { .clone(); let connect = connect_over_ssh( - ConnectionIdentifier::Setup, + ConnectionIdentifier::setup(), connection_options.clone(), prompt, cx, diff --git a/crates/remote/src/ssh_session.rs b/crates/remote/src/ssh_session.rs index ba19fa5c14..f6466e9973 100644 --- a/crates/remote/src/ssh_session.rs +++ b/crates/remote/src/ssh_session.rs @@ -40,7 +40,7 @@ use std::{ ops::ControlFlow, path::{Path, PathBuf}, sync::{ - atomic::{AtomicU32, Ordering::SeqCst}, + atomic::{AtomicU32, AtomicU64, Ordering::SeqCst}, Arc, Weak, }, time::{Duration, Instant}, @@ -484,11 +484,16 @@ impl EventEmitter for SshRemoteClient {} // Identifies the socket on the remote server so that reconnects // can re-join the same project. pub enum ConnectionIdentifier { - Setup, + Setup(u64), Workspace(i64), } +static NEXT_ID: AtomicU64 = AtomicU64::new(1); + impl ConnectionIdentifier { + pub fn setup() -> Self { + Self::Setup(NEXT_ID.fetch_add(1, SeqCst)) + } // This string gets used in a socket name, and so must be relatively short. // The total length of: // /home/{username}/.local/share/zed/server_state/{name}/stdout.sock @@ -501,7 +506,7 @@ impl ConnectionIdentifier { release_channel => format!("{}-", release_channel.dev_name()), }; match self { - Self::Setup => format!("{identifier_prefix}setup"), + Self::Setup(setup_id) => format!("{identifier_prefix}setup-{setup_id}"), Self::Workspace(workspace_id) => { format!("{identifier_prefix}workspace-{workspace_id}",) } @@ -1079,7 +1084,7 @@ impl SshRemoteClient { client_cx .update(|cx| { Self::new( - ConnectionIdentifier::Setup, + ConnectionIdentifier::setup(), opts, rx, Arc::new(fake::Delegate),