Skip to content

Commit 7855054

Browse files
ethanndicksonmatifali
authored andcommitted
fix: lock adding to tailnet waitgroup to avoid race (and fix flake) (#14195)
1 parent 45fd174 commit 7855054

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tailnet/conn.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,6 @@ func (c *Conn) Closed() <-chan struct{} {
556556
func (c *Conn) Close() error {
557557
c.logger.Info(context.Background(), "closing tailnet Conn")
558558
c.watchCancel()
559-
c.telemetryWg.Wait()
560559
c.configMaps.close()
561560
c.nodeUpdater.close()
562561
c.mutex.Lock()
@@ -567,6 +566,7 @@ func (c *Conn) Close() error {
567566
default:
568567
}
569568
close(c.closed)
569+
c.telemetryWg.Wait()
570570
c.mutex.Unlock()
571571

572572
var wg sync.WaitGroup
@@ -783,6 +783,13 @@ func (c *Conn) newTelemetryEvent() *proto.TelemetryEvent {
783783
}
784784

785785
func (c *Conn) sendTelemetryBackground(e *proto.TelemetryEvent) {
786+
c.mutex.Lock()
787+
defer c.mutex.Unlock()
788+
select {
789+
case <-c.closed:
790+
return
791+
default:
792+
}
786793
c.telemetryWg.Add(1)
787794
go func() {
788795
defer c.telemetryWg.Done()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy