Skip to content

fix(server): close opposite socket on EOF to prevent descriptor leaks - #85

Merged
kernelshard merged 1 commit into
developfrom
fix/server-symmetric-teardown
Oct 22, 2026
Merged

kernelshard merged 1 commit into
developfrom
fix/server-symmetric-teardown

Conversation

@kernelshard

Copy link
Copy Markdown
Owner

When proxying in ServeHTTP, if the visitor disconnected early, the background routine copying from the laptop remained blocked indefinitely because the opposite socket was never closed on EOF, leaking descriptors.

This PR:

  • Uses sync.WaitGroup to symmetrically run and wait for both copy routines.
  • Explicitly closes the opposite socket when either direction finishes, unblocking the sibling routine.
  • Renames clientConn to visitorConn in ServeHTTP to eliminate naming ambiguity.
  • Adds a unit test verifying the tunnel socket unblocks immediately with EOF when a visitor disconnects.

Fixes #58

@kernelshard kernelshard added bug Something isn't working enhancement New feature or request and removed enhancement New feature or request labels Oct 22, 2026
@kernelshard
kernelshard merged commit 8ef1f80 into develop Oct 22, 2026
2 checks passed
@kernelshard
kernelshard deleted the fix/server-symmetric-teardown branch October 22, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(server): synchronize bidirectional proxy copy to prevent socket descriptor leaks

1 participant