init private data
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 8 Nov 2011 14:59:54 +0000 (09:59 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 8 Nov 2011 14:59:54 +0000 (09:59 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/lttng/ust-events.h
liblttng-ust/ltt-events.c
liblttng-ust/ltt-ring-buffer-client.h
liblttng-ust/ltt-ring-buffer-metadata-client.h
liblttng-ust/lttng-ust-abi.c
libringbuffer/frontend.h
libringbuffer/ring_buffer_frontend.c

index 5068a3b35c3c53acd3c51e0f345f8e8bfb838535..9ce39701ad3aadf77c38595df96b4890a3d56940 100644 (file)
@@ -221,7 +221,8 @@ struct ltt_channel_ops {
                                unsigned int switch_timer_interval,
                                unsigned int read_timer_interval,
                                int *shm_fd, int *wait_fd,
-                               uint64_t *memory_map_size);
+                               uint64_t *memory_map_size,
+                               struct ltt_channel *chan_priv_init);
        void (*channel_destroy)(struct ltt_channel *ltt_chan);
        struct lttng_ust_lib_ring_buffer *(*buffer_read_open)(struct channel *chan,
                                struct lttng_ust_shm_handle *handle,
@@ -306,7 +307,8 @@ struct ltt_channel *ltt_channel_create(struct ltt_session *session,
                                       unsigned int switch_timer_interval,
                                       unsigned int read_timer_interval,
                                       int *shm_fd, int *wait_fd,
-                                      uint64_t *memory_map_size);
+                                      uint64_t *memory_map_size,
+                                      struct ltt_channel *chan_priv_init);
 struct ltt_channel *ltt_global_channel_create(struct ltt_session *session,
                                       int overwrite, void *buf_addr,
                                       size_t subbuf_size, size_t num_subbuf,
index d31412c6747490db0428826c0c028d2c36c25d6d..4c41531a6519c05d1373c53c43de738bbc98b952 100644 (file)
@@ -293,7 +293,8 @@ struct ltt_channel *ltt_channel_create(struct ltt_session *session,
                                       unsigned int switch_timer_interval,
                                       unsigned int read_timer_interval,
                                       int *shm_fd, int *wait_fd,
-                                      uint64_t *memory_map_size)
+                                      uint64_t *memory_map_size,
+                                      struct ltt_channel *chan_priv_init)
 {
        struct ltt_channel *chan = NULL;
        struct ltt_transport *transport;
@@ -306,6 +307,8 @@ struct ltt_channel *ltt_channel_create(struct ltt_session *session,
                       transport_name);
                goto notransport;
        }
+       chan_priv_init->id = session->free_chan_id++;
+       chan_priv_init->session = session;
        /*
         * Note: the channel creation op already writes into the packet
         * headers. Therefore the "chan" information used as input
@@ -314,11 +317,9 @@ struct ltt_channel *ltt_channel_create(struct ltt_session *session,
        chan = transport->ops.channel_create("[lttng]", buf_addr,
                        subbuf_size, num_subbuf, switch_timer_interval,
                        read_timer_interval, shm_fd, wait_fd,
-                       memory_map_size);
+                       memory_map_size, chan_priv_init);
        if (!chan)
                goto create_error;
-       chan->session = session;
-       chan->id = session->free_chan_id++;
        chan->enabled = 1;
        chan->ops = &transport->ops;
        cds_list_add(&chan->list, &session->chan);
index abbaf705282b7e07655dd26e6c2f17f3d0703f05..8844ae28cf8944650f99fcc7c3f2a833e15bd1d7 100644 (file)
@@ -386,7 +386,8 @@ struct ltt_channel *_channel_create(const char *name,
                                unsigned int switch_timer_interval,
                                unsigned int read_timer_interval,
                                int *shm_fd, int *wait_fd,
-                               uint64_t *memory_map_size)
+                               uint64_t *memory_map_size,
+                               struct ltt_channel *chan_priv_init)
 {
        void *priv;
        struct ltt_channel *ltt_chan = NULL;
@@ -394,6 +395,7 @@ struct ltt_channel *_channel_create(const char *name,
 
        handle = channel_create(&client_config, name,
                        &priv, __alignof__(*ltt_chan), sizeof(*ltt_chan),
+                       chan_priv_init,
                        buf_addr, subbuf_size, num_subbuf,
                        switch_timer_interval, read_timer_interval,
                        shm_fd, wait_fd, memory_map_size);
index 46aab3cce8d87d9300f2fcd032717e6a00cfd689..0fd4d22264614fcc6633e55b5b0caf26e2d5e7f6 100644 (file)
@@ -169,7 +169,8 @@ struct ltt_channel *_channel_create(const char *name,
                                unsigned int switch_timer_interval,
                                unsigned int read_timer_interval,
                                int *shm_fd, int *wait_fd,
-                               uint64_t *memory_map_size)
+                               uint64_t *memory_map_size,
+                               struct ltt_channel *chan_priv_init)
 {
        void *priv;
        struct ltt_channel *ltt_chan = NULL;
@@ -177,6 +178,7 @@ struct ltt_channel *_channel_create(const char *name,
 
        handle = channel_create(&client_config, name,
                        &priv, __alignof__(*ltt_chan), sizeof(*ltt_chan),
+                       chan_priv_init,
                        buf_addr, subbuf_size, num_subbuf,
                        switch_timer_interval, read_timer_interval,
                        shm_fd, wait_fd, memory_map_size);
index 639165eb3b21ad6a8606d7f3c0e720945f652d04..e7ef1579a575ff1212735b9f3f3c03cde46b7ed1 100644 (file)
@@ -370,6 +370,7 @@ int lttng_abi_create_channel(int session_objd,
        struct ltt_channel *chan;
        int chan_objd;
        int ret = 0;
+       struct ltt_channel chan_priv_init;
 
        chan_objd = objd_alloc(NULL, &lttng_channel_ops);
        if (chan_objd < 0) {
@@ -397,6 +398,10 @@ int lttng_abi_create_channel(int session_objd,
                transport_name = "<unknown>";
                break;
        }
+       memset(&chan_priv_init, 0, sizeof(chan_priv_init));
+       /* Copy of session UUID for consumer (availability through shm) */
+       memcpy(chan_priv_init.uuid, session->uuid, sizeof(session->uuid));
+       
        /*
         * We tolerate no failure path after channel creation. It will stay
         * invariant for the rest of the session.
@@ -408,7 +413,8 @@ int lttng_abi_create_channel(int session_objd,
                                  chan_param->read_timer_interval,
                                  &chan_param->shm_fd,
                                  &chan_param->wait_fd,
-                                 &chan_param->memory_map_size);
+                                 &chan_param->memory_map_size,
+                                 &chan_priv_init);
        if (!chan) {
                ret = -EINVAL;
                goto chan_error;
@@ -421,8 +427,6 @@ int lttng_abi_create_channel(int session_objd,
        }
        /* The channel created holds a reference on the session */
        objd_ref(session_objd);
-       /* Copy of session UUID for consumer (availability through shm) */
-       memcpy(chan->uuid, session->uuid, sizeof(session->uuid));
 
        return chan_objd;
 
index 993a391730d7ab7a3518301a27fcd12711982d6b..eb95e6225986a759df3e809be09ad6e955222d5a 100644 (file)
@@ -47,6 +47,7 @@ struct lttng_ust_shm_handle *channel_create(const struct lttng_ust_lib_ring_buff
                                void **priv_data,
                                size_t priv_data_align,
                                size_t priv_data_size,
+                               void *priv_data_init,
                                void *buf_addr,
                                size_t subbuf_size, size_t num_subbuf,
                                unsigned int switch_timer_interval,
index fdb4bdfcc9b4f0a289a2dac09facd5aefdb501a9..6de8336861e4dadc43d77cf4f77140c54f67f64f 100644 (file)
@@ -411,6 +411,7 @@ static void channel_free(struct channel *chan, struct lttng_ust_shm_handle *hand
  * @name: name of the channel
  * @priv_data: ring buffer client private data area pointer (output)
  * @priv_data_size: length, in bytes, of the private data area.
+ * @priv_data_init: initialization data for private data.
  * @buf_addr: pointer the the beginning of the preallocated buffer contiguous
  *            address mapping. It is used only by RING_BUFFER_STATIC
  *            configuration. It can be set to NULL for other backends.
@@ -429,6 +430,7 @@ struct lttng_ust_shm_handle *channel_create(const struct lttng_ust_lib_ring_buff
                   void **priv_data,
                   size_t priv_data_align,
                   size_t priv_data_size,
+                  void *priv_data_init,
                   void *buf_addr, size_t subbuf_size,
                   size_t num_subbuf, unsigned int switch_timer_interval,
                   unsigned int read_timer_interval,
@@ -486,6 +488,7 @@ struct lttng_ust_shm_handle *channel_create(const struct lttng_ust_lib_ring_buff
                if (!shmp(handle, priv_data_alloc))
                        goto error_append;
                *priv_data = channel_get_private(chan);
+               memcpy(*priv_data, priv_data_init, priv_data_size);
        } else {
                chan->priv_data_offset = -1;
                *priv_data = NULL;
This page took 0.031813 seconds and 4 git commands to generate.