Use a "comm" variant of the LTTNG_OPTIONAL helper in sessiond-comm
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 4 Jul 2019 12:59:08 +0000 (08:59 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 25 Jul 2019 19:51:47 +0000 (15:51 -0400)
The LTTNG_OPTIONAL helper is currently communication safe (as long
as LTTNG_PACKED is used). However, this could change in the future.
An LTTNG_OPTIONAL_COMM alias is introduced in order to make it easier
to change the layout of LTTNG_OPTIONAL should it become necessary
in the future.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/optional.h
src/common/sessiond-comm/sessiond-comm.h

index 1da5fda5da21ac0e8d9acd9c4b7f9f3821b950a9..aee5fcc5ec911d9d17e97218632767348f827cb8 100644 (file)
@@ -32,9 +32,6 @@
  * Prefer using this macro where "special" values would be used, e.g.
  * -1ULL for uint64_t types.
  *
- * LTTNG_OPTIONAL should be combined with the LTTNG_PACKED macro when
- * used for IPC / network communication.
- *
  * Declaration example:
  * struct my_struct {
  *     int a;
                type value;  \
        }
 
+/*
+ * Alias used for communication structures. If the layout of an LTTNG_OPTIONAL
+ * is changed, the original layout should still be used for communication
+ * purposes.
+ *
+ * LTTNG_OPTIONAL_COMM should be combined with the LTTNG_PACKED macro when
+ * used for IPC / network communication.
+ */
+#define LTTNG_OPTIONAL_COMM LTTNG_OPTIONAL
+
 /*
  * This macro is available as a 'convenience' to allow sites that assume
  * an optional value is set to assert() that it is set when accessing it.
index 3b0093bfbc9e0d7d06d598a74ba6cace921ab6a2..d9177cf37d8554c723e94a80a448839071042fc6 100644 (file)
@@ -480,7 +480,7 @@ struct lttcomm_consumer_msg {
                        uint64_t channel_key;
                        uint64_t session_id;
                        /* ID of the session's current trace chunk. */
-                       LTTNG_OPTIONAL(uint64_t) LTTNG_PACKED chunk_id;
+                       LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED chunk_id;
                        char pathname[PATH_MAX];
                        uint64_t relayd_id;
                        /* nb_init_streams is the number of streams open initially. */
@@ -542,7 +542,7 @@ struct lttcomm_consumer_msg {
                        uint64_t relayd_id;                     /* Relayd id if apply. */
                        uint64_t key;                           /* Unique channel key. */
                        /* ID of the session's current trace chunk. */
-                       LTTNG_OPTIONAL(uint64_t) LTTNG_PACKED chunk_id;
+                       LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED chunk_id;
                        unsigned char uuid[UUID_LEN];   /* uuid for ust tracer. */
                        uint32_t chan_id;                       /* Channel ID on the tracer side. */
                        uint64_t tracefile_size;        /* bytes */
@@ -634,7 +634,7 @@ struct lttcomm_consumer_msg {
                         * `override_name` is left NULL (all-zeroes) if the
                         * chunk's name is not overriden.
                         */
-                       LTTNG_OPTIONAL(uint64_t) LTTNG_PACKED relayd_id;
+                       LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED relayd_id;
                        char override_name[LTTNG_NAME_MAX];
                        uint64_t session_id;
                        uint64_t chunk_id;
@@ -645,13 +645,13 @@ struct lttcomm_consumer_msg {
                        } LTTNG_PACKED credentials;
                } LTTNG_PACKED create_trace_chunk;
                struct {
-                       LTTNG_OPTIONAL(uint64_t) LTTNG_PACKED relayd_id;
+                       LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED relayd_id;
                        uint64_t session_id;
                        uint64_t chunk_id;
                        uint64_t close_timestamp;
                } LTTNG_PACKED close_trace_chunk;
                struct {
-                       LTTNG_OPTIONAL(uint64_t) LTTNG_PACKED relayd_id;
+                       LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED relayd_id;
                        uint64_t session_id;
                        uint64_t chunk_id;
                } LTTNG_PACKED trace_chunk_exists;
This page took 0.029035 seconds and 4 git commands to generate.