]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: pattern: perform a single call to pat_delete_gen() under the expression
authorWilly Tarreau <w@1wt.eu>
Mon, 2 Nov 2020 19:15:40 +0000 (20:15 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 5 Nov 2020 18:27:09 +0000 (19:27 +0100)
When we're removing an element under the expression lock, we don't need
anymore to run over all ->delete() functions via the expressions, since
we know that the single function does it fine now. Note that at this
point, pattern->delete() is not used at all through out the code anymore.

src/pattern.c

index 0a2032e6d93e05a13fd8bcdb0cb15b5ef865c794..89a5c4844b20ba3c1f37d15a138a8aab9dce32ce 100644 (file)
@@ -1527,11 +1527,11 @@ int pat_ref_delete_by_id(struct pat_ref *ref, struct pat_ref_elt *refelt)
                                bref->ref = elt->list.n;
                        }
 
+                       /* delete all entries from all expressions for this pattern */
                        list_for_each_entry(expr, &ref->pat, list)
                                HA_RWLOCK_WRLOCK(PATEXP_LOCK, &expr->lock);
 
-                       list_for_each_entry(expr, &ref->pat, list)
-                               expr->pat_head->delete(expr->ref, elt);
+                       pat_delete_gen(ref, elt);
 
                        list_for_each_entry(expr, &ref->pat, list)
                                HA_RWLOCK_WRUNLOCK(PATEXP_LOCK, &expr->lock);
@@ -1577,8 +1577,7 @@ int pat_ref_delete(struct pat_ref *ref, const char *key)
                        list_for_each_entry(expr, &ref->pat, list)
                                HA_RWLOCK_WRLOCK(PATEXP_LOCK, &expr->lock);
 
-                       list_for_each_entry(expr, &ref->pat, list)
-                               expr->pat_head->delete(expr->ref, elt);
+                       pat_delete_gen(ref, elt);
 
                        list_for_each_entry(expr, &ref->pat, list)
                                HA_RWLOCK_WRUNLOCK(PATEXP_LOCK, &expr->lock);