int cmd_add_context(struct ltt_session *session, int domain,
char *channel_name, struct lttng_event_context *ctx, int kwpipe)
{
- int ret;
+ int ret, chan_kern_created = 0, chan_ust_created = 0;
switch (domain) {
case LTTNG_DOMAIN_KERNEL:
if (ret != LTTNG_OK) {
goto error;
}
+ chan_kern_created = 1;
}
/* Add kernel context to kernel tracer */
goto error;
}
free(attr);
+ chan_ust_created = 1;
}
ret = context_ust_add(usess, domain, ctx, channel_name);
goto error;
}
- ret = LTTNG_OK;
+ return LTTNG_OK;
error:
+ if (chan_kern_created) {
+ struct ltt_kernel_channel *kchan =
+ trace_kernel_get_channel_by_name(DEFAULT_CHANNEL_NAME,
+ session->kernel_session);
+ /* Created previously, this should NOT fail. */
+ assert(kchan);
+ kernel_destroy_channel(kchan);
+ }
+
+ if (chan_ust_created) {
+ struct ltt_ust_channel *uchan =
+ trace_ust_find_channel_by_name(
+ session->ust_session->domain_global.channels,
+ DEFAULT_CHANNEL_NAME);
+ /* Created previously, this should NOT fail. */
+ assert(uchan);
+ /* Remove from the channel list of the session. */
+ trace_ust_delete_channel(session->ust_session->domain_global.channels,
+ uchan);
+ trace_ust_destroy_channel(uchan);
+ }
return ret;
}
call_rcu(&channel->node.head, destroy_channel_rcu);
}
+/*
+ * Remove an UST channel from a channel HT.
+ */
+void trace_ust_delete_channel(struct lttng_ht *ht,
+ struct ltt_ust_channel *channel)
+{
+ int ret;
+ struct lttng_ht_iter iter;
+
+ assert(ht);
+ assert(channel);
+
+ iter.iter.node = &channel->node.node;
+ ret = lttng_ht_del(ht, &iter);
+ assert(!ret);
+}
+
/*
* Cleanup ust metadata structure.
*/
struct ltt_ust_metadata *trace_ust_create_metadata(char *path);
struct ltt_ust_context *trace_ust_create_context(
struct lttng_event_context *ctx);
+void trace_ust_delete_channel(struct lttng_ht *ht,
+ struct ltt_ust_channel *channel);
/*
* Destroy functions free() the data structure and remove from linked list if
{
return NULL;
}
+static inline
+void trace_ust_delete_channel(struct lttng_ht *ht,
+ struct ltt_ust_channel *channel)
+{
+ return;
+}
#endif /* HAVE_LIBLTTNG_UST_CTL */