]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
commands: simplify
authorChristian Brauner <christian.brauner@ubuntu.com>
Sat, 20 Oct 2018 09:09:54 +0000 (11:09 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 22 Oct 2018 14:47:43 +0000 (16:47 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/commands.c

index 5c2ce04fe4e8a9de3a8e06ec409a33f201babec8..1d3c2eaef8e99be7d206e14d1fde41c3c2edef14 100644 (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",
                         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;
        }
 
@@ -314,12 +309,12 @@ static int lxc_cmd(const char *name, struct lxc_cmd_rr *cmd, int *stopped,
        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;