Refactoring: struct lttng_channel_ops
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 16 Mar 2021 02:50:28 +0000 (22:50 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 16 Mar 2021 02:50:28 +0000 (22:50 -0400)
- Namespace this structure with lttng_ust_ prefix,
- Use struct_size extensibility scheme. There was no prior padding, so
  extensibility was an issue in the past.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ie8334f5f651f100aaea60ee83d3c8e2b6b300a5a

include/lttng/ust-events.h
liblttng-ust/lttng-ring-buffer-client.h
liblttng-ust/lttng-ring-buffer-metadata-client.h
liblttng-ust/ust-events-internal.h

index 164c82c4c8288617702a56edc5eec30ba341b6aa..d070a3cc1128d7909b9eec222498a8e551608a6c 100644 (file)
@@ -498,8 +498,14 @@ struct lttng_ust_shm_handle;
  * IMPORTANT: this structure is part of the ABI between the probe and
  * UST. Fields need to be only added at the end, never reordered, never
  * removed.
+ *
+ * The field @struct_size should be used to determine the size of the
+ * structure. It should be queried before using additional fields added
+ * at the end of the structure.
  */
-struct lttng_channel_ops {
+struct lttng_ust_channel_ops {
+       uint32_t struct_size;
+
        struct lttng_channel *(*channel_create)(const char *name,
                        void *buf_addr,
                        size_t subbuf_size, size_t num_subbuf,
@@ -527,6 +533,8 @@ struct lttng_channel_ops {
        int (*flush_buffer)(struct channel *chan, struct lttng_ust_shm_handle *handle);
        void (*event_strcpy)(struct lttng_ust_lib_ring_buffer_ctx *ctx,
                        const char *src, size_t len);
+
+       /* End of base ABI. Fields below should be used after checking struct_size. */
 };
 
 /*
@@ -548,7 +556,7 @@ struct lttng_channel {
        struct lttng_session *session;
        int objd;                       /* Object associated to channel */
        struct cds_list_head node;      /* Channel list in session */
-       const struct lttng_channel_ops *ops;
+       const struct lttng_ust_channel_ops *ops;
        int header_type;                /* 0: unset, 1: compact, 2: large */
        struct lttng_ust_shm_handle *handle;    /* shared-memory handle */
 
index 9cc862cf759166b1a4f57eafad4dc98aa72f5ac1..c3b77182c2b0223fec775a678d477a66cff60950 100644 (file)
@@ -792,6 +792,7 @@ int lttng_flush_buffer(struct channel *chan, struct lttng_ust_shm_handle *handle
 static struct lttng_transport lttng_relay_transport = {
        .name = "relay-" RING_BUFFER_MODE_TEMPLATE_STRING "-mmap",
        .ops = {
+               .struct_size = sizeof(struct lttng_ust_channel_ops),
                .channel_create = _channel_create,
                .channel_destroy = lttng_channel_destroy,
                .event_reserve = lttng_event_reserve,
index 5a3840c89ac050bfc3b77b9c4e94f20da57ed2a0..bb5c5dfe8abb2d1160ec0c256d7b98ff8ae4e6d9 100644 (file)
@@ -314,14 +314,14 @@ int lttng_flush_buffer(struct channel *chan, struct lttng_ust_shm_handle *handle
 static struct lttng_transport lttng_relay_transport = {
        .name = "relay-" RING_BUFFER_MODE_TEMPLATE_STRING "-mmap",
        .ops = {
+               .struct_size = sizeof(struct lttng_ust_channel_ops),
+
                .channel_create = _channel_create,
                .channel_destroy = lttng_channel_destroy,
                .event_reserve = lttng_event_reserve,
                .event_commit = lttng_event_commit,
                .event_write = lttng_event_write,
                .packet_avail_size = lttng_packet_avail_size,
-               //.get_reader_wait_queue = lttng_get_reader_wait_queue,
-               //.get_hp_wait_queue = lttng_get_hp_wait_queue,
                .is_finalized = lttng_is_finalized,
                .is_disabled = lttng_is_disabled,
                .flush_buffer = lttng_flush_buffer,
index f351e954767f0fe0e8c19a6f92fa82e15a507383..a3146b373a7d0c46b00e0a6163a6c2c2085e3b0c 100644 (file)
@@ -189,7 +189,7 @@ struct lttng_event_notifier_group {
 struct lttng_transport {
        char *name;
        struct cds_list_head node;
-       struct lttng_channel_ops ops;
+       struct lttng_ust_channel_ops ops;
        const struct lttng_ust_lib_ring_buffer_config *client_config;
 };
 
This page took 0.027325 seconds and 4 git commands to generate.