From b90b9b46538a9448fd34b2d014fe412f431d7bb4 Mon Sep 17 00:00:00 2001 From: Maisem Ali Date: Tue, 29 Aug 2023 18:50:04 -0700 Subject: [PATCH] client/web: fix data race Fixes #9150 Signed-off-by: Maisem Ali --- client/web/web_test.go | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/client/web/web_test.go b/client/web/web_test.go index fbfd8ad18..8289d5536 100644 --- a/client/web/web_test.go +++ b/client/web/web_test.go @@ -77,17 +77,13 @@ func TestQnapAuthnURL(t *testing.T) { func TestServeAPI(t *testing.T) { lal := memnet.Listen("local-tailscaled.sock:80") defer lal.Close() - // Serve dummy localapi. Just returns "success". - go func() { - localapi := &http.Server{Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - fmt.Fprintf(w, "success") - })} - defer localapi.Close() - if err := localapi.Serve(lal); err != nil { - t.Error(err) - } - }() + localapi := &http.Server{Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, "success") + })} + defer localapi.Close() + + go localapi.Serve(lal) s := &Server{lc: &tailscale.LocalClient{Dial: lal.Dial}} tests := []struct {