From 55d097957f5bb8138959ad2202a40d85d49f029e Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Sun, 15 Sep 2013 17:03:24 -0500 Subject: [PATCH] Move health into its own common/ static library - Introduce lttng/health-internal.h (not installed) Signed-off-by: Mathieu Desnoyers --- configure.ac | 1 + include/Makefile.am | 9 ++++- .../lttng/health-internal.h | 10 ++--- src/bin/lttng-sessiond/Makefile.am | 5 ++- src/bin/lttng-sessiond/health-sessiond.h | 2 +- src/bin/lttng-sessiond/main.c | 1 - src/common/Makefile.am | 2 +- src/common/health/Makefile.am | 5 +++ .../lttng-sessiond => common/health}/health.c | 37 ++++++++++--------- 9 files changed, 42 insertions(+), 30 deletions(-) rename src/bin/lttng-sessiond/health.h => include/lttng/health-internal.h (95%) create mode 100644 src/common/health/Makefile.am rename src/{bin/lttng-sessiond => common/health}/health.c (98%) diff --git a/configure.ac b/configure.ac index eee05aacd..2b4a340f5 100644 --- a/configure.ac +++ b/configure.ac @@ -354,6 +354,7 @@ AC_CONFIG_FILES([ src/common/relayd/Makefile src/common/testpoint/Makefile src/common/index/Makefile + src/common/health/Makefile src/lib/Makefile src/lib/lttng-ctl/Makefile src/lib/lttng-ctl/filter/Makefile diff --git a/include/Makefile.am b/include/Makefile.am index f3413e6df..15479d4a7 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1,3 +1,8 @@ -lttnginclude_HEADERS = lttng/lttng.h lttng/lttng-error.h lttng/snapshot.h +lttnginclude_HEADERS = \ + lttng/lttng.h \ + lttng/lttng-error.h \ + lttng/snapshot.h -noinst_HEADERS = lttng/snapshot-internal.h +noinst_HEADERS = \ + lttng/snapshot-internal.h \ + lttng/health-internal.h diff --git a/src/bin/lttng-sessiond/health.h b/include/lttng/health-internal.h similarity index 95% rename from src/bin/lttng-sessiond/health.h rename to include/lttng/health-internal.h index 82cfc87df..764e998e3 100644 --- a/src/bin/lttng-sessiond/health.h +++ b/include/lttng/health-internal.h @@ -1,5 +1,9 @@ +#ifndef HEALTH_INTERNAL_H +#define HEALTH_INTERNAL_H + /* * Copyright (C) 2012 - David Goulet + * Copyright (C) 2013 - Mathieu Desnoyers * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License, version 2 only, as @@ -15,9 +19,6 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef _HEALTH_H -#define _HEALTH_H - #include #include #include @@ -111,6 +112,5 @@ void health_app_destroy(struct health_app *ha); int health_check_state(struct health_app *ha, int type); void health_register(struct health_app *ha, int type); void health_unregister(struct health_app *ha); -void health_init(struct health_app *ha); -#endif /* _HEALTH_H */ +#endif /* HEALTH_INTERNAL_H */ diff --git a/src/bin/lttng-sessiond/Makefile.am b/src/bin/lttng-sessiond/Makefile.am index 0fab90f33..3d96907de 100644 --- a/src/bin/lttng-sessiond/Makefile.am +++ b/src/bin/lttng-sessiond/Makefile.am @@ -22,7 +22,7 @@ lttng_sessiond_SOURCES = utils.c utils.h \ fd-limit.c fd-limit.h \ kernel-consumer.c kernel-consumer.h \ consumer.h \ - health.c health.h health-sessiond.h \ + health-sessiond.h \ cmd.c cmd.h \ buffer-registry.c buffer-registry.h \ testpoint.h ht-cleanup.c \ @@ -46,7 +46,8 @@ lttng_sessiond_LDADD = -lrt -lurcu-common -lurcu \ $(top_builddir)/src/common/libcommon.la \ $(top_builddir)/src/common/compat/libcompat.la \ $(top_builddir)/src/common/relayd/librelayd.la \ - $(top_builddir)/src/common/testpoint/libtestpoint.la + $(top_builddir)/src/common/testpoint/libtestpoint.la \ + $(top_builddir)/src/common/health/libhealth.la if HAVE_LIBLTTNG_UST_CTL lttng_sessiond_LDADD += -llttng-ust-ctl diff --git a/src/bin/lttng-sessiond/health-sessiond.h b/src/bin/lttng-sessiond/health-sessiond.h index 18f922728..49f9e0b9c 100644 --- a/src/bin/lttng-sessiond/health-sessiond.h +++ b/src/bin/lttng-sessiond/health-sessiond.h @@ -18,7 +18,7 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "health.h" +#include enum health_type { HEALTH_TYPE_CMD = 0, diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index a54c0bf8d..550aa1b83 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -4727,7 +4727,6 @@ int main(int argc, char **argv) PERROR("health_app_create error"); goto exit_health_sessiond_cleanup; } - health_init(health_sessiond); /* Create thread to manage the client socket */ ret = pthread_create(&ht_cleanup_thread, NULL, diff --git a/src/common/Makefile.am b/src/common/Makefile.am index 8454b5a51..0c02d533c 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -1,6 +1,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src -SUBDIRS = compat hashtable kernel-ctl sessiond-comm relayd \ +SUBDIRS = compat health hashtable kernel-ctl sessiond-comm relayd \ kernel-consumer ust-consumer testpoint index AM_CFLAGS = -fno-strict-aliasing diff --git a/src/common/health/Makefile.am b/src/common/health/Makefile.am new file mode 100644 index 000000000..d82f9de9e --- /dev/null +++ b/src/common/health/Makefile.am @@ -0,0 +1,5 @@ +AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src + +noinst_LTLIBRARIES = libhealth.la + +libhealth_la_SOURCES = health.c diff --git a/src/bin/lttng-sessiond/health.c b/src/common/health/health.c similarity index 98% rename from src/bin/lttng-sessiond/health.c rename to src/common/health/health.c index 7e1d4731a..d2414ae57 100644 --- a/src/bin/lttng-sessiond/health.c +++ b/src/common/health/health.c @@ -28,7 +28,7 @@ #include #include -#include "health.h" +#include /* * An application-specific error state for unregistered thread keeps @@ -56,6 +56,23 @@ struct health_app { /* Define TLS health state. */ DEFINE_URCU_TLS(struct health_state, health_state); +/* + * Initialize health check subsytem. + */ +static +void health_init(struct health_app *ha) +{ + /* + * Get the maximum value between the default delta value and the TCP + * timeout with a safety net of the default health check delta. + */ + ha->time_delta.tv_sec = max_t(unsigned long, + lttcomm_inet_tcp_timeout + DEFAULT_HEALTH_CHECK_DELTA_S, + ha->time_delta.tv_sec); + DBG("Health check time delta in seconds set to %lu", + ha->time_delta.tv_sec); +} + struct health_app *health_app_create(int nr_types) { struct health_app *ha; @@ -73,6 +90,7 @@ struct health_app *health_app_create(int nr_types) ha->nr_types = nr_types; ha->time_delta.tv_sec = DEFAULT_HEALTH_CHECK_DELTA_S; ha->time_delta.tv_nsec = DEFAULT_HEALTH_CHECK_DELTA_NS; + health_init(ha); return ha; error_flags: @@ -285,20 +303,3 @@ void health_unregister(struct health_app *ha) cds_list_del(&URCU_TLS(health_state).node); state_unlock(ha); } - -/* - * Initiliazie health check subsytem. This should be called before any health - * register occurs. - */ -void health_init(struct health_app *ha) -{ - /* - * Get the maximum value between the default delta value and the TCP - * timeout with a safety net of the default health check delta. - */ - ha->time_delta.tv_sec = max_t(unsigned long, - lttcomm_inet_tcp_timeout + DEFAULT_HEALTH_CHECK_DELTA_S, - ha->time_delta.tv_sec); - DBG("Health check time delta in seconds set to %lu", - ha->time_delta.tv_sec); -} -- 2.34.1