Skip to content

Commit

Permalink
Merge pull request #2425 from brauner/2018-06-22/cleanups
Browse files Browse the repository at this point in the history
commands: simplify lxc_cmd()
  • Loading branch information
stgraber committed Jun 22, 2018
2 parents 7d1e281 + 6a93ae7 commit 9dbb10c
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/lxc/commands.c
Expand Up @@ -309,21 +309,22 @@ static int lxc_cmd(const char *name, struct lxc_cmd_rr *cmd, int *stopped,
if (client_fd < 0) {
TRACE("%s - Command \"%s\" failed to connect command socket",
strerror(errno), lxc_cmd_str(cmd->req.cmd));
if (client_fd == -ECONNREFUSED) {

if (client_fd == -ECONNREFUSED)
*stopped = 1;
return -1;
}

if (client_fd == -EPIPE)
goto epipe;
if (client_fd == -EPIPE) {
*stopped = 1;
client_fd = 0;
}

goto out;
return client_fd;
}

ret = lxc_cmd_rsp_recv(client_fd, cmd);
if (ret == -ECONNRESET)
*stopped = 1;
out:

if (!stay_connected || ret <= 0)
if (client_fd >= 0)
close(client_fd);
Expand All @@ -332,10 +333,6 @@ static int lxc_cmd(const char *name, struct lxc_cmd_rr *cmd, int *stopped,
cmd->rsp.ret = client_fd;

return ret;

epipe:
*stopped = 1;
return 0;
}

int lxc_try_cmd(const char *name, const char *lxcpath)
Expand Down

0 comments on commit 9dbb10c

Please sign in to comment.