[lttng-dev] [lttng-tools PATCH 3/4] Use the consumerd_path variables for kernel consumers too

Alexandre Montplaisir alexandre.montplaisir at gmail.com
Mon Dec 5 10:11:52 EST 2011


Right now the sessiond will only look in its own directory for
the consumerd when starting a kernel trace. This patch makes it
look in the consumerd32_ and consumerd64_ paths too.

Signed-off-by: Alexandre Montplaisir <alexandre.montplaisir at gmail.com>
---
 lttng-sessiond/main.c |   29 ++++++++++++++++++++++++-----
 1 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/lttng-sessiond/main.c b/lttng-sessiond/main.c
index aa15554..ac03e34 100644
--- a/lttng-sessiond/main.c
+++ b/lttng-sessiond/main.c
@@ -1509,7 +1509,9 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data)
 {
 	int ret;
 	pid_t pid;
+	const char *consumer_to_use;
 	const char *verbosity;
+	struct stat st;
 
 	DBG("Spawning consumerd");
 
@@ -1525,11 +1527,26 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data)
 		}
 		switch (consumer_data->type) {
 		case LTTNG_CONSUMER_KERNEL:
-			execl(INSTALL_BIN_PATH "/lttng-consumerd",
-					"lttng-consumerd", verbosity, "-k",
-					"--consumerd-cmd-sock", consumer_data->cmd_unix_sock_path,
-					"--consumerd-err-sock", consumer_data->err_unix_sock_path,
-					NULL);
+			/*
+			 * Find out which consumerd to execute. We will first
+			 * try the 64-bit path, then the 32-bit one, then
+			 * fallback on sessiond's installation directory.
+			 */
+			if (stat(consumerd64_path, &st) == 0) {
+				consumer_to_use = consumerd64_path;
+			} else if (stat(consumerd32_path, &st) == 0) {
+				consumer_to_use = consumerd32_path;
+			} else if (stat(INSTALL_BIN_PATH "/" CONSUMERD_FILE, &st) == 0) {
+				consumer_to_use = INSTALL_BIN_PATH "/" CONSUMERD_FILE;
+			} else {
+				break;
+			}
+			DBG("Using kernel consumer at: %s",  consumer_to_use);
+			execl(consumer_to_use,
+				"lttng-consumerd", verbosity, "-k",
+				"--consumerd-cmd-sock", consumer_data->cmd_unix_sock_path,
+				"--consumerd-err-sock", consumer_data->err_unix_sock_path,
+				NULL);
 			break;
 		case LTTNG_CONSUMER64_UST:
 		{
@@ -1562,6 +1579,7 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data)
 					goto error;
 				}
 			}
+			DBG("Using 64-bit UST consumer at: %s",  consumerd64_path);
 			ret = execl(consumerd64_path, verbosity, "-u",
 					"--consumerd-cmd-sock", consumer_data->cmd_unix_sock_path,
 					"--consumerd-err-sock", consumer_data->err_unix_sock_path,
@@ -1605,6 +1623,7 @@ static pid_t spawn_consumerd(struct consumer_data *consumer_data)
 					goto error;
 				}
 			}
+			DBG("Using 32-bit UST consumer at: %s",  consumerd32_path);
 			ret = execl(consumerd32_path, verbosity, "-u",
 					"--consumerd-cmd-sock", consumer_data->cmd_unix_sock_path,
 					"--consumerd-err-sock", consumer_data->err_unix_sock_path,
-- 
1.7.7.3




More information about the lttng-dev mailing list