[lxc-devel] [lxc/master] commands: simplify lxc_cmd()

brauner on Github lxc-bot at linuxcontainers.org
Fri Jun 22 12:16:13 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180622/31596d0e/attachment.bin>
-------------- next part --------------
From 6a93ae77108ced03ab58c1c4bf6e349c3f0c16c1 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Fri, 22 Jun 2018 14:13:06 +0200
Subject: [PATCH] commands: simplify lxc_cmd()

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 src/lxc/commands.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/src/lxc/commands.c b/src/lxc/commands.c
index e83002d37..8c1a03d58 100644
--- a/src/lxc/commands.c
+++ b/src/lxc/commands.c
@@ -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);
@@ -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)


More information about the lxc-devel mailing list