lxccontainer: restore blocking wait()

Closes #2027. Closes lxc/go-lxc#98. Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent e4a68417
...@@ -850,7 +850,8 @@ int lxc_cmd_add_state_client(const char *name, const char *lxcpath, ...@@ -850,7 +850,8 @@ int lxc_cmd_add_state_client(const char *name, const char *lxcpath,
return STOPPED; return STOPPED;
if (ret < 0) { if (ret < 0) {
ERROR("%s - Failed to execute command", strerror(errno)); if (errno != ECONNREFUSED)
ERROR("%s - Failed to execute command", strerror(errno));
return -1; return -1;
} }
......
...@@ -115,13 +115,26 @@ extern int lxc_wait(const char *lxcname, const char *states, int timeout, ...@@ -115,13 +115,26 @@ extern int lxc_wait(const char *lxcname, const char *states, int timeout,
if (fillwaitedstates(states, s)) if (fillwaitedstates(states, s))
return -1; return -1;
state = lxc_cmd_sock_get_state(lxcname, lxcpath, s, timeout); for (;;) {
if (state < 0) { state = lxc_cmd_sock_get_state(lxcname, lxcpath, s, timeout);
SYSERROR("failed to receive state from monitor"); if (state >= 0)
return -1; 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]) if (!s[state])
return -1; return -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment