ipn/ipnlocal: fix race condition that results in a panic sending on a closed channel

Fixes #13288

Signed-off-by: Nick Khyl <nickk@tailscale.com>
This commit is contained in:
Nick Khyl
2024-08-27 23:11:00 -05:00
committed by Nick Khyl
parent 35423fcf69
commit 959285e0c5
3 changed files with 21 additions and 6 deletions

View File

@@ -251,6 +251,14 @@ func TestServeConfigForeground(t *testing.T) {
t.Fatal(err)
}
// Introduce a race between [LocalBackend] sending notifications
// and [LocalBackend.WatchNotifications] shutting down due to
// setting the serve config below.
const N = 1000
for range N {
go b.send(ipn.Notify{})
}
// Setting a new serve config should shut down WatchNotifications
// whose session IDs are no longer found: session1 goes, session2 stays.
err = b.SetServeConfig(&ipn.ServeConfig{