mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-05-09 11:18:04 +00:00
CLEANUP: pattern: remove the unused and dangerous pat_ref_reload()
This function was not used anymore after the atomic updates were implemented in 2.3, and it must not be used given that it does not yield and can easily make the process hang for tens of seconds on large acls/maps. Let's remove it before someone uses it as an example to implement something else!
This commit is contained in:
parent
f5fb858bb7
commit
da7f11bfb5
@ -193,7 +193,6 @@ int pat_ref_delete_by_id(struct pat_ref *ref, struct pat_ref_elt *refelt);
|
||||
int pat_ref_prune(struct pat_ref *ref);
|
||||
int pat_ref_commit_elt(struct pat_ref *ref, struct pat_ref_elt *elt, char **err);
|
||||
int pat_ref_purge_range(struct pat_ref *ref, uint from, uint to, int budget);
|
||||
void pat_ref_reload(struct pat_ref *ref, struct pat_ref *replace);
|
||||
|
||||
/* Create a new generation number for next pattern updates and returns it. This
|
||||
* must be used to atomically insert new patterns that will atomically replace
|
||||
|
@ -2081,96 +2081,6 @@ int pat_ref_purge_range(struct pat_ref *ref, uint from, uint to, int budget)
|
||||
return done;
|
||||
}
|
||||
|
||||
/* This function prunes <ref>, replaces all references by the references
|
||||
* of <replace>, and reindexes all the news values.
|
||||
*
|
||||
* The patterns are loaded in best effort and the errors are ignored,
|
||||
* but written in the logs.
|
||||
*/
|
||||
void pat_ref_reload(struct pat_ref *ref, struct pat_ref *replace)
|
||||
{
|
||||
struct pattern_expr *expr;
|
||||
struct pat_ref_elt *elt, *safe;
|
||||
struct bref *bref, *back;
|
||||
struct pattern pattern;
|
||||
|
||||
|
||||
HA_SPIN_LOCK(PATREF_LOCK, &ref->lock);
|
||||
list_for_each_entry(expr, &ref->pat, list) {
|
||||
HA_RWLOCK_WRLOCK(PATEXP_LOCK, &expr->lock);
|
||||
}
|
||||
|
||||
/* 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. */
|
||||
LIST_DEL_INIT(&bref->users);
|
||||
bref->ref = NULL;
|
||||
}
|
||||
pat_delete_gen(ref, elt);
|
||||
LIST_DELETE(&elt->list);
|
||||
free(elt->pattern);
|
||||
free(elt->sample);
|
||||
free(elt);
|
||||
}
|
||||
|
||||
/* switch pat_ret_elt lists */
|
||||
LIST_INSERT(&replace->head, &ref->head);
|
||||
LIST_DELETE(&replace->head);
|
||||
|
||||
list_for_each_entry(expr, &ref->pat, list) {
|
||||
list_for_each_entry(elt, &ref->head, list) {
|
||||
char *err = NULL;
|
||||
struct sample_data *data = NULL;
|
||||
|
||||
/* Create sample */
|
||||
if (elt->sample && expr->pat_head->parse_smp) {
|
||||
/* New sample. */
|
||||
data = malloc(sizeof(*data));
|
||||
if (!data)
|
||||
continue;
|
||||
|
||||
/* Parse value. */
|
||||
if (!expr->pat_head->parse_smp(elt->sample, data)) {
|
||||
memprintf(&err, "unable to parse '%s'", elt->sample);
|
||||
send_log(NULL, LOG_NOTICE, "%s", err);
|
||||
free(err);
|
||||
free(data);
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* initialise pattern */
|
||||
memset(&pattern, 0, sizeof(pattern));
|
||||
pattern.data = data;
|
||||
pattern.ref = elt;
|
||||
|
||||
/* parse pattern */
|
||||
if (!expr->pat_head->parse(elt->pattern, &pattern, expr->mflags, &err)) {
|
||||
send_log(NULL, LOG_NOTICE, "%s", err);
|
||||
free(err);
|
||||
free(data);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* index pattern */
|
||||
if (!expr->pat_head->index(expr, &pattern, &err)) {
|
||||
send_log(NULL, LOG_NOTICE, "%s", err);
|
||||
free(err);
|
||||
free(data);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
HA_RWLOCK_WRUNLOCK(PATEXP_LOCK, &expr->lock);
|
||||
}
|
||||
HA_SPIN_UNLOCK(PATREF_LOCK, &ref->lock);
|
||||
|
||||
#if defined(HA_HAVE_MALLOC_TRIM)
|
||||
malloc_trim(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* This function prunes all entries of <ref> and all their associated
|
||||
* pattern_expr. It may return before the end of the list is reached,
|
||||
* returning 0, to yield, indicating to the caller that it must call it again.
|
||||
|
Loading…
Reference in New Issue
Block a user