X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fevent.c;h=189236beb1171a05ba21e89b3ecb51216a7b5e47;hp=f97148db113c2bf1c8f3cc32dd9b6dd38170f599;hb=ab5be9fa2eb5ba9600a82cd18fd3cfcbac69169a;hpb=88e3c2f5610b9ac89b0923d448fee34140fc46fb diff --git a/src/bin/lttng-sessiond/event.c b/src/bin/lttng-sessiond/event.c index f97148db1..189236beb 100644 --- a/src/bin/lttng-sessiond/event.c +++ b/src/bin/lttng-sessiond/event.c @@ -1,19 +1,9 @@ /* - * Copyright (C) 2011 - David Goulet - * Copyright (C) 2016 - Jérémie Galarneau + * Copyright (C) 2011 David Goulet + * Copyright (C) 2016 Jérémie Galarneau * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2 only, - * as published by the Free Software Foundation. + * SPDX-License-Identifier: GPL-2.0-only * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #define _LGPL_SOURCE @@ -31,7 +21,8 @@ #include "event.h" #include "kernel.h" #include "lttng-sessiond.h" -#include "ust-ctl.h" +#include "lttng-ust-ctl.h" +#include "lttng-ust-error.h" #include "ust-app.h" #include "trace-kernel.h" #include "trace-ust.h" @@ -69,7 +60,7 @@ static void add_unique_ust_event(struct lttng_ht *ht, * If event_name is NULL all events of the specified type are disabled. */ int event_kernel_disable_event(struct ltt_kernel_channel *kchan, - char *event_name, enum lttng_event_type type) + const char *event_name, enum lttng_event_type type) { int ret, error = 0, found = 0; struct ltt_kernel_event *kevent; @@ -172,7 +163,8 @@ int event_ust_enable_tracepoint(struct ltt_ust_session *usess, rcu_read_lock(); uevent = trace_ust_find_event(uchan->events, event->name, filter, - event->loglevel_type, event->loglevel, exclusion); + (enum lttng_ust_loglevel_type) event->loglevel_type, + event->loglevel, exclusion); if (!uevent) { ret = trace_ust_create_event(event, filter_expression, filter, exclusion, internal_event, &uevent); @@ -190,6 +182,7 @@ int event_ust_enable_tracepoint(struct ltt_ust_session *usess, if (uevent->enabled) { /* It's already enabled so everything is OK */ + assert(!to_create); ret = LTTNG_ERR_UST_EVENT_ENABLED; goto end; } @@ -257,7 +250,7 @@ error: * Disable UST tracepoint of a channel from a UST session. */ int event_ust_disable_tracepoint(struct ltt_ust_session *usess, - struct ltt_ust_channel *uchan, char *event_name) + struct ltt_ust_channel *uchan, const char *event_name) { int ret; struct ltt_ust_event *uevent; @@ -506,12 +499,15 @@ int event_agent_enable(struct ltt_ust_session *usess, ret = LTTNG_ERR_NOMEM; goto error; } - + filter = NULL; + filter_expression = NULL; created = 1; + assert(!aevent->enabled); } - if (created && filter) { - ret = add_filter_app_ctx(filter, filter_expression, agt); + if (created && aevent->filter) { + ret = add_filter_app_ctx( + aevent->filter, aevent->filter_expression, agt); if (ret != LTTNG_OK) { goto error; } @@ -533,13 +529,16 @@ int event_agent_enable(struct ltt_ust_session *usess, agent_add_event(aevent, agt); } -end: - return LTTNG_OK; + ret = LTTNG_OK; + goto end; error: if (created) { agent_destroy_event(aevent); } +end: + free(filter); + free(filter_expression); return ret; } @@ -666,7 +665,7 @@ error: * Return LTTNG_OK on success or else a LTTNG_ERR* code. */ int event_agent_disable(struct ltt_ust_session *usess, struct agent *agt, - char *event_name) + const char *event_name) { int ret = LTTNG_OK; struct agent_event *aevent;