mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-03-05 10:58:14 +00:00
MINOR: pattern: Add function to prune and reload pattern list.
This function it is used for dynamically update all the patterns attached to one file. This function is atomic. All parsing or indexation failures are reported in the haproxy logs.
This commit is contained in:
parent
a47a94fb13
commit
46006bde3c
@ -180,6 +180,8 @@ int pat_ref_delete(struct pat_ref *ref, const char *key);
|
|||||||
int pat_ref_delete_by_id(struct pat_ref *ref, struct pat_ref_elt *refelt);
|
int pat_ref_delete_by_id(struct pat_ref *ref, struct pat_ref_elt *refelt);
|
||||||
void pat_ref_prune(struct pat_ref *ref);
|
void pat_ref_prune(struct pat_ref *ref);
|
||||||
int pat_ref_load(struct pat_ref *ref, struct pattern_expr *expr, int patflags, int soe, char **err);
|
int pat_ref_load(struct pat_ref *ref, struct pattern_expr *expr, int patflags, int soe, char **err);
|
||||||
|
void pat_ref_reload(struct pat_ref *ref, struct pat_ref *replace);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* pattern_head manipulation.
|
* pattern_head manipulation.
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include <types/global.h>
|
#include <types/global.h>
|
||||||
#include <types/pattern.h>
|
#include <types/pattern.h>
|
||||||
|
|
||||||
|
#include <proto/log.h>
|
||||||
#include <proto/pattern.h>
|
#include <proto/pattern.h>
|
||||||
#include <proto/sample.h>
|
#include <proto/sample.h>
|
||||||
|
|
||||||
@ -1723,6 +1724,34 @@ int pat_ref_add(struct pat_ref *ref,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This function prune <ref>, replace all reference by the references
|
||||||
|
* of <replace>, and reindex all the news values.
|
||||||
|
*
|
||||||
|
* The pattern are loaded in best effort and the errors are ignored,
|
||||||
|
* but writed in the logs.
|
||||||
|
*/
|
||||||
|
void pat_ref_reload(struct pat_ref *ref, struct pat_ref *replace)
|
||||||
|
{
|
||||||
|
struct pattern_expr *expr;
|
||||||
|
struct pat_ref_elt *elt;
|
||||||
|
char *err = NULL;
|
||||||
|
|
||||||
|
pat_ref_prune(ref);
|
||||||
|
|
||||||
|
LIST_ADD(&replace->head, &ref->head);
|
||||||
|
LIST_DEL(&replace->head);
|
||||||
|
|
||||||
|
list_for_each_entry(elt, &ref->head, list) {
|
||||||
|
list_for_each_entry(expr, &ref->pat, list) {
|
||||||
|
if (!pat_ref_push(elt, expr, 0, &err)) {
|
||||||
|
send_log(NULL, LOG_NOTICE, "%s", err);
|
||||||
|
free(err);
|
||||||
|
err = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* This function prune all entries of <ref>. This function
|
/* This function prune all entries of <ref>. This function
|
||||||
* prune the associated pattern_expr.
|
* prune the associated pattern_expr.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user