@@ -130,8 +130,15 @@ func (n *connectionManager) getAndResetTrafficCheck(localIndex uint32) (bool, bo
130130}
131131
132132func (n * connectionManager ) AddTrafficWatch (localIndex uint32 ) {
133- n .Out (localIndex )
133+ // Use a write lock directly because it should be incredibly rare that we are ever already tracking this index
134+ n .outLock .Lock ()
135+ if _ , ok := n .out [localIndex ]; ok {
136+ n .inLock .Unlock ()
137+ return
138+ }
139+ n .out [localIndex ] = struct {}{}
134140 n .trafficTimer .Add (localIndex , n .checkInterval )
141+ n .outLock .Unlock ()
135142}
136143
137144func (n * connectionManager ) Start (ctx context.Context ) {
@@ -363,15 +370,19 @@ func (n *connectionManager) makeTrafficDecision(localIndex uint32, p, nb, out []
363370 return doNothing , nil , nil
364371 }
365372
366- hostinfo .logger (n .l ).
367- WithField ("tunnelCheck" , m {"state" : "testing" , "method" : "active" }).
368- Debug ("Tunnel status" )
373+ if n .l .Level >= logrus .DebugLevel {
374+ hostinfo .logger (n .l ).
375+ WithField ("tunnelCheck" , m {"state" : "testing" , "method" : "active" }).
376+ Debug ("Tunnel status" )
377+ }
369378
370379 // Send a test packet to trigger an authenticated tunnel test, this should suss out any lingering tunnel issues
371380 n .intf .SendMessageToHostInfo (header .Test , header .TestRequest , hostinfo , p , nb , out )
372381
373382 } else {
374- hostinfo .logger (n .l ).Debugf ("Hostinfo sadness" )
383+ if n .l .Level >= logrus .DebugLevel {
384+ hostinfo .logger (n .l ).Debugf ("Hostinfo sadness" )
385+ }
375386 }
376387
377388 n .pendingDeletion [hostinfo .localIndexId ] = struct {}{}
0 commit comments