commands: simplify

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
Christian Brauner 2018-10-20 11:09:54 +02:00
parent 33eb2ec186
commit 00e5ca1384
No known key found for this signature in database
GPG Key ID: 8EB056D53EECB12D

View File

@ -299,14 +299,9 @@ static int lxc_cmd(const char *name, struct lxc_cmd_rr *cmd, int *stopped,
SYSTRACE("Command \"%s\" failed to connect command socket", SYSTRACE("Command \"%s\" failed to connect command socket",
lxc_cmd_str(cmd->req.cmd)); lxc_cmd_str(cmd->req.cmd));
if (errno == ECONNREFUSED) if (errno == ECONNREFUSED || errno == EPIPE)
*stopped = 1; *stopped = 1;
if (errno == EPIPE) {
*stopped = 1;
client_fd = 0;
}
return -1; return -1;
} }
@ -314,11 +309,11 @@ static int lxc_cmd(const char *name, struct lxc_cmd_rr *cmd, int *stopped,
if (ret < 0 && errno == ECONNRESET) if (ret < 0 && errno == ECONNRESET)
*stopped = 1; *stopped = 1;
if (!stay_connected || ret <= 0) if (!stay_connected || ret <= 0) {
if (client_fd >= 0) {
saved_errno = errno; saved_errno = errno;
close(client_fd); close(client_fd);
errno = saved_errno; errno = saved_errno;
return ret;
} }
if (stay_connected && ret > 0) if (stay_connected && ret > 0)