struct lttng_channel *chan)
{
struct ltt_kernel_channel *lkc;
- struct lttng_channel_extended *extended;
+ struct lttng_channel_extended *extended = NULL;
assert(chan);
lkc->stream_count = 0;
lkc->event_count = 0;
lkc->enabled = 1;
+ lkc->published_to_notification_thread = false;
/* Init linked list */
CDS_INIT_LIST_HEAD(&lkc->events_list.head);
CDS_INIT_LIST_HEAD(&lkc->stream_list.head);
if (ctx) {
memcpy(&kctx->ctx, ctx, sizeof(kctx->ctx));
}
+error:
+ return kctx;
+}
- CDS_INIT_LIST_HEAD(&kctx->list);
+/*
+ * Allocate and init a kernel context object from an existing kernel context
+ * object.
+ *
+ * Return the allocated object or NULL on error.
+ */
+struct ltt_kernel_context *trace_kernel_copy_context(
+ struct ltt_kernel_context *kctx)
+{
+ struct ltt_kernel_context *kctx_copy;
+
+ assert(kctx);
+ kctx_copy = zmalloc(sizeof(*kctx_copy));
+ if (!kctx_copy) {
+ PERROR("zmalloc ltt_kernel_context");
+ goto error;
+ }
+
+ memcpy(kctx_copy, kctx, sizeof(*kctx_copy));
+ memset(&kctx_copy->list, 0, sizeof(kctx_copy->list));
error:
- return kctx;
+ return kctx_copy;
}
/*
{
assert(ctx);
- cds_list_del(&ctx->list);
+ if (ctx->in_list) {
+ cds_list_del(&ctx->list);
+ }
free(ctx);
}
/* Remove from channel list */
cds_list_del(&channel->list);
- status = notification_thread_command_remove_channel(
- notification_thread_handle,
- channel->fd, LTTNG_DOMAIN_KERNEL);
- assert(status == LTTNG_OK);
+ if (notification_thread_handle
+ && channel->published_to_notification_thread) {
+ status = notification_thread_command_remove_channel(
+ notification_thread_handle,
+ channel->key, LTTNG_DOMAIN_KERNEL);
+ assert(status == LTTNG_OK);
+ }
free(channel->channel->attr.extended.ptr);
free(channel->channel);
free(channel);