Backport of bug: prevent go routine leakage due to existing DeferCheck into release/1.16.x (#18565)
* backport of commit 06d4c72f682881c78265248fb749ebfd5cc365b8 * backport of commit 42c37bb2c1e4d8eac8078f17c16b8e6797baa446 --------- Co-authored-by: cskh <hui.kang@hashicorp.com>
This commit is contained in:
parent
ad458ac361
commit
b63db8b411
|
@ -0,0 +1,3 @@
|
||||||
|
```release-note:bug
|
||||||
|
check: prevent go routine leakage when existing Defercheck of same check id is not nil
|
||||||
|
```
|
|
@ -838,6 +838,12 @@ func (l *State) setCheckStateLocked(c *CheckState) {
|
||||||
existing := l.checks[id]
|
existing := l.checks[id]
|
||||||
if existing != nil {
|
if existing != nil {
|
||||||
c.InSync = c.Check.IsSame(existing.Check)
|
c.InSync = c.Check.IsSame(existing.Check)
|
||||||
|
// If the existing check has a Defercheck, it needs to be
|
||||||
|
// assigned to the new check
|
||||||
|
if existing.DeferCheck != nil && c.DeferCheck == nil {
|
||||||
|
c.DeferCheck = existing.DeferCheck
|
||||||
|
c.InSync = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
l.checks[id] = c
|
l.checks[id] = c
|
||||||
|
|
Loading…
Reference in New Issue