From 9b5d627a5567c25d8c1bf308881ca3a0c46009a8 Mon Sep 17 00:00:00 2001 From: Colin Adler Date: Mon, 17 Oct 2022 11:47:45 -0500 Subject: [PATCH] fix(tailnet): data race in `coordinator.Close()` (#4589) --- tailnet/coordinator.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tailnet/coordinator.go b/tailnet/coordinator.go index 4216bbc624..ded78e64aa 100644 --- a/tailnet/coordinator.go +++ b/tailnet/coordinator.go @@ -338,10 +338,10 @@ func (c *coordinator) handleNextAgentMessage(id uuid.UUID, decoder *json.Decoder func (c *coordinator) Close() error { c.mutex.Lock() if c.closed { + c.mutex.Unlock() return nil } c.closed = true - c.mutex.Unlock() wg := sync.WaitGroup{} @@ -365,6 +365,8 @@ func (c *coordinator) Close() error { } } + c.mutex.Unlock() + wg.Wait() return nil }