From: Mathieu Desnoyers Date: Mon, 7 Nov 2011 05:24:20 +0000 (-0500) Subject: Fix shadow channel struct callback override in consumer X-Git-Tag: v1.9.1~125 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=7a7849896a95db678d916ccb7c5d91371828e3f8;p=lttng-ust.git Fix shadow channel struct callback override in consumer Signed-off-by: Mathieu Desnoyers --- diff --git a/include/lttng/ust-events.h b/include/lttng/ust-events.h index cb794b40..f6d76528 100644 --- a/include/lttng/ust-events.h +++ b/include/lttng/ust-events.h @@ -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); diff --git a/liblttng-ust-ctl/ustctl.c b/liblttng-ust-ctl/ustctl.c index 3d510f6e..b4234eff 100644 --- a/liblttng-ust-ctl/ustctl.c +++ b/liblttng-ust-ctl/ustctl.c @@ -23,6 +23,7 @@ #include #include #include +#include #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; } diff --git a/liblttng-ust/ltt-ring-buffer-client.h b/liblttng-ust/ltt-ring-buffer-client.h index b7d286d2..9bbcab90 100644 --- a/liblttng-ust/ltt-ring-buffer-client.h +++ b/liblttng-ust/ltt-ring-buffer-client.h @@ -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, diff --git a/liblttng-ust/ltt-ring-buffer-metadata-client.h b/liblttng-ust/ltt-ring-buffer-metadata-client.h index b541f3df..4f2620e0 100644 --- a/liblttng-ust/ltt-ring-buffer-metadata-client.h +++ b/liblttng-ust/ltt-ring-buffer-metadata-client.h @@ -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, diff --git a/libringbuffer/shm.c b/libringbuffer/shm.c index fc7fbfb2..781295be 100644 --- a/libringbuffer/shm.c +++ b/libringbuffer/shm.c @@ -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"); diff --git a/libringbuffer/shm_types.h b/libringbuffer/shm_types.h index 9869eb88..10fb1ae0 100644 --- a/libringbuffer/shm_types.h +++ b/libringbuffer/shm_types.h @@ -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; };