Fix: sessiond: ODR violation results in memory corruption
[lttng-tools.git] / src / bin / lttng-sessiond / dispatch.cpp
index 107e205c6f61a7fc49fbeb20275e9d506a7c008b..8e80c29855e934576b0a17f8814433d835f0114f 100644 (file)
 #include <stddef.h>
 #include <stdlib.h>
 #include <urcu.h>
-#include <common/futex.h>
-#include <common/macros.h>
-
-#include "dispatch.h"
-#include "ust-app.h"
-#include "testpoint.h"
-#include "fd-limit.h"
-#include "health-sessiond.h"
-#include "lttng-sessiond.h"
-#include "thread.h"
-
+#include <common/futex.hpp>
+#include <common/macros.hpp>
+
+#include "dispatch.hpp"
+#include "ust-app.hpp"
+#include "testpoint.hpp"
+#include "fd-limit.hpp"
+#include "health-sessiond.hpp"
+#include "lttng-sessiond.hpp"
+#include "thread.hpp"
+
+namespace {
 struct thread_notifiers {
        struct ust_cmd_queue *ust_cmd_queue;
        int apps_cmd_pipe_write_fd;
        int apps_cmd_notify_pipe_write_fd;
        int dispatch_thread_exit;
 };
+} /* namespace */
 
 /*
  * For each tracing session, update newly registered apps. The session list
@@ -231,6 +233,7 @@ static void *thread_dispatch_ust_registration(void *data)
        struct ust_reg_wait_node *wait_node = NULL, *tmp_wait_node;
        struct ust_reg_wait_queue wait_queue = {
                .count = 0,
+               .head = {},
        };
        struct thread_notifiers *notifiers = (thread_notifiers *) data;
 
@@ -291,7 +294,7 @@ static void *thread_dispatch_ust_registration(void *data)
                                        ust_cmd->reg_msg.major, ust_cmd->reg_msg.minor);
 
                        if (ust_cmd->reg_msg.type == LTTNG_UST_CTL_SOCKET_CMD) {
-                               wait_node = (ust_reg_wait_node *) zmalloc(sizeof(*wait_node));
+                               wait_node = zmalloc<ust_reg_wait_node>();
                                if (!wait_node) {
                                        PERROR("zmalloc wait_node dispatch");
                                        ret = close(ust_cmd->sock);
@@ -509,7 +512,7 @@ bool launch_ust_dispatch_thread(struct ust_cmd_queue *cmd_queue,
        struct lttng_thread *thread;
        struct thread_notifiers *notifiers;
 
-       notifiers = (thread_notifiers *) zmalloc(sizeof(*notifiers));
+       notifiers = zmalloc<thread_notifiers>();
        if (!notifiers) {
                goto error;
        }
This page took 0.023495 seconds and 4 git commands to generate.