add paranoid check before listener thread destruction
[ust.git] / libust / tracectl.c
index ef0155db3388441d83fe3afe813f66b5e78d64e3..03220373c92dee9c7eea7ee259d231de8924b809 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
+/* This file contains the implementation of the UST listener thread, which
+ * receives trace control commands. It also coordinates the initialization of
+ * libust.
+ */
+
 #define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
@@ -1065,8 +1070,9 @@ void create_listener(void)
        if(result) {
                PERROR("pthread_sigmask: %s", strerror(result));
        }
-
-       have_listener = 1;
+       else {
+               have_listener = 1;
+       }
 }
 
 static int init_socket(void)
@@ -1364,10 +1370,13 @@ int restarting_usleep(useconds_t usecs)
        return result;
 }
 
-static void stop_listener()
+static void stop_listener(void)
 {
        int result;
 
+       if(!have_listener)
+               return;
+
        result = pthread_cancel(listener_thread);
        if(result != 0) {
                ERR("pthread_cancel: %s", strerror(result));
This page took 0.022452 seconds and 4 git commands to generate.