+/*
+ * Match trigger based on name and credentials only.
+ * Name duplication is NOT allowed for the same uid.
+ */
+static
+int match_trigger_by_name_uid(struct cds_lfht_node *node,
+ const void *key)
+{
+ bool match = false;
+ const char *name;
+ const char *key_name;
+ enum lttng_trigger_status status;
+ const struct lttng_credentials *key_creds;
+ const struct lttng_credentials *node_creds;
+ const struct lttng_trigger *trigger_key =
+ (const struct lttng_trigger *) key;
+ const struct lttng_trigger_ht_element *trigger_ht_element =
+ caa_container_of(node,
+ struct lttng_trigger_ht_element,
+ node_by_name_uid);
+
+ status = lttng_trigger_get_name(trigger_ht_element->trigger, &name);
+ assert(status == LTTNG_TRIGGER_STATUS_OK);
+
+ status = lttng_trigger_get_name(trigger_key, &key_name);
+ assert(status == LTTNG_TRIGGER_STATUS_OK);
+
+ /* Compare the names. */
+ if (strcmp(name, key_name) != 0) {
+ goto end;
+ }
+
+ /* Compare the owners' UIDs. */
+ key_creds = lttng_trigger_get_credentials(trigger_key);
+ node_creds = lttng_trigger_get_credentials(trigger_ht_element->trigger);
+
+ match = lttng_credentials_is_equal_uid(key_creds, node_creds);
+
+end:
+ return match;
+}
+
+/*
+ * Hash trigger based on name and credentials only.
+ */
+static
+unsigned long hash_trigger_by_name_uid(const struct lttng_trigger *trigger)
+{
+ unsigned long hash = 0;
+ const struct lttng_credentials *trigger_creds;
+ const char *trigger_name;
+ enum lttng_trigger_status status;
+
+ status = lttng_trigger_get_name(trigger, &trigger_name);
+ if (status == LTTNG_TRIGGER_STATUS_OK) {
+ hash = hash_key_str(trigger_name, lttng_ht_seed);
+ }
+
+ trigger_creds = lttng_trigger_get_credentials(trigger);
+ hash ^= hash_key_ulong((void *) (unsigned long) LTTNG_OPTIONAL_GET(trigger_creds->uid),
+ lttng_ht_seed);
+
+ return hash;
+}
+