mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-12 05:37:32 +00:00
ipn/ipnlocal: add mutex to webClient struct
Adds a new sync.Mutex field to the webClient struct, rather than using the general LocalBackend mutex. Since webClientGetOrInit (previously WebClientInit) gets called on every connection, we want to avoid holding the lock on LocalBackend just to check if the server is initialized. Moves all web_client.go funcs over to using the webClient.mu field. Updates tailscale/corp#14335 Signed-off-by: Sonia Appasamy <sonia@tailscale.com>
This commit is contained in:

committed by
Sonia Appasamy

parent
7d4221c295
commit
055394f3be
@@ -656,7 +656,7 @@ func (b *LocalBackend) Shutdown() {
|
||||
b.debugSink = nil
|
||||
}
|
||||
b.mu.Unlock()
|
||||
b.WebClientShutdown()
|
||||
b.webClientShutdown()
|
||||
|
||||
if b.sockstatLogger != nil {
|
||||
b.sockstatLogger.Shutdown()
|
||||
@@ -4252,7 +4252,7 @@ func (b *LocalBackend) setWebClientAtomicBoolLocked(nm *netmap.NetworkMap, prefs
|
||||
shouldRun := prefs.Valid() && prefs.RunWebClient()
|
||||
wasRunning := b.webClientAtomicBool.Swap(shouldRun)
|
||||
if wasRunning && !shouldRun {
|
||||
go b.WebClientShutdown() // stop web client
|
||||
go b.webClientShutdown() // stop web client
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user