From: Alexandre Montplaisir Date: Fri, 12 Feb 2016 16:51:47 +0000 (-0500) Subject: Fix: Correctly report filter notifications on Java agent teardown X-Git-Tag: v2.8.0-rc1~35 X-Git-Url: http://git.liburcu.org/?a=commitdiff_plain;h=5c76231c94c9bbe2c4b707e7b63766d6c28452fa;hp=e1357790eb9dbd638a9f35a5c5e4cea237957f2f;p=lttng-ust.git Fix: Correctly report filter notifications on Java agent teardown If a Java agent gets disposed, it should not just clear() all its tracked event rules: it should first send corresponding filter change notifications indicating that these rules are not tracked anymore. This fixes a problem where if event rules were still enabled on agent tear down, the filter notifier's own tracked events would become out of sync. Signed-off-by: Alexandre Montplaisir Signed-off-by: Mathieu Desnoyers --- diff --git a/liblttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/AbstractLttngAgent.java b/liblttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/AbstractLttngAgent.java index 3c64e180..a5880364 100644 --- a/liblttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/AbstractLttngAgent.java +++ b/liblttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/AbstractLttngAgent.java @@ -199,11 +199,40 @@ public abstract class AbstractLttngAgent userSessiondClient = null; userSessiondClientThread = null; - /* Reset all enabled event counts to 0 */ + /* + * Send filter change notifications for all event rules currently + * active, then clear them. + */ + FilterChangeNotifier fcn = FilterChangeNotifier.getInstance(); + + for (Map.Entry entry : enabledEvents.entrySet()) { + String eventName = entry.getKey(); + Integer nb = entry.getValue(); + for (int i = 0; i < nb.intValue(); i++) { + fcn.removeEventRules(eventName); + } + } enabledEvents.clear(); + + for (Map.Entry entry : enabledEventPrefixes.entrySet()) { + /* Re-add the * at the end, the FCN tracks the rules that way */ + String eventName = (entry.getKey() + "*"); + Integer nb = entry.getValue(); + for (int i = 0; i < nb.intValue(); i++) { + fcn.removeEventRules(eventName); + } + } enabledEventPrefixes.clear(); - enabledWildcards.set(0); + int wildcardRules = enabledWildcards.getAndSet(0); + for (int i = 0; i < wildcardRules; i++) { + fcn.removeEventRules(WILDCARD); + } + + /* + * Also clear tracked app contexts (no filter notifications sent for + * those currently). + */ enabledAppContexts.clear(); initialized = false;