Browse code

Fix missing unlock in libcontainerd.Restore()

This was preventing the "exit" event to be correctly processed during
the restore process without live-restore enabled.

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
(cherry picked from commit ac068a1f9de2b20b145b5682cd514c1f6b1fac17)
Signed-off-by: Tibor Vass <tibor@docker.com>

Kenfe-Mickael Laventure authored on 2016/07/23 07:21:10
Showing 1 changed files
... ...
@@ -544,6 +544,8 @@ func (clnt *client) Restore(containerID string, options ...CreateOption) error {
544 544
 	if err := clnt.Signal(containerID, int(syscall.SIGTERM)); err != nil {
545 545
 		logrus.Errorf("libcontainerd: error sending sigterm to %v: %v", containerID, err)
546 546
 	}
547
+	// Let the main loop handle the exit event
548
+	clnt.remote.Unlock()
547 549
 	select {
548 550
 	case <-time.After(10 * time.Second):
549 551
 		if err := clnt.Signal(containerID, int(syscall.SIGKILL)); err != nil {
... ...
@@ -552,9 +554,13 @@ func (clnt *client) Restore(containerID string, options ...CreateOption) error {
552 552
 		select {
553 553
 		case <-time.After(2 * time.Second):
554 554
 		case <-w.wait():
555
+			// relock because of the defer
556
+			clnt.remote.Lock()
555 557
 			return nil
556 558
 		}
557 559
 	case <-w.wait():
560
+		// relock because of the defer
561
+		clnt.remote.Lock()
558 562
 		return nil
559 563
 	}
560 564