Fix: sessiond: size-based rotation threshold exceeded in per-pid tracing (1/2)
[lttng-tools.git] / src / bin / lttng-sessiond / buffer-registry.cpp
index 64e98333ffb6549cb2ffc5ca849a4d598b8780f4..ab7d11ae4f51f093c4907f74a23377034cff3cf5 100644 (file)
@@ -8,15 +8,15 @@
 #define _LGPL_SOURCE
 #include <inttypes.h>
 
-#include <common/common.h>
-#include <common/hashtable/utils.h>
+#include <common/common.hpp>
+#include <common/hashtable/utils.hpp>
 
-#include "buffer-registry.h"
-#include "fd-limit.h"
-#include "ust-consumer.h"
-#include "lttng-ust-ctl.h"
-#include "lttng-ust-error.h"
-#include "utils.h"
+#include "buffer-registry.hpp"
+#include "fd-limit.hpp"
+#include "ust-consumer.hpp"
+#include "lttng-ust-ctl.hpp"
+#include "lttng-ust-error.hpp"
+#include "utils.hpp"
 
 /*
  * Set in main.c during initialization process of the daemon. This contains
@@ -104,14 +104,14 @@ int buffer_reg_uid_create(uint64_t session_id, uint32_t bits_per_long, uid_t uid
 
        LTTNG_ASSERT(regp);
 
-       reg = (buffer_reg_uid *) zmalloc(sizeof(*reg));
+       reg = zmalloc<buffer_reg_uid>();
        if (!reg) {
                PERROR("zmalloc buffer registry uid");
                ret = -ENOMEM;
                goto error;
        }
 
-       reg->registry = (buffer_reg_session *) zmalloc(sizeof(struct buffer_reg_session));
+       reg->registry = zmalloc<buffer_reg_session>();
        if (!reg->registry) {
                PERROR("zmalloc buffer registry uid session");
                ret = -ENOMEM;
@@ -202,7 +202,7 @@ struct buffer_reg_uid *buffer_reg_uid_find(uint64_t session_id,
        if (!node) {
                goto end;
        }
-       reg = caa_container_of(node, struct buffer_reg_uid, node);
+       reg = lttng::utils::container_of(node, &buffer_reg_uid::node);
 
 end:
        return reg;
@@ -234,14 +234,14 @@ int buffer_reg_pid_create(uint64_t session_id, struct buffer_reg_pid **regp,
 
        LTTNG_ASSERT(regp);
 
-       reg = (buffer_reg_pid *) zmalloc(sizeof(*reg));
+       reg = zmalloc<buffer_reg_pid>();
        if (!reg) {
                PERROR("zmalloc buffer registry pid");
                ret = -ENOMEM;
                goto error;
        }
 
-       reg->registry = (buffer_reg_session *) zmalloc(sizeof(struct buffer_reg_session));
+       reg->registry = zmalloc<buffer_reg_session>();
        if (!reg->registry) {
                PERROR("zmalloc buffer registry pid session");
                ret = -ENOMEM;
@@ -314,7 +314,7 @@ struct buffer_reg_pid *buffer_reg_pid_find(uint64_t session_id)
        if (!node) {
                goto end;
        }
-       reg = caa_container_of(node, struct buffer_reg_pid, node);
+       reg = lttng::utils::container_of(node, &buffer_reg_pid::node);
 
 end:
        return reg;
@@ -371,7 +371,7 @@ int buffer_reg_channel_create(uint64_t key, struct buffer_reg_channel **regp)
 
        DBG3("Buffer registry channel create with key: %" PRIu64, key);
 
-       reg = (buffer_reg_channel *) zmalloc(sizeof(*reg));
+       reg = zmalloc<buffer_reg_channel>();
        if (!reg) {
                PERROR("zmalloc buffer registry channel");
                return -ENOMEM;
@@ -401,7 +401,7 @@ int buffer_reg_stream_create(struct buffer_reg_stream **regp)
 
        DBG3("Buffer registry creating stream");
 
-       reg = (buffer_reg_stream *) zmalloc(sizeof(*reg));
+       reg = zmalloc<buffer_reg_stream>();
        if (!reg) {
                PERROR("zmalloc buffer registry stream");
                return -ENOMEM;
@@ -472,7 +472,7 @@ struct buffer_reg_channel *buffer_reg_channel_find(uint64_t key,
        if (!node) {
                goto end;
        }
-       chan = caa_container_of(node, struct buffer_reg_channel, node);
+       chan = lttng::utils::container_of(node, &buffer_reg_channel::node);
 
 end:
        return chan;
@@ -601,7 +601,6 @@ static void buffer_reg_session_destroy(struct buffer_reg_session *regp,
        switch (domain) {
        case LTTNG_DOMAIN_UST:
                ust_registry_session_destroy(regp->reg.ust);
-               free(regp->reg.ust);
                break;
        default:
                abort();
@@ -631,9 +630,9 @@ void buffer_reg_uid_remove(struct buffer_reg_uid *regp)
 static void rcu_free_buffer_reg_uid(struct rcu_head *head)
 {
        struct lttng_ht_node_u64 *node =
-               caa_container_of(head, struct lttng_ht_node_u64, head);
+               lttng::utils::container_of(head, &lttng_ht_node_u64::head);
        struct buffer_reg_uid *reg =
-               caa_container_of(node, struct buffer_reg_uid, node);
+               lttng::utils::container_of(node, &buffer_reg_uid::node);
 
        buffer_reg_session_destroy(reg->registry, reg->domain);
        free(reg);
@@ -642,9 +641,9 @@ static void rcu_free_buffer_reg_uid(struct rcu_head *head)
 static void rcu_free_buffer_reg_pid(struct rcu_head *head)
 {
        struct lttng_ht_node_u64 *node =
-               caa_container_of(head, struct lttng_ht_node_u64, head);
+               lttng::utils::container_of(head, &lttng_ht_node_u64::head);
        struct buffer_reg_pid *reg =
-               caa_container_of(node, struct buffer_reg_pid, node);
+               lttng::utils::container_of(node, &buffer_reg_pid::node);
 
        buffer_reg_session_destroy(reg->registry, LTTNG_DOMAIN_UST);
        free(reg);
@@ -681,10 +680,10 @@ void buffer_reg_uid_destroy(struct buffer_reg_uid *regp,
 
        switch (regp->domain) {
        case LTTNG_DOMAIN_UST:
-               if (regp->registry->reg.ust->metadata_key) {
+               if (regp->registry->reg.ust->_metadata_key) {
                        /* Return value does not matter. This call will print errors. */
                        (void) consumer_close_metadata(socket,
-                                       regp->registry->reg.ust->metadata_key);
+                                       regp->registry->reg.ust->_metadata_key);
                }
                break;
        default:
This page took 0.042497 seconds and 4 git commands to generate.