Add type-checked versions of allocation and deallocations functions
[lttng-tools.git] / src / bin / lttng-sessiond / buffer-registry.cpp
index aca8ec1f227f54cc9f8fded46d8924c4b53841be..7a446633b8f878cbd6cfaad67a2a07ee33dd281b 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;
@@ -185,6 +185,8 @@ struct buffer_reg_uid *buffer_reg_uid_find(uint64_t session_id,
        struct buffer_reg_uid *reg = NULL, key;
        struct lttng_ht *ht = buffer_registry_uid;
 
+       ASSERT_RCU_READ_LOCKED();
+
        /* Setup key we are looking for. */
        key.session_id = session_id;
        key.bits_per_long = bits_per_long;
@@ -232,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;
@@ -369,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;
@@ -399,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;
@@ -574,8 +576,6 @@ void buffer_reg_channel_destroy(struct buffer_reg_channel *regp,
 
 /*
  * Destroy a buffer registry session with the given domain.
- *
- * Should *NOT* be called with RCU read-side lock held.
  */
 static void buffer_reg_session_destroy(struct buffer_reg_session *regp,
                enum lttng_domain_type domain)
@@ -596,7 +596,7 @@ static void buffer_reg_session_destroy(struct buffer_reg_session *regp,
        }
        rcu_read_unlock();
 
-       ht_cleanup_push(regp->channels);
+       lttng_ht_destroy(regp->channels);
 
        switch (domain) {
        case LTTNG_DOMAIN_UST:
@@ -735,12 +735,10 @@ void buffer_reg_pid_destroy(struct buffer_reg_pid *regp)
 
 /*
  * Destroy per PID and UID registry hash table.
- *
- * Should *NOT* be called with RCU read-side lock held.
  */
 void buffer_reg_destroy_registries(void)
 {
        DBG3("Buffer registry destroy all registry");
-       ht_cleanup_push(buffer_registry_uid);
-       ht_cleanup_push(buffer_registry_pid);
+       lttng_ht_destroy(buffer_registry_uid);
+       lttng_ht_destroy(buffer_registry_pid);
 }
This page took 0.026385 seconds and 4 git commands to generate.