From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id E9B72A0471 for ; Wed, 19 Jun 2019 17:17:43 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6832B1C3B9; Wed, 19 Jun 2019 17:15:55 +0200 (CEST) Received: from mx0.arrikto.com (mx0.arrikto.com [212.71.252.59]) by dpdk.org (Postfix) with ESMTP id E5DF81C389 for ; Wed, 19 Jun 2019 17:15:38 +0200 (CEST) Received: from troi.prod.arr (mail.arr [10.99.0.5]) by mx0.arrikto.com (Postfix) with ESMTP id C6E1D18200B; Wed, 19 Jun 2019 18:15:38 +0300 (EEST) Received: from localhost.localdomain (unknown [10.89.50.133]) by troi.prod.arr (Postfix) with ESMTPSA id 51CE12B2; Wed, 19 Jun 2019 18:15:38 +0300 (EEST) From: Nikos Dragazis To: dev@dpdk.org Cc: Maxime Coquelin , Tiwei Bie , Zhihong Wang , Stefan Hajnoczi , Wei Wang , Stojaczyk Dariusz , Vangelis Koukis Date: Wed, 19 Jun 2019 18:14:32 +0300 Message-Id: <1560957293-17294-8-git-send-email-ndragazis@arrikto.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1560957293-17294-1-git-send-email-ndragazis@arrikto.com> References: <1560957293-17294-1-git-send-email-ndragazis@arrikto.com> Subject: [dpdk-dev] [PATCH 07/28] vhost: move vhost-user reconnection 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" The socket reconnection code is highly specific to AF_UNIX, so move the remaining pieces of it into trans_af_unix.c. Signed-off-by: Nikos Dragazis Signed-off-by: Stefan Hajnoczi --- lib/librte_vhost/socket.c | 4 ---- lib/librte_vhost/trans_af_unix.c | 9 +++++++-- lib/librte_vhost/vhost.h | 10 +++------- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c index 976343c..373c01d 100644 --- a/lib/librte_vhost/socket.c +++ b/lib/librte_vhost/socket.c @@ -394,10 +394,6 @@ rte_vhost_driver_register(const char *path, uint64_t flags) if ((flags & RTE_VHOST_USER_CLIENT) != 0) { vsocket->reconnect = !(flags & RTE_VHOST_USER_NO_RECONNECT); - if (vsocket->reconnect && reconn_tid == 0) { - if (vhost_user_reconnect_init() != 0) - goto out_free; - } } else { vsocket->is_server = true; } diff --git a/lib/librte_vhost/trans_af_unix.c b/lib/librte_vhost/trans_af_unix.c index 58fc9e2..00d5366 100644 --- a/lib/librte_vhost/trans_af_unix.c +++ b/lib/librte_vhost/trans_af_unix.c @@ -361,7 +361,7 @@ struct vhost_user_reconnect_list { }; static struct vhost_user_reconnect_list reconn_list; -pthread_t reconn_tid; +static pthread_t reconn_tid; static int vhost_user_connect_nonblock(int fd, struct sockaddr *un, size_t sz) @@ -431,7 +431,7 @@ vhost_user_client_reconnect(void *arg __rte_unused) return NULL; } -int +static int vhost_user_reconnect_init(void) { int ret; @@ -532,6 +532,11 @@ af_unix_socket_init(struct vhost_user_socket *vsocket, container_of(vsocket, struct af_unix_socket, socket); int ret; + if (vsocket->reconnect && reconn_tid == 0) { + if (vhost_user_reconnect_init() != 0) + return -1; + } + TAILQ_INIT(&af_vsocket->conn_list); ret = pthread_mutex_init(&af_vsocket->conn_mutex, NULL); if (ret) { diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h index 5c3987d..d8b5ec2 100644 --- a/lib/librte_vhost/vhost.h +++ b/lib/librte_vhost/vhost.h @@ -404,9 +404,9 @@ struct virtio_net { struct rte_vhost_user_extern_ops extern_ops; } __rte_cache_aligned; -/* The vhost_user, vhost_user_socket, and reconnect declarations are temporary - * measures for moving AF_UNIX code into trans_af_unix.c. They will be cleaned - * up as socket.c is untangled from trans_af_unix.c. +/* The vhost_user and vhost_user_socket declarations are temporary measures for + * moving AF_UNIX code into trans_af_unix.c. They will be cleaned up as + * socket.c is untangled from trans_af_unix.c. */ /* * Every time rte_vhost_driver_register() is invoked, an associated @@ -458,10 +458,6 @@ struct vhost_user { extern struct vhost_user vhost_user; -extern pthread_t reconn_tid; - -int vhost_user_reconnect_init(void); - static __rte_always_inline bool vq_is_packed(struct virtio_net *dev) { -- 2.7.4