From: Christian Brauner Date: Wed, 6 Dec 2017 14:33:23 +0000 (+0100) Subject: commands: return -ECONNRESET to caller X-Git-Tag: lxc-3.0.0.beta1~130^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b7f85cbcdce8bd5d6b1c4c719ae776d6b3ffb06;p=thirdparty%2Flxc.git commands: return -ECONNRESET to caller 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 --- diff --git a/src/lxc/commands.c b/src/lxc/commands.c index 0a19f5f3d..d99f06780 100644 --- a/src/lxc/commands.c +++ b/src/lxc/commands.c @@ -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);