DPDK patches and discussions
 help / color / mirror / Atom feed
From: qikai <roland.qi@ucloud.cn>
To: dev@dpdk.org
Cc: qikai <roland.qi@ucloud.cn>
Subject: [dpdk-dev] [PATCH] vhost: fix check peer close
Date: Fri,  3 Apr 2020 14:27:04 +0800	[thread overview]
Message-ID: <20200403062704.3947-1-roland.qi@ucloud.cn> (raw)

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 <roland.qi@ucloud.cn>
---
 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


             reply	other threads:[~2020-04-03  6:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-03  6:27 qikai [this message]
2020-04-07  3:45 qikai
2020-04-17 14:10 ` Maxime Coquelin
2020-04-21  7:52 Roland Qi
2020-04-21  8:59 Roland Qi
2020-04-27  8:53 ` Maxime Coquelin
2020-04-28 16:06 ` Maxime Coquelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200403062704.3947-1-roland.qi@ucloud.cn \
    --to=roland.qi@ucloud.cn \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).