mirror of
https://github.com/tailscale/tailscale.git
synced 2025-03-31 13:32:24 +00:00
ipn/ipnlocal: fix missing mutex usage for profileManager
It required holding b.mu but was documented incorrectly, fix. Updates #cleanup Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
parent
959362a1f4
commit
f52273767f
@ -143,7 +143,6 @@ type LocalBackend struct {
|
|||||||
statsLogf logger.Logf // for printing peers stats on change
|
statsLogf logger.Logf // for printing peers stats on change
|
||||||
sys *tsd.System
|
sys *tsd.System
|
||||||
e wgengine.Engine // non-nil; TODO(bradfitz): remove; use sys
|
e wgengine.Engine // non-nil; TODO(bradfitz): remove; use sys
|
||||||
pm *profileManager
|
|
||||||
store ipn.StateStore // non-nil; TODO(bradfitz): remove; use sys
|
store ipn.StateStore // non-nil; TODO(bradfitz): remove; use sys
|
||||||
dialer *tsdial.Dialer // non-nil; TODO(bradfitz): remove; use sys
|
dialer *tsdial.Dialer // non-nil; TODO(bradfitz): remove; use sys
|
||||||
backendLogID logid.PublicID
|
backendLogID logid.PublicID
|
||||||
@ -188,6 +187,7 @@ type LocalBackend struct {
|
|||||||
|
|
||||||
// The mutex protects the following elements.
|
// The mutex protects the following elements.
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
|
pm *profileManager // mu guards access
|
||||||
filterHash deephash.Sum
|
filterHash deephash.Sum
|
||||||
httpTestClient *http.Client // for controlclient. nil by default, used by tests.
|
httpTestClient *http.Client // for controlclient. nil by default, used by tests.
|
||||||
ccGen clientGen // function for producing controlclient; lazily populated
|
ccGen clientGen // function for producing controlclient; lazily populated
|
||||||
@ -1289,10 +1289,6 @@ func (b *LocalBackend) startIsNoopLocked(opts ipn.Options) bool {
|
|||||||
// actually a supported operation (it should be, but it's very unclear
|
// actually a supported operation (it should be, but it's very unclear
|
||||||
// from the following whether or not that is a safe transition).
|
// from the following whether or not that is a safe transition).
|
||||||
func (b *LocalBackend) Start(opts ipn.Options) error {
|
func (b *LocalBackend) Start(opts ipn.Options) error {
|
||||||
if opts.LegacyMigrationPrefs == nil && !b.pm.CurrentPrefs().Valid() {
|
|
||||||
return errors.New("no prefs provided")
|
|
||||||
}
|
|
||||||
|
|
||||||
if opts.LegacyMigrationPrefs != nil {
|
if opts.LegacyMigrationPrefs != nil {
|
||||||
b.logf("Start: %v", opts.LegacyMigrationPrefs.Pretty())
|
b.logf("Start: %v", opts.LegacyMigrationPrefs.Pretty())
|
||||||
} else {
|
} else {
|
||||||
@ -1300,6 +1296,11 @@ func (b *LocalBackend) Start(opts ipn.Options) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
|
if opts.LegacyMigrationPrefs == nil && !b.pm.CurrentPrefs().Valid() {
|
||||||
|
b.mu.Unlock()
|
||||||
|
return errors.New("no prefs provided")
|
||||||
|
}
|
||||||
|
|
||||||
if opts.UpdatePrefs != nil {
|
if opts.UpdatePrefs != nil {
|
||||||
if err := b.checkPrefsLocked(opts.UpdatePrefs); err != nil {
|
if err := b.checkPrefsLocked(opts.UpdatePrefs); err != nil {
|
||||||
b.mu.Unlock()
|
b.mu.Unlock()
|
||||||
|
@ -28,6 +28,8 @@ var debug = envknob.RegisterBool("TS_DEBUG_PROFILES")
|
|||||||
|
|
||||||
// profileManager is a wrapper around a StateStore that manages
|
// profileManager is a wrapper around a StateStore that manages
|
||||||
// multiple profiles and the current profile.
|
// multiple profiles and the current profile.
|
||||||
|
//
|
||||||
|
// It is not safe for concurrent use.
|
||||||
type profileManager struct {
|
type profileManager struct {
|
||||||
store ipn.StateStore
|
store ipn.StateStore
|
||||||
logf logger.Logf
|
logf logger.Logf
|
||||||
|
Loading…
x
Reference in New Issue
Block a user