wgengine/magicsock: quiet log flood at tailscaled shutdown

When you hit control-C on a tailscaled (notably in dev mode, but
also on any systemctl stop/restart), there is a flood of messages like:

magicsock: doing cleanup for discovery key d:aa9c92321db0807f
magicsock: doing cleanup for discovery key d:bb0f16aacadbfd46
magicsock: doing cleanup for discovery key d:b5b2d386296536f2
magicsock: doing cleanup for discovery key d:3b640649f6796c91
magicsock: doing cleanup for discovery key d:71d7b1afbcce52cd
magicsock: doing cleanup for discovery key d:315b61d7e0111377
magicsock: doing cleanup for discovery key d:9301f63dce69bf45
magicsock: doing cleanup for discovery key d:376141884d6fe072
....

It can be hundreds or even tens of thousands.

So don't do that. Not a useful log message during shutdown.

Change-Id: I029a8510741023f740877df28adff778246c18e5
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/6998/head
Brad Fitzpatrick 2 years ago committed by Brad Fitzpatrick
parent 3addcacfe9
commit 2df38b1feb

@ -353,7 +353,8 @@ type Conn struct {
mu sync.Mutex mu sync.Mutex
muCond *sync.Cond muCond *sync.Cond
closed bool // Close was called closed bool // Close was called
closing atomic.Bool // Close is in progress (or done)
// derpCleanupTimer is the timer that fires to occasionally clean // derpCleanupTimer is the timer that fires to occasionally clean
// up idle DERP connections. It's only used when there is a non-home // up idle DERP connections. It's only used when there is a non-home
@ -2859,6 +2860,7 @@ func (c *Conn) Close() error {
if c.closed { if c.closed {
return nil return nil
} }
c.closing.Store(true)
if c.derpCleanupTimerArmed { if c.derpCleanupTimerArmed {
c.derpCleanupTimer.Stop() c.derpCleanupTimer.Stop()
} }
@ -4441,7 +4443,9 @@ func (de *endpoint) stopAndReset() {
de.mu.Lock() de.mu.Lock()
defer de.mu.Unlock() defer de.mu.Unlock()
de.c.logf("[v1] magicsock: doing cleanup for discovery key %s", de.discoKey.ShortString()) if closing := de.c.closing.Load(); !closing {
de.c.logf("[v1] magicsock: doing cleanup for discovery key %s", de.discoKey.ShortString())
}
de.resetLocked() de.resetLocked()
if de.heartBeatTimer != nil { if de.heartBeatTimer != nil {

Loading…
Cancel
Save