mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-05-04 00:38:02 +00:00
MINOR: pattern: move the update revision to the pat_ref, not the expression
It's not possible to uniquely update a single expression without updating the pattern reference, I don't know why we've put the revision in the expression back then, given that it in fact provides an update for a full pattern. Let's move the revision into the reference's head instead.
This commit is contained in:
parent
114d698fde
commit
3ee0de1b41
@ -106,6 +106,7 @@ struct pat_ref {
|
||||
struct list pat; /* The head of the list of struct pattern_expr. */
|
||||
unsigned int flags; /* flags PAT_REF_*. */
|
||||
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 */
|
||||
};
|
||||
|
||||
@ -179,7 +180,6 @@ struct pattern_list {
|
||||
*/
|
||||
struct pattern_expr {
|
||||
struct list list; /* Used for chaining pattern_expr in pat_ref. */
|
||||
unsigned long long revision; /* updated for each update */
|
||||
struct pat_ref *ref; /* The pattern reference if exists. */
|
||||
struct pattern_head *pat_head; /* Point to the pattern_head that contain manipulation functions.
|
||||
* Note that this link point on compatible head but not on the real
|
||||
|
@ -500,7 +500,7 @@ struct pattern *pat_match_str(struct sample *smp, struct pattern_expr *expr, int
|
||||
unsigned long long seed = pat_lru_seed ^ (long)expr;
|
||||
|
||||
lru = lru64_get(XXH64(smp->data.u.str.area, smp->data.u.str.data, seed),
|
||||
pat_lru_tree, expr, expr->revision);
|
||||
pat_lru_tree, expr, expr->ref->revision);
|
||||
if (lru && lru->domain) {
|
||||
ret = lru->data;
|
||||
return ret;
|
||||
@ -523,7 +523,7 @@ struct pattern *pat_match_str(struct sample *smp, struct pattern_expr *expr, int
|
||||
}
|
||||
|
||||
if (lru)
|
||||
lru64_commit(lru, ret, expr, expr->revision, NULL);
|
||||
lru64_commit(lru, ret, expr, expr->ref->revision, NULL);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -540,7 +540,7 @@ struct pattern *pat_match_bin(struct sample *smp, struct pattern_expr *expr, int
|
||||
unsigned long long seed = pat_lru_seed ^ (long)expr;
|
||||
|
||||
lru = lru64_get(XXH64(smp->data.u.str.area, smp->data.u.str.data, seed),
|
||||
pat_lru_tree, expr, expr->revision);
|
||||
pat_lru_tree, expr, expr->ref->revision);
|
||||
if (lru && lru->domain) {
|
||||
ret = lru->data;
|
||||
return ret;
|
||||
@ -560,7 +560,7 @@ struct pattern *pat_match_bin(struct sample *smp, struct pattern_expr *expr, int
|
||||
}
|
||||
|
||||
if (lru)
|
||||
lru64_commit(lru, ret, expr, expr->revision, NULL);
|
||||
lru64_commit(lru, ret, expr, expr->ref->revision, NULL);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -603,7 +603,7 @@ struct pattern *pat_match_reg(struct sample *smp, struct pattern_expr *expr, int
|
||||
unsigned long long seed = pat_lru_seed ^ (long)expr;
|
||||
|
||||
lru = lru64_get(XXH64(smp->data.u.str.area, smp->data.u.str.data, seed),
|
||||
pat_lru_tree, expr, expr->revision);
|
||||
pat_lru_tree, expr, expr->ref->revision);
|
||||
if (lru && lru->domain) {
|
||||
ret = lru->data;
|
||||
return ret;
|
||||
@ -620,7 +620,7 @@ struct pattern *pat_match_reg(struct sample *smp, struct pattern_expr *expr, int
|
||||
}
|
||||
|
||||
if (lru)
|
||||
lru64_commit(lru, ret, expr, expr->revision, NULL);
|
||||
lru64_commit(lru, ret, expr, expr->ref->revision, NULL);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -679,7 +679,7 @@ struct pattern *pat_match_beg(struct sample *smp, struct pattern_expr *expr, int
|
||||
unsigned long long seed = pat_lru_seed ^ (long)expr;
|
||||
|
||||
lru = lru64_get(XXH64(smp->data.u.str.area, smp->data.u.str.data, seed),
|
||||
pat_lru_tree, expr, expr->revision);
|
||||
pat_lru_tree, expr, expr->ref->revision);
|
||||
if (lru && lru->domain) {
|
||||
ret = lru->data;
|
||||
return ret;
|
||||
@ -702,7 +702,7 @@ struct pattern *pat_match_beg(struct sample *smp, struct pattern_expr *expr, int
|
||||
}
|
||||
|
||||
if (lru)
|
||||
lru64_commit(lru, ret, expr, expr->revision, NULL);
|
||||
lru64_commit(lru, ret, expr, expr->ref->revision, NULL);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -720,7 +720,7 @@ struct pattern *pat_match_end(struct sample *smp, struct pattern_expr *expr, int
|
||||
unsigned long long seed = pat_lru_seed ^ (long)expr;
|
||||
|
||||
lru = lru64_get(XXH64(smp->data.u.str.area, smp->data.u.str.data, seed),
|
||||
pat_lru_tree, expr, expr->revision);
|
||||
pat_lru_tree, expr, expr->ref->revision);
|
||||
if (lru && lru->domain) {
|
||||
ret = lru->data;
|
||||
return ret;
|
||||
@ -743,7 +743,7 @@ struct pattern *pat_match_end(struct sample *smp, struct pattern_expr *expr, int
|
||||
}
|
||||
|
||||
if (lru)
|
||||
lru64_commit(lru, ret, expr, expr->revision, NULL);
|
||||
lru64_commit(lru, ret, expr, expr->ref->revision, NULL);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -765,7 +765,7 @@ struct pattern *pat_match_sub(struct sample *smp, struct pattern_expr *expr, int
|
||||
unsigned long long seed = pat_lru_seed ^ (long)expr;
|
||||
|
||||
lru = lru64_get(XXH64(smp->data.u.str.area, smp->data.u.str.data, seed),
|
||||
pat_lru_tree, expr, expr->revision);
|
||||
pat_lru_tree, expr, expr->ref->revision);
|
||||
if (lru && lru->domain) {
|
||||
ret = lru->data;
|
||||
return ret;
|
||||
@ -802,7 +802,7 @@ struct pattern *pat_match_sub(struct sample *smp, struct pattern_expr *expr, int
|
||||
}
|
||||
leave:
|
||||
if (lru)
|
||||
lru64_commit(lru, ret, expr, expr->revision, NULL);
|
||||
lru64_commit(lru, ret, expr, expr->ref->revision, NULL);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -1101,7 +1101,7 @@ void pat_prune_val(struct pattern_expr *expr)
|
||||
free_pattern_tree(&expr->pattern_tree);
|
||||
free_pattern_tree(&expr->pattern_tree_2);
|
||||
LIST_INIT(&expr->patterns);
|
||||
expr->revision = rdtsc();
|
||||
expr->ref->revision = rdtsc();
|
||||
}
|
||||
|
||||
void pat_prune_ptr(struct pattern_expr *expr)
|
||||
@ -1118,7 +1118,7 @@ void pat_prune_ptr(struct pattern_expr *expr)
|
||||
free_pattern_tree(&expr->pattern_tree);
|
||||
free_pattern_tree(&expr->pattern_tree_2);
|
||||
LIST_INIT(&expr->patterns);
|
||||
expr->revision = rdtsc();
|
||||
expr->ref->revision = rdtsc();
|
||||
}
|
||||
|
||||
void pat_prune_reg(struct pattern_expr *expr)
|
||||
@ -1135,7 +1135,7 @@ void pat_prune_reg(struct pattern_expr *expr)
|
||||
free_pattern_tree(&expr->pattern_tree);
|
||||
free_pattern_tree(&expr->pattern_tree_2);
|
||||
LIST_INIT(&expr->patterns);
|
||||
expr->revision = rdtsc();
|
||||
expr->ref->revision = rdtsc();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1160,7 +1160,7 @@ int pat_idx_list_val(struct pattern_expr *expr, struct pattern *pat, char **err)
|
||||
|
||||
/* chain pattern in the expression */
|
||||
LIST_ADDQ(&expr->patterns, &patl->list);
|
||||
expr->revision = rdtsc();
|
||||
expr->ref->revision = rdtsc();
|
||||
|
||||
/* that's ok */
|
||||
return 1;
|
||||
@ -1189,7 +1189,7 @@ int pat_idx_list_ptr(struct pattern_expr *expr, struct pattern *pat, char **err)
|
||||
|
||||
/* chain pattern in the expression */
|
||||
LIST_ADDQ(&expr->patterns, &patl->list);
|
||||
expr->revision = rdtsc();
|
||||
expr->ref->revision = rdtsc();
|
||||
|
||||
/* that's ok */
|
||||
return 1;
|
||||
@ -1219,7 +1219,7 @@ int pat_idx_list_str(struct pattern_expr *expr, struct pattern *pat, char **err)
|
||||
|
||||
/* chain pattern in the expression */
|
||||
LIST_ADDQ(&expr->patterns, &patl->list);
|
||||
expr->revision = rdtsc();
|
||||
expr->ref->revision = rdtsc();
|
||||
|
||||
/* that's ok */
|
||||
return 1;
|
||||
@ -1248,7 +1248,7 @@ int pat_idx_list_reg_cap(struct pattern_expr *expr, struct pattern *pat, int cap
|
||||
|
||||
/* chain pattern in the expression */
|
||||
LIST_ADDQ(&expr->patterns, &patl->list);
|
||||
expr->revision = rdtsc();
|
||||
expr->ref->revision = rdtsc();
|
||||
|
||||
/* that's ok */
|
||||
return 1;
|
||||
@ -1297,7 +1297,7 @@ int pat_idx_tree_ip(struct pattern_expr *expr, struct pattern *pat, char **err)
|
||||
|
||||
/* Insert the entry. */
|
||||
ebmb_insert_prefix(&expr->pattern_tree, &node->node, 4);
|
||||
expr->revision = rdtsc();
|
||||
expr->ref->revision = rdtsc();
|
||||
|
||||
/* that's ok */
|
||||
return 1;
|
||||
@ -1325,7 +1325,7 @@ int pat_idx_tree_ip(struct pattern_expr *expr, struct pattern *pat, char **err)
|
||||
|
||||
/* Insert the entry. */
|
||||
ebmb_insert_prefix(&expr->pattern_tree_2, &node->node, 16);
|
||||
expr->revision = rdtsc();
|
||||
expr->ref->revision = rdtsc();
|
||||
|
||||
/* that's ok */
|
||||
return 1;
|
||||
@ -1369,7 +1369,7 @@ int pat_idx_tree_str(struct pattern_expr *expr, struct pattern *pat, char **err)
|
||||
|
||||
/* index the new node */
|
||||
ebst_insert(&expr->pattern_tree, &node->node);
|
||||
expr->revision = rdtsc();
|
||||
expr->ref->revision = rdtsc();
|
||||
|
||||
/* that's ok */
|
||||
return 1;
|
||||
@ -1411,7 +1411,7 @@ int pat_idx_tree_pfx(struct pattern_expr *expr, struct pattern *pat, char **err)
|
||||
|
||||
/* index the new node */
|
||||
ebmb_insert_prefix(&expr->pattern_tree, &node->node, len);
|
||||
expr->revision = rdtsc();
|
||||
expr->ref->revision = rdtsc();
|
||||
|
||||
/* that's ok */
|
||||
return 1;
|
||||
@ -1432,7 +1432,7 @@ void pat_del_list_val(struct pattern_expr *expr, struct pat_ref_elt *ref)
|
||||
free(pat->pat.data);
|
||||
free(pat);
|
||||
}
|
||||
expr->revision = rdtsc();
|
||||
expr->ref->revision = rdtsc();
|
||||
}
|
||||
|
||||
void pat_del_tree_ip(struct pattern_expr *expr, struct pat_ref_elt *ref)
|
||||
@ -1476,7 +1476,7 @@ void pat_del_tree_ip(struct pattern_expr *expr, struct pat_ref_elt *ref)
|
||||
free(elt->data);
|
||||
free(elt);
|
||||
}
|
||||
expr->revision = rdtsc();
|
||||
expr->ref->revision = rdtsc();
|
||||
}
|
||||
|
||||
void pat_del_list_ptr(struct pattern_expr *expr, struct pat_ref_elt *ref)
|
||||
@ -1495,7 +1495,7 @@ void pat_del_list_ptr(struct pattern_expr *expr, struct pat_ref_elt *ref)
|
||||
free(pat->pat.data);
|
||||
free(pat);
|
||||
}
|
||||
expr->revision = rdtsc();
|
||||
expr->ref->revision = rdtsc();
|
||||
}
|
||||
|
||||
void pat_del_tree_str(struct pattern_expr *expr, struct pat_ref_elt *ref)
|
||||
@ -1523,7 +1523,7 @@ void pat_del_tree_str(struct pattern_expr *expr, struct pat_ref_elt *ref)
|
||||
free(elt->data);
|
||||
free(elt);
|
||||
}
|
||||
expr->revision = rdtsc();
|
||||
expr->ref->revision = rdtsc();
|
||||
}
|
||||
|
||||
void pat_del_list_reg(struct pattern_expr *expr, struct pat_ref_elt *ref)
|
||||
@ -1542,13 +1542,12 @@ void pat_del_list_reg(struct pattern_expr *expr, struct pat_ref_elt *ref)
|
||||
free(pat->pat.data);
|
||||
free(pat);
|
||||
}
|
||||
expr->revision = rdtsc();
|
||||
expr->ref->revision = rdtsc();
|
||||
}
|
||||
|
||||
void pattern_init_expr(struct pattern_expr *expr)
|
||||
{
|
||||
LIST_INIT(&expr->patterns);
|
||||
expr->revision = 0;
|
||||
expr->pattern_tree = EB_ROOT;
|
||||
expr->pattern_tree_2 = EB_ROOT;
|
||||
}
|
||||
@ -1853,6 +1852,7 @@ struct pat_ref *pat_ref_new(const char *reference, const char *display, unsigned
|
||||
|
||||
ref->flags = flags;
|
||||
ref->unique_id = -1;
|
||||
ref->revision = 0;
|
||||
|
||||
LIST_INIT(&ref->head);
|
||||
LIST_INIT(&ref->pat);
|
||||
|
Loading…
Reference in New Issue
Block a user