Fix shadow channel struct callback override in consumer
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 7 Nov 2011 05:24:20 +0000 (00:24 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 7 Nov 2011 05:24:20 +0000 (00:24 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/lttng/ust-events.h
liblttng-ust-ctl/ustctl.c
liblttng-ust/ltt-ring-buffer-client.h
liblttng-ust/ltt-ring-buffer-metadata-client.h
libringbuffer/shm.c
libringbuffer/shm_types.h

index cb794b40a511efc0c0f1fd1989c4aace3d2940b4..f6d765282ab8951e967d6cc2fecb0dcb045a86cd 100644 (file)
@@ -339,9 +339,9 @@ int lttng_add_procname_to_ctx(struct lttng_ctx **ctx);
 void lttng_context_vtid_reset(void);
 void lttng_context_vpid_reset(void);
 
-const struct lttng_ust_lib_ring_buffer_config *lttng_client_callbacks_metadata;
-const struct lttng_ust_lib_ring_buffer_config *lttng_client_callbacks_discard;
-const struct lttng_ust_lib_ring_buffer_config *lttng_client_callbacks_overwrite;
+const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_metadata;
+const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_discard;
+const struct lttng_ust_lib_ring_buffer_client_cb *lttng_client_callbacks_overwrite;
 
 struct cds_list_head ltt_transport_list;
 struct ltt_transport *ltt_transport_find(const char *name);
index 3d510f6e0760f334db9635996e7754e8e3ca78e5..b4234effc01212bb43f4150716429364a4f340e4 100644 (file)
@@ -23,6 +23,7 @@
 #include <lttng/usterr-signal-safe.h>
 #include <lttng/ust-comm.h>
 #include <lttng/ust-events.h>
+#include <sys/mman.h>
 
 #include "../libringbuffer/backend.h"
 #include "../libringbuffer/frontend.h"
@@ -422,6 +423,7 @@ struct lttng_ust_shm_handle *ustctl_map_channel(struct lttng_ust_object_data *ch
        struct channel *chan;
        size_t chan_size;
        struct lttng_ust_lib_ring_buffer_config *config;
+       int ret;
 
        handle = channel_handle_create(chan_data->shm_fd,
                chan_data->wait_fd,
@@ -474,6 +476,15 @@ struct lttng_ust_shm_handle *ustctl_map_channel(struct lttng_ust_object_data *ch
                channel_destroy(chan, handle, 1);
                return NULL;
        }
+       /* Replace the object table pointer. */
+       ret = munmap(handle->table->objects[0].memory_map,
+               handle->table->objects[0].memory_map_size);
+       if (ret) {
+               perror("munmap");
+               assert(0);
+       }
+       handle->table->objects[0].memory_map = (char *) handle->shadow_chan;
+       handle->table->objects[0].is_shadow = 1;
        return handle;
 }
 
index b7d286d210c7d723c4600d2c0d01c34316075f6b..9bbcab90b5494a78b8df3de310017b1c0fc0f402 100644 (file)
@@ -378,7 +378,7 @@ static const struct lttng_ust_lib_ring_buffer_config client_config = {
        .client_type = LTTNG_CLIENT_TYPE,
 };
 
-const struct lttng_ust_lib_ring_buffer_config *LTTNG_CLIENT_CALLBACKS = &client_config;
+const struct lttng_ust_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_config.cb;
 
 static
 struct ltt_channel *_channel_create(const char *name,
index b541f3df82e1d1af3759eba67d7c5fe9de30fdc3..4f2620e0a5426441b5aeb9a6e307e80199bfd388 100644 (file)
@@ -161,7 +161,7 @@ static const struct lttng_ust_lib_ring_buffer_config client_config = {
        .client_type = LTTNG_CLIENT_TYPE,
 };
 
-const struct lttng_ust_lib_ring_buffer_config *LTTNG_CLIENT_CALLBACKS = &client_config;
+const struct lttng_ust_lib_ring_buffer_client_cb *LTTNG_CLIENT_CALLBACKS = &client_config.cb;
 
 static
 struct ltt_channel *_channel_create(const char *name,
index fc7fbfb2c0642ca0c410ddae0c6cd1a45b5a792e..781295beb718c69057fb9ba54e89916fba5ad00c 100644 (file)
@@ -203,11 +203,13 @@ void shmp_object_destroy(struct shm_object *obj)
 {
        int ret, i;
 
-        ret = munmap(obj->memory_map, obj->memory_map_size);
-        if (ret) {
-                PERROR("umnmap");
-                assert(0);
-        }
+       if (!obj->is_shadow) {
+               ret = munmap(obj->memory_map, obj->memory_map_size);
+               if (ret) {
+                       PERROR("umnmap");
+                       assert(0);
+               }
+       }
        ret = close(obj->shm_fd);
        if (ret) {
                PERROR("close");
index 9869eb88a82af57f25d1c34bed6ef306a4c48478..10fb1ae005402d5e256b9b1d5bb8cf0480ec2049 100644 (file)
@@ -19,6 +19,7 @@ struct shm_object {
        int shm_fd;     /* shm fd */
        int wait_fd[2]; /* fd for wait/wakeup */
        char *memory_map;
+       int is_shadow;
        size_t memory_map_size;
        size_t allocated_len;
 };
This page took 0.030384 seconds and 4 git commands to generate.