ipn/ipnlocal: don't bind localListener if its context is canceled (#12621)

The context can get canceled during backoff, and binding after that
makes the listener impossible to close afterwards.

Fixes #12620.

Signed-off-by: Naman Sood <mail@nsood.in>
This commit is contained in:
Naman Sood 2024-06-26 11:18:45 -04:00 committed by GitHub
parent 787ead835f
commit 75254178a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -150,6 +150,14 @@ func (s *localListener) Run() {
tcp4or6 = "tcp6"
}
// while we were backing off and trying again, the context got canceled
// so don't bind, just return, because otherwise there will be no way
// to close this listener
if s.ctx.Err() != nil {
s.logf("localListener context closed before binding")
return
}
ln, err := lc.Listen(s.ctx, tcp4or6, net.JoinHostPort(ipStr, fmt.Sprint(s.ap.Port())))
if err != nil {
if s.shouldWarnAboutListenError(err) {