Identical matches are only one time in the hash map but multiple
times in the list; when removing, the hash will be empty but the
list still has entries.
Not adding dupicates to the list should keep us in sync and prevent
hitting the assert.
first = hashmap_get(c->matches, m->match);
LIST_PREPEND(matches, first, m);
r = hashmap_replace(c->matches, m->match, first);
- if (r < 0) {
+ if (r == 0) {
+ log_debug("Match '%s' already installed, ignoring request.", m->match);
+ LIST_REMOVE(matches, first, m);
+ } else if (r < 0) {
LIST_REMOVE(matches, first, m);
goto fail;
}