Fix: push metadata on stop for per-UID buffers
[lttng-tools.git] / src / bin / lttng-sessiond / trace-ust.c
index 7592d774177a43abb8782424084c711e371bcc5c..9eabf6225376360d2eef8e9d83d33b668e84c35e 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <inttypes.h>
 
 #include <common/common.h>
 #include <common/defaults.h>
 
 #include "buffer-registry.h"
 #include "trace-ust.h"
+#include "utils.h"
 
 /*
  * Match function for the events hash table lookup.
@@ -180,7 +182,7 @@ error:
  *
  * Return pointer to structure or NULL.
  */
-struct ltt_ust_session *trace_ust_create_session(unsigned int session_id)
+struct ltt_ust_session *trace_ust_create_session(uint64_t session_id)
 {
        struct ltt_ust_session *lus;
 
@@ -201,7 +203,7 @@ struct ltt_ust_session *trace_ust_create_session(unsigned int session_id)
         * during the session lifetime which is at the first enable channel and
         * only before start. The flag buffer_type_changed indicates the status.
         */
-       lus->buffer_type = LTTNG_BUFFER_PER_PID;
+       lus->buffer_type = LTTNG_BUFFER_PER_UID;
        /* Once set to 1, the buffer_type is immutable for the session. */
        lus->buffer_type_changed = 0;
        /* Init it in case it get used after allocation. */
@@ -228,7 +230,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 +386,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;
@@ -430,6 +432,9 @@ struct ltt_ust_context *trace_ust_create_context(
        case LTTNG_EVENT_CONTEXT_PROCNAME:
                utype = LTTNG_UST_CONTEXT_PROCNAME;
                break;
+       case LTTNG_EVENT_CONTEXT_IP:
+               utype = LTTNG_UST_CONTEXT_IP;
+               break;
        default:
                ERR("Invalid UST context");
                return NULL;
@@ -483,7 +488,7 @@ static void destroy_contexts(struct lttng_ht *ht)
        }
        rcu_read_unlock();
 
-       lttng_ht_destroy(ht);
+       ht_cleanup_push(ht);
 }
 
 /*
@@ -530,7 +535,7 @@ static void destroy_events(struct lttng_ht *events)
        }
        rcu_read_unlock();
 
-       lttng_ht_destroy(events);
+       ht_cleanup_push(events);
 }
 
 /*
@@ -570,6 +575,23 @@ void trace_ust_destroy_channel(struct ltt_ust_channel *channel)
        call_rcu(&channel->node.head, destroy_channel_rcu);
 }
 
+/*
+ * Remove an UST channel from a channel HT.
+ */
+void trace_ust_delete_channel(struct lttng_ht *ht,
+               struct ltt_ust_channel *channel)
+{
+       int ret;
+       struct lttng_ht_iter iter;
+
+       assert(ht);
+       assert(channel);
+
+       iter.iter.node = &channel->node.node;
+       ret = lttng_ht_del(ht, &iter);
+       assert(!ret);
+}
+
 /*
  * Cleanup ust metadata structure.
  */
@@ -604,7 +626,7 @@ static void destroy_channels(struct lttng_ht *channels)
        }
        rcu_read_unlock();
 
-       lttng_ht_destroy(channels);
+       ht_cleanup_push(channels);
 }
 
 /*
@@ -628,7 +650,7 @@ void trace_ust_destroy_session(struct ltt_ust_session *session)
 
        assert(session);
 
-       DBG2("Trace UST destroy session %u", session->id);
+       DBG2("Trace UST destroy session %" PRIu64, session->id);
 
        /* Cleaning up UST domain */
        destroy_domain_global(&session->domain_global);
This page took 0.02615 seconds and 5 git commands to generate.