Skip to content

Commit 42ce5c8

Browse files
committed
wgengine/magicsock: unblock Conn.Synchronize on Conn.Close
I noticed a deadlock in a test in a in-development PR where during a shutdown storm of things (from a tsnet.Server.Close), LocalBackend was trying to call magicsock.Conn.Synchronize but the magicsock and/or eventbus was already shut down and no longer processing events. Updates tailscale#16369 Change-Id: I58b1f86c8959303c3fb46e2e3b7f38f6385036f1 Signed-off-by: Brad Fitzpatrick <[email protected]>
1 parent 2ad2d4d commit 42ce5c8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

wgengine/magicsock/magicsock.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,10 @@ func (c *Conn) Synchronize() {
665665
}
666666
sp := syncPoint(make(chan struct{}))
667667
c.syncPub.Publish(sp)
668-
sp.Wait()
668+
select {
669+
case <-sp:
670+
case <-c.donec:
671+
}
669672
}
670673

671674
// NewConn creates a magic Conn listening on opts.Port.

0 commit comments

Comments
 (0)