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: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent 44552fb2
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment