common: move lttng_payload[_view] to libcommon
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 19 Jun 2020 22:43:47 +0000 (18:43 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 27 Jul 2020 20:31:05 +0000 (16:31 -0400)
The payload utils are moved from libsessiond-comm to libcommon since
they present a circular dependancy: a payload uses the dynamic buffer
utilities while the actions, triggers, and conditions make use of the
lttng_payload utilities.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ib448bde0e442e7660bb7a61cd629f29442715b21

23 files changed:
include/lttng/action/action-internal.h
include/lttng/condition/condition-internal.h
src/bin/lttng-sessiond/client.c
src/bin/lttng-sessiond/cmd.c
src/bin/lttng-sessiond/lttng-sessiond.h
src/common/Makefile.am
src/common/actions/group.c
src/common/actions/snapshot-session.c
src/common/notification.c
src/common/payload-view.c [new file with mode: 0644]
src/common/payload-view.h [new file with mode: 0644]
src/common/payload.c [new file with mode: 0644]
src/common/payload.h [new file with mode: 0644]
src/common/sessiond-comm/Makefile.am
src/common/sessiond-comm/payload-view.c [deleted file]
src/common/sessiond-comm/payload-view.h [deleted file]
src/common/sessiond-comm/payload.c [deleted file]
src/common/sessiond-comm/payload.h [deleted file]
src/common/snapshot.c
src/common/trigger.c
src/common/userspace-probe.c
src/lib/lttng-ctl/lttng-ctl.c
tests/unit/test_payload.c

index 57035d869d5dd47e435b8bdb448278aa114914ab..20faea69713e050db033beeaeccbef50aca6d913 100644 (file)
@@ -12,8 +12,8 @@
 #include <common/macros.h>
 #include <common/buffer-view.h>
 #include <common/dynamic-buffer.h>
 #include <common/macros.h>
 #include <common/buffer-view.h>
 #include <common/dynamic-buffer.h>
-#include <common/sessiond-comm/payload-view.h>
-#include <common/sessiond-comm/payload.h>
+#include <common/payload-view.h>
+#include <common/payload.h>
 #include <stdbool.h>
 #include <sys/types.h>
 #include <urcu/ref.h>
 #include <stdbool.h>
 #include <sys/types.h>
 #include <urcu/ref.h>
index 306272ab81e8b12d1ceb182e30160a48d5d54c7c..98a8309421684aa6d607ceb51834d0ed09743875 100644 (file)
@@ -10,8 +10,8 @@
 
 #include <lttng/condition/condition.h>
 #include <common/macros.h>
 
 #include <lttng/condition/condition.h>
 #include <common/macros.h>
-#include <common/sessiond-comm/payload-view.h>
-#include <common/sessiond-comm/payload.h>
+#include <common/payload-view.h>
+#include <common/payload.h>
 #include <stdbool.h>
 #include <urcu/list.h>
 #include <stdint.h>
 #include <stdbool.h>
 #include <urcu/list.h>
 #include <stdint.h>
index 04c04465f2659385282a42fe0dcdf2e75b59efb2..0238538501b04117cae42280b01a57d3a3c647c3 100644 (file)
@@ -11,8 +11,8 @@
 #include "common/compat/socket.h"
 #include "common/dynamic-buffer.h"
 #include "common/dynamic-array.h"
 #include "common/compat/socket.h"
 #include "common/dynamic-buffer.h"
 #include "common/dynamic-array.h"
-#include "common/sessiond-comm/payload.h"
-#include "common/sessiond-comm/payload-view.h"
+#include "common/payload.h"
+#include "common/payload-view.h"
 #include "common/sessiond-comm/sessiond-comm.h"
 #include "lttng/lttng-error.h"
 #include "lttng/tracker.h"
 #include "common/sessiond-comm/sessiond-comm.h"
 #include "lttng/lttng-error.h"
 #include "lttng/tracker.h"
index 200396df67688be647e3d56f74dbb2d47d9cc08d..8b78e627f88d545515fbd2125ffd7aa448e7efff 100644 (file)
@@ -7,7 +7,6 @@
  */
 
 #include "bin/lttng-sessiond/tracker.h"
  */
 
 #include "bin/lttng-sessiond/tracker.h"
-#include "common/sessiond-comm/payload.h"
 #include "lttng/lttng-error.h"
 #include "lttng/tracker.h"
 #define _LGPL_SOURCE
 #include "lttng/lttng-error.h"
 #include "lttng/tracker.h"
 #define _LGPL_SOURCE
@@ -27,8 +26,8 @@
 #include <common/kernel-ctl/kernel-ctl.h>
 #include <common/dynamic-buffer.h>
 #include <common/buffer-view.h>
 #include <common/kernel-ctl/kernel-ctl.h>
 #include <common/dynamic-buffer.h>
 #include <common/buffer-view.h>
-#include <common/sessiond-comm/payload.h>
-#include <common/sessiond-comm/payload-view.h>
+#include <common/payload.h>
+#include <common/payload-view.h>
 #include <common/trace-chunk.h>
 #include <lttng/location-internal.h>
 #include <lttng/trigger/trigger-internal.h>
 #include <common/trace-chunk.h>
 #include <lttng/location-internal.h>
 #include <lttng/trigger/trigger-internal.h>
index 6c83b6a34c96ede6515e75fad702824970c9744b..edc1bc115fbb9f5268108a8383d34f5b02c726e0 100644 (file)
@@ -13,7 +13,7 @@
 #include <urcu/wfcqueue.h>
 
 #include <common/sessiond-comm/sessiond-comm.h>
 #include <urcu/wfcqueue.h>
 
 #include <common/sessiond-comm/sessiond-comm.h>
-#include <common/sessiond-comm/payload.h>
+#include <common/payload.h>
 #include <common/compat/poll.h>
 #include <common/compat/socket.h>
 #include <common/uuid.h>
 #include <common/compat/poll.h>
 #include <common/compat/socket.h>
 #include <common/uuid.h>
index 32b28c82f57e4fc6e2c4d41772f39918363edc73..d071bdfdfca6f4bc3dcc6dcbc12dbc445a2586cb 100644 (file)
@@ -55,6 +55,8 @@ libcommon_la_SOURCES = \
        mi-lttng.c mi-lttng.h \
        notification.c \
        optional.h \
        mi-lttng.c mi-lttng.h \
        notification.c \
        optional.h \
+       payload.c payload.h \
+       payload-view.c payload-view.h \
        pipe.c pipe.h \
        readwrite.c readwrite.h \
        runas.c runas.h \
        pipe.c pipe.h \
        readwrite.c readwrite.h \
        runas.c runas.h \
index 5931eb38ba4534c64b59d843aa083576b39ec36f..1a434616f3d08fb1845f6d3c95faadeef029c59f 100644 (file)
@@ -7,8 +7,8 @@
 
 #include <assert.h>
 #include <common/dynamic-array.h>
 
 #include <assert.h>
 #include <common/dynamic-array.h>
-#include <common/sessiond-comm/payload.h>
-#include <common/sessiond-comm/payload-view.h>
+#include <common/payload.h>
+#include <common/payload-view.h>
 #include <common/error.h>
 #include <common/macros.h>
 #include <lttng/action/action-internal.h>
 #include <common/error.h>
 #include <common/macros.h>
 #include <lttng/action/action-internal.h>
index 058179633db411d6e29c42fc52c59af24b13fc94..667166770d30839c2ee13c066e70e1deb09223fb 100644 (file)
@@ -9,8 +9,8 @@
 #include <common/error.h>
 #include <common/macros.h>
 #include <common/snapshot.h>
 #include <common/error.h>
 #include <common/macros.h>
 #include <common/snapshot.h>
-#include <common/sessiond-comm/payload.h>
-#include <common/sessiond-comm/payload-view.h>
+#include <common/payload.h>
+#include <common/payload-view.h>
 #include <lttng/action/action-internal.h>
 #include <lttng/action/snapshot-session-internal.h>
 #include <lttng/action/snapshot-session.h>
 #include <lttng/action/action-internal.h>
 #include <lttng/action/snapshot-session-internal.h>
 #include <lttng/action/snapshot-session.h>
index 806c5561936a985142882636423c7e58c09c2269..2544d042fd8192ee309558df6b41e483dc4db3ca 100644 (file)
@@ -10,8 +10,8 @@
 #include <lttng/condition/evaluation-internal.h>
 #include <lttng/condition/condition.h>
 #include <lttng/condition/evaluation.h>
 #include <lttng/condition/evaluation-internal.h>
 #include <lttng/condition/condition.h>
 #include <lttng/condition/evaluation.h>
-#include <common/sessiond-comm/payload.h>
-#include <common/sessiond-comm/payload-view.h>
+#include <common/payload.h>
+#include <common/payload-view.h>
 #include <assert.h>
 
 LTTNG_HIDDEN
 #include <assert.h>
 
 LTTNG_HIDDEN
diff --git a/src/common/payload-view.c b/src/common/payload-view.c
new file mode 100644 (file)
index 0000000..fdfef61
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#include <common/buffer-view.h>
+#include "payload-view.h"
+#include "payload.h"
+#include <stddef.h>
+
+LTTNG_HIDDEN
+struct lttng_payload_view lttng_payload_view_from_payload(
+               const struct lttng_payload *payload, size_t offset,
+               ptrdiff_t len)
+{
+       return (struct lttng_payload_view) {
+               .buffer = lttng_buffer_view_from_dynamic_buffer(
+                       &payload->buffer, offset, len),
+               ._fds = payload->_fds,
+       };
+}
+
+LTTNG_HIDDEN
+struct lttng_payload_view lttng_payload_view_from_view(
+               struct lttng_payload_view *view, size_t offset,
+               ptrdiff_t len)
+{
+       return (struct lttng_payload_view) {
+               .buffer = lttng_buffer_view_from_view(
+                       &view->buffer, offset, len),
+               ._fds = view->_fds,
+               ._iterator.p_fds_position = &view->_iterator.fds_position,
+       };
+}
+
+LTTNG_HIDDEN
+struct lttng_payload_view lttng_payload_view_from_dynamic_buffer(
+               const struct lttng_dynamic_buffer *buffer, size_t offset,
+               ptrdiff_t len)
+{
+       return (struct lttng_payload_view) {
+               .buffer = lttng_buffer_view_from_dynamic_buffer(
+                       buffer, offset, len)
+       };
+}
+
+LTTNG_HIDDEN
+int lttng_payload_view_pop_fd(struct lttng_payload_view *view)
+{
+       int ret = 0;
+       size_t fd_count;
+       size_t *pos;
+
+       if (!view) {
+               ret = -1;
+               goto end;
+       }
+
+       fd_count = lttng_dynamic_array_get_count(&view->_fds);
+       pos = view->_iterator.p_fds_position ? view->_iterator.p_fds_position :
+               &view->_iterator.fds_position;
+
+       if (*pos >= fd_count) {
+               ret = -1;
+               goto end;
+       }
+
+       ret = *((int *) lttng_dynamic_array_get_element(
+                       &view->_fds, *pos));
+       (*pos)++;
+end:
+       return ret;
+}
diff --git a/src/common/payload-view.h b/src/common/payload-view.h
new file mode 100644 (file)
index 0000000..f125e88
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_PAYLOAD_VIEW_H
+#define LTTNG_PAYLOAD_VIEW_H
+
+#include <common/buffer-view.h>
+#include <common/dynamic-array.h>
+
+struct lttng_payload;
+
+/*
+ * An lttng_payload_view references a payload and allows code to share
+ * a `const` version of a subset of a payload.
+ *
+ * A payload view is invalidated whenever its source (a payload, or another
+ * payload view) is modified.
+ *
+ * While a payload view does not allow users to modify the underlying bytes
+ * of the payload, it can be used to 'pop' file descriptors using an iterator
+ * belonging to the top-level payload view.
+ *
+ * Hence, a payload view created from a        payload or a dynamic buffer contains
+ * an implicit file descriptor iterator. Any payload view created from another
+ * payload view will share the same underlying file descriptor iterator.
+ *
+ * The rationale for this is that a payload is never consumed directly, it
+ * must be consumed through a payload view.
+ *
+ * Typically, a payload view will be used to rebuild a previously serialized
+ * object hierarchy. Sharing an underlying iterator allows aggregate objects
+ * to provide a restricted view of the payload to their members, which will
+ * report the number of bytes consumed and `pop` the file descriptors they
+ * should own. In return, those objects can create an even narrower view for
+ * their children, allowing them to also consume file descriptors.
+ *
+ * Note that a payload view never assumes any ownership of the underlying
+ * payload.
+ */
+struct lttng_payload_view {
+       struct lttng_buffer_view buffer;
+       /* private */
+       const struct lttng_dynamic_array _fds;
+       struct {
+               size_t *p_fds_position;
+               size_t fds_position;
+       } _iterator;
+};
+
+/**
+ * Return a payload view referencing a subset of a payload.
+ *
+ * @payload    Source payload to reference
+ * @offset     Offset to apply to the payload's buffer
+ * @len                Length of the contents to reference. Passing -1 will
+ *             cause the view to reference the whole payload from the
+ *             offset provided.
+ */
+LTTNG_HIDDEN
+struct lttng_payload_view lttng_payload_view_from_payload(
+               const struct lttng_payload *payload, size_t offset,
+               ptrdiff_t len);
+
+/**
+ * Return a payload view referencing a subset of a payload referenced by
+ * another payload view.
+ *
+ * @view       Source payload view to reference
+ * @offset     Offset to apply to the payload view's buffer view
+ * @len                Length of the contents to reference. Passing -1 will
+ *             cause the payload view to reference the whole payload view's
+ *             buffer view from the offset provided.
+ */
+LTTNG_HIDDEN
+struct lttng_payload_view lttng_payload_view_from_view(
+               struct lttng_payload_view *view, size_t offset,
+               ptrdiff_t len);
+
+/**
+ * Return a payload view referencing a subset of a dynamic buffer.
+ *
+ * Meant as an adapter for code paths that need to create a payload view
+ * from an existing dynamic buffer.
+ *
+ * @src                Source dynamic buffer to reference
+ * @offset     Offset to apply to the payload's buffer
+ * @len                Length of the buffer contents to reference. Passing -1 will
+ *             cause the payload view to reference the whole payload from the
+ *             offset provided.
+ */
+LTTNG_HIDDEN
+struct lttng_payload_view lttng_payload_view_from_dynamic_buffer(
+               const struct lttng_dynamic_buffer *buffer, size_t offset,
+               ptrdiff_t len);
+
+/**
+ * Pop an fd from a payload view.
+ * No ownership of the file descriptor is assumed by the payload.
+ *
+ * @payload    Payload instance
+ *
+ * Returns a file descriptor on success, -1 on error.
+ */
+LTTNG_HIDDEN
+int lttng_payload_view_pop_fd(struct lttng_payload_view *payload_view);
+
+#endif /* LTTNG_PAYLOAD_VIEW_H */
diff --git a/src/common/payload.c b/src/common/payload.c
new file mode 100644 (file)
index 0000000..592964a
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#include "payload.h"
+
+LTTNG_HIDDEN
+void lttng_payload_init(struct lttng_payload *payload)
+{
+       assert(payload);
+       lttng_dynamic_buffer_init(&payload->buffer);
+       lttng_dynamic_array_init(&payload->_fds, sizeof(int), NULL);
+}
+
+LTTNG_HIDDEN
+void lttng_payload_reset(struct lttng_payload *payload)
+{
+       if (!payload) {
+               return;
+       }
+
+       lttng_dynamic_buffer_reset(&payload->buffer);
+       lttng_dynamic_array_reset(&payload->_fds);
+}
+
+LTTNG_HIDDEN
+int lttng_payload_push_fd(struct lttng_payload *payload, int fd)
+{
+       int ret;
+
+       if (!payload) {
+               ret = -1;
+               goto end;
+       }
+
+       ret = lttng_dynamic_array_add_element(&payload->_fds, &fd);
+end:
+       return ret;
+}
diff --git a/src/common/payload.h b/src/common/payload.h
new file mode 100644 (file)
index 0000000..3f1aa8c
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
+ *
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ */
+
+#ifndef LTTNG_PAYLOAD_H
+#define LTTNG_PAYLOAD_H
+
+#include <common/dynamic-buffer.h>
+#include <common/dynamic-array.h>
+
+/*
+ * An lttng_payload encompasses the 'data' (bytes) and any passed file
+ * descriptors as part of a message between liblttng-ctl and the session
+ * daemon.
+ */
+struct lttng_payload {
+       struct lttng_dynamic_buffer buffer;
+       /* private */
+       struct lttng_dynamic_array _fds;
+};
+
+/*
+ * Initialize a payload. This performs no allocation and is meant
+ * to be used instead.
+ */
+LTTNG_HIDDEN
+void lttng_payload_init(struct lttng_payload *payload);
+
+/* Release any memory used by the payload. */
+LTTNG_HIDDEN
+void lttng_payload_reset(struct lttng_payload *payload);
+
+/**
+ * Add an fd to the payload.
+ * No ownership of the file descriptor is assumed by the payload.
+ *
+ * @payload    Payload instance
+ * @fd         File descriptor to add to the payload
+ *
+ * Returns 0 on success, -1 on allocation error.
+ */
+LTTNG_HIDDEN
+int lttng_payload_push_fd(struct lttng_payload *payload, int fd);
+
+#endif /* LTTNG_PAYLOAD_H */
index 0e7eb49227eb401b0db0ce8492664b13bfb8af10..d026651a66f0ef7253ae133459955ccf1f2d0638 100644 (file)
@@ -4,5 +4,4 @@ noinst_LTLIBRARIES = libsessiond-comm.la
 
 libsessiond_comm_la_SOURCES = sessiond-comm.c sessiond-comm.h \
                               inet.c inet.h inet6.c inet6.h \
 
 libsessiond_comm_la_SOURCES = sessiond-comm.c sessiond-comm.h \
                               inet.c inet.h inet6.c inet6.h \
-                              relayd.h agent.h payload.h \
-                              payload.c payload-view.h payload-view.c
+                              relayd.h agent.h
diff --git a/src/common/sessiond-comm/payload-view.c b/src/common/sessiond-comm/payload-view.c
deleted file mode 100644 (file)
index fdfef61..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#include <common/buffer-view.h>
-#include "payload-view.h"
-#include "payload.h"
-#include <stddef.h>
-
-LTTNG_HIDDEN
-struct lttng_payload_view lttng_payload_view_from_payload(
-               const struct lttng_payload *payload, size_t offset,
-               ptrdiff_t len)
-{
-       return (struct lttng_payload_view) {
-               .buffer = lttng_buffer_view_from_dynamic_buffer(
-                       &payload->buffer, offset, len),
-               ._fds = payload->_fds,
-       };
-}
-
-LTTNG_HIDDEN
-struct lttng_payload_view lttng_payload_view_from_view(
-               struct lttng_payload_view *view, size_t offset,
-               ptrdiff_t len)
-{
-       return (struct lttng_payload_view) {
-               .buffer = lttng_buffer_view_from_view(
-                       &view->buffer, offset, len),
-               ._fds = view->_fds,
-               ._iterator.p_fds_position = &view->_iterator.fds_position,
-       };
-}
-
-LTTNG_HIDDEN
-struct lttng_payload_view lttng_payload_view_from_dynamic_buffer(
-               const struct lttng_dynamic_buffer *buffer, size_t offset,
-               ptrdiff_t len)
-{
-       return (struct lttng_payload_view) {
-               .buffer = lttng_buffer_view_from_dynamic_buffer(
-                       buffer, offset, len)
-       };
-}
-
-LTTNG_HIDDEN
-int lttng_payload_view_pop_fd(struct lttng_payload_view *view)
-{
-       int ret = 0;
-       size_t fd_count;
-       size_t *pos;
-
-       if (!view) {
-               ret = -1;
-               goto end;
-       }
-
-       fd_count = lttng_dynamic_array_get_count(&view->_fds);
-       pos = view->_iterator.p_fds_position ? view->_iterator.p_fds_position :
-               &view->_iterator.fds_position;
-
-       if (*pos >= fd_count) {
-               ret = -1;
-               goto end;
-       }
-
-       ret = *((int *) lttng_dynamic_array_get_element(
-                       &view->_fds, *pos));
-       (*pos)++;
-end:
-       return ret;
-}
diff --git a/src/common/sessiond-comm/payload-view.h b/src/common/sessiond-comm/payload-view.h
deleted file mode 100644 (file)
index f125e88..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_PAYLOAD_VIEW_H
-#define LTTNG_PAYLOAD_VIEW_H
-
-#include <common/buffer-view.h>
-#include <common/dynamic-array.h>
-
-struct lttng_payload;
-
-/*
- * An lttng_payload_view references a payload and allows code to share
- * a `const` version of a subset of a payload.
- *
- * A payload view is invalidated whenever its source (a payload, or another
- * payload view) is modified.
- *
- * While a payload view does not allow users to modify the underlying bytes
- * of the payload, it can be used to 'pop' file descriptors using an iterator
- * belonging to the top-level payload view.
- *
- * Hence, a payload view created from a        payload or a dynamic buffer contains
- * an implicit file descriptor iterator. Any payload view created from another
- * payload view will share the same underlying file descriptor iterator.
- *
- * The rationale for this is that a payload is never consumed directly, it
- * must be consumed through a payload view.
- *
- * Typically, a payload view will be used to rebuild a previously serialized
- * object hierarchy. Sharing an underlying iterator allows aggregate objects
- * to provide a restricted view of the payload to their members, which will
- * report the number of bytes consumed and `pop` the file descriptors they
- * should own. In return, those objects can create an even narrower view for
- * their children, allowing them to also consume file descriptors.
- *
- * Note that a payload view never assumes any ownership of the underlying
- * payload.
- */
-struct lttng_payload_view {
-       struct lttng_buffer_view buffer;
-       /* private */
-       const struct lttng_dynamic_array _fds;
-       struct {
-               size_t *p_fds_position;
-               size_t fds_position;
-       } _iterator;
-};
-
-/**
- * Return a payload view referencing a subset of a payload.
- *
- * @payload    Source payload to reference
- * @offset     Offset to apply to the payload's buffer
- * @len                Length of the contents to reference. Passing -1 will
- *             cause the view to reference the whole payload from the
- *             offset provided.
- */
-LTTNG_HIDDEN
-struct lttng_payload_view lttng_payload_view_from_payload(
-               const struct lttng_payload *payload, size_t offset,
-               ptrdiff_t len);
-
-/**
- * Return a payload view referencing a subset of a payload referenced by
- * another payload view.
- *
- * @view       Source payload view to reference
- * @offset     Offset to apply to the payload view's buffer view
- * @len                Length of the contents to reference. Passing -1 will
- *             cause the payload view to reference the whole payload view's
- *             buffer view from the offset provided.
- */
-LTTNG_HIDDEN
-struct lttng_payload_view lttng_payload_view_from_view(
-               struct lttng_payload_view *view, size_t offset,
-               ptrdiff_t len);
-
-/**
- * Return a payload view referencing a subset of a dynamic buffer.
- *
- * Meant as an adapter for code paths that need to create a payload view
- * from an existing dynamic buffer.
- *
- * @src                Source dynamic buffer to reference
- * @offset     Offset to apply to the payload's buffer
- * @len                Length of the buffer contents to reference. Passing -1 will
- *             cause the payload view to reference the whole payload from the
- *             offset provided.
- */
-LTTNG_HIDDEN
-struct lttng_payload_view lttng_payload_view_from_dynamic_buffer(
-               const struct lttng_dynamic_buffer *buffer, size_t offset,
-               ptrdiff_t len);
-
-/**
- * Pop an fd from a payload view.
- * No ownership of the file descriptor is assumed by the payload.
- *
- * @payload    Payload instance
- *
- * Returns a file descriptor on success, -1 on error.
- */
-LTTNG_HIDDEN
-int lttng_payload_view_pop_fd(struct lttng_payload_view *payload_view);
-
-#endif /* LTTNG_PAYLOAD_VIEW_H */
diff --git a/src/common/sessiond-comm/payload.c b/src/common/sessiond-comm/payload.c
deleted file mode 100644 (file)
index 592964a..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#include "payload.h"
-
-LTTNG_HIDDEN
-void lttng_payload_init(struct lttng_payload *payload)
-{
-       assert(payload);
-       lttng_dynamic_buffer_init(&payload->buffer);
-       lttng_dynamic_array_init(&payload->_fds, sizeof(int), NULL);
-}
-
-LTTNG_HIDDEN
-void lttng_payload_reset(struct lttng_payload *payload)
-{
-       if (!payload) {
-               return;
-       }
-
-       lttng_dynamic_buffer_reset(&payload->buffer);
-       lttng_dynamic_array_reset(&payload->_fds);
-}
-
-LTTNG_HIDDEN
-int lttng_payload_push_fd(struct lttng_payload *payload, int fd)
-{
-       int ret;
-
-       if (!payload) {
-               ret = -1;
-               goto end;
-       }
-
-       ret = lttng_dynamic_array_add_element(&payload->_fds, &fd);
-end:
-       return ret;
-}
diff --git a/src/common/sessiond-comm/payload.h b/src/common/sessiond-comm/payload.h
deleted file mode 100644 (file)
index 3f1aa8c..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * SPDX-License-Identifier: LGPL-2.1-only
- *
- */
-
-#ifndef LTTNG_PAYLOAD_H
-#define LTTNG_PAYLOAD_H
-
-#include <common/dynamic-buffer.h>
-#include <common/dynamic-array.h>
-
-/*
- * An lttng_payload encompasses the 'data' (bytes) and any passed file
- * descriptors as part of a message between liblttng-ctl and the session
- * daemon.
- */
-struct lttng_payload {
-       struct lttng_dynamic_buffer buffer;
-       /* private */
-       struct lttng_dynamic_array _fds;
-};
-
-/*
- * Initialize a payload. This performs no allocation and is meant
- * to be used instead.
- */
-LTTNG_HIDDEN
-void lttng_payload_init(struct lttng_payload *payload);
-
-/* Release any memory used by the payload. */
-LTTNG_HIDDEN
-void lttng_payload_reset(struct lttng_payload *payload);
-
-/**
- * Add an fd to the payload.
- * No ownership of the file descriptor is assumed by the payload.
- *
- * @payload    Payload instance
- * @fd         File descriptor to add to the payload
- *
- * Returns 0 on success, -1 on allocation error.
- */
-LTTNG_HIDDEN
-int lttng_payload_push_fd(struct lttng_payload *payload, int fd);
-
-#endif /* LTTNG_PAYLOAD_H */
index c2efcc02b80523bd4193f21d2b3f126c980d5c7b..b0bebc81d19f803edca1009e0eacf1e157e34d58 100644 (file)
@@ -5,8 +5,8 @@
  *
  */
 
  *
  */
 
-#include <common/sessiond-comm/payload.h>
-#include <common/sessiond-comm/payload-view.h>
+#include <common/payload.h>
+#include <common/payload-view.h>
 #include <common/snapshot.h>
 #include <lttng/snapshot-internal.h>
 #include <lttng/snapshot.h>
 #include <common/snapshot.h>
 #include <lttng/snapshot-internal.h>
 #include <lttng/snapshot.h>
index 57f84d6a6becf6579b6ddff5f3e9bf66b4a4533a..5ff478a46f220c7815dd0f4db48343d7577e7690 100644 (file)
@@ -8,8 +8,8 @@
 #include <lttng/trigger/trigger-internal.h>
 #include <lttng/condition/condition-internal.h>
 #include <lttng/action/action-internal.h>
 #include <lttng/trigger/trigger-internal.h>
 #include <lttng/condition/condition-internal.h>
 #include <lttng/action/action-internal.h>
-#include <common/sessiond-comm/payload.h>
-#include <common/sessiond-comm/payload-view.h>
+#include <common/payload.h>
+#include <common/payload-view.h>
 #include <common/error.h>
 #include <assert.h>
 
 #include <common/error.h>
 #include <assert.h>
 
index 8c6adaca620b62d6fb7a47a94cbf67bffb051d7f..e6c987c2326839e4c2577a1509919a3dd369230e 100644 (file)
@@ -9,6 +9,8 @@
 #include <common/compat/string.h>
 #include <common/error.h>
 #include <common/macros.h>
 #include <common/compat/string.h>
 #include <common/error.h>
 #include <common/macros.h>
+#include <common/payload.h>
+#include <common/payload-view.h>
 #include <fcntl.h>
 #include <lttng/constant.h>
 #include <lttng/userspace-probe-internal.h>
 #include <fcntl.h>
 #include <lttng/constant.h>
 #include <lttng/userspace-probe-internal.h>
index b74c78749857bbc2a26c5799a9dd08bf06670ea7..d1b2fdfd9482ed479872965425b629831a60fdef 100644 (file)
@@ -23,8 +23,8 @@
 #include <common/compat/string.h>
 #include <common/defaults.h>
 #include <common/dynamic-buffer.h>
 #include <common/compat/string.h>
 #include <common/defaults.h>
 #include <common/dynamic-buffer.h>
-#include <common/sessiond-comm/payload.h>
-#include <common/sessiond-comm/payload-view.h>
+#include <common/payload.h>
+#include <common/payload-view.h>
 #include <common/sessiond-comm/sessiond-comm.h>
 #include <common/tracker.h>
 #include <common/uri.h>
 #include <common/sessiond-comm/sessiond-comm.h>
 #include <common/tracker.h>
 #include <common/uri.h>
index 50f08cd759661e3e12981130d5cb554b66b5a273..11c57f21de911e842f53a95c0342558fe2a81f15 100644 (file)
@@ -5,8 +5,8 @@
  *
  */
 
  *
  */
 
-#include <common/sessiond-comm/payload.h>
-#include <common/sessiond-comm/payload-view.h>
+#include <common/payload.h>
+#include <common/payload-view.h>
 #include <tap/tap.h>
 
 static const int TEST_COUNT = 5;
 #include <tap/tap.h>
 
 static const int TEST_COUNT = 5;
This page took 0.038034 seconds and 4 git commands to generate.