]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxccontainer: restore blocking wait()
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 17 Jan 2018 14:22:36 +0000 (15:22 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 17 Jan 2018 23:43:57 +0000 (00:43 +0100)
Closes #2027.
Closes lxc/go-lxc#98.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/commands.c
src/lxc/state.c

index 8ce658363cea366a9184d6db58887acd9ca4f13d..814ce88c1f1e2d515cce93b6fb7fe7669399b5e8 100644 (file)
@@ -859,7 +859,8 @@ int lxc_cmd_add_state_client(const char *name, const char *lxcpath,
                return STOPPED;
 
        if (ret < 0) {
-               ERROR("%s - Failed to execute command", strerror(errno));
+               if (errno != ECONNREFUSED)
+                       ERROR("%s - Failed to execute command", strerror(errno));
                return -1;
        }
 
index 9c9bf8318433751a535909b2554f3f833c2978aa..13b99d8ff09471f137917c4e60a2641e8451fcd8 100644 (file)
@@ -115,13 +115,26 @@ extern int lxc_wait(const char *lxcname, const char *states, int timeout,
        if (fillwaitedstates(states, s))
                return -1;
 
-       state = lxc_cmd_sock_get_state(lxcname, lxcpath, s, timeout);
-       if (state < 0) {
-               SYSERROR("failed to receive state from monitor");
-               return -1;
+       for (;;) {
+               state = lxc_cmd_sock_get_state(lxcname, lxcpath, s, timeout);
+               if (state >= 0)
+                       break;
+
+               if (errno != ECONNREFUSED) {
+                       SYSERROR("Failed to receive state from monitor");
+                       return -1;
+               }
+
+               sleep(1);
+
+               if (timeout > 0)
+                       timeout--;
+
+               if (timeout == 0)
+                       return -1;
        }
 
-       TRACE("retrieved state of container %s", lxc_state2str(state));
+       TRACE("Retrieved state of container %s", lxc_state2str(state));
        if (!s[state])
                return -1;