X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Fadd_trigger.c;h=ceaf3e807b71f07521bde5df95181e31f9b3f573;hb=a5c2d2a71919b8d1542b62f6d32579125cc2c8f8;hp=91f849c131fe169304cbd3692426ddc15ec20f1f;hpb=8dbb86b8a981917165030d3a7fbbc2cb932888ed;p=lttng-tools.git diff --git a/src/bin/lttng/commands/add_trigger.c b/src/bin/lttng/commands/add_trigger.c index 91f849c13..ceaf3e807 100644 --- a/src/bin/lttng/commands/add_trigger.c +++ b/src/bin/lttng/commands/add_trigger.c @@ -2012,13 +2012,14 @@ int cmd_add_trigger(int argc, const char **argv) struct lttng_dynamic_pointer_array actions; struct argpar_state *argpar_state = NULL; struct argpar_item *argpar_item = NULL; - struct lttng_action *action_group = NULL; + struct lttng_action *action_list = NULL; struct lttng_action *action = NULL; struct lttng_trigger *trigger = NULL; char *error = NULL; char *name = NULL; int i; char *owner_uid = NULL; + enum lttng_error_code ret_code; lttng_dynamic_pointer_array_init(&actions, lttng_actions_destructor); @@ -2148,8 +2149,8 @@ int cmd_add_trigger(int argc, const char **argv) goto error; } - action_group = lttng_action_group_create(); - if (!action_group) { + action_list = lttng_action_list_create(); + if (!action_list) { goto error; } @@ -2158,34 +2159,24 @@ int cmd_add_trigger(int argc, const char **argv) action = lttng_dynamic_pointer_array_steal_pointer(&actions, i); - status = lttng_action_group_add_action(action_group, action); + status = lttng_action_list_add_action(action_list, action); if (status != LTTNG_ACTION_STATUS_OK) { goto error; } /* - * The `lttng_action_group_add_action()` takes a reference to + * The `lttng_action_list_add_action()` takes a reference to * the action. We can destroy ours. */ lttng_action_destroy(action); action = NULL; } - trigger = lttng_trigger_create(condition, action_group); + trigger = lttng_trigger_create(condition, action_list); if (!trigger) { 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; @@ -2222,7 +2220,7 @@ end: argpar_item_destroy(argpar_item); lttng_dynamic_pointer_array_reset(&actions); lttng_condition_destroy(condition); - lttng_action_destroy(action_group); + lttng_action_destroy(action_list); lttng_action_destroy(action); lttng_trigger_destroy(trigger); free(error);