Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions client/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -259,14 +259,6 @@ func (s *Server) connectWithRetryRuns(ctx context.Context, profileConfig *profil
}
}()

if s.config.DisableAutoConnect {
Comment thread
riccardomanfrin marked this conversation as resolved.
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)
Expand Down Expand Up @@ -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
Expand Down
Loading