]> 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>
Fri, 19 Jan 2018 14:10:11 +0000 (15:10 +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 b339581002a78eb22bc01880ed714424766bf0c5..d3db288ec798ee98aa1a7995749db2f071e0dddf 100644 (file)
@@ -850,7 +850,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 97b22a98e55e9b8508f4abb3787c4ec8529e8aeb..0193b77fa0f823cb9c74f4b2dfdaa71bbcfe7ee7 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;