From 495ac46dc189e6607c660ac46479bd4b84256463 Mon Sep 17 00:00:00 2001 From: Mike Luu Date: Mon, 23 Aug 2021 14:57:26 -0700 Subject: [PATCH] do not block accepting connections When using a plain TCP listener, goScanConnection creates some data structures and moves on to scan which is wrapped in a goroutine. When using a TLS listener, goScanConnection does not return until the TLS handshake is complete. A lot can go wrong during this stage. This change wraps goScanConnection in a goroutine to avoid blocking accepting the next connection. --- server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server.go b/server.go index 352597b..e7f45f6 100644 --- a/server.go +++ b/server.go @@ -184,7 +184,7 @@ func (s *Server) goAcceptConnection(listener net.Listener) { continue } - s.goScanConnection(connection) + go s.goScanConnection(connection) } s.wait.Done()