cmd/tailscale: avoid deadlocking between backend calls and callbacks

The runBackend goroutine issues backend requests (StartLoginInteractive,
Logout, SetPrefs) from the same select that receives callbacks the
backend.

Avoid the potential for same-goroutine deadlock by issuing backend requests on
separate goroutines.

Fixes tailscale/tailscale#470

Signed-off-by: Elias Naur <mail@eliasnaur.com>
pull/2/head
Elias Naur 4 years ago
parent dd2cdacbed
commit 0d0a049057

@ -224,15 +224,15 @@ func (a *App) runBackend() error {
case e := <-a.backend:
switch e := e.(type) {
case ReauthEvent:
b.backend.StartLoginInteractive()
go b.backend.StartLoginInteractive()
case LogoutEvent:
b.backend.Logout()
go b.backend.Logout()
case ConnectEvent:
prefs.mu.Lock()
p := prefs.prefs
prefs.mu.Unlock()
p.WantRunning = e.Enable
b.backend.SetPrefs(p)
go b.backend.SetPrefs(p)
}
case s := <-onConnect:
jni.Do(a.jvm, func(env jni.Env) error {

Loading…
Cancel
Save