Skip to content

v2.0.1 - TCP Race Condition Fix

Choose a tag to compare

@mojo333 mojo333 released this 01 Feb 13:12
· 18 commits to master since this release

πŸ› Bug Fixes

This release fixes a critical race condition in TCP connection handling that caused use of closed network connection errors in production environments, particularly with HTTP/2.0 queries.

What was fixed?

TCP Race Condition (#1)

  • Fixed race condition where TCP connections were closed while query processing goroutines were still running
  • Added sync.WaitGroup synchronization to ensure all in-flight queries complete before connection closure
  • Prevents "write tcp: use of closed network connection" errors seen in production logs

Technical Details

The issue occurred when:

  1. Client sent a DNS query over TCP
  2. Query processing started asynchronously in a goroutine
  3. Client disconnected or connection timed out
  4. Connection was closed immediately
  5. Goroutine tried to write response to closed connection β†’ error

The fix ensures graceful shutdown by waiting for all query processing to complete before closing the connection.

Testing

  • Added comprehensive TCP connection tests (proxy/tcp_test.go)
  • All tests pass with race detector enabled (-race)
  • Verified fix prevents connection errors under concurrent load

πŸ“¦ Installation

Linux (arm64)

wget https://github.com/mojo333/nextdns/releases/download/v2.0.1/nextdns_2.0.1_linux_arm64.tar.gz
tar xzf nextdns_2.0.1_linux_arm64.tar.gz
sudo mv nextdns /usr/bin/

Other Platforms

Download the appropriate archive for your platform from the assets below.

πŸ” Checksums

See SHA256SUMS in the release assets for file integrity verification.


Full Changelog: v2.0.0...v2.0.1