Persist only named/prewarmed sessions, not implicit ones
Implicit sessions (dosh host with no --session) get a random
term-<millis>-<pid> name you can never reattach to, so persisting them just
left unreattachable holder processes lingering across restarts. The server
now only uses a persistent holder for prewarmed or explicitly-named
sessions; implicit ones use the in-process shell that dies on restart and
reaps on disconnect, as before. Adds a shared
protocol::{generate,is}_implicit_session_name as the single source of truth
for the name shape, used by both client (generate) and server (detect).
Server-only behavior change; wire VERSION unchanged.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
eec8ef0a02
commit
2835da76b0
+5
-10
@@ -37,7 +37,7 @@ use std::path::{Path, PathBuf};
|
||||
use std::process::{Command, Stdio};
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicU64, Ordering};
|
||||
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
|
||||
use std::time::{Duration, Instant};
|
||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||
use tokio::net::{TcpListener, TcpStream, UdpSocket, UnixStream};
|
||||
use tokio::signal::unix::{SignalKind, signal};
|
||||
@@ -1173,15 +1173,10 @@ fn select_session(requested: Option<&str>, _force_new: bool) -> String {
|
||||
if let Some(session) = requested {
|
||||
return session.to_string();
|
||||
}
|
||||
unique_session_name()
|
||||
}
|
||||
|
||||
fn unique_session_name() -> String {
|
||||
let millis = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap_or_default()
|
||||
.as_millis();
|
||||
format!("term-{millis}-{}", std::process::id())
|
||||
// Implicit, ephemeral session: the server recognizes this name shape
|
||||
// (`protocol::is_implicit_session_name`) and does NOT persist it across
|
||||
// restarts, since you can never reattach to a random name.
|
||||
protocol::generate_implicit_session_name()
|
||||
}
|
||||
|
||||
fn ssh_bootstrap(
|
||||
|
||||
Reference in New Issue
Block a user