Skip to content

Fix TCP relay source handover and shutdown races - #263

Open
sylvesterkaczmarek wants to merge 1 commit into
nasa:mainfrom
sylvesterkaczmarek:fix/tcp-relay-connection-lifecycle
Open

sylvesterkaczmarek wants to merge 1 commit into
nasa:mainfrom
sylvesterkaczmarek:fix/tcp-relay-connection-lifecycle

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown
Contributor

Fixes #262. Related to #247 and #261.

Give each TCP relay instance its own cancellation context and join its listener/connection workers before Start returns, including after partial startup failure. Install sources in accept order before launching readers, close sockets when readers finish, and make source dialing context-aware.

Regression tests cover both source modes, failures in duplex/readable port setup, delayed reader scheduling, EOF cleanup, canceled dialing, and immediate port reuse after shutdown. The startup rollback, delayed reader, EOF, and canceled-dial regressions fail against unmodified main.

Validation

macOS arm64, Go 1.27.1:

Test limitation

A 90-run full relay stress test combined with #261 hit one TestRelayReadable startup failure (bind: address already in use). The existing test helper releases an ephemeral port before the provider binds it, leaving a separate port-allocation race. No race-detector warnings or lifecycle-regression failures were reported in that run. This runtime fix does not change test-port allocation.

This PR and #261 change disjoint files and target main independently.

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.

TCP relay leaks resources after failed startup and can replace newer sources

1 participant