dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: dev@dpdk.org
Subject: [PATCH 3/4] vhost: get rid of duplicate code
Date: Wed,  9 Sep 2015 13:34:35 +0800	[thread overview]
Message-ID: <1441776876-14595-3-git-send-email-yuanhan.liu@linux.intel.com> (raw)
In-Reply-To: <1441776876-14595-1-git-send-email-yuanhan.liu@linux.intel.com>

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Acked-by: Changchun Ouyang <Changchun.ouyang@intel.com>
Acked-by: Huawei Xie <huawei.xie@intel.com>
---
 lib/librte_vhost/vhost_user/vhost-net-user.c | 36 ++++++++--------------------
 1 file changed, 10 insertions(+), 26 deletions(-)

diff --git a/lib/librte_vhost/vhost_user/vhost-net-user.c b/lib/librte_vhost/vhost_user/vhost-net-user.c
index f406a94..d1f8877 100644
--- a/lib/librte_vhost/vhost_user/vhost-net-user.c
+++ b/lib/librte_vhost/vhost_user/vhost-net-user.c
@@ -329,32 +329,16 @@ vserver_message_handler(int connfd, void *dat, int *remove)
 
 	ctx.fh = cfd_ctx->fh;
 	ret = read_vhost_message(connfd, &msg);
-	if (ret < 0) {
-		RTE_LOG(ERR, VHOST_CONFIG,
-			"vhost read message failed\n");
-
-		close(connfd);
-		*remove = 1;
-		free(cfd_ctx);
-		user_destroy_device(ctx);
-		ops->destroy_device(ctx);
-
-		return;
-	} else if (ret == 0) {
-		RTE_LOG(INFO, VHOST_CONFIG,
-			"vhost peer closed\n");
-
-		close(connfd);
-		*remove = 1;
-		free(cfd_ctx);
-		user_destroy_device(ctx);
-		ops->destroy_device(ctx);
-
-		return;
-	}
-	if (msg.request > VHOST_USER_MAX) {
-		RTE_LOG(ERR, VHOST_CONFIG,
-			"vhost read incorrect message\n");
+	if (ret <= 0 || msg.request > VHOST_USER_MAX) {
+		if (ret < 0)
+			RTE_LOG(ERR, VHOST_CONFIG,
+				"vhost read message failed\n");
+		else if (ret == 0)
+			RTE_LOG(INFO, VHOST_CONFIG,
+				"vhost peer closed\n");
+		else
+			RTE_LOG(ERR, VHOST_CONFIG,
+				"vhost read incorrect message\n");
 
 		close(connfd);
 		*remove = 1;
-- 
1.9.0

  parent reply	other threads:[~2015-09-09  5:31 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-09  5:34 [PATCH 1/4] vhost: remove redundant ; Yuanhan Liu
2015-09-09  5:34 ` [PATCH 2/4] vhost: fix typo Yuanhan Liu
2015-09-09  5:34 ` Yuanhan Liu [this message]
2015-09-09  5:34 ` [PATCH 4/4 v2] vhost: fix wrong usage of eventfd_t Yuanhan Liu
2015-09-09  5:44   ` Xie, Huawei
2015-09-24 14:01     ` Yuanhan Liu
2015-09-25 12:44       ` Thomas Monjalon
2015-09-25 12:59         ` Thomas Monjalon
2015-09-27  0:17         ` Yuanhan Liu
2015-09-27 19:35           ` Thomas Monjalon
2015-10-08  6:29             ` Yuanhan Liu
  -- strict thread matches above, loose matches on Subject: below --
2015-08-24  3:54 [PATCH 1/4] vhost: remove redundant ; Yuanhan Liu
2015-08-24  3:54 ` [PATCH 3/4] vhost: get rid of duplicate code Yuanhan Liu
2015-09-09  1:28   ` Ouyang, Changchun
2015-09-09  5:19   ` Xie, Huawei

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=1441776876-14595-3-git-send-email-yuanhan.liu@linux.intel.com \
    --to=yuanhan.liu@linux.intel.com \
    --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).