Fix: clarify tracefile size/count in lttng.1 man
[lttng-tools.git] / src / bin / lttng-sessiond / trace-ust.c
index 0c97d37f1c86883474dc731c7d329638a4d47e8b..51632bad4ed602bcbc52fc769cc346bb709c74b3 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "buffer-registry.h"
 #include "trace-ust.h"
+#include "utils.h"
 
 /*
  * Match function for the events hash table lookup.
@@ -228,7 +229,7 @@ struct ltt_ust_session *trace_ust_create_session(unsigned int session_id)
        return lus;
 
 error_consumer:
-       lttng_ht_destroy(lus->domain_global.channels);
+       ht_cleanup_push(lus->domain_global.channels);
        free(lus);
 error:
        return NULL;
@@ -384,8 +385,8 @@ struct ltt_ust_metadata *trace_ust_create_metadata(char *path)
        lum->attr.overwrite = DEFAULT_CHANNEL_OVERWRITE;
        lum->attr.subbuf_size = default_get_metadata_subbuf_size();
        lum->attr.num_subbuf = DEFAULT_METADATA_SUBBUF_NUM;
-       lum->attr.switch_timer_interval = DEFAULT_UST_CHANNEL_SWITCH_TIMER;
-       lum->attr.read_timer_interval = DEFAULT_UST_CHANNEL_READ_TIMER;
+       lum->attr.switch_timer_interval = DEFAULT_METADATA_SWITCH_TIMER;
+       lum->attr.read_timer_interval = DEFAULT_METADATA_READ_TIMER;
        lum->attr.output = LTTNG_UST_MMAP;
 
        lum->handle = -1;
@@ -474,14 +475,16 @@ static void destroy_contexts(struct lttng_ht *ht)
 
        assert(ht);
 
+       rcu_read_lock();
        cds_lfht_for_each_entry(ht->ht, &iter.iter, node, node) {
                ret = lttng_ht_del(ht, &iter);
                if (!ret) {
                        call_rcu(&node->head, destroy_context_rcu);
                }
        }
+       rcu_read_unlock();
 
-       lttng_ht_destroy(ht);
+       ht_cleanup_push(ht);
 }
 
 /*
@@ -520,34 +523,34 @@ static void destroy_events(struct lttng_ht *events)
 
        assert(events);
 
+       rcu_read_lock();
        cds_lfht_for_each_entry(events->ht, &iter.iter, node, node) {
                ret = lttng_ht_del(events, &iter);
                assert(!ret);
                call_rcu(&node->head, destroy_event_rcu);
        }
+       rcu_read_unlock();
 
-       lttng_ht_destroy(events);
+       ht_cleanup_push(events);
 }
 
 /*
  * Cleanup ust channel structure.
+ *
+ * Should _NOT_ be called with RCU read lock held.
  */
-void trace_ust_destroy_channel(struct ltt_ust_channel *channel)
+static void _trace_ust_destroy_channel(struct ltt_ust_channel *channel)
 {
        assert(channel);
 
        DBG2("Trace destroy UST channel %s", channel->name);
 
-       rcu_read_lock();
-
        /* Destroying all events of the channel */
        destroy_events(channel->events);
        /* Destroying all context of the channel */
        destroy_contexts(channel->ctx);
 
        free(channel);
-
-       rcu_read_unlock();
 }
 
 /*
@@ -560,7 +563,12 @@ static void destroy_channel_rcu(struct rcu_head *head)
        struct ltt_ust_channel *channel =
                caa_container_of(node, struct ltt_ust_channel, node);
 
-       trace_ust_destroy_channel(channel);
+       _trace_ust_destroy_channel(channel);
+}
+
+void trace_ust_destroy_channel(struct ltt_ust_channel *channel)
+{
+       call_rcu(&channel->node.head, destroy_channel_rcu);
 }
 
 /*
@@ -595,10 +603,9 @@ static void destroy_channels(struct lttng_ht *channels)
                assert(!ret);
                call_rcu(&node->head, destroy_channel_rcu);
        }
-
-       lttng_ht_destroy(channels);
-
        rcu_read_unlock();
+
+       ht_cleanup_push(channels);
 }
 
 /*
@@ -613,6 +620,8 @@ static void destroy_domain_global(struct ltt_ust_domain_global *dom)
 
 /*
  * Cleanup ust session structure
+ *
+ * Should *NOT* be called with RCU read-side lock held.
  */
 void trace_ust_destroy_session(struct ltt_ust_session *session)
 {
@@ -620,8 +629,6 @@ void trace_ust_destroy_session(struct ltt_ust_session *session)
 
        assert(session);
 
-       rcu_read_lock();
-
        DBG2("Trace UST destroy session %u", session->id);
 
        /* Cleaning up UST domain */
@@ -639,6 +646,4 @@ void trace_ust_destroy_session(struct ltt_ust_session *session)
        consumer_destroy_output(session->tmp_consumer);
 
        free(session);
-
-       rcu_read_unlock();
 }
This page took 0.024783 seconds and 4 git commands to generate.