From 9b5e086337f67aaf99375fc39d911d167fd8c778 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Sun, 26 Jan 2014 23:51:55 -0500 Subject: [PATCH] relayd: add testpoints Signed-off-by: Mathieu Desnoyers --- src/bin/lttng-relayd/Makefile.am | 5 +++-- src/bin/lttng-relayd/live.c | 16 ++++++++++++++++ src/bin/lttng-relayd/main.c | 16 ++++++++++++++++ src/bin/lttng-relayd/testpoint.h | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 src/bin/lttng-relayd/testpoint.h diff --git a/src/bin/lttng-relayd/Makefile.am b/src/bin/lttng-relayd/Makefile.am index 331b634b7..f940e3f90 100644 --- a/src/bin/lttng-relayd/Makefile.am +++ b/src/bin/lttng-relayd/Makefile.am @@ -13,7 +13,7 @@ lttng_relayd_SOURCES = main.c lttng-relayd.h utils.h utils.c cmd.h \ cmd-2-2.c cmd-2-2.h \ cmd-2-4.c cmd-2-4.h \ health-relayd.c health-relayd.h \ - lttng-viewer.h + lttng-viewer.h testpoint.h # link on liblttngctl for check if relayd is already alive. lttng_relayd_LDADD = -lrt -lurcu-common -lurcu \ @@ -24,4 +24,5 @@ lttng_relayd_LDADD = -lrt -lurcu-common -lurcu \ $(top_builddir)/src/common/compat/libcompat.la \ $(top_builddir)/src/common/index/libindex.la \ $(top_builddir)/src/common/health/libhealth.la \ - $(top_builddir)/src/common/config/libconfig.la + $(top_builddir)/src/common/config/libconfig.la \ + $(top_builddir)/src/common/testpoint/libtestpoint.la diff --git a/src/bin/lttng-relayd/live.c b/src/bin/lttng-relayd/live.c index bfa7b8525..80c3da57a 100644 --- a/src/bin/lttng-relayd/live.c +++ b/src/bin/lttng-relayd/live.c @@ -57,6 +57,7 @@ #include "lttng-viewer.h" #include "utils.h" #include "health-relayd.h" +#include "testpoint.h" static struct lttng_uri *live_uri; @@ -253,6 +254,10 @@ void *thread_listener(void *data) lttng_relay_notify_ready(); + if (testpoint(relayd_thread_live_listener)) { + goto error_testpoint; + } + while (1) { health_code_update(); @@ -340,6 +345,7 @@ restart: exit: error: error_poll_add: +error_testpoint: lttng_poll_clean(&events); error_create_poll: if (live_control_sock->fd >= 0) { @@ -375,6 +381,10 @@ void *thread_dispatcher(void *data) health_register(health_relayd, HEALTH_RELAYD_TYPE_LIVE_DISPATCHER); + if (testpoint(relayd_thread_live_dispatcher)) { + goto error_testpoint; + } + health_code_update(); while (!CMM_LOAD_SHARED(live_dispatch_thread_exit)) { @@ -423,6 +433,7 @@ void *thread_dispatcher(void *data) err = 0; error: +error_testpoint: if (err) { health_error(); ERR("Health error occurred in %s", __func__); @@ -1825,6 +1836,10 @@ void *thread_worker(void *data) health_register(health_relayd, HEALTH_RELAYD_TYPE_LIVE_WORKER); + if (testpoint(relayd_thread_live_worker)) { + goto error_testpoint; + } + /* table of connections indexed on socket */ relay_connections_ht = lttng_ht_new(0, LTTNG_HT_TYPE_ULONG); if (!relay_connections_ht) { @@ -1980,6 +1995,7 @@ relay_connections_ht_error: DBG("Viewer worker thread exited with error"); } DBG("Viewer worker thread cleanup complete"); +error_testpoint: if (err) { health_error(); ERR("Health error occurred in %s", __func__); diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c index 789e3300a..8e6cb4d28 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -61,6 +61,7 @@ #include "lttng-relayd.h" #include "live.h" #include "health-relayd.h" +#include "testpoint.h" /* command line options */ char *opt_output_path; @@ -753,6 +754,10 @@ void *relay_thread_listener(void *data) lttng_relay_notify_ready(); + if (testpoint(relayd_thread_listener)) { + goto error_testpoint; + } + while (1) { health_code_update(); @@ -853,6 +858,7 @@ restart: exit: error: error_poll_add: +error_testpoint: lttng_poll_clean(&events); error_create_poll: if (data_sock->fd >= 0) { @@ -896,6 +902,10 @@ void *relay_thread_dispatcher(void *data) health_register(health_relayd, HEALTH_RELAYD_TYPE_DISPATCHER); + if (testpoint(relayd_thread_dispatcher)) { + goto error_testpoint; + } + health_code_update(); while (!CMM_LOAD_SHARED(dispatch_thread_exit)) { @@ -942,6 +952,7 @@ void *relay_thread_dispatcher(void *data) err = 0; error: +error_testpoint: if (err) { health_error(); ERR("Health error occurred in %s", __func__); @@ -2560,6 +2571,10 @@ void *relay_thread_worker(void *data) health_register(health_relayd, HEALTH_RELAYD_TYPE_WORKER); + if (testpoint(relayd_thread_worker)) { + goto error_testpoint; + } + health_code_update(); /* table of connections indexed on socket */ @@ -2821,6 +2836,7 @@ relay_connections_ht_error: } DBG("Worker thread cleanup complete"); free(data_buffer); +error_testpoint: if (err) { health_error(); ERR("Health error occurred in %s", __func__); diff --git a/src/bin/lttng-relayd/testpoint.h b/src/bin/lttng-relayd/testpoint.h new file mode 100644 index 000000000..ceece09e3 --- /dev/null +++ b/src/bin/lttng-relayd/testpoint.h @@ -0,0 +1,32 @@ +#ifndef RELAYD_TESTPOINT_H +#define RELAYD_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(relayd_thread_dispatcher); +TESTPOINT_DECL(relayd_thread_worker); +TESTPOINT_DECL(relayd_thread_listener); +TESTPOINT_DECL(relayd_thread_live_dispatcher); +TESTPOINT_DECL(relayd_thread_live_worker); +TESTPOINT_DECL(relayd_thread_live_listener); + +#endif /* SESSIOND_TESTPOINT_H */ -- 2.34.1