-
Notifications
You must be signed in to change notification settings - Fork 5.5k
fix: remove shutdown_flag param to run_login_server() #2399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Aug 17, 2025
Merged
easong-openai
approved these changes
Aug 18, 2025
bolinfest
added a commit
that referenced
this pull request
Aug 18, 2025
Letting the caller deal with `Err` seems preferable to using `expect()` (which would `panic!()`), particularly given that the function already returns `Result`. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/openai/codex/pull/2389). * #2399 * #2398 * #2396 * #2395 * #2394 * #2393 * __->__ #2389
bolinfest
added a commit
that referenced
this pull request
Aug 19, 2025
This replaces blocking I/O with async/non-blocking I/O in a number of cases. This facilitates the use of `tokio::sync::Notify` and `tokio::select!` in #2394. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/openai/codex/pull/2393). * #2399 * #2398 * #2396 * #2395 * #2394 * __->__ #2393 * #2389
bolinfest
added a commit
that referenced
this pull request
Aug 19, 2025
…otify` (#2394) Prior to this PR, we had: https://github.com/openai/codex/blob/71cae06e6643b4adf644d9769208c3c5fcd1f2be/codex-rs/login/src/server.rs#L141-L142 which means that we could be blocked waiting for a new request in `server_for_thread.recv()` and not notice that the state of `shutdown_flag` had changed. With this PR, we use `shutdown_flag: Notify` so that we can `tokio::select!` on `shutdown_notify.notified()` and `rx.recv()` (which is the "async stream" of requests read from `server_for_thread.recv()`) and handle whichever one happens first. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/openai/codex/pull/2394). * #2399 * #2398 * #2396 * #2395 * __->__ #2394 * #2393 * #2389
bolinfest
added a commit
that referenced
this pull request
Aug 19, 2025
…:time::timeout() instead (#2395) #2373 introduced `ServerOptions.login_timeout` and `spawn_timeout_watcher()` to use an extra thread to manage the timeout for the login server. Now that we have asyncified the login stack, we can use `tokio::time::timeout()` from "outside" the login library to manage the timeout rather than having to a commit to a specific "timeout" concept from within. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/openai/codex/pull/2395). * #2399 * #2398 * #2396 * __->__ #2395 * #2394 * #2393 * #2389
bolinfest
added a commit
that referenced
this pull request
Aug 19, 2025
Folds the top-level `shutdown()` function into a method of `ShutdownHandle` and then simply stores `ShutdownHandle` on `LoginServer` since the two fields it contains were always being used together, anyway. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/openai/codex/pull/2396). * #2399 * #2398 * __->__ #2396 * #2395 * #2394 * #2393 * #2389
bolinfest
added a commit
that referenced
this pull request
Aug 19, 2025
Updates the tokio task that monitors `shutdown_notify` and server requests to ensure that `server.unblock()` is always called, which means that `ShutdownHandle` only has to invoke `notify_waiters()`. Now `LoginServer` no longer has to maintain a reference to `Server`. The `Arc<Server>` only has two active references: the `thread::spawn()` for reading server messages and the `tokio::task()` that consumes them (and the shutdown message). Now when shutdown is called (or if login completes successfully), the `server.unblock()` call ensures the thread terminates cleanly, which in turn ensures `rx.recv()` in the `tokio::spawn()` returns `Err`, causing the `tokio::task()` to exit cleanly, as well. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/openai/codex/pull/2398). * #2399 * __->__ #2398 * #2396 * #2395 * #2394 * #2393 * #2389
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In practice, this was always passed in as
None
, so eliminated the param and updated all the call sites.Stack created with Sapling. Best reviewed with ReviewStack.
shutdown_flag
fromArc<AtomicBool>
totokio::sync::Notify
#2394