Clean-up: sessiond: move ust_registry_session under lttng::sessiond::ust
[lttng-tools.git] / src / bin / lttng-sessiond / trace-ust.cpp
index 285ff0811f3a9f5be3573cad48893d9985ad244d..6f423c9c6485d459afb5e452d5c0be476dd862a2 100644 (file)
@@ -24,6 +24,8 @@
 #include "ust-app.hpp"
 #include "agent.hpp"
 
+namespace lsu = lttng::sessiond::ust;
+
 /*
  * Match function for the events hash table lookup.
  *
@@ -271,7 +273,7 @@ struct ltt_ust_session *trace_ust_create_session(uint64_t session_id)
        struct ltt_ust_session *lus;
 
        /* Allocate a new ltt ust session */
-       lus = (ltt_ust_session *) zmalloc(sizeof(struct ltt_ust_session));
+       lus = zmalloc<ltt_ust_session>();
        if (lus == NULL) {
                PERROR("create ust session zmalloc");
                goto error_alloc;
@@ -350,7 +352,7 @@ struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *chan,
 
        LTTNG_ASSERT(chan);
 
-       luc = (ltt_ust_channel *) zmalloc(sizeof(struct ltt_ust_channel));
+       luc = zmalloc<ltt_ust_channel>();
        if (luc == NULL) {
                PERROR("ltt_ust_channel zmalloc");
                goto error;
@@ -463,7 +465,7 @@ enum lttng_error_code trace_ust_create_event(struct lttng_event *ev,
                goto error;
        }
 
-       local_ust_event = (ltt_ust_event *) zmalloc(sizeof(struct ltt_ust_event));
+       local_ust_event = zmalloc<ltt_ust_event>();
        if (local_ust_event == NULL) {
                PERROR("ust event zmalloc");
                ret = LTTNG_ERR_NOMEM;
@@ -687,7 +689,7 @@ struct ltt_ust_context *trace_ust_create_context(
                goto end;
        }
 
-       uctx = (ltt_ust_context *) zmalloc(sizeof(struct ltt_ust_context));
+       uctx = zmalloc<ltt_ust_context>();
        if (!uctx) {
                PERROR("zmalloc ltt_ust_context");
                goto end;
@@ -813,7 +815,7 @@ static int id_tracker_add_id(struct ust_id_tracker *id_tracker, int id)
                retval = LTTNG_ERR_PROCESS_ATTR_EXISTS;
                goto end;
        }
-       tracker_node = (ust_id_tracker_node *) zmalloc(sizeof(*tracker_node));
+       tracker_node = zmalloc<ust_id_tracker_node>();
        if (!tracker_node) {
                retval = LTTNG_ERR_NOMEM;
                goto end;
@@ -1353,6 +1355,33 @@ void trace_ust_delete_channel(struct lttng_ht *ht,
        LTTNG_ASSERT(!ret);
 }
 
+int trace_ust_regenerate_metadata(struct ltt_ust_session *usess)
+{
+       int ret = 0;
+       struct buffer_reg_uid *uid_reg = NULL;
+       struct buffer_reg_session *session_reg = NULL;
+
+       rcu_read_lock();
+       cds_list_for_each_entry(uid_reg, &usess->buffer_reg_uid_list, lnode) {
+               lsu::registry_session *registry;
+
+               session_reg = uid_reg->registry;
+               registry = session_reg->reg.ust;
+
+               try {
+                       registry->regenerate_metadata();
+               } catch (const std::exception& ex) {
+                       ERR("Failed to regenerate user space session metadata: %s", ex.what());
+                       ret = -1;
+                       goto end;
+               }
+       }
+
+end:
+       rcu_read_unlock();
+       return ret;
+}
+
 /*
  * Iterate over a hash table containing channels and cleanup safely.
  */
This page took 0.024746 seconds and 4 git commands to generate.