From cc6ab0a70f8660b0051ad18d8006b715740f454b Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Mon, 14 Jun 2021 08:59:09 -0700 Subject: [PATCH] ipn/ipnlocal: retry peerapi listen on Android, like we do on Windows Updates #1960 Signed-off-by: Brad Fitzpatrick --- ipn/ipnlocal/local.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go index 3fb0564c6..462cd60af 100644 --- a/ipn/ipnlocal/local.go +++ b/ipn/ipnlocal/local.go @@ -244,7 +244,7 @@ func (b *LocalBackend) linkChange(major bool, ifst *interfaces.State) { // need updating to tweak default routes. b.updateFilter(b.netMap, b.prefs) - if runtime.GOOS == "windows" && b.netMap != nil && b.state == ipn.Running { + if peerAPIListenAsync && b.netMap != nil && b.state == ipn.Running { want := len(b.netMap.Addresses) b.logf("linkChange: peerAPIListeners too low; trying again") if len(b.peerAPIListeners) < want { @@ -1884,6 +1884,13 @@ func (b *LocalBackend) closePeerAPIListenersLocked() { b.peerAPIListeners = nil } +// peerAPIListenAsync is whether the operating system requires that we +// retry listening on the peerAPI ip/port for whatever reason. +// +// On Windows, see Issue 1620. +// On Android, see Issue 1960. +const peerAPIListenAsync = runtime.GOOS == "windows" || runtime.GOOS == "android" + func (b *LocalBackend) initPeerAPIListener() { b.mu.Lock() defer b.mu.Unlock() @@ -1947,9 +1954,8 @@ func (b *LocalBackend) initPeerAPIListener() { if !skipListen { ln, err = ps.listen(a.IP(), b.prevIfState) if err != nil { - if runtime.GOOS == "windows" { - // Expected for now. See Issue 1620. - // But we fix it later in linkChange + if peerAPIListenAsync { + // Expected. But we fix it later in linkChange // ("peerAPIListeners too low"). continue }