error:
if (lks) {
trace_kernel_destroy_session(lks);
+ trace_kernel_free_session(lks);
}
return ret;
}
}
/*
- * 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)
{
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.
*/
*/
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;
struct consumer_socket *socket;
struct lttng_ht_iter iter;
struct ltt_kernel_metadata *saved_metadata;
+ char *trace_path = NULL;
assert(ksess);
assert(ksess->consumer);
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;
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,
/* 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;
}
ksess->metadata = saved_metadata;
ksess->metadata_stream_fd = saved_metadata_fd;
rcu_read_unlock();
+ free(trace_path);
return status;
}