]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: pattern: delete the back refs at once during pat_ref_reload()
authorWilly Tarreau <w@1wt.eu>
Tue, 27 Oct 2020 17:55:20 +0000 (18:55 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 5 Nov 2020 18:27:08 +0000 (19:27 +0100)
It's pointless to delete a backref and relink it to the next entry since
the next entry is going to do the exact same and so on until all of them
are deleted. Let's simply delete backrefs on reload.

src/pattern.c

index 328c514168cbe55f23f4eca58e64e5ddceb407ce..e4a1e2785b5bdc49e60450a688b45d1e44ba64ad 100644 (file)
@@ -2033,15 +2033,9 @@ void pat_ref_reload(struct pat_ref *ref, struct pat_ref *replace)
        /* all expr are locked, we can safely remove all pat_ref */
        list_for_each_entry_safe(elt, safe, &ref->head, list) {
                list_for_each_entry_safe(bref, back, &elt->back_refs, users) {
-                       /*
-                        * we have to unlink all watchers. We must not relink them if
-                        * this elt  was the last one in the list.
-                        */
-                       LIST_DEL(&bref->users);
-                       LIST_INIT(&bref->users);
-                       if (elt->list.n != &ref->head)
-                               LIST_ADDQ(&LIST_ELEM(elt->list.n, typeof(elt), list)->back_refs, &bref->users);
-                       bref->ref = elt->list.n;
+                       /* we have to unlink all watchers. */
+                       LIST_DEL_INIT(&bref->users);
+                       bref->ref = NULL;
                }
                LIST_DEL(&elt->list);
                free(elt->pattern);