net/portmapper: add UPnP-IGD release timeout

Smallest possible change that could help mitigate a deadlock if a release
is haning.

Updates tailscale/corp#33619

Signed-off-by: Claus Lensbøl <claus@tailscale.com>
cmol/add_upnp_release_timeout
Claus Lensbøl 3 months ago
parent afaa23c3b4
commit c686a9d6d0
No known key found for this signature in database
GPG Key ID: 060429CBEC62B1B4

@ -395,7 +395,9 @@ func (c *Client) listenPacket(ctx context.Context, network, addr string) (nettyp
func (c *Client) invalidateMappingsLocked(releaseOld bool) {
if c.mapping != nil {
if releaseOld {
c.mapping.Release(context.Background())
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
c.mapping.Release(ctx)
}
c.mapping = nil
}

Loading…
Cancel
Save