Skip to content

Fix app-server thread listener startup and shutdown races - #57787

Merged
copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/d05e348b0a81bddb2defa963d0cfd3fde08dbd03
Oct 28, 2026
Merged

copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/d05e348b0a81bddb2defa963d0cfd3fde08dbd03

Conversation

@copyberry

@copyberry copyberry Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Fix app-server thread listener startup and shutdown races

Why

A thread runtime can shut down while listener setup is awaiting I/O, and a cold resume can start before the previous listener forwards ShutdownComplete. Listener replacement must preserve those buffered terminal events.

What changed

  • Coordinate listener installation and connection subscriptions with pending unloads, and reject closing or replaced runtimes.
  • Allow a newly created runtime that has already shut down to drain its queued events, while enforcing one event reader per runtime.
  • Track shutdown draining with a shared watch channel so cold resume and runtime replacement wait for terminal events to be processed.
  • Serialize idle unloading with goal edits and cold resume, and recheck thread state after acquiring the lock.

## Why

A thread runtime can shut down while listener setup is awaiting I/O, and a cold resume can start before the previous listener forwards `ShutdownComplete`. Listener replacement must preserve those buffered terminal events.

## What changed

- Coordinate listener installation and connection subscriptions with pending unloads, and reject closing or replaced runtimes.
- Allow a newly created runtime that has already shut down to drain its queued events, while enforcing one event reader per runtime.
- Track shutdown draining with a shared watch channel so cold resume and runtime replacement wait for terminal events to be processed.
- Serialize idle unloading with goal edits and cold resume, and recheck thread state after acquiring the lock.

GitOrigin-RevId: d05e348b0a81bddb2defa963d0cfd3fde08dbd03
@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-28T16:54:08.703075Z ec6f22d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@copyberry
copyberry Bot force-pushed the copyberry/codex-internal-to-codex-oss/d05e348b0a81bddb2defa963d0cfd3fde08dbd03 branch from ec6f22d to 575cc53 Compare October 28, 2026 16:54
@copyberry
copyberry Bot merged commit 575cc53 into main Oct 28, 2026
22 of 23 checks passed
@copyberry
copyberry Bot deleted the copyberry/codex-internal-to-codex-oss/d05e348b0a81bddb2defa963d0cfd3fde08dbd03 branch October 28, 2026 16:55
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant