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 BF8C1A0562; Fri, 3 Apr 2020 08:27:27 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 344AB1C06D; Fri, 3 Apr 2020 08:27:27 +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 C6FA51C068 for ; Fri, 3 Apr 2020 08:27:25 +0200 (CEST) Received: from localhost.localdomain (unknown [120.132.1.226]) by m9785.mail.qiye.163.com (Hmail) with ESMTPA id B5C765C1A57; Fri, 3 Apr 2020 14:27:17 +0800 (CST) From: qikai To: dev@dpdk.org Cc: qikai Date: Fri, 3 Apr 2020 14:27:04 +0800 Message-Id: <20200403062704.3947-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: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZSFVPQkhLS0tLSEtOSkxOQ1lXWShZQU lCN1dZLVlBSVdZCQ4XHghZQVk1NCk2OjckKS43PlkG X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6MBQ6Vgw*KDgzHhVPAgMfMRgq HU4wCipVSlVKTkNOQ0JOSUhMQkJKVTMWGhIXVQkUFxoVH1UKEjsOGBcUDh9VGBVFWVdZEgtZQVlK SUtVSkhJVUpVSUlNWVdZCAFZQUpMTEs3Bg++ X-HM-Tid: 0a713eb8e8b52087kuqyb5c765c1a57 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