proxycfg: fix goroutine leak when service is re-registered (#14988)

Fixes a bug where we'd leak a goroutine in state.run when the given
context was canceled while there was a pending update.
This commit is contained in:
Dan Upton 2022-10-17 11:31:10 +01:00 committed by GitHub
parent 73d252c6d8
commit 90129919a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -317,7 +317,10 @@ func (s *state) run(ctx context.Context, snap *ConfigSnapshot) {
// This runs in another goroutine so we can't just do the send
// directly here as access to snap is racy. Instead, signal the main
// loop above.
sendCh <- struct{}{}
select {
case sendCh <- struct{}{}:
case <-ctx.Done():
}
})
}