From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 82533A0577; Tue, 7 Apr 2020 05:46:10 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C7EF82B86; Tue, 7 Apr 2020 05:46:09 +0200 (CEST) Received: from m9785.mail.qiye.163.com (m9785.mail.qiye.163.com [220.181.97.85]) by dpdk.org (Postfix) with ESMTP id 58B05FFA for ; Tue, 7 Apr 2020 05:46:08 +0200 (CEST) Received: from localhost.localdomain (unknown [120.132.1.226]) by m9785.mail.qiye.163.com (Hmail) with ESMTPA id 587085C17D8; Tue, 7 Apr 2020 11:46:04 +0800 (CST) From: qikai To: dev@dpdk.org Cc: qikai Date: Tue, 7 Apr 2020 11:45:50 +0800 Message-Id: <20200407034550.1814-1-roland.qi@ucloud.cn> X-Mailer: git-send-email 2.23.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZSVVDQkNCQkJCSUJPSUNKWVdZKFlBSU I3V1ktWUFJV1kJDhceCFlBWTU0KTY6NyQpLjc#WQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6N006Kxw4Czg5QxQfQzhDIi4U Gj8KCklVSlVKTkNNSUhKSk1PTkNDVTMWGhIXVQkUFxoVH1UKEjsOGBcUDh9VGBVFWVdZEgtZQVlK SUtVSkhJVUpVSUlNWVdZCAFZQUpMTEg3Bg++ X-HM-Tid: 0a7152bebe0e2087kuqy587085c17d8 Subject: [dpdk-dev] [PATCH] vhost: fix check peer close X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" In process_slave_message_reply(), there is a possibility that receiving a peer close message instead of a real message response. this patch targeting to handle the peer close scenario and report the correct error message. Signed-off-by: qikai --- lib/librte_vhost/vhost_user.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index bd1be0104..971ccdb01 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -2812,11 +2812,19 @@ static int process_slave_message_reply(struct virtio_net *dev, if ((msg->flags & VHOST_USER_NEED_REPLY) == 0) return 0; - if (read_vhost_message(dev->slave_req_fd, &msg_reply) < 0) { + ret = read_vhost_message(dev->slave_req_fd, &msg_reply); + if (ret <= 0) { + if (ret < 0) + VHOST_LOG_CONFIG(ERR, + "vhost read slave message reply failed\n"); + else + VHOST_LOG_CONFIG(INFO, + "vhost peer closed\n"); ret = -1; goto out; } + ret = 0; if (msg_reply.request.slave != msg->request.slave) { VHOST_LOG_CONFIG(ERR, "Received unexpected msg type (%u), expected %u\n", -- 2.23.0.windows.1