mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-15 10:49:18 +00:00
health: add Tracker type, in prep for removing global variables
This moves most of the health package global variables to a new `health.Tracker` type. But then rather than plumbing the Tracker in tsd.System everywhere, this only goes halfway and makes one new global Tracker (`health.Global`) that all the existing callers now use. A future change will eliminate that global. Updates #11874 Updates #4136 Change-Id: I6ee27e0b2e35f68cb38fecdb3b2dc4c3f2e09d68 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:

committed by
Brad Fitzpatrick

parent
d5fc52a0f5
commit
ebc552d2e0
@@ -666,7 +666,7 @@ func (c *Conn) updateNetInfo(ctx context.Context) (*netcheck.Report, error) {
|
||||
// NOTE(andrew-d): I don't love that we're depending on the
|
||||
// health package here, but I'd rather do that and not store
|
||||
// the exact same state in two different places.
|
||||
GetLastDERPActivity: health.GetDERPRegionReceivedTime,
|
||||
GetLastDERPActivity: health.Global.GetDERPRegionReceivedTime,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -2471,7 +2471,7 @@ func (c *Conn) bindSocket(ruc *RebindingUDPConn, network string, curPortFate cur
|
||||
}
|
||||
ruc.setConnLocked(pconn, network, c.bind.BatchSize())
|
||||
if network == "udp4" {
|
||||
health.SetUDP4Unbound(false)
|
||||
health.Global.SetUDP4Unbound(false)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -2482,7 +2482,7 @@ func (c *Conn) bindSocket(ruc *RebindingUDPConn, network string, curPortFate cur
|
||||
// we get a link change and we can try binding again.
|
||||
ruc.setConnLocked(newBlockForeverConn(), "", c.bind.BatchSize())
|
||||
if network == "udp4" {
|
||||
health.SetUDP4Unbound(true)
|
||||
health.Global.SetUDP4Unbound(true)
|
||||
}
|
||||
return fmt.Errorf("failed to bind any ports (tried %v)", ports)
|
||||
}
|
||||
|
Reference in New Issue
Block a user