X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fkernel.c;h=53072f97187654dc37db1b6042f8100b375cbb70;hb=3637639a75795ff18c0daf7d579eaa57608e7a14;hp=c395f425542abe4bffe9f6ecfcf28a6f97e67be0;hpb=d295668767ac8234e83984e1812d342d03293d88;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index c395f4255..53072f971 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -131,6 +131,7 @@ int kernel_create_session(struct ltt_session *session, int tracer_fd) error: if (lks) { trace_kernel_destroy_session(lks); + trace_kernel_free_session(lks); } return ret; } @@ -1156,7 +1157,7 @@ end_boot_id: } /* - * Complete teardown of a kernel session. + * Teardown of a kernel session, keeping data required by destroy notifiers. */ void kernel_destroy_session(struct ltt_kernel_session *ksess) { @@ -1205,6 +1206,15 @@ void kernel_destroy_session(struct ltt_kernel_session *ksess) lttng_trace_chunk_put(trace_chunk); } +/* Teardown of data required by destroy notifiers. */ +void kernel_free_session(struct ltt_kernel_session *ksess) +{ + if (ksess == NULL) { + return; + } + trace_kernel_free_session(ksess); +} + /* * Destroy a kernel channel object. It does not do anything on the tracer side. */ @@ -1242,7 +1252,7 @@ void kernel_destroy_channel(struct ltt_kernel_channel *kchan) */ enum lttng_error_code kernel_snapshot_record( struct ltt_kernel_session *ksess, - const struct snapshot_output *output, int wait, + const struct consumer_output *output, int wait, uint64_t nb_packets_per_stream) { int err, ret, saved_metadata_fd; @@ -1250,6 +1260,7 @@ enum lttng_error_code kernel_snapshot_record( struct consumer_socket *socket; struct lttng_ht_iter iter; struct ltt_kernel_metadata *saved_metadata; + char *trace_path = NULL; assert(ksess); assert(ksess->consumer); @@ -1275,25 +1286,21 @@ enum lttng_error_code kernel_snapshot_record( goto error_open_stream; } + trace_path = setup_channel_trace_path(ksess->consumer, + DEFAULT_KERNEL_TRACE_DIR); + if (!trace_path) { + status = LTTNG_ERR_INVALID; + goto error; + } /* Send metadata to consumer and snapshot everything. */ - cds_lfht_for_each_entry(ksess->consumer->socks->ht, &iter.iter, + cds_lfht_for_each_entry(output->socks->ht, &iter.iter, socket, node.node) { - struct consumer_output *saved_output; struct ltt_kernel_channel *chan; - /* - * Temporarly switch consumer output for our snapshot output. As long - * as the session lock is taken, this is safe. - */ - saved_output = ksess->consumer; - ksess->consumer = output->consumer; - pthread_mutex_lock(socket->lock); /* This stream must not be monitored by the consumer. */ ret = kernel_consumer_add_metadata(socket, ksess, 0); pthread_mutex_unlock(socket->lock); - /* Put back the saved consumer output into the session. */ - ksess->consumer = saved_output; if (ret < 0) { status = LTTNG_ERR_KERN_META_FAIL; goto error_consumer; @@ -1303,7 +1310,7 @@ enum lttng_error_code kernel_snapshot_record( cds_list_for_each_entry(chan, &ksess->channel_list.head, list) { status = consumer_snapshot_channel(socket, chan->key, output, 0, ksess->uid, ksess->gid, - DEFAULT_KERNEL_TRACE_DIR, wait, + trace_path, wait, nb_packets_per_stream); if (status != LTTNG_OK) { (void) kernel_consumer_destroy_metadata(socket, @@ -1314,8 +1321,7 @@ enum lttng_error_code kernel_snapshot_record( /* Snapshot metadata, */ status = consumer_snapshot_channel(socket, ksess->metadata->key, output, - 1, ksess->uid, ksess->gid, - DEFAULT_KERNEL_TRACE_DIR, wait, 0); + 1, ksess->uid, ksess->gid, trace_path, wait, 0); if (status != LTTNG_OK) { goto error_consumer; } @@ -1341,6 +1347,7 @@ error: ksess->metadata = saved_metadata; ksess->metadata_stream_fd = saved_metadata_fd; rcu_read_unlock(); + free(trace_path); return status; }