Browse code

update container's state after we close the waitLock

Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)

Victor Vieux authored on 2014/05/28 09:17:11
Showing 1 changed files
... ...
@@ -468,6 +468,20 @@ func (container *Container) monitor(callback execdriver.StartCallback) error {
468 468
 		utils.Errorf("Error running container: %s", err)
469 469
 	}
470 470
 
471
+	// Cleanup
472
+	container.cleanup()
473
+
474
+	// Re-create a brand new stdin pipe once the container exited
475
+	if container.Config.OpenStdin {
476
+		container.stdin, container.stdinPipe = io.Pipe()
477
+	}
478
+
479
+	if container.daemon != nil && container.daemon.srv != nil {
480
+		container.daemon.srv.LogEvent("die", container.ID, container.daemon.repositories.ImageName(container.Image))
481
+	}
482
+
483
+	close(container.waitLock)
484
+
471 485
 	if container.daemon != nil && container.daemon.srv != nil && container.daemon.srv.IsRunning() {
472 486
 		container.State.SetStopped(exitCode)
473 487
 
... ...
@@ -483,20 +497,6 @@ func (container *Container) monitor(callback execdriver.StartCallback) error {
483 483
 		}
484 484
 	}
485 485
 
486
-	// Cleanup
487
-	container.cleanup()
488
-
489
-	// Re-create a brand new stdin pipe once the container exited
490
-	if container.Config.OpenStdin {
491
-		container.stdin, container.stdinPipe = io.Pipe()
492
-	}
493
-
494
-	if container.daemon != nil && container.daemon.srv != nil {
495
-		container.daemon.srv.LogEvent("die", container.ID, container.daemon.repositories.ImageName(container.Image))
496
-	}
497
-
498
-	close(container.waitLock)
499
-
500 486
 	return err
501 487
 }
502 488