summaryrefslogtreecommitdiffhomepage
path: root/net/tsdial/tsdial.go
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@tailscale.com>2025-12-02 12:50:33 -0800
committerBrad Fitzpatrick <bradfitz@tailscale.com>2025-12-02 15:12:13 -0800
commit381de776c4878dd9af76b126cfa37bc80cad363f (patch)
treec3ddcbf9613db3074c9c6882bb757357cf5bdd0a /net/tsdial/tsdial.go
parentb8c58ca7c1a49fb772d095c65693cdab06488047 (diff)
downloadtailscale-bradfitz/mutex_debug.tar.xz
tailscale-bradfitz/mutex_debug.zip
syncs: start working on mutex debugging, registrationbradfitz/mutex_debug
Updates #17852 Change-Id: Ib1b634eedd30cc4006bc1b39aa8d479d37c5f1f2 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
Diffstat (limited to 'net/tsdial/tsdial.go')
-rw-r--r--net/tsdial/tsdial.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/net/tsdial/tsdial.go b/net/tsdial/tsdial.go
index 065c01384..669055a49 100644
--- a/net/tsdial/tsdial.go
+++ b/net/tsdial/tsdial.go
@@ -75,6 +75,8 @@ type Dialer struct {
// If nil, it's not used.
NetstackDialUDP func(context.Context, netip.AddrPort) (net.Conn, error)
+ registerMutexOnce sync.Once
+
peerClientOnce sync.Once
peerClient *http.Client
@@ -142,6 +144,7 @@ func (d *Dialer) SetExitDNSDoH(doh string) {
if !buildfeatures.HasUseExitNode {
return
}
+ d.registerMutexOnce.Do(d.registerMutex)
d.mu.Lock()
defer d.mu.Unlock()
if d.exitDNSDoHBase == doh {
@@ -193,9 +196,15 @@ func (d *Dialer) Close() error {
return nil
}
+func (d *Dialer) registerMutex() {
+ syncs.RegisterMutex(&d.mu, "tsdial.Dialer.mu")
+}
+
// SetNetMon sets d's network monitor to netMon.
// It is a no-op to call SetNetMon with the same netMon as the current one.
func (d *Dialer) SetNetMon(netMon *netmon.Monitor) {
+ d.registerMutexOnce.Do(d.registerMutex)
+
d.mu.Lock()
defer d.mu.Unlock()
if d.netMon == netMon {
@@ -220,12 +229,14 @@ func (d *Dialer) SetNetMon(netMon *netmon.Monitor) {
// NetMon returns the Dialer's network monitor.
// It returns nil if SetNetMon has not been called.
func (d *Dialer) NetMon() *netmon.Monitor {
+ d.registerMutexOnce.Do(d.registerMutex)
d.mu.Lock()
defer d.mu.Unlock()
return d.netMon
}
func (d *Dialer) SetBus(bus *eventbus.Bus) {
+ d.registerMutexOnce.Do(d.registerMutex)
d.mu.Lock()
defer d.mu.Unlock()
if d.bus == bus {