X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=src%2Flib%2Flttng-ust-java-agent%2Fjava%2Flttng-ust-agent-common%2Forg%2Flttng%2Fust%2Fagent%2Fclient%2FLttngTcpSessiondClient.java;h=95376044a0116e52a6eb9f26656d391ac30e9a62;hb=c0f6fb054d2f16518d047a6adf7e8aa81eff5403;hp=cb84087af6a42fc81aa434dd7ec1018098c3e567;hpb=47bc09f338f3c1199a878f77b7b18be8d2a224f6;p=lttng-ust.git diff --git a/src/lib/lttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/client/LttngTcpSessiondClient.java b/src/lib/lttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/client/LttngTcpSessiondClient.java index cb84087a..95376044 100644 --- a/src/lib/lttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/client/LttngTcpSessiondClient.java +++ b/src/lib/lttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/client/LttngTcpSessiondClient.java @@ -170,20 +170,32 @@ public class LttngTcpSessiondClient implements Runnable { } private void connectToSessiond() throws IOException { - int rootPort = getPortFromFile(ROOT_PORT_FILE); - int userPort = getPortFromFile(getHomePath() + USER_PORT_FILE); + int portToUse; /* - * Check for the edge case of both files existing but pointing to the - * same port. In this case, let the root client handle it. + * The environment variable LTTNG_UST_APP_PATH disables + * connection to per-user and root session daemons. */ - if ((rootPort != 0) && (rootPort == userPort) && (!isRoot)) { - log("User and root config files both point to port " + rootPort + - ". Letting the root client handle it."); - throw new IOException(); - } + String lttngUstAppPath = getUstAppPath(); + + if (lttngUstAppPath != null) { + portToUse = getPortFromFile(lttngUstAppPath + USER_PORT_FILE); + } else { + int rootPort = getPortFromFile(ROOT_PORT_FILE); + int userPort = getPortFromFile(getHomePath() + USER_PORT_FILE); + + /* + * Check for the edge case of both files existing but pointing to the + * same port. In this case, let the root client handle it. + */ + if ((rootPort != 0) && (rootPort == userPort) && (!isRoot)) { + log("User and root config files both point to port " + rootPort + + ". Letting the root client handle it."); + throw new IOException(); + } - int portToUse = (isRoot ? rootPort : userPort); + portToUse = (isRoot ? rootPort : userPort); + } if (portToUse == 0) { /* No session daemon available. Stop and retry later. */ @@ -195,17 +207,20 @@ public class LttngTcpSessiondClient implements Runnable { this.outToSessiond = new DataOutputStream(sessiondSock.getOutputStream()); } + private static String getUstAppPath() { + return System.getenv("LTTNG_UST_APP_PATH"); + } + private static String getHomePath() { /* * The environment variable LTTNG_HOME overrides HOME if - * defined. + * set. */ - String homePath = System.getenv("LTTNG_HOME"); - - if (homePath == null) { - homePath = System.getProperty("user.home"); + String lttngHomePath = System.getenv("LTTNG_HOME"); + if (lttngHomePath != null) { + return lttngHomePath; } - return homePath; + return System.getProperty("user.home"); } /**