Skip to content

Commit

Permalink
Agent defers to daemon to advise when ready
Browse files Browse the repository at this point in the history
The a.ready channel is still useful to synchronize the access to a.daemon,
preventing nil pointer access when the deamon is not yet initialized.
Checking for nil is still needed, as the a.ready channel may be closed without ever serving.
  • Loading branch information
CarlosNihelton committed Nov 26, 2024
1 parent d0d0fbf commit 0cc4ba9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions windows-agent/cmd/ubuntu-pro-agent/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ func (a *App) Quit() {
// Note: we need to use a pointer to not copy the App object before the daemon is ready, and thus, creates a data race.
func (a *App) WaitReady() {
<-a.ready
if a.daemon == nil {
return
}
a.daemon.WaitReady()
}

// RootCmd returns a copy of the root command for the app. Shouldn't be in general necessary apart when running generators.
Expand Down

0 comments on commit 0cc4ba9

Please sign in to comment.