Skip to content

Commit d856c68

Browse files
committed
Fix: Disable all UST events matching the given name
The session daemon will only disable the first event matching the name provided to the disable-event command. This fix iterates on all events matching the name, ignoring their filter, loglevel and exclusion list. Signed-off-by: Jérémie Galarneau <[email protected]>
1 parent 93c4b58 commit d856c68

File tree

1 file changed

+57
-21
lines changed

1 file changed

+57
-21
lines changed

src/bin/lttng-sessiond/ust-app.c

+57-21
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,34 @@ static int ht_match_ust_app_event(struct cds_lfht_node *node, const void *_key)
169169
return 0;
170170
}
171171

172+
/*
173+
* Match function for the hash table lookup.
174+
*
175+
* Matches an ust app event based on its name only.
176+
*/
177+
static int ht_match_ust_app_event_by_name(struct cds_lfht_node *node,
178+
const void *_key)
179+
{
180+
struct ust_app_event *event;
181+
const char *name;
182+
183+
assert(node);
184+
assert(_key);
185+
186+
event = caa_container_of(node, struct ust_app_event, node.node);
187+
name = _key;
188+
189+
if (strncmp(event->attr.name, name, sizeof(event->attr.name))) {
190+
goto no_match;
191+
}
192+
193+
/* Match. */
194+
return 1;
195+
196+
no_match:
197+
return 0;
198+
}
199+
172200
/*
173201
* Unique add of an ust app event in the given ht. This uses the custom
174202
* ht_match_ust_app_event match function and the event name as hash.
@@ -3873,11 +3901,9 @@ int ust_app_disable_event_glb(struct ltt_ust_session *usess,
38733901
{
38743902
int ret = 0;
38753903
struct lttng_ht_iter iter, uiter;
3876-
struct lttng_ht_node_str *ua_chan_node, *ua_event_node;
3904+
struct lttng_ht_node_str *ua_chan_node;
38773905
struct ust_app *app;
3878-
struct ust_app_session *ua_sess;
38793906
struct ust_app_channel *ua_chan;
3880-
struct ust_app_event *ua_event;
38813907

38823908
DBG("UST app disabling event %s for all apps in channel "
38833909
"%s for session id %" PRIu64,
@@ -3887,10 +3913,13 @@ int ust_app_disable_event_glb(struct ltt_ust_session *usess,
38873913

38883914
/* For all registered applications */
38893915
cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
3916+
struct ust_app_session *ua_sess;
3917+
struct cds_lfht_node *ua_event_node;
3918+
38903919
if (!app->compatible) {
38913920
/*
3892-
* TODO: In time, we should notice the caller of this error by
3893-
* telling him that this is a version error.
3921+
* TODO: In time, we should notice the caller of this
3922+
* error by telling him that this is a version error.
38943923
*/
38953924
continue;
38963925
}
@@ -3901,28 +3930,35 @@ int ust_app_disable_event_glb(struct ltt_ust_session *usess,
39013930
}
39023931

39033932
/* Lookup channel in the ust app session */
3904-
lttng_ht_lookup(ua_sess->channels, (void *)uchan->name, &uiter);
3933+
lttng_ht_lookup(ua_sess->channels, (void *) uchan->name,
3934+
&uiter);
39053935
ua_chan_node = lttng_ht_iter_get_node_str(&uiter);
3906-
if (ua_chan_node == NULL) {
3936+
if (!ua_chan_node) {
39073937
DBG2("Channel %s not found in session id %" PRIu64 " for app pid %d."
3908-
"Skipping", uchan->name, usess->id, app->pid);
3938+
"Skipping", uchan->name, usess->id,
3939+
app->pid);
39093940
continue;
39103941
}
39113942
ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node);
39123943

3913-
lttng_ht_lookup(ua_chan->events, (void *)uevent->attr.name, &uiter);
3914-
ua_event_node = lttng_ht_iter_get_node_str(&uiter);
3915-
if (ua_event_node == NULL) {
3916-
DBG2("Event %s not found in channel %s for app pid %d."
3917-
"Skipping", uevent->attr.name, uchan->name, app->pid);
3918-
continue;
3919-
}
3920-
ua_event = caa_container_of(ua_event_node, struct ust_app_event, node);
3921-
3922-
ret = disable_ust_app_event(ua_sess, ua_event, app);
3923-
if (ret < 0) {
3924-
/* XXX: Report error someday... */
3925-
continue;
3944+
cds_lfht_for_each_duplicate(ua_chan->events->ht,
3945+
ua_chan->events->hash_fct(uevent->attr.name,
3946+
lttng_ht_seed),
3947+
ht_match_ust_app_event_by_name,
3948+
(void *) uevent->attr.name, &uiter.iter,
3949+
ua_event_node) {
3950+
struct ust_app_event *ua_event;
3951+
3952+
ua_event = caa_container_of(ua_event_node,
3953+
struct ust_app_event, node);
3954+
ret = disable_ust_app_event(ua_sess, ua_event, app);
3955+
if (ret < 0) {
3956+
DBG("Failed to disable event %s in channel %s "
3957+
"of app pid %d.",
3958+
uevent->attr.name,
3959+
uchan->name, app->pid);
3960+
continue;
3961+
}
39263962
}
39273963
}
39283964

0 commit comments

Comments
 (0)