Skip to content

Prevent live Unix servers from sharing a TCP port - #2125

Merged
Badrish Chandramouli (badrishc) merged 2 commits into
microsoft:mainfrom
sylvesterkaczmarek:fix/2119-exclusive-unix-listeners
Sep 10, 2026
Merged

Badrish Chandramouli (badrishc) merged 2 commits into
microsoft:mainfrom
sylvesterkaczmarek:fix/2119-exclusive-unix-listeners

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown
Contributor

Fixes #2119.

Disable native SO_REUSEPORT after setting managed ReuseAddress on Linux, macOS, and FreeBSD. This retains SO_REUSEADDR for immediate restarts while preventing two live Garnet listeners from sharing an endpoint. Windows and Unix-domain sockets are unchanged.

Adds IPv4/IPv6 regressions for duplicate listeners, restarting a closed listener, and restarting after a server-side connection enters TIME_WAIT. Both duplicate-listener cases fail before the fix.

Validation on macOS arm64:

  • All six new cases pass on .NET 8 and .NET 10.
  • Listener/configuration selection: 52 passed and one existing Azure-config skip on each framework.
  • Four hostname-resolution cases also fail against the unmodified source; those are excluded from the final selection.
  • Whitespace formatting and git diff --check pass.

Linux, FreeBSD, and Windows were not tested locally.

Copilot AI balanced review requested due to automatic review settings September 10, 2026 17:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new test fixture omits the repository-required TestBase inheritance and teardown leak check.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Prevents concurrent Unix TCP listeners from sharing an endpoint while preserving immediate port reuse after shutdown.

Changes:

  • Disables native SO_REUSEPORT on Linux, macOS, and FreeBSD.
  • Adds IPv4/IPv6 regression tests for duplicate listeners and restart scenarios.
File summaries
File Description
libs/server/Servers/GarnetServerTcp.cs Retains SO_REUSEADDR while disabling SO_REUSEPORT.
test/standalone/Garnet.test/GarnetServerTcpTests.cs Tests duplicate binding and endpoint reuse behavior.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread test/standalone/Garnet.test/GarnetServerTcpTests.cs Outdated
@badrishc
Badrish Chandramouli (badrishc) merged commit 42c9352 into microsoft:main Sep 10, 2026
168 of 169 checks passed
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.

Two servers can silently bind the same port on Unix (ReuseAddress implies SO_REUSEPORT in .NET)

3 participants