From 2fdbcbdf8687d7e2a8965aa73b91b8a1f62191fb Mon Sep 17 00:00:00 2001 From: Adrian Dewhurst Date: Wed, 25 Sep 2024 14:50:39 -0400 Subject: [PATCH] wgengine/magicsock: only used cached results for GetLastNetcheckReport When querying for an exit node suggestion, occasionally it triggers a new report concurrently with an existing report in progress. Generally, there should always be a recent report or one in progress, so it is redundant to start one there, and it causes concurrency issues. Fixes #12643 Change-Id: I66ab9003972f673e5d4416f40eccd7c6676272a5 Signed-off-by: Adrian Dewhurst --- wgengine/magicsock/magicsock.go | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/wgengine/magicsock/magicsock.go b/wgengine/magicsock/magicsock.go index ff3d02336..9e1bcd059 100644 --- a/wgengine/magicsock/magicsock.go +++ b/wgengine/magicsock/magicsock.go @@ -3027,18 +3027,9 @@ func getPeerMTUsProbedMetric(mtu tstun.WireMTU) *clientmetric.Metric { return mm } -// GetLastNetcheckReport returns the last netcheck report, running a new one if a recent one does not exist. +// GetLastNetcheckReport returns the last netcheck report, returning nil if a recent one does not exist. func (c *Conn) GetLastNetcheckReport(ctx context.Context) *netcheck.Report { - lastReport := c.lastNetCheckReport.Load() - if lastReport == nil { - nr, err := c.updateNetInfo(ctx) - if err != nil { - c.logf("magicsock.Conn.GetLastNetcheckReport: updateNetInfo: %v", err) - return nil - } - return nr - } - return lastReport + return c.lastNetCheckReport.Load() } // SetLastNetcheckReportForTest sets the magicsock conn's last netcheck report.