#include "event.h"
#include "kernel.h"
#include "kernel-consumer.h"
-#include "modprobe.h"
#include "shm.h"
#include "ust-ctl.h"
#include "ust-consumer.h"
#include "notification-thread.h"
#include "notification-thread-commands.h"
#include "rotation-thread.h"
-#include "lttng-syscall.h"
#include "agent.h"
#include "ht-cleanup.h"
#include "sessiond-config.h"
*/
static struct ust_cmd_queue ust_cmd_queue;
-static const char *module_proc_lttng = "/proc/lttng";
-
/*
* Section name to look for in the daemon configuration file.
*/
pthread_mutex_destroy(&session_list->lock);
- wait_consumer(&kconsumer_data);
- wait_consumer(&ustconsumer64_data);
- wait_consumer(&ustconsumer32_data);
-
DBG("Cleaning up all agent apps");
agent_app_ht_clean();
-
DBG("Closing all UST sockets");
ust_app_clean_list();
buffer_reg_destroy_registries();
+ close_consumer_sockets();
+
+ wait_consumer(&kconsumer_data);
+ wait_consumer(&ustconsumer64_data);
+ wait_consumer(&ustconsumer32_data);
+
if (is_root && !config.no_kernel) {
- DBG2("Closing kernel fd");
- if (kernel_tracer_fd >= 0) {
- ret = close(kernel_tracer_fd);
- if (ret) {
- PERROR("close");
- }
- }
- DBG("Unloading kernel modules");
- modprobe_remove_lttng_all();
- free(syscall_table);
+ cleanup_kernel_tracer();
}
- close_consumer_sockets();
-
/*
* We do NOT rmdir rundir because there are other processes
* using it, for instance lttng-relayd, which can start in
run_as_destroy_worker();
}
-/*
- * Setup necessary data for kernel tracer action.
- */
-static int init_kernel_tracer(void)
-{
- int ret;
-
- /* Modprobe lttng kernel modules */
- ret = modprobe_lttng_control();
- if (ret < 0) {
- goto error;
- }
-
- /* Open debugfs lttng */
- kernel_tracer_fd = open(module_proc_lttng, O_RDWR);
- if (kernel_tracer_fd < 0) {
- DBG("Failed to open %s", module_proc_lttng);
- goto error_open;
- }
-
- /* Validate kernel version */
- ret = kernel_validate_version(kernel_tracer_fd, &kernel_tracer_version,
- &kernel_tracer_abi_version);
- if (ret < 0) {
- goto error_version;
- }
-
- ret = modprobe_lttng_data();
- if (ret < 0) {
- goto error_modules;
- }
-
- ret = kernel_supports_ring_buffer_snapshot_sample_positions(
- kernel_tracer_fd);
- if (ret < 0) {
- goto error_modules;
- }
-
- if (ret < 1) {
- WARN("Kernel tracer does not support buffer monitoring. "
- "The monitoring timer of channels in the kernel domain "
- "will be set to 0 (disabled).");
- }
-
- DBG("Kernel tracer fd %d", kernel_tracer_fd);
- return 0;
-
-error_version:
- modprobe_remove_lttng_control();
- ret = close(kernel_tracer_fd);
- if (ret) {
- PERROR("close");
- }
- kernel_tracer_fd = -1;
- return LTTNG_ERR_KERN_VERSION;
-
-error_modules:
- ret = close(kernel_tracer_fd);
- if (ret) {
- PERROR("close");
- }
-
-error_open:
- modprobe_remove_lttng_control();
-
-error:
- WARN("No kernel tracer available");
- kernel_tracer_fd = -1;
- if (!is_root) {
- return LTTNG_ERR_NEED_ROOT_SESSIOND;
- } else {
- return LTTNG_ERR_KERN_NA;
- }
-}
-
static int string_match(const char *str1, const char *str2)
{
return (str1 && str2) && !strcmp(str1, str2);
goto unlock_session;
}
(void) cmd_stop_trace(session);
- (void) cmd_destroy_session(session,
- notification_thread_handle);
+ (void) cmd_destroy_session(session, notification_thread_handle,
+ NULL);
unlock_session:
session_unlock(session);
session_put(session);
/* Setup kernel tracer */
if (!config.no_kernel) {
init_kernel_tracer();
- if (kernel_tracer_fd >= 0) {
- ret = syscall_init_table();
- if (ret < 0) {
- ERR("Unable to populate syscall table. "
- "Syscall tracing won't work "
- "for this session daemon.");
- }
- }
}
/* Set ulimit for open files */
*/
/* Initiate teardown once activity occurs on the quit pipe. */
- sessiond_wait_for_quit_pipe(-1U);
+ sessiond_wait_for_quit_pipe(-1);
stop_threads:
/*