Fix: sessiond: wait for health check readiness
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 27 Jan 2014 03:54:15 +0000 (22:54 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Tue, 28 Jan 2014 21:20:45 +0000 (16:20 -0500)
Wait for health check readiness before notifying the parent.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Conflicts:
src/bin/lttng-sessiond/main.c

src/bin/lttng-sessiond/main.c

index c05be0a91533797a088670af6b6ec52c00637154..4a6b68a381c5394993b802f598ffc33625cfac1b 100644 (file)
@@ -243,6 +243,38 @@ struct health_app *health_sessiond;
 /* JUL TCP port for registration. Used by the JUL thread. */
 unsigned int jul_tcp_port = DEFAULT_JUL_TCP_PORT;
 
+/*
+ * Whether sessiond is ready for commands/health check requests.
+ * NR_LTTNG_SESSIOND_READY must match the number of calls to
+ * lttng_sessiond_notify_ready().
+ */
+#define NR_LTTNG_SESSIOND_READY                2
+int lttng_sessiond_ready = NR_LTTNG_SESSIOND_READY;
+
+/* Notify parents that we are ready for cmd and health check */
+static
+void lttng_sessiond_notify_ready(void)
+{
+       if (uatomic_sub_return(&lttng_sessiond_ready, 1) == 0) {
+               /*
+                * Notify parent pid that we are ready to accept command
+                * for client side.  This ppid is the one from the
+                * external process that spawned us.
+                */
+               if (opt_sig_parent) {
+                       kill(ppid, SIGUSR1);
+               }
+
+               /*
+                * Notify the parent of the fork() process that we are
+                * ready.
+                */
+               if (opt_daemon) {
+                       kill(child_ppid, SIGUSR1);
+               }
+       }
+}
+
 static
 void setup_consumerd_path(void)
 {
@@ -3565,6 +3597,8 @@ static void *thread_manage_health(void *data)
                goto error;
        }
 
+       lttng_sessiond_notify_ready();
+
        while (1) {
                DBG("Health check ready");
 
@@ -3715,18 +3749,7 @@ static void *thread_manage_clients(void *data)
                goto error;
        }
 
-       /*
-        * Notify parent pid that we are ready to accept command for client side.
-        * This ppid is the one from the external process that spawned us.
-        */
-       if (opt_sig_parent) {
-               kill(ppid, SIGUSR1);
-       }
-
-       /* Notify the parent of the fork() process that we are ready. */
-       if (opt_daemon) {
-               kill(child_ppid, SIGUSR1);
-       }
+       lttng_sessiond_notify_ready();
 
        /* This testpoint is after we signal readiness to the parent. */
        if (testpoint(sessiond_thread_manage_clients)) {
This page took 0.027508 seconds and 4 git commands to generate.