From: David Goulet Date: Mon, 6 Aug 2012 17:57:31 +0000 (-0400) Subject: Fix socket lock and PID in register_consumer X-Git-Tag: v2.1.0-rc1~39 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=e8209f6b352b3aa279d8d452e396adef6f7159c7 Fix socket lock and PID in register_consumer Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index c79a47405..4b6a39dd5 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -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 */