[dpdk-dev] [PATCH 3/4] vhost: get rid of duplicate code

2015-09-09 Thread Yuanhan Liu
Signed-off-by: Yuanhan Liu 
Acked-by: Changchun Ouyang 
Acked-by: Huawei Xie 
---
 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



[dpdk-dev] [PATCH 3/4] vhost: get rid of duplicate code

2015-09-09 Thread Xie, Huawei

On 8/24/2015 11:54 AM, Yuanhan Liu wrote:
> Signed-off-by: Yuanhan Liu 
Acked-by: Huawei Xie 

> ---
>  lib/librte_vhost/vhost_user/vhost-net-user.c | 36 
> 
>  1 file changed, 10 insertions(+), 26 deletions(-)
>
>



[dpdk-dev] [PATCH 3/4] vhost: get rid of duplicate code

2015-09-09 Thread Ouyang, Changchun


> -Original Message-
> From: Yuanhan Liu [mailto:yuanhan.liu at linux.intel.com]
> Sent: Monday, August 24, 2015 11:55 AM
> To: dev at dpdk.org
> Cc: Xie, Huawei; Ouyang, Changchun; Yuanhan Liu
> Subject: [PATCH 3/4] vhost: get rid of duplicate code
> 
> Signed-off-by: Yuanhan Liu 

Acked-by: Changchun Ouyang 



[dpdk-dev] [PATCH 3/4] vhost: get rid of duplicate code

2015-08-24 Thread Yuanhan Liu
Signed-off-by: Yuanhan Liu 
---
 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