Fix: wrong error code returned by kernel_snapshot_record()
[lttng-tools.git] / src / bin / lttng-sessiond / kernel.c
index abf038f4d59a3f1c9f021123e29e947db3fd4db1..760db52ea46955bc8139c99881cfc1ac59ec3cb2 100644 (file)
@@ -36,6 +36,8 @@
 
 /*
  * Add context on a kernel channel.
+ *
+ * Assumes the ownership of ctx.
  */
 int kernel_add_channel_context(struct ltt_kernel_channel *chan,
                struct ltt_kernel_context *ctx)
@@ -67,7 +69,12 @@ int kernel_add_channel_context(struct ltt_kernel_channel *chan,
 
 end:
        cds_list_add_tail(&ctx->list, &chan->ctx_list);
+       ctx->in_list = true;
+       ctx = NULL;
 error:
+       if (ctx) {
+               trace_kernel_destroy_context(ctx);
+       }
        return ret;
 }
 
@@ -1016,18 +1023,16 @@ int kernel_snapshot_record(struct ltt_kernel_session *ksess,
                /* Put back the saved consumer output into the session. */
                ksess->consumer = saved_output;
                if (ret < 0) {
-                       ret = LTTNG_ERR_KERN_CONSUMER_FAIL;
+                       ret = LTTNG_ERR_KERN_META_FAIL;
                        goto error_consumer;
                }
 
                /* For each channel, ask the consumer to snapshot it. */
                cds_list_for_each_entry(chan, &ksess->channel_list.head, list) {
-                       pthread_mutex_lock(socket->lock);
                        ret = consumer_snapshot_channel(socket, chan->fd, output, 0,
                                        ksess->uid, ksess->gid,
                                        DEFAULT_KERNEL_TRACE_DIR, wait,
                                        nb_packets_per_stream);
-                       pthread_mutex_unlock(socket->lock);
                        if (ret < 0) {
                                ret = LTTNG_ERR_KERN_CONSUMER_FAIL;
                                (void) kernel_consumer_destroy_metadata(socket,
@@ -1037,11 +1042,9 @@ int kernel_snapshot_record(struct ltt_kernel_session *ksess,
                }
 
                /* Snapshot metadata, */
-               pthread_mutex_lock(socket->lock);
                ret = consumer_snapshot_channel(socket, ksess->metadata->fd, output,
                                1, ksess->uid, ksess->gid,
                                DEFAULT_KERNEL_TRACE_DIR, wait, 0);
-               pthread_mutex_unlock(socket->lock);
                if (ret < 0) {
                        ret = LTTNG_ERR_KERN_CONSUMER_FAIL;
                        goto error_consumer;
This page took 0.023901 seconds and 4 git commands to generate.