From: Christian Brauner Date: Wed, 6 Dec 2017 14:33:23 +0000 (+0100) Subject: commands: return -ECONNRESET to caller X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f44c23639bdcb2a7676ca08f505fae9847a01e90;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 9e2cc0942..ca3f5116c 100644 --- a/src/lxc/commands.c +++ b/src/lxc/commands.c @@ -125,6 +125,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)); @@ -309,6 +312,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);