Fix: handle pthread errors
[lttng-ust.git] / liblttng-ust / lttng-ust-comm.c
index 76c8ee3da149ff49ecfe4633d7904927f1683de9..37f21c80d01ea4881e54b74c5b49e998a8588879 100644 (file)
@@ -236,6 +236,7 @@ int handle_message(struct sock_info *sock_info,
        struct ustcomm_ust_reply lur;
        int shm_fd, wait_fd;
        union ust_args args;
+       ssize_t len;
 
        ust_lock();
 
@@ -346,6 +347,22 @@ end:
                        goto error;
                }
        }
+       /*
+        * LTTNG_UST_TRACEPOINT_FIELD_LIST_GET needs to send the field
+        * after the reply.
+        */
+       if (lur.ret_code == USTCOMM_OK) {
+               switch (lum->cmd) {
+               case LTTNG_UST_TRACEPOINT_FIELD_LIST_GET:
+                       len = ustcomm_send_unix_sock(sock,
+                               &args.field_list.entry,
+                               sizeof(args.field_list.entry));
+                       if (len != sizeof(args.field_list.entry)) {
+                               ret = -1;
+                               goto error;
+                       }
+               }
+       }
        /*
         * We still have the memory map reference, and the fds have been
         * sent to the sessiond. We can therefore close those fds. Note
@@ -878,15 +895,20 @@ void __attribute__((constructor)) lttng_ust_init(void)
        sigfillset(&sig_all_blocked);
        ret = pthread_sigmask(SIG_SETMASK, &sig_all_blocked, &orig_parent_mask);
        if (ret) {
-               PERROR("pthread_sigmask: %s", strerror(ret));
+               ERR("pthread_sigmask: %s", strerror(ret));
        }
 
-       ret = pthread_create(&local_apps.ust_listener, NULL,
-                       ust_listener_thread, &local_apps);
-
+       ret = pthread_create(&global_apps.ust_listener, NULL,
+                       ust_listener_thread, &global_apps);
+       if (ret) {
+               ERR("pthread_create global: %s", strerror(ret));
+       }
        if (local_apps.allowed) {
-               ret = pthread_create(&global_apps.ust_listener, NULL,
-                               ust_listener_thread, &global_apps);
+               ret = pthread_create(&local_apps.ust_listener, NULL,
+                               ust_listener_thread, &local_apps);
+               if (ret) {
+                       ERR("pthread_create local: %s", strerror(ret));
+               }
        } else {
                handle_register_done(&local_apps);
        }
@@ -894,7 +916,7 @@ void __attribute__((constructor)) lttng_ust_init(void)
        /* Restore original signal mask in parent */
        ret = pthread_sigmask(SIG_SETMASK, &orig_parent_mask, NULL);
        if (ret) {
-               PERROR("pthread_sigmask: %s", strerror(ret));
+               ERR("pthread_sigmask: %s", strerror(ret));
        }
 
        switch (timeout_mode) {
@@ -970,12 +992,14 @@ void __attribute__((destructor)) lttng_ust_exit(void)
        /* cancel threads */
        ret = pthread_cancel(global_apps.ust_listener);
        if (ret) {
-               ERR("Error cancelling global ust listener thread");
+               ERR("Error cancelling global ust listener thread: %s",
+                       strerror(ret));
        }
        if (local_apps.allowed) {
                ret = pthread_cancel(local_apps.ust_listener);
                if (ret) {
-                       ERR("Error cancelling local ust listener thread");
+                       ERR("Error cancelling local ust listener thread: %s",
+                               strerror(ret));
                }
        }
        /*
This page took 0.024329 seconds and 4 git commands to generate.