MCPcopy Index your code
hub / github.com/docker/docker-agent / Stop

Method Stop

pkg/tools/lifecycle/supervisor.go:402–436  ·  view source on GitHub ↗

Stop tears the supervisor down. Idempotent. Blocks until the underlying session is closed.

(ctx context.Context)

Source from the content-addressed store, hash-verified

400// Stop tears the supervisor down. Idempotent. Blocks until the underlying
401// session is closed.
402func (s *Supervisor) Stop(ctx context.Context) error {
403 s.mu.Lock()
404 if s.stopping {
405 watchDone := s.watchDone
406 s.mu.Unlock()
407 return waitForWatcher(ctx, watchDone)
408 }
409 s.stopping = true
410 sess := s.session
411 s.session = nil
412 watchDone := s.watchDone
413 pending := s.inflightConnect
414 s.inflightConnect = nil
415 s.mu.Unlock()
416
417 s.tracker.Set(StateStopped)
418 s.signalDone()
419
420 // Reap a Connect left in flight by a startup timeout so its eventual
421 // session is closed rather than leaked. Runs in the background: a wedged
422 // handshake must not block Stop.
423 if pending != nil {
424 go s.reapPendingConnect(context.WithoutCancel(ctx), pending)
425 }
426
427 var closeErr error
428 if sess != nil {
429 closeErr = sess.Close(context.WithoutCancel(ctx))
430 }
431 waitErr := waitForWatcher(ctx, watchDone)
432 if closeErr != nil && ctx.Err() == nil {
433 return closeErr
434 }
435 return waitErr
436}
437
438func waitForWatcher(ctx context.Context, done <-chan struct{}) error {
439 if done == nil {

Callers

nothing calls this directly

Calls 8

signalDoneMethod · 0.95
reapPendingConnectMethod · 0.95
waitForWatcherFunction · 0.85
CloseMethod · 0.65
ErrMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected