From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 3/4] vhost: get rid of duplicate code
Date: Mon, 24 Aug 2015 11:54:44 +0800 [thread overview]
Message-ID: <1440388485-13554-3-git-send-email-yuanhan.liu@linux.intel.com> (raw)
In-Reply-To: <1440388485-13554-1-git-send-email-yuanhan.liu@linux.intel.com>
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.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
next prev parent reply other threads:[~2015-08-24 3:54 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-24 3:54 [dpdk-dev] [PATCH 1/4] vhost: remove redundant ; Yuanhan Liu
2015-08-24 3:54 ` [dpdk-dev] [PATCH 2/4] vhost: fix typo Yuanhan Liu
2015-09-09 1:24 ` Ouyang, Changchun
2015-09-09 5:19 ` Xie, Huawei
2015-08-24 3:54 ` Yuanhan Liu [this message]
2015-09-09 1:28 ` [dpdk-dev] [PATCH 3/4] vhost: get rid of duplicate code Ouyang, Changchun
2015-09-09 5:19 ` Xie, Huawei
2015-08-24 3:54 ` [dpdk-dev] [PATCH 4/4] vhost: define callfd and kickfd as int type Yuanhan Liu
2015-09-09 1:43 ` Ouyang, Changchun
2015-09-09 1:54 ` Yuanhan Liu
2015-09-09 2:37 ` Ouyang, Changchun
2015-09-09 2:41 ` Ouyang, Changchun
2015-09-09 2:52 ` Yuanhan Liu
2015-09-09 1:49 ` [dpdk-dev] [PATCH 1/4] vhost: remove redundant ; Ouyang, Changchun
2015-09-09 5:20 ` Xie, Huawei
2015-09-09 5:34 Yuanhan Liu
2015-09-09 5:34 ` [dpdk-dev] [PATCH 3/4] vhost: get rid of duplicate code Yuanhan Liu
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=1440388485-13554-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).