Skip to content

Fix mux new-conn channel close race#201

Merged
djylb merged 1 commit intomasterfrom
codex/analyze-and-fix-client-disconnect-issue
Jan 21, 2026
Merged

Fix mux new-conn channel close race#201
djylb merged 1 commit intomasterfrom
codex/analyze-and-fix-client-disconnect-issue

Conversation

@djylb
Copy link
Copy Markdown
Owner

@djylb djylb commented Jan 21, 2026

Motivation

  • Prevent a panic: send on closed channel that occurred when Mux is closed while the readSession goroutine can still send new connections to newConnCh under high-frequency mixed proxy (HTTP CONNECT) traffic.

Description

  • In lib/mux/mux.go update the readSession new-connection dispatch loop to return immediately when closeChan is signaled by adding case <-s.closeChan: return to the select that sends to newConnCh.
  • Stop closing newConnCh in Mux.Close() to avoid send-on-closed races during shutdown and add a clarifying comment.

Testing

  • No automated tests were run.

@djylb djylb merged commit b811d7c into master Jan 21, 2026
@djylb djylb deleted the codex/analyze-and-fix-client-disconnect-issue branch January 21, 2026 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant