From cdaabd27b2d3d091007d816d396c0b55301f2a42 Mon Sep 17 00:00:00 2001
From: haozi007 <liuhao27@huawei.com>
Date: Mon, 27 Apr 2020 10:54:37 +0800
Subject: [PATCH] set state to stopped

if send cmd to lxc-monitor timeout

Signed-off-by: haozi007 <liuhao27@huawei.com>
---
 src/lxc/commands.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/lxc/commands.c b/src/lxc/commands.c
index c32aef19..37354e87 100644
--- a/src/lxc/commands.c
+++ b/src/lxc/commands.c
@@ -122,6 +122,9 @@ static int lxc_cmd_rsp_recv(int sock, struct lxc_cmd_rr *cmd)
 #ifdef HAVE_ISULAD
 	/*isulad: add timeout 1s to avoid long block due to [lxc monitor] error*/
 	ret = lxc_abstract_unix_recv_fds_timeout(sock, &fd_rsp, 1, rsp, sizeof(*rsp), 1000 * 1000);
+	if (ret < 0 && (errno == ECONNRESET || errno == EAGAIN || errno == EWOULDBLOCK)) {
+		errno = ECONNRESET; /*isulad set errno ECONNRESET when timeout */
+	}
 #else
 	ret = lxc_abstract_unix_recv_fds(sock, &fd_rsp, 1, rsp, sizeof(*rsp));
 #endif
-- 
2.25.3

