[lttng-dev] [PATCH] Java Agent: Make the agent protocol consistently network endian
Alexandre Montplaisir
alexmonthy at voxpopuli.im
Fri Oct 23 17:24:03 EDT 2015
+1
In the case of SessiondDisableEventCommand it was not a big deal because
it only reads a string from the buffer, so individual bytes, not
affected by endianness. For SessiondEnableEventCommand however it would
result in erroneous values for log levels!
On 2015-10-23 05:12 PM, Jérémie Galarneau wrote:
> Considering the Agent Protocol is bumped to v2.0 as of 2.8.x,
> this patch revisits the unfortunate decision of communicating
> in host-endianness from the session daemon to the agents, and
> in big endian from the agents to the session daemon.
>
> This change does not affect the Python agent which was erroneously
> (although quite reasonably) assuming communications were occurring
> in network endianness.
>
> Signed-off-by: Jérémie Galarneau <jeremie.galarneau at efficios.com>
> ---
> .../org/lttng/ust/agent/client/SessiondDisableEventCommand.java | 2 +-
> .../org/lttng/ust/agent/client/SessiondEnableEventCommand.java | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/liblttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/client/SessiondDisableEventCommand.java b/liblttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/client/SessiondDisableEventCommand.java
> index 03cd9de..2956c7e 100644
> --- a/liblttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/client/SessiondDisableEventCommand.java
> +++ b/liblttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/client/SessiondDisableEventCommand.java
> @@ -38,7 +38,7 @@ class SessiondDisableEventCommand implements ISessiondCommand {
> throw new IllegalArgumentException();
> }
> ByteBuffer buf = ByteBuffer.wrap(data);
> - buf.order(ByteOrder.LITTLE_ENDIAN);
> + buf.order(ByteOrder.BIG_ENDIAN);
> eventName = new String(data).trim();
> }
>
> diff --git a/liblttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/client/SessiondEnableEventCommand.java b/liblttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/client/SessiondEnableEventCommand.java
> index c9183d1..5665a69 100644
> --- a/liblttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/client/SessiondEnableEventCommand.java
> +++ b/liblttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/client/SessiondEnableEventCommand.java
> @@ -48,7 +48,7 @@ class SessiondEnableEventCommand implements ISessiondCommand {
> throw new IllegalArgumentException();
> }
> ByteBuffer buf = ByteBuffer.wrap(data);
> - buf.order(ByteOrder.LITTLE_ENDIAN);
> + buf.order(ByteOrder.BIG_ENDIAN);
> int logLevel = buf.getInt();
> int logLevelType = buf.getInt();
> logLevelFilter = new LogLevelSelector(logLevel, logLevelType);
More information about the lttng-dev
mailing list