fix(tailnet): data race in `coordinator.Close()` (#4589)

This commit is contained in:
Colin Adler 2022-10-17 11:47:45 -05:00 committed by GitHub
parent 29acd25b4e
commit 9b5d627a55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -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
}