Fix: set the health delta tcp timeout aware
authorDavid Goulet <dgoulet@efficios.com>
Tue, 27 Aug 2013 19:23:18 +0000 (15:23 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Tue, 27 Aug 2013 19:33:31 +0000 (15:33 -0400)
The health check subsystem now initialized the time delta using the TCP
timeout. It takes the maximum value between our default internal delta
and the TCP timeout fetched by the lttcomm inet subsytem.

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

index dcf3b96e2b48c7fc4030005818d2bb92b4dda71a..fafc9095df57e89d88baeede25e4adfa8b634fe9 100644 (file)
 
 #include <common/defaults.h>
 #include <common/error.h>
+#include <common/macros.h>
+#include <common/sessiond-comm/inet.h>
 
 #include "health.h"
 
-static const struct timespec time_delta = {
+static struct timespec time_delta = {
        .tv_sec = DEFAULT_HEALTH_CHECK_DELTA_S,
        .tv_nsec = DEFAULT_HEALTH_CHECK_DELTA_NS,
 };
@@ -253,3 +255,19 @@ void health_unregister(void)
        cds_list_del(&URCU_TLS(health_state).node);
        state_unlock();
 }
+
+/*
+ * Initiliazie health check subsytem. This should be called before any health
+ * register occurs.
+ */
+void health_init(void)
+{
+       /*
+        * Get the maximum value between the default delta value and the TCP
+        * timeout with a safety net of the default health check delta.
+        */
+       time_delta.tv_sec = max_t(unsigned long,
+                       lttcomm_inet_tcp_timeout + DEFAULT_HEALTH_CHECK_DELTA_S,
+                       time_delta.tv_sec);
+       DBG("Health check time delta in seconds set to %lu", time_delta.tv_sec);
+}
index d04d18b78ff4b436f59dae699892638f98e8c565..ebbc0cb0f7ccee5d08da37e32c16c396c8dd0bed 100644 (file)
@@ -124,5 +124,6 @@ static inline void health_error(void)
 int health_check_state(enum health_type type);
 void health_register(enum health_type type);
 void health_unregister(void);
+void health_init(void);
 
 #endif /* _HEALTH_H */
index 627560f499773e0732e4e1f8cccf70c220483cc2..f3b007a4fac7b1fc3cf17ad1927c1264c375c1d0 100644 (file)
@@ -4655,6 +4655,12 @@ int main(int argc, char **argv)
        /* This is to get the TCP timeout value. */
        lttcomm_inet_init();
 
+       /*
+        * Initialize the health check subsystem. This call should set the
+        * appropriate time values.
+        */
+       health_init();
+
        /* Create thread to manage the client socket */
        ret = pthread_create(&ht_cleanup_thread, NULL,
                        thread_ht_cleanup, (void *) NULL);
This page took 0.029605 seconds and 5 git commands to generate.