Fix adding multiple kernel context at once
authorDavid Goulet <david.goulet@polymtl.ca>
Thu, 28 Jul 2011 17:12:34 +0000 (13:12 -0400)
committerDavid Goulet <david.goulet@polymtl.ca>
Thu, 28 Jul 2011 17:12:34 +0000 (13:12 -0400)
The session name was not set when multiple add-context was asked.

Also fix error message and session daemon return error when one add
kernel context fails.

Signed-off-by: David Goulet <david.goulet@polymtl.ca>
ltt-sessiond/main.c
lttng/commands/add_context.c

index 7603ffd1417e466f60847c7173092e24038ffc35..3195e3c191160351fbade811d482cfaa6a7603c1 100644 (file)
@@ -1318,7 +1318,8 @@ static int process_client_msg(struct command_ctx *cmd_ctx)
                                if (no_event) {
                                        ret = kernel_add_channel_context(chan, &ctx);
                                        if (ret < 0) {
-                                               continue;
+                                               ret = LTTCOMM_KERN_CONTEXT_FAIL;
+                                               goto error;
                                        }
                                } else {
                                        event = get_kernel_event_by_name(cmd_ctx->lsm->u.context.event_name, chan);
index b7a482bf7963e6b13024eff7b4a13dc389499750..5756684caedb85299d054590b7367c9fa9fbf1c6 100644 (file)
@@ -349,19 +349,19 @@ static int add_context(void)
        struct ctx_type *type;
        char *ptr;
 
-       if (set_session_name(opt_session_name) < 0) {
-               ret = CMD_ERROR;
-               goto error;
-       }
-
        /* Iterate over all context type given */
        cds_list_for_each_entry(type, &ctx_type_list.head, list) {
+               /* Set session name for the current command */
+               if (set_session_name(opt_session_name) < 0) {
+                       ret = CMD_ERROR;
+                       goto error;
+               }
+
                context.ctx = type->opt->ctx_type;
                if (context.ctx == LTTNG_EVENT_CONTEXT_PERF_COUNTER) {
                        context.u.perf_counter.type = type->opt->u.perf.type;
                        context.u.perf_counter.config = type->opt->u.perf.config;
-                       strcpy(context.u.perf_counter.name,
-                              type->opt->symbol);
+                       strcpy(context.u.perf_counter.name, type->opt->symbol);
                        /* Replace : and - by _ */
                        while ((ptr = strchr(context.u.perf_counter.name, '-')) != NULL) {
                                *ptr = '_';
@@ -378,6 +378,7 @@ static int add_context(void)
                        ret = lttng_add_context(&dom, &context, opt_event_name,
                                        opt_channel_name);
                        if (ret < 0) {
+                               fprintf(stderr, "%s: ", type->opt->symbol);
                                goto error;
                        } else {
                                MSG("Kernel context %s added", type->opt->symbol);
This page took 0.027437 seconds and 4 git commands to generate.