From: Jonathan Rajotte Date: Tue, 24 Mar 2020 15:32:08 +0000 (-0400) Subject: trigger: implement is_equal X-Git-Tag: v2.13.0-rc1~434 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=85c06c443aa9b896639681ec6a536e4b80a2bd02;p=lttng-tools.git trigger: implement is_equal Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau Change-Id: I646c13e7fb26fda66b888ce90253e87567b2cab8 --- diff --git a/include/lttng/trigger/trigger-internal.h b/include/lttng/trigger/trigger-internal.h index a554a31e5..6d05b6d1d 100644 --- a/include/lttng/trigger/trigger-internal.h +++ b/include/lttng/trigger/trigger-internal.h @@ -61,6 +61,10 @@ const struct lttng_action *lttng_trigger_get_const_action( LTTNG_HIDDEN bool lttng_trigger_validate(struct lttng_trigger *trigger); +LTTNG_HIDDEN +bool lttng_trigger_is_equal( + const struct lttng_trigger *a, const struct lttng_trigger *b); + LTTNG_HIDDEN void lttng_trigger_get(struct lttng_trigger *trigger); diff --git a/src/bin/lttng-sessiond/notification-thread-events.c b/src/bin/lttng-sessiond/notification-thread-events.c index 9e9a83888..e52e4bd97 100644 --- a/src/bin/lttng-sessiond/notification-thread-events.c +++ b/src/bin/lttng-sessiond/notification-thread-events.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include diff --git a/src/common/trigger.c b/src/common/trigger.c index 5ae84f3d9..e6849fccf 100644 --- a/src/common/trigger.c +++ b/src/common/trigger.c @@ -263,6 +263,29 @@ end: return ret; } +LTTNG_HIDDEN +bool lttng_trigger_is_equal( + const struct lttng_trigger *a, const struct lttng_trigger *b) +{ + /* + * Name is not taken into account since it is cosmetic only. + */ + if (!lttng_condition_is_equal(a->condition, b->condition)) { + return false; + } + + if (!lttng_action_is_equal(a->action, b->action)) { + return false; + } + + if (!lttng_credentials_is_equal(lttng_trigger_get_credentials(a), + lttng_trigger_get_credentials(b))) { + return false; + } + + return true; +} + LTTNG_HIDDEN void lttng_trigger_get(struct lttng_trigger *trigger) {