diff --git a/include/haproxy/pattern-t.h b/include/haproxy/pattern-t.h index 477b2bbc6..30ff999b5 100644 --- a/include/haproxy/pattern-t.h +++ b/include/haproxy/pattern-t.h @@ -106,6 +106,8 @@ struct pat_ref { struct list head; /* The head of the list of struct pat_ref_elt. */ struct list pat; /* The head of the list of struct pattern_expr. */ unsigned int flags; /* flags PAT_REF_*. */ + unsigned int curr_gen; /* current generation number (anything below can be removed) */ + unsigned int next_gen; /* next generation number (insertions use this one) */ int unique_id; /* Each pattern reference have unique id. */ unsigned long long revision; /* updated for each update */ __decl_thread(HA_SPINLOCK_T lock); /* Lock used to protect pat ref elements */ @@ -122,6 +124,7 @@ struct pat_ref_elt { struct list tree_head; /* all pattern_tree derived from this reference */ char *pattern; char *sample; + unsigned int gen_id; /* generation of pat_ref this was made for */ int line; }; diff --git a/src/pattern.c b/src/pattern.c index 7f4f44958..7b4d876e2 100644 --- a/src/pattern.c +++ b/src/pattern.c @@ -1756,6 +1756,8 @@ struct pat_ref *pat_ref_newid(int unique_id, const char *display, unsigned int f ref->reference = NULL; ref->flags = flags; + ref->curr_gen = 0; + ref->next_gen = 0; ref->unique_id = unique_id; LIST_INIT(&ref->head); LIST_INIT(&ref->pat); @@ -1767,7 +1769,8 @@ struct pat_ref *pat_ref_newid(int unique_id, const char *display, unsigned int f /* This function adds entry to . It can fail on memory error. It returns * the newly added element on success, or NULL on failure. The PATREF_LOCK on - * must be held. + * must be held. It sets the newly created pattern's generation number + * to the same value as the reference's. */ struct pat_ref_elt *pat_ref_append(struct pat_ref *ref, const char *pattern, const char *sample, int line) { @@ -1777,6 +1780,7 @@ struct pat_ref_elt *pat_ref_append(struct pat_ref *ref, const char *pattern, con if (!elt) goto fail; + elt->gen_id = ref->curr_gen; elt->line = line; elt->pattern = strdup(pattern);