X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fcmd.c;h=860622d0065b9c3c80f22c32ee0b2d44b11f511d;hb=df5b86c84d896eb2d74a8757c234492c1d1fc3be;hp=f8fa4dedddda209c3280b05e71f105d45a79a66d;hpb=141feb8ca12d48ef5adfcda81faa7e0d2fc32c7a;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index f8fa4dedd..860622d00 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -1114,9 +1114,40 @@ int cmd_enable_channel(struct ltt_session *session, break; } case LTTNG_DOMAIN_UST: + case LTTNG_DOMAIN_JUL: + case LTTNG_DOMAIN_LOG4J: + case LTTNG_DOMAIN_PYTHON: { struct ltt_ust_channel *uchan; + /* + * FIXME + * + * Current agent implementation limitations force us to allow + * only one channel at once in "agent" subdomains. Each + * subdomain has a default channel name which must be strictly + * adhered to. + */ + if (domain->type == LTTNG_DOMAIN_JUL) { + if (strncmp(attr->name, DEFAULT_JUL_CHANNEL_NAME, + LTTNG_SYMBOL_NAME_LEN)) { + ret = LTTNG_ERR_INVALID_CHANNEL_NAME; + goto error; + } + } else if (domain->type == LTTNG_DOMAIN_LOG4J) { + if (strncmp(attr->name, DEFAULT_LOG4J_CHANNEL_NAME, + LTTNG_SYMBOL_NAME_LEN)) { + ret = LTTNG_ERR_INVALID_CHANNEL_NAME; + goto error; + } + } else if (domain->type == LTTNG_DOMAIN_PYTHON) { + if (strncmp(attr->name, DEFAULT_PYTHON_CHANNEL_NAME, + LTTNG_SYMBOL_NAME_LEN)) { + ret = LTTNG_ERR_INVALID_CHANNEL_NAME; + goto error; + } + } + chan_ht = usess->domain_global.channels; uchan = trace_ust_find_channel_by_name(chan_ht, attr->name); @@ -1751,7 +1782,8 @@ static int _cmd_enable_event(struct ltt_session *session, memset(&uevent, 0, sizeof(uevent)); uevent.type = LTTNG_EVENT_TRACEPOINT; uevent.loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL; - default_event_name = event_get_default_agent_ust_name(domain->type); + default_event_name = event_get_default_agent_ust_name( + domain->type); if (!default_event_name) { ret = LTTNG_ERR_FATAL; goto error; @@ -1783,29 +1815,30 @@ static int _cmd_enable_event(struct ltt_session *session, } { - struct lttng_filter_bytecode *filter_copy = NULL; char *filter_expression_copy = NULL; + struct lttng_filter_bytecode *filter_copy = NULL; if (filter) { - filter_copy = zmalloc( - sizeof(struct lttng_filter_bytecode) - + filter->len); + const size_t filter_size = sizeof( + struct lttng_filter_bytecode) + + filter->len; + + filter_copy = zmalloc(filter_size); if (!filter_copy) { ret = LTTNG_ERR_NOMEM; - goto error; } + memcpy(filter_copy, filter, filter_size); - memcpy(filter_copy, filter, - sizeof(struct lttng_filter_bytecode) - + filter->len); - } - - if (filter_expression) { filter_expression_copy = strdup(filter_expression); if (!filter_expression) { ret = LTTNG_ERR_NOMEM; - goto error_free_copy; + } + + if (!filter_expression_copy || !filter_copy) { + free(filter_expression_copy); + free(filter_copy); + goto error; } } @@ -1813,11 +1846,6 @@ static int _cmd_enable_event(struct ltt_session *session, (char *) default_chan_name, &uevent, filter_expression_copy, filter_copy, NULL, wpipe); - filter_copy = NULL; - filter_expression_copy = NULL; -error_free_copy: - free(filter_copy); - free(filter_expression_copy); } if (ret != LTTNG_OK && ret != LTTNG_ERR_UST_EVENT_ENABLED) { @@ -1828,12 +1856,12 @@ error_free_copy: if (strncmp(event->name, "*", 1) == 0 && strlen(event->name) == 1) { ret = event_agent_enable_all(usess, agt, event, filter, filter_expression); - filter = NULL; } else { ret = event_agent_enable(usess, agt, event, filter, filter_expression); - filter = NULL; } + filter = NULL; + filter_expression = NULL; if (ret != LTTNG_OK) { goto error; }