From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id DFAD31B33D for ; Fri, 19 Jan 2018 14:45:56 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4046E883CD; Fri, 19 Jan 2018 13:45:56 +0000 (UTC) Received: from localhost (ovpn-116-254.ams2.redhat.com [10.36.116.254]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B65C5D6B2; Fri, 19 Jan 2018 13:45:55 +0000 (UTC) From: Stefan Hajnoczi To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, Yuanhan Liu , wei.w.wang@intel.com, mst@redhat.com, zhiyong.yang@intel.com, jasowang@redhat.com, Stefan Hajnoczi Date: Fri, 19 Jan 2018 13:44:27 +0000 Message-Id: <20180119134444.24927-8-stefanha@redhat.com> In-Reply-To: <20180119134444.24927-1-stefanha@redhat.com> References: <20180119134444.24927-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 19 Jan 2018 13:45:56 +0000 (UTC) Subject: [dpdk-dev] [RFC 07/24] vhost: move vhost_user_reconnect_init() into trans_af_unix.c 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: , X-List-Received-Date: Fri, 19 Jan 2018 13:45:57 -0000 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: Stefan Hajnoczi --- lib/librte_vhost/vhost.h | 10 +++------- lib/librte_vhost/socket.c | 4 ---- lib/librte_vhost/trans_af_unix.c | 9 +++++++-- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h index 734a8721d..8f18c1ed0 100644 --- a/lib/librte_vhost/vhost.h +++ b/lib/librte_vhost/vhost.h @@ -302,9 +302,9 @@ struct virtio_net { int slave_req_fd; } __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 @@ -346,10 +346,6 @@ struct vhost_user { extern struct vhost_user vhost_user; -extern pthread_t reconn_tid; - -int vhost_user_reconnect_init(void); - #define VHOST_LOG_PAGE 4096 /* diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c index 4fd86fd5b..f9069fcb1 100644 --- a/lib/librte_vhost/socket.c +++ b/lib/librte_vhost/socket.c @@ -177,10 +177,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 747fd9690..ad07a8e24 100644 --- a/lib/librte_vhost/trans_af_unix.c +++ b/lib/librte_vhost/trans_af_unix.c @@ -347,7 +347,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) @@ -417,7 +417,7 @@ vhost_user_client_reconnect(void *arg __rte_unused) return NULL; } -int +static int vhost_user_reconnect_init(void) { int ret; @@ -527,6 +527,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(&s->conn_list); ret = pthread_mutex_init(&s->conn_mutex, NULL); if (ret) { -- 2.14.3