Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

fix: make ShutdownHandle a private field of LoginServer (#2396)

Michael Bolind5b42ba1ac89
diff --git a/codex-rs/login/src/server.rs b/codex-rs/login/src/server.rs
index f33f1ae4fb..f3256ee6c8 100644
--- a/codex-rs/login/src/server.rs
+++ b/codex-rs/login/src/server.rs
@@ -46,9 +46,8 @@ impl ServerOptions {
pub struct LoginServer {
pub auth_url: String,
pub actual_port: u16,
- shutdown_flag: Arc<tokio::sync::Notify>,
server_handle: tokio::task::JoinHandle<io::Result<()>>,
- server: Arc<Server>,
+ shutdown_handle: ShutdownHandle,
}
impl LoginServer {
@@ -59,14 +58,11 @@ impl LoginServer {
}
pub fn cancel(&self) {
- shutdown(&self.shutdown_flag, &self.server);
+ self.shutdown_handle.shutdown();
}
pub fn cancel_handle(&self) -> ShutdownHandle {
- ShutdownHandle {
- shutdown_notify: self.shutdown_flag.clone(),
- server: self.server.clone(),
- }
+ self.shutdown_handle.clone()
}
}
@@ -85,16 +81,12 @@ impl std::fmt::Debug for ShutdownHandle {
}
impl ShutdownHandle {
- pub fn cancel(&self) {
- shutdown(&self.shutdown_notify, &self.server);
+ pub fn shutdown(&self) {
+ self.shutdown_notify.notify_waiters();
+ self.server.unblock();
}
}
-pub fn shutdown(shutdown_notify: &tokio::sync::Notify, server: &Server) {
- shutdown_notify.notify_waiters();
- server.unblock();
-}
-
pub fn run_login_server(
opts: ServerOptions,
shutdown_flag: Option<Arc<tokio::sync::Notify>>,
@@ -181,8 +173,10 @@ pub fn run_login_server(
auth_url,
actual_port,
server_handle,
- shutdown_flag: shutdown_notify,
- server,
+ shutdown_handle: ShutdownHandle {
+ shutdown_notify,
+ server,
+ },
})
}
diff --git a/codex-rs/mcp-server/src/codex_message_processor.rs b/codex-rs/mcp-server/src/codex_message_processor.rs
index 00c8717c43..4f2b3bb693 100644
--- a/codex-rs/mcp-server/src/codex_message_processor.rs
+++ b/codex-rs/mcp-server/src/codex_message_processor.rs
@@ -66,7 +66,7 @@ struct ActiveLogin {
impl ActiveLogin {
fn drop(&self) {
- self.shutdown_handle.cancel();
+ self.shutdown_handle.shutdown();
}
}
@@ -190,7 +190,7 @@ impl CodexMessageProcessor {
Ok(Err(err)) => (false, Some(format!("Login server error: {err}"))),
Err(_elapsed) => {
// Timeout: cancel server and report
- shutdown_handle.cancel();
+ shutdown_handle.shutdown();
(false, Some("Login timed out".to_string()))
}
};
diff --git a/codex-rs/tui/src/onboarding/auth.rs b/codex-rs/tui/src/onboarding/auth.rs
index 7166e349c3..490f85bff8 100644
--- a/codex-rs/tui/src/onboarding/auth.rs
+++ b/codex-rs/tui/src/onboarding/auth.rs
@@ -50,7 +50,7 @@ pub(crate) struct ContinueInBrowserState {
impl Drop for ContinueInBrowserState {
fn drop(&mut self) {
if let Some(flag) = &self.shutdown_handle {
- flag.cancel();
+ flag.shutdown();
}
}
}