From b8ec3da8333ea4489eaee6b3060287adc666a729 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 28 Feb 2013 18:42:17 -0500 Subject: [PATCH] Add with-sessiond-bin configure option I also cleaned up the little check_sessiond function. The check using access(2) was only done for the command line option, but I think it is a good idea to do it wherever the path comes from. Closes #441 Signed-off-by: Simon Marchi Signed-off-by: David Goulet --- configure.ac | 17 +++++++++++++++++ src/bin/lttng/lttng.c | 40 ++++++++++++++++++++++------------------ 2 files changed, 39 insertions(+), 18 deletions(-) diff --git a/configure.ac b/configure.ac index b9ee7ec3f..9f120f2fc 100644 --- a/configure.ac +++ b/configure.ac @@ -91,12 +91,20 @@ AC_ARG_WITH([consumerd64-libdir], [CONSUMERD64_LIBDIR='']) AC_SUBST([CONSUMERD64_LIBDIR]) +AC_ARG_WITH([sessiond-bin], + AS_HELP_STRING([--with-sessiond-bin], + [Location of the sessiond executable (including the filename)]), + [SESSIOND_BIN="$withval"], + [SESSIOND_BIN='']) +AC_SUBST([SESSIOND_BIN]) + AC_DEFINE_UNQUOTED([CONFIG_CONSUMERD32_BIN], "$CONSUMERD32_BIN", [Location of the 32-bit consumerd executable.]) AC_DEFINE_UNQUOTED([CONFIG_CONSUMERD64_BIN], "$CONSUMERD64_BIN", [Location of the 64-bit consumerd executable]) AC_DEFINE_UNQUOTED([CONFIG_CONSUMERD32_LIBDIR], "$CONSUMERD32_LIBDIR", [Search for consumerd 32-bit libraries in this location.]) AC_DEFINE_UNQUOTED([CONFIG_CONSUMERD64_LIBDIR], "$CONSUMERD64_LIBDIR", [Search for consumerd 64-bit libraries in this location.]) AC_DEFINE_UNQUOTED([CONFIG_BABELTRACE_BIN], "$BABELTRACE_BIN", [Location of the babeltrace viewer executable.]) AC_DEFINE_UNQUOTED([CONFIG_LTTV_GUI_BIN], "$LTTV_GUI_BIN", [Location of the lttv GUI viewer executable.]) +AC_DEFINE_UNQUOTED([CONFIG_SESSIOND_BIN], "$SESSIOND_BIN", [Location of the sessiond executable.]) # Check for pthread AC_CHECK_LIB([pthread], [pthread_create], [], @@ -387,6 +395,15 @@ AS_ECHO("`eval eval echo $libdir`") # If we build the sessiond, print the paths it will use AS_IF([test "x$consumerd_only" = "xno"],[ + AS_ECHO() + AS_ECHO_N("The lttng command will look for the lttng-sessiond executable at: ") + AS_IF([test "$SESSIOND_BIN" = ""],[ + AS_ECHO_N("`eval eval echo $bindir`") + AS_ECHO("/lttng-sessiond") + ],[ + AS_ECHO("$SESSIOND_BIN") + ]) + AS_ECHO() AS_ECHO("The sessiond daemon will look in the following directories: ") AS_ECHO_N("32-bit consumerd executable at: ") diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c index be673f94f..d3aaa8424 100644 --- a/src/bin/lttng/lttng.c +++ b/src/bin/lttng/lttng.c @@ -346,39 +346,43 @@ end: static int check_sessiond(void) { int ret; - char *pathname = NULL, *alloc_pathname = NULL; + char *pathname = NULL; ret = lttng_session_daemon_alive(); if (ret == 0) { /* not alive */ /* Try command line option path */ - if (opt_sessiond_path != NULL) { - ret = access(opt_sessiond_path, F_OK | X_OK); - if (ret < 0) { - ERR("No such file or access denied: %s", opt_sessiond_path); - goto end; - } - pathname = opt_sessiond_path; - } else { - /* Try LTTNG_SESSIOND_PATH env variable */ + pathname = opt_sessiond_path; + + /* Try LTTNG_SESSIOND_PATH env variable */ + if (pathname == NULL) { pathname = getenv(DEFAULT_SESSIOND_PATH_ENV); } - /* Let's rock and roll */ + /* Try with configured path */ if (pathname == NULL) { - ret = asprintf(&alloc_pathname, INSTALL_BIN_PATH "/lttng-sessiond"); - if (ret < 0) { - perror("asprintf spawn sessiond"); - goto end; + if (CONFIG_SESSIOND_BIN[0] != '\0') { + pathname = CONFIG_SESSIOND_BIN; } - pathname = alloc_pathname; + } + + /* Let's rock and roll while trying the default path */ + if (pathname == NULL) { + pathname = INSTALL_BIN_PATH "/lttng-sessiond"; + } + + DBG("Session daemon at: %s", pathname); + + /* Check existence and permissions */ + ret = access(pathname, F_OK | X_OK); + if (ret < 0) { + ERR("No such file or access denied: %s", pathname); + goto end; } ret = spawn_sessiond(pathname); if (ret < 0) { ERR("Problem occurred when starting %s", pathname); } - - free(alloc_pathname); } end: return ret; -- 2.34.1