Ver código fonte

Merge pull request #47300 from corhere/libc8d/fix-startup-data-race

libcontainerd/supervisor: fix data race
Brian Goff 1 ano atrás
pai
commit
e240ba44b7
1 arquivos alterados com 3 adições e 2 exclusões
  1. 3 2
      libcontainerd/supervisor/remote_daemon.go

+ 3 - 2
libcontainerd/supervisor/remote_daemon.go

@@ -190,12 +190,13 @@ func (r *remote) startContainerd() error {
 		runtime.LockOSThread()
 		runtime.LockOSThread()
 		defer runtime.UnlockOSThread()
 		defer runtime.UnlockOSThread()
 		err := cmd.Start()
 		err := cmd.Start()
-		startedCh <- err
 		if err != nil {
 		if err != nil {
+			startedCh <- err
 			return
 			return
 		}
 		}
-
 		r.daemonWaitCh = make(chan struct{})
 		r.daemonWaitCh = make(chan struct{})
+		startedCh <- nil
+
 		// Reap our child when needed
 		// Reap our child when needed
 		if err := cmd.Wait(); err != nil {
 		if err := cmd.Wait(); err != nil {
 			r.logger.WithError(err).Errorf("containerd did not exit successfully")
 			r.logger.WithError(err).Errorf("containerd did not exit successfully")