eal/linux: fix build with glibc < 2.12
[dpdk.git] / examples / vhost_xen / main.c
index 5d20700..ca725f2 100644 (file)
@@ -1432,6 +1432,7 @@ main(int argc, char *argv[])
        int ret;
        uint8_t portid;
        static pthread_t tid;
+       char thread_name[RTE_MAX_THREAD_NAME_LEN];
 
        /* init EAL */
        ret = rte_eal_init(argc, argv);
@@ -1501,8 +1502,19 @@ main(int argc, char *argv[])
        memset(&dev_statistics, 0, sizeof(dev_statistics));
 
        /* Enable stats if the user option is set. */
-       if (enable_stats)
-               pthread_create(&tid, NULL, (void*)print_stats, NULL );
+       if (enable_stats) {
+               ret = pthread_create(&tid, NULL, (void *)print_stats, NULL);
+               if (ret != 0)
+                       rte_exit(EXIT_FAILURE,
+                               "Cannot create print-stats thread\n");
+
+               /* Set thread_name for aid in debugging. */
+               snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN, "print-xen-stats");
+               ret = rte_thread_setname(tid, thread_name);
+               if (ret != 0)
+                       RTE_LOG(ERR, VHOST_CONFIG,
+                               "Cannot set print-stats name\n");
+       }
 
        /* Launch all data cores. */
        RTE_LCORE_FOREACH_SLAVE(lcore_id) {