From 7eda3af0344dbf4bc1e09faf7ec54a26ec56e313 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 10 Mar 2020 17:31:27 -0700 Subject: [PATCH] wgengine/magicsock: clean up derp http servers on shutdown. Failure to do this leads to fd exhaustion at -count=10000, and increasingly poor execution north of -count=100. Signed-off-by: David Anderson --- wgengine/magicsock/magicsock_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wgengine/magicsock/magicsock_test.go b/wgengine/magicsock/magicsock_test.go index b78b58089..3738d7c98 100644 --- a/wgengine/magicsock/magicsock_test.go +++ b/wgengine/magicsock/magicsock_test.go @@ -267,7 +267,6 @@ func runDERP(t *testing.T) (s *derp.Server, addr string, cleanupFn func()) { } s = derp.NewServer(serverPrivateKey, t.Logf) - // TODO: cleanup httpsrv.CloseClientConnections / Close httpsrv := httptest.NewUnstartedServer(derphttp.Handler(s)) httpsrv.Config.TLSNextProto = make(map[string]func(*http.Server, *tls.Conn, http.Handler)) @@ -276,6 +275,8 @@ func runDERP(t *testing.T) (s *derp.Server, addr string, cleanupFn func()) { addr = strings.TrimPrefix(httpsrv.URL, "https://") cleanupFn = func() { + httpsrv.CloseClientConnections() + httpsrv.Close() s.Close() }