*/
struct consumer_output *consumer_copy_output(struct consumer_output *obj)
{
+ struct lttng_ht *tmp_ht_ptr;
struct lttng_ht_iter iter;
struct consumer_socket *socket, *copy_sock;
struct consumer_output *output;
if (output == NULL) {
goto error;
}
+ /* Avoid losing the HT reference after the memcpy() */
+ tmp_ht_ptr = output->socks;
memcpy(output, obj, sizeof(struct consumer_output));
- /* Copy sockets */
- output->socks = lttng_ht_new(0, LTTNG_HT_TYPE_ULONG);
+ /* Putting back the HT pointer and start copying socket(s). */
+ output->socks = tmp_ht_ptr;
cds_lfht_for_each_entry(obj->socks->ht, &iter.iter, socket, node.node) {
/* Create new socket object. */
goto malloc_error;
}
+ copy_sock->registered = socket->registered;
copy_sock->lock = socket->lock;
consumer_add_socket(copy_sock, output);
}
switch (domain) {
case LTTNG_DOMAIN_KERNEL:
DBG3("Copying tracing session consumer output in kernel session");
+ /*
+ * XXX: We should audit the session creation and what this function
+ * does "extra" in order to avoid a destroy since this function is used
+ * in the domain session creation (kernel and ust) only. Same for UST
+ * domain.
+ */
+ if (session->kernel_session->consumer) {
+ consumer_destroy_output(session->kernel_session->consumer);
+ }
session->kernel_session->consumer =
consumer_copy_output(session->consumer);
/* Ease our life a bit for the next part */
break;
case LTTNG_DOMAIN_UST:
DBG3("Copying tracing session consumer output in UST session");
+ if (session->ust_session->consumer) {
+ consumer_destroy_output(session->ust_session->consumer);
+ }
session->ust_session->consumer =
consumer_copy_output(session->consumer);
/* Ease our life a bit for the next part */
lus->consumer = consumer_create_output(CONSUMER_DST_LOCAL);
if (lus->consumer == NULL) {
- goto error_free_session;
+ goto error_consumer;
}
/*
"%s" DEFAULT_UST_TRACE_DIR, path);
if (ret < 0) {
PERROR("snprintf UST consumer trace path");
- goto error;
+ goto error_path;
}
/* Set session path */
path);
if (ret < 0) {
PERROR("snprintf kernel traces path");
- goto error_free_session;
+ goto error_path;
}
}
return lus;
-error_free_session:
+error_path:
+ consumer_destroy_output(lus->consumer);
+error_consumer:
lttng_ht_destroy(lus->domain_global.channels);
lttng_ht_destroy(lus->domain_exec);
lttng_ht_destroy(lus->domain_pid);