X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=ltt-sessiond%2Fmain.c;h=97db535d142b16f802e9e80c77a19ef094097d5a;hp=bae3f27458eb0b09c41ae788876682644c523a03;hb=c49dc785799508e445e3e386c87f8151eef3c34c;hpb=e7d10b0958f6bd5adbaac502d1e708daf34fed20 diff --git a/ltt-sessiond/main.c b/ltt-sessiond/main.c index bae3f2745..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: @@ -1411,8 +1415,12 @@ static int create_lttng_rundir(void) ret = mkdir(LTTNG_RUNDIR, S_IRWXU | S_IRWXG ); if (ret < 0) { - ERR("Unable to create " LTTNG_RUNDIR); - goto error; + if (errno != EEXIST) { + ERR("Unable to create " LTTNG_RUNDIR); + goto error; + } else { + ret = 0; + } } error: