-/*
- * Add UST context to event.
- */
-static int add_uctx_to_event(struct ltt_ust_session *usess, int domain,
- struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent,
- struct lttng_event_context *ctx)
-{
- int ret;
- struct ltt_ust_context *uctx;
- struct lttng_ht_iter iter;
- struct lttng_ht_node_ulong *uctx_node;
-
- /* Create ltt UST context */
- uctx = trace_ust_create_context(ctx);
- if (uctx == NULL) {
- /* Context values are invalid. */
- ret = -EINVAL;
- goto error;
- }
-
- switch (domain) {
- case LTTNG_DOMAIN_UST:
- ret = ust_app_add_ctx_event_glb(usess, uchan, uevent, uctx);
- if (ret < 0) {
- goto error;
- }
- break;
- default:
- ret = -ENOSYS;
- goto error;
- }
-
- /* Lookup context before adding it */
- lttng_ht_lookup(uevent->ctx, (void *)((unsigned long)uctx->ctx.ctx), &iter);
- uctx_node = lttng_ht_iter_get_node_ulong(&iter);
- if (uctx_node != NULL) {
- ret = -EEXIST;
- goto error;
- }
-
- /* Add ltt UST context node to ltt UST event */
- lttng_ht_add_unique_ulong(uevent->ctx, &uctx->node);
-
- DBG("Context UST %d added to event %s", uctx->ctx.ctx, uevent->attr.name);
-
- return 0;
-
-error:
- free(uctx);
- return ret;
-}
-