Skip to content

fix(plugin): close connections after failed listener handoff - #5614

Draft
shizukunacho wants to merge 1 commit into
fatedier:devfrom
shizukunacho:fix/http-plugin-connection-handoff
Draft

shizukunacho wants to merge 1 commit into
fatedier:devfrom
shizukunacho:fix/http-plugin-connection-handoff

Conversation

@shizukunacho

Copy link
Copy Markdown

WHY

A work connection can be scheduled before a proxy stops and reach the HTTP plugin after its listener has closed. Listener.PutConn then returns an error without taking ownership of the connection. The static-file plugin, HTTP bridge plugins and the non-CONNECT path of http_proxy discard that error, and the caller does not close connections retained by plugins. The connection remains open even though no HTTP server will handle it.

Close the connection wrapper when listener handoff fails at those three call sites. A successful handoff continues to transfer ownership to the HTTP server.

The regression test creates each real plugin, closes it, then calls Handle with a pipe connection. After Handle returns, the peer must observe EOF. All three cases timed out before the fix and pass afterward; the HTTP-proxy case supplies the method prefix needed to reach its non-CONNECT handoff.

Validation on Windows/amd64 with Go 1.26.11:

  • go test ./pkg/plugin/client -count=1
  • go test -race ./pkg/plugin/client -count=1
  • go vet ./pkg/plugin/client
  • go test -tags noweb ./client/proxy -count=1
  • gofmt and git diff --check

The full end-to-end suite was not run locally.

Draft while #5612 remains open, in accordance with the repository's one non-draft PR limit.

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