From 2d57de81500759ff5398057bad89c64cf8e9834b Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Sun, 26 Jan 2014 22:43:13 -0500 Subject: [PATCH] Consumer: add testpoints Signed-off-by: Mathieu Desnoyers --- src/bin/lttng-consumerd/Makefile.am | 1 + src/common/Makefile.am | 3 ++- src/common/consumer-testpoint.h | 31 +++++++++++++++++++++++++++++ src/common/consumer-timer.c | 9 ++++++++- src/common/consumer.c | 21 +++++++++++++++++++ 5 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 src/common/consumer-testpoint.h diff --git a/src/bin/lttng-consumerd/Makefile.am b/src/bin/lttng-consumerd/Makefile.am index 1aa0f27f7..28034ca34 100644 --- a/src/bin/lttng-consumerd/Makefile.am +++ b/src/bin/lttng-consumerd/Makefile.am @@ -13,6 +13,7 @@ lttng_consumerd_LDADD = \ $(top_builddir)/src/common/libcommon.la \ $(top_builddir)/src/common/index/libindex.la \ $(top_builddir)/src/common/health/libhealth.la \ + $(top_builddir)/src/common/testpoint/libtestpoint.la \ -lrt if HAVE_LIBLTTNG_UST_CTL diff --git a/src/common/Makefile.am b/src/common/Makefile.am index 3ba5fed51..1a764aec1 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -7,7 +7,8 @@ AM_CFLAGS = -fno-strict-aliasing noinst_HEADERS = lttng-kernel.h defaults.h macros.h error.h futex.h \ uri.h utils.h lttng-kernel-old.h \ - consumer-metadata-cache.h consumer-timer.h + consumer-metadata-cache.h consumer-timer.h \ + consumer-testpoint.h # Common library noinst_LTLIBRARIES = libcommon.la diff --git a/src/common/consumer-testpoint.h b/src/common/consumer-testpoint.h new file mode 100644 index 000000000..e94ce57a2 --- /dev/null +++ b/src/common/consumer-testpoint.h @@ -0,0 +1,31 @@ +#ifndef CONSUMERD_TESTPOINT_H +#define CONSUMERD_TESTPOINT_H + +/* + * Copyright (C) 2012 - Christian Babeux + * Copyright (C) 2014 - 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 + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include + +/* Testpoints, internal use only */ +TESTPOINT_DECL(consumerd_thread_channel); +TESTPOINT_DECL(consumerd_thread_metadata); +TESTPOINT_DECL(consumerd_thread_data); +TESTPOINT_DECL(consumerd_thread_sessiond); +TESTPOINT_DECL(consumerd_thread_metadata_timer); + +#endif /* CONSUMERD_TESTPOINT_H */ diff --git a/src/common/consumer-timer.c b/src/common/consumer-timer.c index b681ae763..b867a35bf 100644 --- a/src/common/consumer-timer.c +++ b/src/common/consumer-timer.c @@ -28,6 +28,7 @@ #include #include "consumer-timer.h" +#include "consumer-testpoint.h" #include "ust-consumer/ust-consumer.h" static struct timer_signal_data timer_signal = { @@ -472,6 +473,10 @@ void *consumer_timer_thread(void *data) health_register(health_consumerd, HEALTH_CONSUMERD_TYPE_METADATA_TIMER); + if (testpoint(consumerd_thread_metadata_timer)) { + goto error_testpoint; + } + health_code_update(); /* Only self thread will receive signal mask. */ @@ -503,7 +508,9 @@ void *consumer_timer_thread(void *data) } } - /* Currently never reached */ +error_testpoint: + /* Only reached in testpoint error */ + health_error(); health_unregister(health_consumerd); /* Never return */ diff --git a/src/common/consumer.c b/src/common/consumer.c index cbcb2f74d..36ec02479 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -45,6 +45,7 @@ #include "consumer.h" #include "consumer-stream.h" +#include "consumer-testpoint.h" struct lttng_consumer_global_data consumer_data = { .stream_count = 0, @@ -2254,6 +2255,10 @@ void *consumer_thread_metadata_poll(void *data) health_register(health_consumerd, HEALTH_CONSUMERD_TYPE_METADATA); + if (testpoint(consumerd_thread_metadata)) { + goto error_testpoint; + } + health_code_update(); DBG("Thread metadata poll started"); @@ -2428,6 +2433,7 @@ end: lttng_poll_clean(&events); end_poll: +error_testpoint: if (err) { health_error(); ERR("Health error occurred in %s", __func__); @@ -2456,6 +2462,10 @@ void *consumer_thread_data_poll(void *data) health_register(health_consumerd, HEALTH_CONSUMERD_TYPE_DATA); + if (testpoint(consumerd_thread_data)) { + goto error_testpoint; + } + health_code_update(); local_stream = zmalloc(sizeof(struct lttng_consumer_stream *)); @@ -2687,6 +2697,7 @@ end: */ (void) lttng_pipe_write_close(ctx->consumer_metadata_pipe); +error_testpoint: if (err) { health_error(); ERR("Health error occurred in %s", __func__); @@ -2787,6 +2798,10 @@ void *consumer_thread_channel_poll(void *data) health_register(health_consumerd, HEALTH_CONSUMERD_TYPE_CHANNEL); + if (testpoint(consumerd_thread_channel)) { + goto error_testpoint; + } + health_code_update(); channel_ht = lttng_ht_new(0, LTTNG_HT_TYPE_U64); @@ -2988,6 +3003,7 @@ end: end_poll: destroy_channel_ht(channel_ht); end_ht: +error_testpoint: DBG("Channel poll thread exiting"); if (err) { health_error(); @@ -3043,6 +3059,10 @@ void *consumer_thread_sessiond_poll(void *data) health_register(health_consumerd, HEALTH_CONSUMERD_TYPE_SESSIOND); + if (testpoint(consumerd_thread_sessiond)) { + goto error_testpoint; + } + health_code_update(); DBG("Creating command socket %s", ctx->consumer_command_sock_path); @@ -3179,6 +3199,7 @@ end: } } +error_testpoint: if (err) { health_error(); ERR("Health error occurred in %s", __func__); -- 2.34.1