pipeline: get table action params
[dpdk.git] / lib / librte_vhost / socket.c
index 992c7aa..a0a95f9 100644 (file)
@@ -4,7 +4,6 @@
 
 #include <stdint.h>
 #include <stdio.h>
-#include <stdbool.h>
 #include <limits.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -243,6 +242,8 @@ vhost_user_add_connection(int fd, struct vhost_user_socket *vsocket)
        pthread_mutex_lock(&vsocket->conn_mutex);
        TAILQ_INSERT_TAIL(&vsocket->conn_list, conn, next);
        pthread_mutex_unlock(&vsocket->conn_mutex);
+
+       fdset_pipe_notify(&vhost_user.fdset);
        return;
 
 err:
@@ -841,6 +842,7 @@ rte_vhost_driver_start(const char *path)
 {
        struct vhost_user_socket *vsocket;
        static pthread_t fdset_tid;
+       char thread_name[RTE_MAX_THREAD_NAME_LEN];
 
        pthread_mutex_lock(&vhost_user.mutex);
        vsocket = find_vhost_user_socket(path);
@@ -850,11 +852,33 @@ rte_vhost_driver_start(const char *path)
                return -1;
 
        if (fdset_tid == 0) {
+               /**
+                * create a pipe which will be waited by poll and notified to
+                * rebuild the wait list of poll.
+                */
+               if (fdset_pipe_init(&vhost_user.fdset) < 0) {
+                       RTE_LOG(ERR, VHOST_CONFIG,
+                               "failed to create pipe for vhost fdset\n");
+                       return -1;
+               }
+
                int ret = pthread_create(&fdset_tid, NULL, fdset_event_dispatch,
                                     &vhost_user.fdset);
-               if (ret != 0)
+               if (ret != 0) {
                        RTE_LOG(ERR, VHOST_CONFIG,
                                "failed to create fdset handling thread");
+
+                       fdset_pipe_uninit(&vhost_user.fdset);
+                       return -1;
+               } else {
+                       snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN,
+                                "vhost-events");
+
+                       if (rte_thread_setname(fdset_tid, thread_name)) {
+                               RTE_LOG(DEBUG, VHOST_CONFIG,
+                                       "failed to set vhost-event thread name");
+                       }
+               }
        }
 
        if (vsocket->is_server)