diff options
| author | Adrian Dewhurst <adrian@tailscale.com> | 2024-09-25 14:50:39 -0400 |
|---|---|---|
| committer | Adrian Dewhurst <sailor@sailorfrag.net> | 2024-09-25 16:50:33 -0400 |
| commit | 2fdbcbdf8687d7e2a8965aa73b91b8a1f62191fb (patch) | |
| tree | 4a6ad4664147f8319d16bb31b0eb791bdcc96365 | |
| parent | c2f0c705e7b5c771aa0464577ada19ca32d87d74 (diff) | |
| download | tailscale-2fdbcbdf8687d7e2a8965aa73b91b8a1f62191fb.tar.xz tailscale-2fdbcbdf8687d7e2a8965aa73b91b8a1f62191fb.zip | |
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 <adrian@tailscale.com>
| -rw-r--r-- | wgengine/magicsock/magicsock.go | 13 |
1 files 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. |
