diff --git a/client/server/server.go b/client/server/server.go index 32daf7718c5..17c77c76fdd 100644 --- a/client/server/server.go +++ b/client/server/server.go @@ -242,12 +242,12 @@ func (s *Server) Start() error { // connectWithRetryRuns runs the client connection with a backoff strategy where we retry the operation as additional // mechanism to keep the client connected even when the connection is lost. + // we cancel retry if the client receive a stop or down command, or if disable auto connect is configured. // // The goroutine's exit is signalled to the daemon via close(giveUpChan) -// — placed in the function-scope defer so every return path (panic, -// DisableAutoConnect early-exit, backoff exhausted, ctx cancel) closes -// it. Callers that need to observe "is the goroutine still alive?" use +// — placed in the function-scope defer so every return path (panic, backoff exhausted, +// ctx cancel) closes it. Callers that need to observe "is the goroutine still alive?" use // Server.connectionGoroutineRunning() which non-blockingly checks the close state // of clientGiveUpChan. The defer does NOT touch s.mutex; the daemon's // "intent" (clientRunning) is maintained by the RPC handlers, not by this @@ -259,14 +259,6 @@ func (s *Server) connectWithRetryRuns(ctx context.Context, profileConfig *profil } }() - if s.config.DisableAutoConnect { - if err := s.connect(ctx, s.config, s.statusRecorder, runningChan); err != nil { - log.Debugf("run client connection exited with error: %v", err) - } - log.Tracef("client connection exited") - return - } - backOff := getConnectWithBackoff(ctx) go func() { t := time.NewTicker(24 * time.Hour) @@ -1770,6 +1762,7 @@ func (s *Server) connect(ctx context.Context, config *profilemanager.Config, sta s.mutex.Unlock() if err := client.Run(runningChan, s.logFile); err != nil { + log.Debugf("run client connection exited with error: %v", err) return err } return nil