Write TCP JUL port in the lttng's rundir
authorDavid Goulet <dgoulet@efficios.com>
Wed, 6 Nov 2013 18:25:20 +0000 (13:25 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Wed, 6 Nov 2013 18:25:20 +0000 (13:25 -0500)
The default name is jul.port and this file will be read by the JavaAgent
at init time so it can connect to a custom port without recompiling the
Java application or modifying the Java application with a sessiond port
option.

Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-sessiond/main.c
src/common/defaults.h

index 958ff0589e763357187f85f5ace6b5b29707c256..a790844a1a484e3745305f91999ca98da8d390e3 100644 (file)
@@ -455,6 +455,11 @@ static void cleanup(void)
        DBG("Removing %s", path);
        (void) unlink(path);
 
+       snprintf(path, PATH_MAX, "%s/%s", rundir,
+                       DEFAULT_LTTNG_SESSIOND_JULPORT_FILE);
+       DBG("Removing %s", path);
+       (void) unlink(path);
+
        /* kconsumerd */
        snprintf(path, PATH_MAX,
                DEFAULT_KCONSUMERD_ERR_SOCK_PATH,
@@ -4429,6 +4434,34 @@ error:
        return;
 }
 
+/*
+ * Write JUL TCP port using the rundir.
+ */
+static void write_julport(void)
+{
+       int ret;
+       char path[PATH_MAX];
+
+       assert(rundir);
+
+       ret = snprintf(path, sizeof(path), "%s/"
+                       DEFAULT_LTTNG_SESSIOND_JULPORT_FILE, rundir);
+       if (ret < 0) {
+               PERROR("snprintf julport path");
+               goto error;
+       }
+
+       /*
+        * Create TCP JUL port file in rundir. Return value is of no importance.
+        * The execution will continue even though we are not able to write the
+        * file.
+        */
+       (void) utils_create_pid_file(jul_tcp_port, path);
+
+error:
+       return;
+}
+
 /*
  * main
  */
@@ -4735,6 +4768,7 @@ int main(int argc, char **argv)
        }
 
        write_pidfile();
+       write_julport();
 
        /* Initialize communication library */
        lttcomm_init();
index 821128eb4df197539d334fb7b5fe67988c022296..6502345426fde7f1d3eb9c394c977a420797f7d6 100644 (file)
@@ -88,6 +88,7 @@
 #define DEFAULT_LTTNG_RUNDIR                    CONFIG_LTTNG_SYSTEM_RUNDIR
 #define DEFAULT_LTTNG_HOME_RUNDIR               "%s/.lttng"
 #define DEFAULT_LTTNG_SESSIOND_PIDFILE          "lttng-sessiond.pid"
+#define DEFAULT_LTTNG_SESSIOND_JULPORT_FILE     "jul.port"
 
 /* Default unix socket path */
 #define DEFAULT_GLOBAL_CLIENT_UNIX_SOCK         DEFAULT_LTTNG_RUNDIR "/client-lttng-sessiond"
This page took 0.029541 seconds and 4 git commands to generate.