Skip to content

multiplex: reject connections opened after mux closure - #318

Open
git-jxj wants to merge 1 commit into
containerd:mainfrom
git-jxj:git-jxj/fix-mux-open-after-close
Open

git-jxj wants to merge 1 commit into
containerd:mainfrom
git-jxj:git-jxj/fix-mux-open-after-close

Conversation

@git-jxj

@git-jxj git-jxj commented Sep 22, 2026

Copy link
Copy Markdown

A mux can close after its trunk connection fails while its consumer is still opening the logical connections. Open currently succeeds after that closure. For a new connection ID, the returned connection is never closed by the already completed mux shutdown, so Read blocks indefinitely. Dialer and Listen inherit the same behavior.

Check the mux's closed channel while holding the connection lock, returning net.ErrClosed before looking up or creating a connection. Add regression coverage for existing and new connection IDs after explicit shutdown and peer disconnect, including the dialer and listener entry points.

Validation:

  • go test -race ./pkg/net/... -count=1
  • make test (main module race tests and the plugin test targets)
  • make build-check
  • golangci-lint run --allow-parallel-runners ./... (v2.12.0, matching CI): no issues.

The new regression fails on the unchanged base and passes with the fix. The socket tests use local Unix socket pairs; no live container runtime or Kubernetes end-to-end testing is claimed.

AI assistance: OpenAI Codex assisted with the investigation, implementation, tests, and PR description.

Open could create a logical connection after Close had already shut down
all existing connections. Reads on that new connection would then block
indefinitely because no subsequent mux shutdown would close it.

Check the closed channel under the connection lock before returning or
creating a connection. Cover explicit closure and peer disconnection for
Open, Dialer, and Listen with both existing and new connection IDs.

Assisted-by: OpenAI Codex
Signed-off-by: xinjun.jiang <xinjun.jiang@daocloud.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant