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 <ndragazis@arrikto.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
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(-)
@@ -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;
}
@@ -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) {
@@ -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)
{