Fix socket lock and PID in register_consumer
authorDavid Goulet <dgoulet@efficios.com>
Mon, 6 Aug 2012 17:57:31 +0000 (13:57 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Mon, 6 Aug 2012 18:07:32 +0000 (14:07 -0400)
Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-sessiond/main.c

index c79a4740577c120179cc67e82e3b54c562e819be..4b6a39dd5ecea5ef176139e7da2c6058f5884094 100644 (file)
@@ -1629,7 +1629,8 @@ static int join_consumer_thread(struct consumer_data *consumer_data)
        void *status;
        int ret;
 
-       if (consumer_data->pid != 0) {
+       /* Consumer pid must be a real one. */
+       if (consumer_data->pid > 0) {
                ret = kill(consumer_data->pid, SIGTERM);
                if (ret) {
                        ERR("Error killing consumer daemon");
@@ -3630,10 +3631,22 @@ static int cmd_register_consumer(struct ltt_session *session, int domain,
                        goto error;
                }
 
+               socket->lock = zmalloc(sizeof(pthread_mutex_t));
+               if (socket->lock == NULL) {
+                       PERROR("zmalloc pthread mutex");
+                       ret = LTTCOMM_FATAL;
+                       goto error;
+               }
+               pthread_mutex_init(socket->lock, NULL);
+
                rcu_read_lock();
                consumer_add_socket(socket, session->kernel_session->consumer);
                rcu_read_unlock();
 
+               pthread_mutex_lock(&kconsumer_data.pid_mutex);
+               kconsumer_data.pid = -1;
+               pthread_mutex_unlock(&kconsumer_data.pid_mutex);
+
                break;
        default:
                /* TODO: Userspace tracing */
This page took 0.033869 seconds and 4 git commands to generate.