X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=ltt-sessiond%2Fmain.c;h=97db535d142b16f802e9e80c77a19ef094097d5a;hp=30b0edd0e75f6d6e46272fa9b98b807495c6c2ac;hb=c49dc785799508e445e3e386c87f8151eef3c34c;hpb=b1f11e69d7782029847845f0a5d018733c15a2f0 diff --git a/ltt-sessiond/main.c b/ltt-sessiond/main.c index 30b0edd0e..97db535d1 100644 --- a/ltt-sessiond/main.c +++ b/ltt-sessiond/main.c @@ -486,6 +486,8 @@ static pid_t spawn_kconsumerd(void) int ret; pid_t pid; + DBG("Spawning kconsumerd"); + pid = fork(); if (pid == 0) { /* @@ -518,21 +520,21 @@ static int start_kconsumerd(void) { int ret; - DBG("Spawning kconsumerd"); - pthread_mutex_lock(&kconsumerd_pid_mutex); - if (kconsumerd_pid == 0) { - ret = spawn_kconsumerd(); - if (ret < 0) { - ERR("Spawning kconsumerd failed"); - ret = LTTCOMM_KERN_CONSUMER_FAIL; - pthread_mutex_unlock(&kconsumerd_pid_mutex); - goto error; - } + if (kconsumerd_pid != 0) { + goto end; + } - /* Setting up the global kconsumerd_pid */ - kconsumerd_pid = ret; + ret = spawn_kconsumerd(); + if (ret < 0) { + ERR("Spawning kconsumerd failed"); + ret = LTTCOMM_KERN_CONSUMER_FAIL; + pthread_mutex_unlock(&kconsumerd_pid_mutex); + goto error; } + + /* Setting up the global kconsumerd_pid */ + kconsumerd_pid = ret; pthread_mutex_unlock(&kconsumerd_pid_mutex); DBG("Kconsumerd pid %d", ret); @@ -544,6 +546,8 @@ static int start_kconsumerd(void) goto error; } +end: + pthread_mutex_unlock(&kconsumerd_pid_mutex); return 0; error: