Add with-sessiond-bin configure option
authorSimon Marchi <simon.marchi@polymtl.ca>
Thu, 28 Feb 2013 23:42:17 +0000 (18:42 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Thu, 21 Mar 2013 17:30:25 +0000 (13:30 -0400)
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 <simon.marchi@polymtl.ca>
Signed-off-by: David Goulet <dgoulet@efficios.com>
configure.ac
src/bin/lttng/lttng.c

index b9ee7ec3f5703bec8be408277cea1f085d5aeeeb..9f120f2fcc0ad65b18a300d4dfb436e286c09343 100644 (file)
@@ -91,12 +91,20 @@ AC_ARG_WITH([consumerd64-libdir],
        [CONSUMERD64_LIBDIR=''])
 AC_SUBST([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_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], [],
 
 # 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"],[
 
 # 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: ")
        AS_ECHO()
        AS_ECHO("The sessiond daemon will look in the following directories: ")
        AS_ECHO_N("32-bit consumerd executable at: ")
index be673f94f2d0ab552c4f9daa3f90bff70637b2d1..d3aaa8424683b58c189d2c8f9afc894f5d937bf2 100644 (file)
@@ -346,39 +346,43 @@ end:
 static int check_sessiond(void)
 {
        int ret;
 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 */
 
        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);
                }
 
                        pathname = getenv(DEFAULT_SESSIOND_PATH_ENV);
                }
 
-               /* Let's rock and roll */
+               /* Try with configured path */
                if (pathname == NULL) {
                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);
                }
                }
 
                ret = spawn_sessiond(pathname);
                if (ret < 0) {
                        ERR("Problem occurred when starting %s", pathname);
                }
-
-               free(alloc_pathname);
        }
 end:
        return ret;
        }
 end:
        return ret;
This page took 0.026704 seconds and 4 git commands to generate.