- 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();
+ }