From: Jérémie Galarneau Date: Mon, 3 Dec 2018 00:04:45 +0000 (-0500) Subject: Load session configurations from lttng-sessiond's main thread X-Git-Tag: v2.12.0-rc1~715 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=3316b9d604bd4607e255ca3bbed0ee3e980dde4a;p=lttng-tools.git Load session configurations from lttng-sessiond's main thread Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/Makefile.am b/src/bin/lttng-sessiond/Makefile.am index cb8da2d6c..eaf388b01 100644 --- a/src/bin/lttng-sessiond/Makefile.am +++ b/src/bin/lttng-sessiond/Makefile.am @@ -30,7 +30,6 @@ lttng_sessiond_SOURCES = utils.c utils.h \ snapshot.c snapshot.h \ agent.c agent.h \ save.h save.c \ - load-session-thread.h load-session-thread.c \ lttng-syscall.h lttng-syscall.c \ notification-thread.h notification-thread.c \ notification-thread-internal.h \ diff --git a/src/bin/lttng-sessiond/load-session-thread.c b/src/bin/lttng-sessiond/load-session-thread.c deleted file mode 100644 index a93a799f6..000000000 --- a/src/bin/lttng-sessiond/load-session-thread.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2014 - Jérémie Galarneau - * - * 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. - */ - -#define _LGPL_SOURCE -#include -#include - -#include "load-session-thread.h" -#include "lttng-sessiond.h" - -/* - * Destroy the thread data previously created with the init function. - */ -void load_session_destroy_data(struct load_session_thread_data *data) -{ - if (!data) { - return; - } -} - -/* - * Initialize the thread data. This MUST be called before the thread load - * session is created. - * - * Return 0 on success else a negative value. Note that the destroy function - * can be called with no or partially initialized data. - */ -int load_session_init_data(struct load_session_thread_data **data) -{ - struct load_session_thread_data *_data = NULL; - - assert(data); - - /* - * Allocate memory here since this function is called from the main thread - * can die *before* the end of the load session thread. - */ - _data = zmalloc(sizeof(*_data)); - if (!_data) { - PERROR("zmalloc load session info"); - goto error; - } - - *data = _data; - return 0; - -error: - free(_data); - return -1; -} - -/* - * This thread loads session configurations once the session daemon is - * ready to process client messages. - */ -void *thread_load_session(void *data) -{ - int ret; - struct load_session_thread_data *info = data; - - DBG("[load-session-thread] Load session"); - - /* Override existing session and autoload also. */ - ret = config_load_session(info->path, NULL, 1, 1, NULL); - if (ret) { - ERR("Session load failed: %s", error_get_str(ret)); - } - - sessiond_signal_parents(); - return NULL; -} diff --git a/src/bin/lttng-sessiond/load-session-thread.h b/src/bin/lttng-sessiond/load-session-thread.h deleted file mode 100644 index aaaea9189..000000000 --- a/src/bin/lttng-sessiond/load-session-thread.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2014 - Jérémie Galarneau - * - * 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. - */ - -#ifndef LOAD_SESSION_THREAD_H -#define LOAD_SESSION_THREAD_H - -#include - -/* Data passed to the thread. */ -struct load_session_thread_data { - /* Path where the sessions are located. */ - const char *path; -}; - -void *thread_load_session(void *data); - -int load_session_init_data(struct load_session_thread_data **data); -void load_session_destroy_data(struct load_session_thread_data *data); - -#endif /* LOAD_SESSION_THREAD_H */ diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 7038e6707..579d49ab8 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -72,7 +72,6 @@ #include "ust-thread.h" #include "agent-thread.h" #include "save.h" -#include "load-session-thread.h" #include "notification-thread.h" #include "notification-thread-commands.h" #include "rotation-thread.h" @@ -145,9 +144,6 @@ static const char *config_ignore_options[] = { "help", "version", "config" }; static int apps_cmd_pipe[2] = { -1, -1 }; static int apps_cmd_notify_pipe[2] = { -1, -1 }; -/* Pthread, Mutexes and Semaphores */ -static pthread_t load_session_thread; - /* * UST registration command queue. This queue is tied with a futex and uses a N * wakers / 1 waiter implemented and detailed in futex.c/.h @@ -161,9 +157,6 @@ static struct ust_cmd_queue ust_cmd_queue; static const char *module_proc_lttng = "/proc/lttng"; -/* Load session thread information to operate. */ -static struct load_session_thread_data *load_info; - /* * Section name to look for in the daemon configuration file. */ @@ -360,11 +353,6 @@ static void sessiond_cleanup(void) close_consumer_sockets(); - if (load_info) { - load_session_destroy_data(load_info); - free(load_info); - } - /* * We do NOT rmdir rundir because there are other processes * using it, for instance lttng-relayd, which can start in @@ -1737,7 +1725,6 @@ static void destroy_all_sessions_and_wait(void) int main(int argc, char **argv) { int ret = 0, retval = 0; - void *status; const char *env_app_timeout; struct lttng_pipe *ust32_channel_monitor_pipe = NULL, *ust64_channel_monitor_pipe = NULL, @@ -2080,12 +2067,6 @@ int main(int argc, char **argv) /* Initialize TCP timeout values */ lttcomm_inet_init(); - if (load_session_init_data(&load_info) < 0) { - retval = -1; - goto exit_init_data; - } - load_info->path = config.load_session_path.value; - /* Create health-check thread. */ if (!launch_health_management_thread()) { retval = -1; @@ -2178,29 +2159,23 @@ int main(int argc, char **argv) } } - /* Create session loading thread. */ - ret = pthread_create(&load_session_thread, default_pthread_attr(), - thread_load_session, load_info); + /* Load sessions. */ + ret = config_load_session(config.load_session_path.value, + NULL, 1, 1, NULL); if (ret) { - errno = ret; - PERROR("pthread_create load_session_thread"); + ERR("Session load failed: %s", error_get_str(ret)); retval = -1; - stop_threads(); goto exit_load_session; } + /* Initialization completed. */ + sessiond_signal_parents(); + /* * This is where we start awaiting program completion (e.g. through * signal that asks threads to teardown). */ - ret = pthread_join(load_session_thread, &status); - if (ret) { - errno = ret; - PERROR("pthread_join load_session_thread"); - retval = -1; - } - /* Initiate teardown once activity occurs on the quit pipe. */ sessiond_wait_for_quit_pipe(-1U); diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am index 8f7c11978..d8d60c8a5 100644 --- a/tests/unit/Makefile.am +++ b/tests/unit/Makefile.am @@ -41,7 +41,6 @@ test_uri_LDADD = $(LIBTAP) $(LIBCOMMON) $(LIBHASHTABLE) $(DL_LIBS) # Sessiond objects SESSIOND_OBJS = $(top_builddir)/src/bin/lttng-sessiond/buffer-registry.$(OBJEXT) \ - $(top_builddir)/src/bin/lttng-sessiond/load-session-thread.$(OBJEXT) \ $(top_builddir)/src/bin/lttng-sessiond/cmd.$(OBJEXT) \ $(top_builddir)/src/bin/lttng-sessiond/save.$(OBJEXT) \ $(top_builddir)/src/bin/lttng-sessiond/notification-thread-commands.$(OBJEXT) \