X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fcondition-internal.c;h=c86bf540106031b674dde19c7931ac681f719be8;hb=0efb2ad7fc448283184e43d6fb0915febae45384;hp=0163a89774721d2e45536e20eb10274c960c938b;hpb=d602bd6a8ee25d5ca662dde4edb3db3cabf264e1;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/condition-internal.c b/src/bin/lttng-sessiond/condition-internal.c index 0163a8977..c86bf5401 100644 --- a/src/bin/lttng-sessiond/condition-internal.c +++ b/src/bin/lttng-sessiond/condition-internal.c @@ -13,9 +13,10 @@ #include #include #include -#include -#include +#include +#include #include +#include #include "condition-internal.h" static @@ -94,17 +95,16 @@ unsigned long lttng_condition_session_rotation_hash( return hash; } -static -unsigned long lttng_condition_on_event_hash( - const struct lttng_condition *condition) +static unsigned long lttng_condition_event_rule_matches_hash( + const struct lttng_condition *condition) { unsigned long hash, condition_type; enum lttng_condition_status condition_status; const struct lttng_event_rule *event_rule; condition_type = (unsigned long) condition->type; - condition_status = lttng_condition_on_event_get_rule(condition, - &event_rule); + condition_status = lttng_condition_event_rule_matches_get_rule( + condition, &event_rule); assert(condition_status == LTTNG_CONDITION_STATUS_OK); hash = hash_key_ulong((void *) condition_type, lttng_ht_seed); @@ -127,10 +127,42 @@ unsigned long lttng_condition_hash(const struct lttng_condition *condition) case LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING: case LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED: return lttng_condition_session_rotation_hash(condition); - case LTTNG_CONDITION_TYPE_ON_EVENT: - return lttng_condition_on_event_hash(condition); + case LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES: + return lttng_condition_event_rule_matches_hash(condition); default: //ERR("[notification-thread] Unexpected condition type caught"); abort(); } } + +LTTNG_HIDDEN +struct lttng_condition *lttng_condition_copy(const struct lttng_condition *condition) +{ + int ret; + struct lttng_payload copy_buffer; + struct lttng_condition *copy = NULL; + + lttng_payload_init(©_buffer); + + ret = lttng_condition_serialize(condition, ©_buffer); + if (ret < 0) { + goto end; + } + + { + struct lttng_payload_view view = + lttng_payload_view_from_payload( + ©_buffer, 0, -1); + + ret = lttng_condition_create_from_payload( + &view, ©); + if (ret < 0) { + copy = NULL; + goto end; + } + } + +end: + lttng_payload_reset(©_buffer); + return copy; +}