Load session configurations from lttng-sessiond's main thread
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 3 Dec 2018 00:04:45 +0000 (19:04 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 10 Dec 2018 20:24:50 +0000 (15:24 -0500)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/Makefile.am
src/bin/lttng-sessiond/load-session-thread.c [deleted file]
src/bin/lttng-sessiond/load-session-thread.h [deleted file]
src/bin/lttng-sessiond/main.c
tests/unit/Makefile.am

index cb8da2d6c7453aecd43db848e1947a9a6b0cc17c..eaf388b015605566db372805929babec64fff526 100644 (file)
@@ -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 (file)
index a93a799..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2014 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <common/error.h>
-#include <common/config/session-config.h>
-
-#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 (file)
index aaaea91..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2014 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * 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 <semaphore.h>
-
-/* 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 */
index 7038e6707347a370471695ac795c5162f1983958..579d49ab8d5c1eff1c16ed8425e4f257dedd687a 100644 (file)
@@ -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);
 
index 8f7c11978cd6bd142b00a2d23381d84f0054501f..d8d60c8a510abdca79ec5f9e8bf8a81f36714991 100644 (file)
@@ -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) \
This page took 0.030031 seconds and 4 git commands to generate.