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.