portlist: move sync.Once up and Close on err

Signed-off-by: Marwan Sulaiman <marwan@tailscale.com>
This commit is contained in:
Marwan Sulaiman 2023-05-25 09:03:28 -04:00
parent 27ea062078
commit 821c589f98
2 changed files with 2 additions and 2 deletions

View File

@ -296,6 +296,7 @@ func NewLocalBackend(logf logger.Logf, logID logid.PublicID, sys *tsd.System, lo
err = portpoll.Check()
if err != nil {
logf("skipping portlist: %s", err)
portpoll.Close()
portpoll = nil
}

View File

@ -29,9 +29,8 @@ type Poller struct {
// This field should only be changed before calling Run.
IncludeLocalhost bool
c chan List // unbuffered
initOnce sync.Once // guards init of private fields
c chan List // unbuffered
// os, if non-nil, is an OS-specific implementation of the portlist getting
// code. When non-nil, it's responsible for getting the complete list of