fix(healthcheck): prevent race condition on the healthchecker (#3400)

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com>

Thanks also to @arturhoo for also trying to resolve this issue in #3410
This commit is contained in:
Matt Van Horn
2026-07-28 19:22:20 -07:00
committed by GitHub
parent 257787ce15
commit df3c9fa668
3 changed files with 18 additions and 8 deletions
+7
View File
@@ -45,6 +45,7 @@ type Loop struct {
start <-chan struct{}
running chan<- models.LoopStatus
userTrigger bool
healthDone <-chan struct{}
// Internal constant values
backoffTime time.Duration
}
@@ -70,6 +71,11 @@ func NewLoop(vpnSettings settings.VPN, ipv6SupportLevel netlink.IPv6SupportLevel
statusManager := loopstate.New(constants.Stopped, start, running, stop, stopped)
state := state.New(statusManager, vpnSettings)
// Initialize healthDone channel to a closed channel so that the first time
// we call <-l.healthDone it does not block
healthDone := make(chan struct{})
close(healthDone)
return &Loop{
statusManager: statusManager,
state: state,
@@ -98,6 +104,7 @@ func NewLoop(vpnSettings settings.VPN, ipv6SupportLevel netlink.IPv6SupportLevel
stop: stop,
stopped: stopped,
userTrigger: true,
healthDone: healthDone,
backoffTime: defaultBackoffTime,
}
}