Project

General

Profile

Bug #884 » 0001-Fix-Java-agent-update-ref-count-in-enabledLoggers.patch

Philippe Proulx, 08/03/2015 04:35 PM

View differences:

liblttng-ust-java-agent/java/org/lttng/ust/agent/LTTngTCPSessiondClient.java
case CMD_REG_DONE:
{
/*
* Check command version:
*
* * 0: Connected to a non-fixed session daemon,
* which could send multiple disable
* event commands: do not decrement
* reference count on disable event command
* (original behaviour).
* * >0: Connected to a fixed session daemon:
* do decrement reference count on disable
* event command.
*/
if (headerCmd.cmd_version > 0) {
this.log.setEnableRefCountDecrement(true);
}
/*
* Release semaphore so meaning registration is done and we
* can proceed to continue tracing.
*/
liblttng-ust-java-agent/java/org/lttng/ust/agent/LogFramework.java
Iterator<String> listLoggers();
Boolean isRoot();
void reset();
void setEnableRefCountDecrement(boolean enableRefCountDecrement);
}
liblttng-ust-java-agent/java/org/lttng/ust/agent/LogFrameworkSkeleton.java
/* A map of event name and reference count */
private Map<String, Integer> enabledLoggers;
/*
* If the following attribute is false, the internal ref count is
* never decremented when disabling a logger. This was the original
* behaviour of this agent, and this bug worked in concert with a
* bug in the session daemon which would send multiple disable
* commands for the same event name (manual disable + another
* disable on session destroy). The following attribute is needed
* because this version of the agent could be connected to a
* fixed session daemon, or a non-fixed session daemon, and it needs
* to work in both situations.
*/
private boolean enableRefCountDecrement = false;
public LogFrameworkSkeleton() {
this.enabledLoggers = new HashMap<String, Integer>();
}
......
refcount--;
assert (refcount >= 0);
if (enableRefCountDecrement) {
// effectively decrement ref count
enabledLoggers.put(name, refcount);
}
if (refcount == 0) {
/* Event is not used anymore, remove it from the map */
Integer oldval = enabledLoggers.remove(name);
......
protected Integer getEventCount() {
return enabledLoggers.size();
}
public void setEnableRefCountDecrement(boolean enableRefCountDecrement) {
this.enableRefCountDecrement = enableRefCountDecrement;
}
}
(1-1/2)