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 599BAA0588; Tue, 21 Apr 2020 10:59:59 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 268D81D93E; Tue, 21 Apr 2020 10:59:59 +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 C36811C434 for ; Tue, 21 Apr 2020 10:59:57 +0200 (CEST) Received: from localhost.localdomain (unknown [120.132.1.226]) by m9785.mail.qiye.163.com (Hmail) with ESMTPA id A5F425C1E8B; Tue, 21 Apr 2020 16:59:50 +0800 (CST) From: Roland Qi To: dev@dpdk.org Cc: Roland Qi Date: Tue, 21 Apr 2020 16:59:39 +0800 Message-Id: <20200421085939.1851-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: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZSFVCTkNLS0tKQ0hKS05PTFlXWShZQU lCN1dZLVlBSVdZCQ4XHghZQVk1NCk2OjckKS43PlkG X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6NBA6Phw4KzgyGgM0MzVDER4# KkMwCzlVSlVKTkNMT05CTkJLQ0JCVTMWGhIXVQkUFxoVH1UKEjsOGBcUDh9VGBVFWVdZEgtZQVlK SUtVSkhJVUpVSUlNWVdZCAFZQUpMQkg3Bg++ X-HM-Tid: 0a719bf70a682087kuqya5f425c1e8b 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: Roland Qi --- 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