X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fcmd.c;h=17dcfc41685a2562aa7d01f297cabe324af7354c;hb=b67578cb27784c08d36e0e445a81123ff507f835;hp=84594ad24927bf9ab4771d534f4dc8f88360491e;hpb=850767541647c102a299d7fbc39c97555ac70224;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 84594ad24..17dcfc416 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -859,15 +859,6 @@ int cmd_enable_channel(struct ltt_session *session, rcu_read_lock(); - /* - * Don't try to enable a channel if the session has been started at - * some point in time before. The tracer does not allow it. - */ - if (session->started) { - ret = LTTNG_ERR_TRACE_ALREADY_STARTED; - goto error; - } - switch (domain->type) { case LTTNG_DOMAIN_KERNEL: { @@ -876,6 +867,15 @@ int cmd_enable_channel(struct ltt_session *session, kchan = trace_kernel_get_channel_by_name(attr->name, session->kernel_session); if (kchan == NULL) { + /* + * Don't try to create a channel if the session + * has been started at some point in time + * before. The tracer does not allow it. + */ + if (session->started) { + ret = LTTNG_ERR_TRACE_ALREADY_STARTED; + goto error; + } ret = channel_kernel_create(session->kernel_session, attr, wpipe); if (attr->name[0] != '\0') { session->kernel_session->has_non_default_channel = 1; @@ -899,6 +899,15 @@ int cmd_enable_channel(struct ltt_session *session, uchan = trace_ust_find_channel_by_name(chan_ht, attr->name); if (uchan == NULL) { + /* + * Don't try to create a channel if the session + * has been started at some point in time + * before. The tracer does not allow it. + */ + if (session->started) { + ret = LTTNG_ERR_TRACE_ALREADY_STARTED; + goto error; + } ret = channel_ust_create(usess, attr, domain->buf_type); if (attr->name[0] != '\0') { usess->has_non_default_channel = 1; @@ -1115,17 +1124,6 @@ int cmd_add_context(struct ltt_session *session, int domain, case LTTNG_DOMAIN_KERNEL: assert(session->kernel_session); - /* - * If a non-default channel has been created in the - * session, explicitely require that -c chan_name needs - * to be provided. - */ - if (session->kernel_session->has_non_default_channel - && channel_name[0] == '\0') { - ret = LTTNG_ERR_NEED_CHANNEL_NAME; - goto error; - } - if (session->kernel_session->channel_count == 0) { /* Create default channel */ ret = channel_kernel_create(session->kernel_session, NULL, kwpipe); @@ -1147,16 +1145,6 @@ int cmd_add_context(struct ltt_session *session, int domain, assert(usess); - /* - * If a non-default channel has been created in the - * session, explicitely require that -c chan_name needs - * to be provided. - */ - if (usess->has_non_default_channel && channel_name[0] == '\0') { - ret = LTTNG_ERR_NEED_CHANNEL_NAME; - goto error; - } - chan_count = lttng_ht_get_count(usess->domain_global.channels); if (chan_count == 0) { struct lttng_channel *attr; @@ -2590,10 +2578,12 @@ static int record_kernel_snapshot(struct ltt_kernel_session *ksess, ret = kernel_snapshot_record(ksess, output, wait, nb_streams); if (ret < 0) { - ret = LTTNG_ERR_SNAPSHOT_FAIL; if (ret == -EINVAL) { ret = LTTNG_ERR_INVALID; + goto error_snapshot; } + + ret = LTTNG_ERR_SNAPSHOT_FAIL; goto error_snapshot; } @@ -2646,10 +2636,12 @@ static int record_ust_snapshot(struct ltt_ust_session *usess, ret = ust_app_snapshot_record(usess, output, wait, nb_streams); if (ret < 0) { - ret = LTTNG_ERR_SNAPSHOT_FAIL; if (ret == -EINVAL) { ret = LTTNG_ERR_INVALID; + goto error_snapshot; } + + ret = LTTNG_ERR_SNAPSHOT_FAIL; goto error_snapshot; } @@ -2844,6 +2836,8 @@ int cmd_snapshot_record(struct ltt_session *session, if (snapshot_success) { session->snapshot.nb_snapshot++; + } else { + ret = LTTNG_ERR_SNAPSHOT_FAIL; } error: