match: make match_rule_link() idempotent
We want to be able to linke the same rule into the same registry
repeatedly. However, we must only actually link into the list once
or the list will be corrupted.
Simply assert on the registry being the same, on subsequent calls.
@@ -312,6 +312,9 @@ MatchRule *match_rule_user_unref(MatchRule *rule) {
}
void match_rule_link(MatchRule *rule, MatchRegistry *registry) {
+ if (c_list_is_linked(&rule->registry_link))
+ assert(rule->registry == registry);
+ else
c_list_link_tail(&registry->rule_list, &rule->registry_link);
rule->registry = registry;
}
