mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-27 10:47:35 +00:00
control/controlclient: merge, simplify two health check calls
I'm trying to remove some stuff from the netmap update path. Updates #1909 Change-Id: Iad2c728dda160cd52f33ef9cf0b75b4940e0ce64 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
17438a98c0
commit
14320290c3
@ -489,7 +489,6 @@ type mapRoutineState struct {
|
|||||||
|
|
||||||
func (mrs mapRoutineState) UpdateFullNetmap(nm *netmap.NetworkMap) {
|
func (mrs mapRoutineState) UpdateFullNetmap(nm *netmap.NetworkMap) {
|
||||||
c := mrs.c
|
c := mrs.c
|
||||||
health.SetInPollNetMap(true)
|
|
||||||
|
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
ctx := c.mapCtx
|
ctx := c.mapCtx
|
||||||
@ -561,11 +560,11 @@ func (c *Auto) mapRoutine() {
|
|||||||
c.logf("[v1] mapRoutine: new map needed while idle.")
|
c.logf("[v1] mapRoutine: new map needed while idle.")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
health.SetInPollNetMap(false)
|
health.SetOutOfPollNetMap()
|
||||||
|
|
||||||
err := c.direct.PollNetMap(ctx, mrs)
|
err := c.direct.PollNetMap(ctx, mrs)
|
||||||
|
|
||||||
health.SetInPollNetMap(false)
|
health.SetOutOfPollNetMap()
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
c.synced = false
|
c.synced = false
|
||||||
if c.state == StateSynchronized {
|
if c.state == StateSynchronized {
|
||||||
|
@ -279,27 +279,31 @@ func SetControlHealth(problems []string) {
|
|||||||
|
|
||||||
// GotStreamedMapResponse notes that we got a tailcfg.MapResponse
|
// GotStreamedMapResponse notes that we got a tailcfg.MapResponse
|
||||||
// message in streaming mode, even if it's just a keep-alive message.
|
// message in streaming mode, even if it's just a keep-alive message.
|
||||||
|
//
|
||||||
|
// This also notes that a map poll is in progress. To unset that, call
|
||||||
|
// SetOutOfPollNetMap().
|
||||||
func GotStreamedMapResponse() {
|
func GotStreamedMapResponse() {
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
defer mu.Unlock()
|
defer mu.Unlock()
|
||||||
lastStreamedMapResponse = time.Now()
|
lastStreamedMapResponse = time.Now()
|
||||||
|
if !inMapPoll {
|
||||||
|
inMapPoll = true
|
||||||
|
inMapPollSince = time.Now()
|
||||||
|
}
|
||||||
selfCheckLocked()
|
selfCheckLocked()
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetInPollNetMap records whether the client has an open
|
// SetOutOfPollNetMap records that the client is no longer in
|
||||||
// HTTP long poll open to the control plane.
|
// an HTTP map request long poll to the control plane.
|
||||||
func SetInPollNetMap(v bool) {
|
func SetOutOfPollNetMap() {
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
defer mu.Unlock()
|
defer mu.Unlock()
|
||||||
if v == inMapPoll {
|
if !inMapPoll {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
inMapPoll = v
|
inMapPoll = false
|
||||||
if v {
|
lastMapPollEndedAt = time.Now()
|
||||||
inMapPollSince = time.Now()
|
selfCheckLocked()
|
||||||
} else {
|
|
||||||
lastMapPollEndedAt = time.Now()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetInPollNetMap reports whether the client has an open
|
// GetInPollNetMap reports whether the client has an open
|
||||||
|
Loading…
x
Reference in New Issue
Block a user