From 67e056446003680180ed4f384217facd90b1a776 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Tue, 27 Aug 2013 15:23:18 -0400 Subject: [PATCH] Fix: set the health delta tcp timeout aware 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 --- src/bin/lttng-sessiond/health.c | 20 +++++++++++++++++++- src/bin/lttng-sessiond/health.h | 1 + src/bin/lttng-sessiond/main.c | 6 ++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/bin/lttng-sessiond/health.c b/src/bin/lttng-sessiond/health.c index dcf3b96e2..fafc9095d 100644 --- a/src/bin/lttng-sessiond/health.c +++ b/src/bin/lttng-sessiond/health.c @@ -24,10 +24,12 @@ #include #include +#include +#include #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); +} diff --git a/src/bin/lttng-sessiond/health.h b/src/bin/lttng-sessiond/health.h index d04d18b78..ebbc0cb0f 100644 --- a/src/bin/lttng-sessiond/health.h +++ b/src/bin/lttng-sessiond/health.h @@ -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 */ diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 627560f49..f3b007a4f 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -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); -- 2.34.1