]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
commands: simplify lxc_cmd()
authorChristian Brauner <christian.brauner@ubuntu.com>
Fri, 22 Jun 2018 12:13:06 +0000 (14:13 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 10 Dec 2018 13:32:29 +0000 (14:32 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/commands.c

index fc821cdc06ad7125c7e670c743bb035ea3e2f255..0be608d8000ab65ec7a09cb4fbae9468937ab50a 100644 (file)
@@ -302,21 +302,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);
@@ -325,10 +326,6 @@ out:
                cmd->rsp.ret = client_fd;
 
        return ret;
-
-epipe:
-       *stopped = 1;
-       return 0;
 }
 
 int lxc_try_cmd(const char *name, const char *lxcpath)