Skip to content

Commit

Permalink
Backport of bug: prevent go routine leakage due to existing DeferChec…
Browse files Browse the repository at this point in the history
…k into release/1.16.x (hashicorp#18565)

* backport of commit 06d4c72

* backport of commit 42c37bb

---------

Co-authored-by: cskh <[email protected]>
  • Loading branch information
hc-github-team-consul-core and huikang authored Aug 23, 2023
1 parent 985b2f5 commit 0d0c5d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/18558.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
check: prevent go routine leakage when existing Defercheck of same check id is not nil
```
6 changes: 6 additions & 0 deletions agent/local/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,12 @@ func (l *State) setCheckStateLocked(c *CheckState) {
existing := l.checks[id]
if existing != nil {
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
Expand Down

0 comments on commit 0d0c5d0

Please sign in to comment.