mirror of
https://github.com/tailscale/tailscale.git
synced 2025-01-05 23:07:44 +00:00
wgengine/magicsock: set up pathfinder (#5994)
Sets up new file for separate silent disco goroutine, tentatively named pathfinder for now. Updates #540 Co-authored-by: Brad Fitzpatrick <bradfitz@tailscale.com> Signed-off-by: Jenny Zhang <jz@tailscale.com>
This commit is contained in:
parent
deac82231c
commit
d13c9cdfb4
@ -3352,7 +3352,11 @@ type endpoint struct {
|
||||
|
||||
pendingCLIPings []pendingCLIPing // any outstanding "tailscale ping" commands running
|
||||
|
||||
heartbeatDisabled bool // heartBeatTimer disabled for silent disco. See issue #540.
|
||||
// The following fields are related to the new "silent disco"
|
||||
// implementation that's a WIP as of 2022-10-20.
|
||||
// See #540 for background.
|
||||
heartbeatDisabled bool
|
||||
pathFinderRunning bool
|
||||
}
|
||||
|
||||
type pendingCLIPing struct {
|
||||
@ -3648,9 +3652,16 @@ func (de *endpoint) send(b []byte) error {
|
||||
return fn(b)
|
||||
}
|
||||
|
||||
now := mono.Now()
|
||||
|
||||
de.mu.Lock()
|
||||
|
||||
// if heartbeat disabled, kick off pathfinder
|
||||
if de.heartbeatDisabled {
|
||||
if !de.pathFinderRunning {
|
||||
de.startPathFinder()
|
||||
}
|
||||
}
|
||||
|
||||
now := mono.Now()
|
||||
udpAddr, derpAddr := de.addrForSendLocked(now)
|
||||
if de.canP2P() && (!udpAddr.IsValid() || now.After(de.trustBestAddrUntil)) {
|
||||
de.sendPingsLocked(now, true)
|
||||
|
13
wgengine/magicsock/pathfinder.go
Normal file
13
wgengine/magicsock/pathfinder.go
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright (c) 2022 Tailscale Inc & AUTHORS All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package magicsock
|
||||
|
||||
// startPathFinder initializes the atomicSendFunc, and
|
||||
// will eventually kick off a goroutine that monitors whether
|
||||
// that sendFunc is still the best option for the endpoint
|
||||
// to use and adjusts accordingly.
|
||||
func (de *endpoint) startPathFinder() {
|
||||
de.pathFinderRunning = true
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user