From b62cfc430a04a4c33748d91a4d9282bdc654ed3a Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Fri, 3 May 2024 09:29:06 -0700 Subject: [PATCH] tstest/integration/testcontrol: fix data race Noticed in earlier GitHub actions failure. Fixes #11994 Change-Id: Iba8d753caaa3dacbe2da9171d96c5f99b12e62d7 Signed-off-by: Brad Fitzpatrick --- tstest/integration/testcontrol/testcontrol.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tstest/integration/testcontrol/testcontrol.go b/tstest/integration/testcontrol/testcontrol.go index 74caaec64..80cf4ef35 100644 --- a/tstest/integration/testcontrol/testcontrol.go +++ b/tstest/integration/testcontrol/testcontrol.go @@ -13,6 +13,7 @@ import ( "fmt" "io" "log" + "maps" "math/rand" "net/http" "net/http/httptest" @@ -914,7 +915,12 @@ func (s *Server) MapResponse(req *tailcfg.MapRequest) (res *tailcfg.MapResponse, // node key rotated away (once test server supports that) return nil, nil } - node.CapMap = s.nodeCapMaps[nk] + + s.mu.Lock() + nodeCapMap := maps.Clone(s.nodeCapMaps[nk]) + s.mu.Unlock() + + node.CapMap = nodeCapMap node.Capabilities = append(node.Capabilities, tailcfg.NodeAttrDisableUPnP) user, _ := s.getUser(nk)