Use bytecode seqnum to force the evaluation ordering of capture bytecode
[lttng-tools.git] / src / bin / lttng-sessiond / ust-app.c
index 01fa7fc93d7fbb738555f065d95ad0d10e39f636..43864bd0fc27d3bae0c759c2ac797ccca080869e 100644 (file)
@@ -28,6 +28,7 @@
 #include <lttng/condition/condition.h>
 #include <lttng/condition/event-rule-internal.h>
 #include <lttng/condition/event-rule.h>
+#include <lttng/trigger/trigger-internal.h>
 #include <common/sessiond-comm/sessiond-comm.h>
 
 #include "buffer-registry.h"
@@ -1578,9 +1579,12 @@ error:
 
 /*
  * Set a capture bytecode for the passed object.
+ * The sequence number enforces the ordering at runtime and on reception of
+ * the captured payloads.
  */
 static int set_ust_capture(struct ust_app *app,
                const struct lttng_bytecode *bytecode,
+               unsigned int capture_seqnum,
                struct lttng_ust_object_data *ust_object)
 {
        int ret;
@@ -1594,6 +1598,11 @@ static int set_ust_capture(struct ust_app *app,
                goto error;
        }
 
+       /*
+        * Set the sequence number to ensure the capture of fields is ordered.
+        */
+       ust_bytecode->seqnum = capture_seqnum;
+
        pthread_mutex_lock(&app->sock_lock);
        ret = ustctl_set_capture(app->sock, ust_bytecode,
                        ust_object);
@@ -2077,6 +2086,8 @@ static int create_ust_event_notifier(struct ust_app *app,
        const struct lttng_condition *condition = NULL;
        struct lttng_ust_event_notifier event_notifier;
        const struct lttng_event_rule *event_rule = NULL;
+       unsigned int capture_bytecode_count = 0, i;
+       enum lttng_condition_status cond_status;
 
        health_code_update();
        assert(app->event_notifier_group.object);
@@ -2146,6 +2157,23 @@ static int create_ust_event_notifier(struct ust_app *app,
                }
        }
 
+       /* Set the capture bytecodes. */
+       cond_status = lttng_condition_event_rule_get_capture_descriptor_count(
+                       condition, &capture_bytecode_count);
+       assert(cond_status == LTTNG_CONDITION_STATUS_OK);
+
+       for (i = 0; i < capture_bytecode_count; i++) {
+               const struct lttng_bytecode *capture_bytecode =
+                               lttng_condition_event_rule_get_capture_bytecode_at_index(
+                                               condition, i);
+
+               ret = set_ust_capture(app, capture_bytecode, i,
+                               ua_event_notifier_rule->obj);
+               if (ret < 0) {
+                       goto error;
+               }
+       }
+
        /*
         * We now need to explicitly enable the event, since it
         * is disabled at creation.
This page took 0.024752 seconds and 4 git commands to generate.