Fix: liblttng-ctl comm: lttng_event_context is not packed
[lttng-tools.git] / src / bin / lttng-sessiond / cmd.c
index 371bd68fd4818952e6484b9ae1cea5ab9b07f4c2..74c50579307ea24d3ef0f6582d6c8e421ded8312 100644 (file)
@@ -1865,27 +1865,24 @@ error:
 /*
  * Command LTTNG_ADD_CONTEXT processed by the client thread.
  */
-int cmd_add_context(struct ltt_session *session, enum lttng_domain_type domain,
-               char *channel_name, const struct lttng_event_context *ctx, int kwpipe)
+int cmd_add_context(struct command_ctx *cmd_ctx,
+       const struct lttng_event_context *event_context, int kwpipe)
 {
        int ret, chan_kern_created = 0, chan_ust_created = 0;
-       char *app_ctx_provider_name = NULL, *app_ctx_name = NULL;
+       const enum lttng_domain_type domain = cmd_ctx->lsm.domain.type;
+       const struct ltt_session *session = cmd_ctx->session;
+       const char *channel_name = cmd_ctx->lsm.u.context.channel_name;
 
        /*
         * Don't try to add a context if the session has been started at
         * some point in time before. The tracer does not allow it and would
         * result in a corrupted trace.
         */
-       if (session->has_been_started) {
+       if (cmd_ctx->session->has_been_started) {
                ret = LTTNG_ERR_TRACE_ALREADY_STARTED;
                goto end;
        }
 
-       if (ctx->ctx == LTTNG_EVENT_CONTEXT_APP_CONTEXT) {
-               app_ctx_provider_name = ctx->u.app_ctx.provider_name;
-               app_ctx_name = ctx->u.app_ctx.ctx_name;
-       }
-
        switch (domain) {
        case LTTNG_DOMAIN_KERNEL:
                assert(session->kernel_session);
@@ -1899,7 +1896,8 @@ int cmd_add_context(struct ltt_session *session, enum lttng_domain_type domain,
                        chan_kern_created = 1;
                }
                /* Add kernel context to kernel tracer */
-               ret = context_kernel_add(session->kernel_session, ctx, channel_name);
+               ret = context_kernel_add(session->kernel_session,
+                               event_context, channel_name);
                if (ret != LTTNG_OK) {
                        goto error;
                }
@@ -1953,11 +1951,8 @@ int cmd_add_context(struct ltt_session *session, enum lttng_domain_type domain,
                        chan_ust_created = 1;
                }
 
-               ret = context_ust_add(usess, domain, ctx, channel_name);
-               free(app_ctx_provider_name);
-               free(app_ctx_name);
-               app_ctx_name = NULL;
-               app_ctx_provider_name = NULL;
+               ret = context_ust_add(usess, domain, event_context,
+                               channel_name);
                if (ret != LTTNG_OK) {
                        goto error;
                }
@@ -1994,8 +1989,6 @@ error:
                trace_ust_destroy_channel(uchan);
        }
 end:
-       free(app_ctx_provider_name);
-       free(app_ctx_name);
        return ret;
 }
 
This page took 0.023721 seconds and 4 git commands to generate.