From 698ef4272c0ac18f9981d2284fad162081bad613 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Fri, 6 Feb 2026 08:51:36 +0000 Subject: [PATCH] hscontrol/mapper: fix copylocks issues in test code Use pointers to node structs instead of copying them to avoid copylocks warnings from govet. The node struct contains atomic fields that shouldn't be copied. Co-Authored-By: Claude Opus 4.5 --- hscontrol/mapper/batcher_test.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hscontrol/mapper/batcher_test.go b/hscontrol/mapper/batcher_test.go index 8c5e783d..4dfd1f8d 100644 --- a/hscontrol/mapper/batcher_test.go +++ b/hscontrol/mapper/batcher_test.go @@ -818,8 +818,8 @@ func TestBatcherBasicOperations(t *testing.T) { defer cleanup() batcher := testData.Batcher - tn := testData.Nodes[0] - tn2 := testData.Nodes[1] + tn := &testData.Nodes[0] + tn2 := &testData.Nodes[1] // Test AddNode with real node ID _ = batcher.AddNode(tn.n.ID, tn.ch, 100) @@ -1136,7 +1136,7 @@ func XTestBatcherChannelClosingRace(t *testing.T) { defer cleanup() batcher := testData.Batcher - testNode := testData.Nodes[0] + testNode := &testData.Nodes[0] var ( channelIssues int @@ -1230,7 +1230,7 @@ func TestBatcherWorkerChannelSafety(t *testing.T) { defer cleanup() batcher := testData.Batcher - testNode := testData.Nodes[0] + testNode := &testData.Nodes[0] var ( panics int @@ -1377,7 +1377,8 @@ func TestBatcherConcurrentClients(t *testing.T) { stableNodes := allNodes[:len(allNodes)/2] // Use first half as stable stableChannels := make(map[types.NodeID]chan *tailcfg.MapResponse) - for _, node := range stableNodes { + for i := range stableNodes { + node := &stableNodes[i] ch := make(chan *tailcfg.MapResponse, NORMAL_BUFFER_SIZE) stableChannels[node.n.ID] = ch _ = batcher.AddNode(node.n.ID, ch, tailcfg.CapabilityVersion(100))