]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
commands: return -ECONNRESET to caller
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 6 Dec 2017 14:33:23 +0000 (15:33 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 6 Dec 2017 15:01:23 +0000 (16:01 +0100)
Callers can then make a decision whether they want to consider the peer closing
the connection an error or not. For example, a c->wait(c, "STOPPED", -1) call
can then consider a ECONNRESET not an error but rather see it - correctly - as
a container exiting before being able to register a state client.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/commands.c

index 0a19f5f3d6a9b71cd68c9edd161cfee320d37cd5..d99f067808d62c2f0a5d6c07753468455220262a 100644 (file)
@@ -128,6 +128,9 @@ static int lxc_cmd_rsp_recv(int sock, struct lxc_cmd_rr *cmd)
        if (ret < 0) {
                WARN("%s - Failed to receive response for command \"%s\"",
                     strerror(errno), lxc_cmd_str(cmd->req.cmd));
+               if (errno == ECONNRESET)
+                       return -ECONNRESET;
+
                return -1;
        }
        TRACE("Command \"%s\" received response", lxc_cmd_str(cmd->req.cmd));
@@ -318,6 +321,8 @@ static int lxc_cmd(const char *name, struct lxc_cmd_rr *cmd, int *stopped,
        }
 
        ret = lxc_cmd_rsp_recv(client_fd, cmd);
+       if (ret == -ECONNRESET)
+               *stopped = 1;
 out:
        if (!stay_connected || ret <= 0)
                close(client_fd);