Skip to content

Commit

Permalink
commands: simplify
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Nov 22, 2018
1 parent 1d2d92c commit 5d6fa5e
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/lxc/commands.c
Expand Up @@ -299,27 +299,22 @@ static int lxc_cmd(const char *name, struct lxc_cmd_rr *cmd, int *stopped,
SYSTRACE("Command \"%s\" failed to connect command socket",
lxc_cmd_str(cmd->req.cmd));

if (errno == ECONNREFUSED)
if (errno == ECONNREFUSED || errno == EPIPE)
*stopped = 1;

if (errno == EPIPE) {
*stopped = 1;
client_fd = 0;
}

return -1;
}

ret = lxc_cmd_rsp_recv(client_fd, cmd);
if (ret < 0 && errno == ECONNRESET)
*stopped = 1;

if (!stay_connected || ret <= 0)
if (client_fd >= 0) {
saved_errno = errno;
close(client_fd);
errno = saved_errno;
}
if (!stay_connected || ret <= 0) {
saved_errno = errno;
close(client_fd);
errno = saved_errno;
return ret;
}

if (stay_connected && ret > 0)
cmd->rsp.ret = client_fd;
Expand Down

0 comments on commit 5d6fa5e

Please sign in to comment.