From: David Goulet Date: Tue, 17 Jun 2014 19:42:39 +0000 (-0400) Subject: Fix: disable JUL event on UST side X-Git-Tag: v2.5.0-rc2~2 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=be6a6276f221b9bc83c16e3c3ba6ca76f5f35350;p=lttng-tools.git Fix: disable JUL event on UST side With the new root logger patch in liblttng-ust-jul, we have to disable the JUL logger on the UST tracer side for the multi session support. Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index d1bf6f0c0..fff4b917c 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -1466,9 +1466,9 @@ int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain, /* The wild card * means that everything should be enabled. */ if (strncmp(event->name, "*", 1) == 0 && strlen(event->name) == 1) { - ret = event_jul_enable_all(usess, event); + ret = event_jul_enable_all(usess, event, filter); } else { - ret = event_jul_enable(usess, event); + ret = event_jul_enable(usess, event, filter); } if (ret != LTTNG_OK) { goto error; @@ -1689,7 +1689,7 @@ int cmd_enable_event_all(struct ltt_session *session, strncpy(event.name, "*", sizeof(event.name)); event.name[sizeof(event.name) - 1] = '\0'; - ret = event_jul_enable_all(usess, &event); + ret = event_jul_enable_all(usess, &event, filter); if (ret != LTTNG_OK) { goto error; } diff --git a/src/bin/lttng-sessiond/event.c b/src/bin/lttng-sessiond/event.c index da6a2913f..2ccffae65 100644 --- a/src/bin/lttng-sessiond/event.c +++ b/src/bin/lttng-sessiond/event.c @@ -27,6 +27,7 @@ #include "channel.h" #include "event.h" #include "kernel.h" +#include "lttng-sessiond.h" #include "ust-ctl.h" #include "ust-app.h" #include "trace-kernel.h" @@ -621,7 +622,7 @@ error: * Return LTTNG_OK on success or else a LTTNG_ERR* code. */ int event_jul_enable_all(struct ltt_ust_session *usess, - struct lttng_event *event) + struct lttng_event *event, struct lttng_filter_bytecode *filter) { int ret; struct jul_event *jevent; @@ -632,7 +633,7 @@ int event_jul_enable_all(struct ltt_ust_session *usess, DBG("Event JUL enabling ALL events for session %" PRIu64, usess->id); /* Enable event on JUL application through TCP socket. */ - ret = event_jul_enable(usess, event); + ret = event_jul_enable(usess, event, filter); if (ret != LTTNG_OK) { goto error; } @@ -656,7 +657,8 @@ error: * * Return LTTNG_OK on success or else a LTTNG_ERR* code. */ -int event_jul_enable(struct ltt_ust_session *usess, struct lttng_event *event) +int event_jul_enable(struct ltt_ust_session *usess, struct lttng_event *event, + struct lttng_filter_bytecode *filter) { int ret, created = 0; struct jul_event *jevent; @@ -670,7 +672,7 @@ int event_jul_enable(struct ltt_ust_session *usess, struct lttng_event *event) jevent = jul_find_event(event->name, event->loglevel, &usess->domain_jul); if (!jevent) { - jevent = jul_create_event(event->name); + jevent = jul_create_event(event->name, filter); if (!jevent) { ret = LTTNG_ERR_NOMEM; goto error; @@ -714,6 +716,9 @@ int event_jul_disable(struct ltt_ust_session *usess, char *event_name) { int ret; struct jul_event *jevent; + struct ltt_ust_event *uevent = NULL; + struct ltt_ust_channel *uchan = NULL; + char *ust_event_name; assert(usess); assert(event_name); @@ -731,6 +736,39 @@ int event_jul_disable(struct ltt_ust_session *usess, char *event_name) goto end; } + /* + * Disable it on the UST side. First get the channel reference then find + * the event and finally disable it. + */ + uchan = trace_ust_find_channel_by_name(usess->domain_global.channels, + DEFAULT_JUL_CHANNEL_NAME); + if (!uchan) { + ret = LTTNG_ERR_UST_CHAN_NOT_FOUND; + goto error; + } + + if (is_root) { + ust_event_name = DEFAULT_SYS_JUL_EVENT_NAME; + } else { + ust_event_name = DEFAULT_USER_JUL_EVENT_NAME; + } + + /* + * The loglevel is hardcoded with 0 here since the JUL ust event is set + * with the loglevel type to ALL thus the loglevel stays 0. The event's + * filter is the one handling the loglevel for JUL. + */ + uevent = trace_ust_find_event(uchan->events, ust_event_name, + jevent->filter, 0, NULL); + /* If the JUL event exists, it must be available on the UST side. */ + assert(uevent); + + ret = ust_app_disable_event_glb(usess, uchan, uevent); + if (ret < 0 && ret != -LTTNG_UST_ERR_EXIST) { + ret = LTTNG_ERR_UST_DISABLE_FAIL; + goto error; + } + ret = jul_disable_event(jevent); if (ret != LTTNG_OK) { goto error; diff --git a/src/bin/lttng-sessiond/event.h b/src/bin/lttng-sessiond/event.h index 4080c4f93..1297b6c48 100644 --- a/src/bin/lttng-sessiond/event.h +++ b/src/bin/lttng-sessiond/event.h @@ -49,9 +49,10 @@ int event_ust_enable_all_tracepoints(struct ltt_ust_session *usess, int event_ust_disable_all_tracepoints(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan); -int event_jul_enable(struct ltt_ust_session *usess, struct lttng_event *event); +int event_jul_enable(struct ltt_ust_session *usess, struct lttng_event *event, + struct lttng_filter_bytecode *filter); int event_jul_enable_all(struct ltt_ust_session *usess, - struct lttng_event *event); + struct lttng_event *event, struct lttng_filter_bytecode *filter); int event_jul_disable(struct ltt_ust_session *usess, char *event_name); int event_jul_disable_all(struct ltt_ust_session *usess); diff --git a/src/bin/lttng-sessiond/jul.c b/src/bin/lttng-sessiond/jul.c index da4cf6782..99e07487b 100644 --- a/src/bin/lttng-sessiond/jul.c +++ b/src/bin/lttng-sessiond/jul.c @@ -722,7 +722,8 @@ error: * * Return a new object else NULL on error. */ -struct jul_event *jul_create_event(const char *name) +struct jul_event *jul_create_event(const char *name, + struct lttng_filter_bytecode *filter) { struct jul_event *event; @@ -739,6 +740,10 @@ struct jul_event *jul_create_event(const char *name) lttng_ht_node_init_str(&event->node, event->name); } + if (filter) { + event->filter = filter; + } + error: return event; } diff --git a/src/bin/lttng-sessiond/jul.h b/src/bin/lttng-sessiond/jul.h index 55c9e18c7..0a0c8ef0e 100644 --- a/src/bin/lttng-sessiond/jul.h +++ b/src/bin/lttng-sessiond/jul.h @@ -84,6 +84,9 @@ struct jul_event { * Hash table nodes of the JUL domain. Indexed by name string. */ struct lttng_ht_node_str node; + + /* Bytecode filter associated with the event . NULL if none. */ + struct lttng_filter_bytecode *filter; }; /* @@ -112,7 +115,8 @@ int jul_init_domain(struct jul_domain *dom); void jul_destroy_domain(struct jul_domain *dom); /* JUL event API. */ -struct jul_event *jul_create_event(const char *name); +struct jul_event *jul_create_event(const char *name, + struct lttng_filter_bytecode *filter); void jul_add_event(struct jul_event *event, struct jul_domain *dom); struct jul_event *jul_find_event(const char *name, enum lttng_loglevel_jul loglevel, struct jul_domain *dom);