lttng-ctl: separate support of named/unnamed trigger registration
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 20 Apr 2021 02:38:49 +0000 (22:38 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 22 Apr 2021 05:56:34 +0000 (01:56 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I37e78344dd14d00c617cd462914dee287e3b24bb

include/lttng/trigger/trigger-internal.h
include/lttng/trigger/trigger.h
src/bin/lttng/commands/add_trigger.c
src/common/trigger.c
src/lib/lttng-ctl/lttng-ctl.c
tests/regression/tools/notification/Makefile.am
tests/regression/tools/notification/base_client.c
tests/regression/tools/notification/notification.c
tests/regression/tools/notification/rotation.c
tests/regression/tools/trigger/utils/register-some-triggers.c

index 6fba6668491d71dd95f9f706a818e7e915c76d1e..c58787ceb2cfb506a7280e02ccf6b6425783ea19 100644 (file)
@@ -242,4 +242,19 @@ enum lttng_trigger_status lttng_trigger_add_action_error_query_results(
                struct lttng_trigger *trigger,
                struct lttng_error_query_results *results);
 
+/*
+ * Set the trigger name.
+ *
+ * A name is optional.
+ * A name will be assigned on trigger registration if no name is set.
+ *
+ * The name is copied.
+ *
+ * Return LTTNG_TRIGGER_STATUS_OK on success, LTTNG_TRIGGER_STATUS_INVALID
+ * if invalid parameters are passed.
+ */
+LTTNG_HIDDEN
+enum lttng_trigger_status lttng_trigger_set_name(
+               struct lttng_trigger *trigger, const char *name);
+
 #endif /* LTTNG_TRIGGER_INTERNAL_H */
index 6490af118a4333eb857d203d46dfce05a78455aa..921ff11bea976ca3c5c62df27ebf4473b7dc1447 100644 (file)
@@ -9,6 +9,7 @@
 #define LTTNG_TRIGGER_H
 
 #include <sys/types.h>
+#include <lttng/constant.h>
 #include <inttypes.h>
 
 struct lttng_action;
@@ -120,38 +121,40 @@ const struct lttng_action *lttng_trigger_get_const_action(
  *
  * Returns LTTNG_TRIGGER_STATUS_OK and a pointer to the trigger's name on
  * success, LTTNG_TRIGGER_STATUS_INVALID if an invalid parameter is passed,
- * or LTTNG_TRIGGER_STATUS_UNSET if a name was not set prior to this call.
+ * or LTTNG_TRIGGER_STATUS_UNSET if the trigger is unnamed.
  */
 extern enum lttng_trigger_status lttng_trigger_get_name(
                const struct lttng_trigger *trigger, const char **name);
 
 /*
- * Set the trigger name.
- *
- * A name is optional.
- * A name will be assigned on trigger registration if no name is set.
- *
- * The name is copied.
- *
- * Return LTTNG_TRIGGER_STATUS_OK on success, LTTNG_TRIGGER_STATUS_INVALID
- * if invalid parameters are passed.
+ * Destroy (frees) a trigger object.
  */
-extern enum lttng_trigger_status lttng_trigger_set_name(
-               struct lttng_trigger *trigger, const char *name);
+extern void lttng_trigger_destroy(struct lttng_trigger *trigger);
 
 /*
- * Destroy (frees) a trigger object.
+ * Register a trigger to the session daemon with a given name.
+ *
+ * The trigger object can be destroyed after this call.
+ * On success, this function will set the trigger's name to `name`.
+ *
+ * Returns an LTTng status code.
  */
-extern void lttng_trigger_destroy(struct lttng_trigger *trigger);
+extern enum lttng_error_code lttng_register_trigger_with_name(
+               struct lttng_trigger *trigger,
+               const char *name);
 
 /*
- * Register a trigger to the session daemon.
+ * Register a trigger to the session daemon, generating a unique name for its
+ * owner.
  *
  * The trigger can be destroyed after this call.
+ * On success, this function will set the trigger's name to the generated
+ * name.
  *
- * Return 0 on success, a negative LTTng error code on error.
+ * Returns an LTTng status code.
  */
-extern int lttng_register_trigger(struct lttng_trigger *trigger);
+extern enum lttng_error_code lttng_register_trigger_with_automatic_name(
+               struct lttng_trigger *trigger);
 
 /*
  * Unregister a trigger from the session daemon.
@@ -201,6 +204,18 @@ extern enum lttng_trigger_status lttng_triggers_get_count(
  */
 extern void lttng_triggers_destroy(struct lttng_triggers *triggers);
 
+/*
+ * Deprecated: invocations should be replaced by
+ * lttng_register_trigger_with_automatic_name().
+ *
+ * Register a trigger to the session daemon.
+ *
+ * The trigger can be destroyed after this call.
+ *
+ * Return 0 on success, a negative LTTng error code on error.
+ */
+LTTNG_DEPRECATED("Use lttng_register_trigger_with_automatic_name")
+extern int lttng_register_trigger(struct lttng_trigger *trigger);
 
 #ifdef __cplusplus
 }
index 32aff65d35f7c07dd2ad60982b266c2f8c72c259..ceaf3e807b71f07521bde5df95181e31f9b3f573 100644 (file)
@@ -2019,6 +2019,7 @@ int cmd_add_trigger(int argc, const char **argv)
        char *name = NULL;
        int i;
        char *owner_uid = NULL;
+       enum lttng_error_code ret_code;
 
        lttng_dynamic_pointer_array_init(&actions, lttng_actions_destructor);
 
@@ -2176,16 +2177,6 @@ int cmd_add_trigger(int argc, const char **argv)
                goto error;
        }
 
-       if (name) {
-               enum lttng_trigger_status trigger_status =
-                               lttng_trigger_set_name(trigger, name);
-
-               if (trigger_status != LTTNG_TRIGGER_STATUS_OK) {
-                       ERR("Failed to set trigger name.");
-                       goto error;
-               }
-       }
-
        if (owner_uid) {
                enum lttng_trigger_status trigger_status;
                char *end;
@@ -2204,13 +2195,20 @@ int cmd_add_trigger(int argc, const char **argv)
                }
        }
 
-       ret = lttng_register_trigger(trigger);
-       if (ret) {
-               ERR("Failed to register trigger: %s.", lttng_strerror(ret));
+       if (name) {
+               ret_code = lttng_register_trigger_with_name(trigger, name);
+       } else {
+               ret_code = lttng_register_trigger_with_automatic_name(trigger);
+       }
+
+       if (ret_code != LTTNG_OK) {
+               ERR("Failed to register trigger: %s.",
+                               lttng_strerror(-ret_code));
                goto error;
        }
 
        MSG("Trigger registered successfully.");
+       ret = 0;
 
        goto end;
 
index 5c48609ea5f12659c11b2eb50e01d28f5225b34f..d740c80c77a377f8ff1a9a7141f6e7682e67cb62 100644 (file)
@@ -371,22 +371,24 @@ bool lttng_trigger_is_equal(
        return true;
 }
 
+LTTNG_HIDDEN
 enum lttng_trigger_status lttng_trigger_set_name(struct lttng_trigger *trigger,
                const char* name)
 {
        char *name_copy = NULL;
        enum lttng_trigger_status status = LTTNG_TRIGGER_STATUS_OK;
 
-       if (!trigger || !name ||
-                       strlen(name) == 0) {
+       if (!trigger) {
                status = LTTNG_TRIGGER_STATUS_INVALID;
                goto end;
        }
 
-       name_copy = strdup(name);
-       if (!name_copy) {
-               status = LTTNG_TRIGGER_STATUS_ERROR;
-               goto end;
+       if (name) {
+               name_copy = strdup(name);
+               if (!name_copy) {
+                       status = LTTNG_TRIGGER_STATUS_ERROR;
+                       goto end;
+               }
        }
 
        free(trigger->name);
index 7efc6bd2ebea7ef007c14a164b43cee48ecc3519..7a38699d9c8438cbedd423a12fd2204884dc266f 100644 (file)
@@ -3082,11 +3082,14 @@ end:
        return ret;
 }
 
-int lttng_register_trigger(struct lttng_trigger *trigger)
+static
+int _lttng_register_trigger(struct lttng_trigger *trigger, const char *name,
+               bool generate_name)
 {
        int ret;
        struct lttcomm_session_msg lsm = {
                .cmd_type = LTTNG_REGISTER_TRIGGER,
+               .u.trigger.is_trigger_anonymous = !name && !generate_name,
        };
        struct lttcomm_session_msg *message_lsm;
        struct lttng_payload message;
@@ -3097,6 +3100,8 @@ int lttng_register_trigger(struct lttng_trigger *trigger)
                .uid = LTTNG_OPTIONAL_INIT_VALUE(geteuid()),
                .gid = LTTNG_OPTIONAL_INIT_UNSET,
        };
+       const char *unused_trigger_name = NULL;
+       enum lttng_trigger_status trigger_status;
 
        lttng_payload_init(&message);
        lttng_payload_init(&reply);
@@ -3106,6 +3111,21 @@ int lttng_register_trigger(struct lttng_trigger *trigger)
                goto end;
        }
 
+       trigger_status = lttng_trigger_get_name(trigger, &unused_trigger_name);
+       if (trigger_status != LTTNG_TRIGGER_STATUS_UNSET) {
+               /* Re-using already registered trigger. */
+               ret = -LTTNG_ERR_INVALID;
+               goto end;
+       }
+
+       if (name) {
+               trigger_status = lttng_trigger_set_name(trigger, name);
+               if (trigger_status != LTTNG_TRIGGER_STATUS_OK) {
+                       ret = -LTTNG_ERR_NOMEM;
+                       goto end;
+               }
+       }
+
        if (!trigger->creds.uid.is_set) {
                /* Use the client's credentials as the trigger credentials. */
                lttng_trigger_set_credentials(trigger, &user_creds);
@@ -3126,14 +3146,14 @@ int lttng_register_trigger(struct lttng_trigger *trigger)
                if (!lttng_credentials_is_equal_uid(trigger_creds, &user_creds)) {
                        if (lttng_credentials_get_uid(&user_creds) != 0) {
                                ret = -LTTNG_ERR_EPERM;
-                               goto end;
+                               goto end_unset_name;
                        }
                }
        }
 
        if (!lttng_trigger_validate(trigger)) {
                ret = -LTTNG_ERR_INVALID_TRIGGER;
-               goto end;
+               goto end_unset_name;
        }
 
        domain_type = lttng_trigger_get_underlying_domain_type_restriction(
@@ -3144,13 +3164,13 @@ int lttng_register_trigger(struct lttng_trigger *trigger)
        ret = lttng_dynamic_buffer_append(&message.buffer, &lsm, sizeof(lsm));
        if (ret) {
                ret = -LTTNG_ERR_NOMEM;
-               goto end;
+               goto end_unset_name;
        }
 
        ret = lttng_trigger_serialize(trigger, &message);
        if (ret < 0) {
                ret = -LTTNG_ERR_UNK;
-               goto end;
+               goto end_unset_name;
        }
 
        /*
@@ -3170,7 +3190,7 @@ int lttng_register_trigger(struct lttng_trigger *trigger)
                                &message_view);
                ret = lttng_ctl_ask_sessiond_payload(&message_view, &reply);
                if (ret < 0) {
-                       goto end;
+                       goto end_unset_name;
                }
        }
 
@@ -3182,18 +3202,27 @@ int lttng_register_trigger(struct lttng_trigger *trigger)
                ret = lttng_trigger_create_from_payload(
                                &reply_view, &reply_trigger);
                if (ret < 0) {
-                       ret = -LTTNG_ERR_FATAL;
-                       goto end;
+                       ret = -LTTNG_ERR_INVALID_PROTOCOL;
+                       goto end_unset_name;
                }
        }
 
-       ret = lttng_trigger_assign_name(trigger, reply_trigger);
-       if (ret < 0) {
-               ret = -LTTNG_ERR_FATAL;
-               goto end;
+       if (name || generate_name) {
+               ret = lttng_trigger_assign_name(trigger, reply_trigger);
+               if (ret < 0) {
+                       ret = -LTTNG_ERR_NOMEM;
+                       goto end;
+               }
        }
 
        ret = 0;
+       goto end;
+
+end_unset_name:
+       trigger_status = lttng_trigger_set_name(trigger, NULL);
+       if (trigger_status != LTTNG_TRIGGER_STATUS_OK) {
+               ret = -LTTNG_ERR_UNK;
+       }
 end:
        lttng_payload_reset(&message);
        lttng_payload_reset(&reply);
@@ -3201,6 +3230,28 @@ end:
        return ret;
 }
 
+int lttng_register_trigger(struct lttng_trigger *trigger)
+{
+       /* Register an anonymous trigger. */
+       return _lttng_register_trigger(trigger, NULL, false);
+}
+
+enum lttng_error_code lttng_register_trigger_with_name(
+               struct lttng_trigger *trigger, const char *name)
+{
+       const int ret = _lttng_register_trigger(trigger, name, false);
+
+       return ret == 0 ? LTTNG_OK : (enum lttng_error_code) -ret;
+}
+
+enum lttng_error_code lttng_register_trigger_with_automatic_name(
+               struct lttng_trigger *trigger)
+{
+       const int ret =  _lttng_register_trigger(trigger, false, true);
+
+       return ret == 0 ? LTTNG_OK : (enum lttng_error_code) -ret;
+}
+
 enum lttng_error_code lttng_error_query_execute(
                const struct lttng_error_query *query,
                const struct lttng_endpoint *endpoint,
index 84e75d3070b056904c3bbe0df55c890b5de8bbbd..b9e4b8ac29d019a7456bb643982d95b038914de3 100644 (file)
@@ -55,6 +55,8 @@ base_client_SOURCES = base_client.c
 base_client_LDADD = $(LIB_LTTNG_CTL)
 
 notification_SOURCES = notification.c
+# Tests the deprecated lttng_register_trigger() interface
+notification_CFLAGS = -Wno-deprecated-declarations $(AM_CFLAGS)
 notification_LDADD = $(LIB_LTTNG_CTL) $(LIBTAP) -lm
 
 rotation_SOURCES = rotation.c
index bb12410e81f7ed971572e2dd3be1400826a9df72..eecdb47885a5520d8a502241ab0a21979af652ca 100644 (file)
@@ -129,6 +129,7 @@ int main(int argc, char **argv)
        struct lttng_condition *condition = NULL;
        struct lttng_action *action = NULL;
        struct lttng_trigger *trigger = NULL;
+       enum lttng_error_code ret_code;
 
        /*
         * Disable buffering on stdout.
@@ -257,14 +258,14 @@ int main(int argc, char **argv)
                goto end;
        }
 
-       ret = lttng_register_trigger(trigger);
+       ret_code = lttng_register_trigger_with_automatic_name(trigger);
 
        /*
         * An equivalent trigger might already be registered if an other app
         * registered an equivalent trigger.
         */
-       if (ret < 0 && ret != -LTTNG_ERR_TRIGGER_EXISTS) {
-               printf("error: %s\n", lttng_strerror(ret));
+       if (ret_code != LTTNG_OK && ret_code != LTTNG_ERR_TRIGGER_EXISTS) {
+               printf("error: %s\n", lttng_strerror(-ret_code));
                ret = 1;
                goto end;
        }
index c097c102698d88871a3c089a8d5558324a9be2b3..092ac5f1ec5e978fafbdaf89467bf3eb3ac2c6ee 100644 (file)
@@ -1449,13 +1449,12 @@ static void create_tracepoint_event_rule_trigger(const char *event_pattern,
                struct lttng_trigger **trigger)
 {
        enum lttng_event_rule_status event_rule_status;
-       enum lttng_trigger_status trigger_status;
-
        struct lttng_action *tmp_action = NULL;
        struct lttng_event_rule *event_rule = NULL;
        struct lttng_condition *tmp_condition = NULL;
        struct lttng_trigger *tmp_trigger = NULL;
        int ret;
+       enum lttng_error_code ret_code;
 
        assert(event_pattern);
        assert(trigger_name);
@@ -1518,12 +1517,8 @@ static void create_tracepoint_event_rule_trigger(const char *event_pattern,
        tmp_trigger = lttng_trigger_create(tmp_condition, tmp_action);
        ok(tmp_trigger, "Trigger object creation %s", trigger_name);
 
-       trigger_status = lttng_trigger_set_name(tmp_trigger, trigger_name);
-       ok(trigger_status == LTTNG_TRIGGER_STATUS_OK,
-                       "Setting name to trigger %s", trigger_name);
-
-       ret = lttng_register_trigger(tmp_trigger);
-       ok(ret == 0, "Trigger registration %s", trigger_name);
+       ret_code = lttng_register_trigger_with_name(tmp_trigger, trigger_name);
+       ok(ret_code == LTTNG_OK, "Trigger registration %s", trigger_name);
 
        lttng_event_rule_destroy(event_rule);
 
@@ -1832,10 +1827,10 @@ static void test_kprobe_event_rule_notification(
                enum lttng_domain_type domain_type)
 {
        int i, ret;
+       enum lttng_error_code ret_code;
        const int notification_count = 3;
        enum lttng_notification_channel_status nc_status;
        enum lttng_event_rule_status event_rule_status;
-       enum lttng_trigger_status trigger_status;
        struct lttng_notification_channel *notification_channel = NULL;
        struct lttng_condition *condition = NULL;
        struct lttng_kernel_probe_location *location = NULL;
@@ -1879,12 +1874,8 @@ static void test_kprobe_event_rule_notification(
                goto end;
        }
 
-       trigger_status = lttng_trigger_set_name(trigger, trigger_name);
-       ok(trigger_status == LTTNG_TRIGGER_STATUS_OK,
-                       "Setting trigger name to '%s'", trigger_name);
-
-       ret = lttng_register_trigger(trigger);
-       if (ret) {
+       ret_code = lttng_register_trigger_with_name(trigger, trigger_name);
+       if (ret_code != LTTNG_OK) {
                fail("Failed to register trigger with kernel probe event rule condition and notify action");
                goto end;
        }
@@ -1933,10 +1924,10 @@ static void test_uprobe_event_rule_notification(
                const char *test_symbol_name)
 {
        int i, ret;
+       enum lttng_error_code ret_code;
        const int notification_count = 3;
        enum lttng_notification_channel_status nc_status;
        enum lttng_event_rule_status event_rule_status;
-       enum lttng_trigger_status trigger_status;
        struct lttng_notification_channel *notification_channel = NULL;
        struct lttng_userspace_probe_location *probe_location = NULL;
        struct lttng_userspace_probe_location_lookup_method *lookup_method =
@@ -1988,12 +1979,8 @@ static void test_uprobe_event_rule_notification(
                goto end;
        }
 
-       trigger_status = lttng_trigger_set_name(trigger, trigger_name);
-       ok(trigger_status == LTTNG_TRIGGER_STATUS_OK,
-                       "Setting name to trigger '%s'", trigger_name);
-
-       ret = lttng_register_trigger(trigger);
-       if (ret) {
+       ret_code = lttng_register_trigger_with_name(trigger, trigger_name);
+       if (ret_code != LTTNG_OK) {
                fail("Failed to register trigger with userspace probe event rule condition and notify action");
                goto end;
        }
@@ -2040,10 +2027,10 @@ static void test_syscall_event_rule_notification(
                enum lttng_domain_type domain_type)
 {
        int i, ret;
+       enum lttng_error_code ret_code;
        const int notification_count = 3;
        enum lttng_notification_channel_status nc_status;
        enum lttng_event_rule_status event_rule_status;
-       enum lttng_trigger_status trigger_status;
        struct lttng_notification_channel *notification_channel = NULL;
        struct lttng_condition *condition = NULL;
        struct lttng_event_rule *event_rule = NULL;
@@ -2080,12 +2067,8 @@ static void test_syscall_event_rule_notification(
                goto end;
        }
 
-       trigger_status = lttng_trigger_set_name(trigger, trigger_name);
-       ok(trigger_status == LTTNG_TRIGGER_STATUS_OK,
-                       "Setting name to trigger '%s'", trigger_name);
-
-       ret = lttng_register_trigger(trigger);
-       if (ret) {
+       ret_code = lttng_register_trigger_with_name(trigger, trigger_name);
+       if (ret_code != LTTNG_OK) {
                fail("Failed to register trigger with syscall event rule condition and notify action");
                goto end;
        }
@@ -2129,10 +2112,10 @@ static void test_syscall_event_rule_notification_filter(
                enum lttng_domain_type domain_type)
 {
        int i, ret;
+       enum lttng_error_code ret_code;
        const int notification_count = 3;
        enum lttng_notification_channel_status nc_status;
        enum lttng_event_rule_status event_rule_status;
-       enum lttng_trigger_status trigger_status;
        struct lttng_notification_channel *notification_channel = NULL;
        struct lttng_condition *condition = NULL;
        struct lttng_event_rule *event_rule = NULL;
@@ -2175,12 +2158,8 @@ static void test_syscall_event_rule_notification_filter(
                goto end;
        }
 
-       trigger_status = lttng_trigger_set_name(trigger, trigger_name);
-       ok(trigger_status == LTTNG_TRIGGER_STATUS_OK,
-                       "Setting name to trigger '%s'", trigger_name);
-
-       ret = lttng_register_trigger(trigger);
-       if (ret) {
+       ret_code = lttng_register_trigger_with_name(trigger, trigger_name);
+       if (ret_code != LTTNG_OK) {
                fail("Failed to register trigger with syscall filtering event rule condition and notify action");
                goto end;
        }
@@ -2509,7 +2488,7 @@ int main(int argc, const char *argv[])
        switch (test_scenario) {
        case 1:
        {
-               plan_tests(44);
+               plan_tests(41);
 
                /* Test cases that need gen-ust-event testapp. */
                diag("Test basic notification error paths for %s domain",
@@ -2575,7 +2554,7 @@ int main(int argc, const char *argv[])
                 * Test cases that need a test app with more than one event
                 * type.
                 */
-               plan_tests(25);
+               plan_tests(23);
 
                /*
                 * At the moment, the only test case of this scenario is
@@ -2647,7 +2626,7 @@ int main(int argc, const char *argv[])
        {
                switch(domain_type) {
                case LTTNG_DOMAIN_UST:
-                       plan_tests(222);
+                       plan_tests(221);
                        break;
                case LTTNG_DOMAIN_KERNEL:
                        plan_tests(216);
index b8089d5c96b9f0492895b1fc776a9faa6d952cbc..f32a0d7737efb95b3b778c3e14784ec19dc40395 100644 (file)
 #include <assert.h>
 #include <tap/tap.h>
 #include <stdint.h>
-#include <lttng/rotation.h>
-#include <lttng/notification/channel.h>
-#include <lttng/notification/notification.h>
-#include <lttng/condition/evaluation.h>
-#include <lttng/condition/condition.h>
-#include <lttng/endpoint.h>
-#include <lttng/action/notify.h>
-#include <lttng/action/action.h>
-#include <lttng/trigger/trigger.h>
-#include <lttng/condition/session-rotation.h>
 #include <string.h>
+#include <lttng/lttng.h>
 
 #define TEST_COUNT 36
 
@@ -79,6 +70,7 @@ int setup_rotation_trigger(const struct session *session,
        struct lttng_trigger *rotation_completed_trigger = NULL;
        enum lttng_condition_status condition_status;
        enum lttng_notification_channel_status notification_channel_status;
+       enum lttng_error_code ret_code;
 
        notify = lttng_action_notify_create();
        if (!notify) {
@@ -162,17 +154,23 @@ int setup_rotation_trigger(const struct session *session,
        }
 
        /* Register rotation ongoing and completed triggers. */
-       ret = lttng_register_trigger(rotation_ongoing_trigger);
-       ok(ret == 0, "Registered session rotation ongoing trigger");
-       if (ret) {
+       ret_code = lttng_register_trigger_with_automatic_name(
+                       rotation_ongoing_trigger);
+       ok(ret_code == LTTNG_OK, "Registered session rotation ongoing trigger");
+       if (ret_code != LTTNG_OK) {
+               ret = -ret_code;
                goto end;
        }
 
-       ret = lttng_register_trigger(rotation_completed_trigger);
-       ok(ret == 0, "Registered session rotation completed trigger");
-       if (ret) {
+       ret_code = lttng_register_trigger_with_automatic_name(
+                       rotation_completed_trigger);
+       ok(ret_code == LTTNG_OK,
+                       "Registered session rotation completed trigger");
+       if (ret_code != LTTNG_OK) {
+               ret = -ret_code;
                goto end;
        }
+
 end:
        lttng_trigger_destroy(rotation_ongoing_trigger);
        lttng_trigger_destroy(rotation_completed_trigger);
index c92ee0f5a5b567853facc6c58cafe60d44259184..f4bba2df4488de26114dabe07eda609048debcee 100644 (file)
@@ -20,14 +20,11 @@ static void register_trigger(const char *trigger_name,
                struct lttng_action *action)
 {
        struct lttng_trigger *trigger;
-       enum lttng_trigger_status trigger_status;
-       int ret;
+       enum lttng_error_code ret;
 
        trigger = lttng_trigger_create(condition, action);
-       trigger_status = lttng_trigger_set_name(trigger, trigger_name);
-       assert(trigger_status == LTTNG_TRIGGER_STATUS_OK);
-       ret = lttng_register_trigger(trigger);
-       assert(ret == 0);
+       ret = lttng_register_trigger_with_name(trigger, trigger_name);
+       assert(ret == LTTNG_OK);
 }
 
 /*
This page took 0.041567 seconds and 4 git commands to generate.