diff options
| author | Willy Tarreau <w@1wt.eu> | 2021-04-30 13:19:37 +0200 |
|---|---|---|
| committer | Willy Tarreau <w@1wt.eu> | 2021-04-30 15:36:31 +0200 |
| commit | a13afe6535e29e7dfe9a488cc2aed7795ed5bbf1 (patch) | |
| tree | b6948df9432e83247cd8de8bf6454993667a75b1 /include/haproxy | |
| parent | 95f753e4037c95c4e17084781616fea2bb4c14bd (diff) | |
| download | haproxy-a13afe6535e29e7dfe9a488cc2aed7795ed5bbf1.tar.gz | |
MINOR: pattern: support purging arbitrary ranges of generations
Instead of being able to purge only values older than a specific value,
let's support arbitrary ranges and make pat_ref_purge_older() just be
one special case of this one.
Diffstat (limited to 'include/haproxy')
| -rw-r--r-- | include/haproxy/pattern.h | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/include/haproxy/pattern.h b/include/haproxy/pattern.h index aaa8964ff..7f785095d 100644 --- a/include/haproxy/pattern.h +++ b/include/haproxy/pattern.h @@ -192,7 +192,7 @@ void pat_ref_delete_by_ptr(struct pat_ref *ref, struct pat_ref_elt *elt); 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_older(struct pat_ref *ref, unsigned int oldest, int budget); +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 @@ -237,6 +237,20 @@ static inline int pat_ref_commit(struct pat_ref *ref, unsigned int gen) return gen - ref->curr_gen; } +/* This function purges all elements from <ref> that are older than generation + * <oldest>. It will not purge more than <budget> entries at once, in order to + * remain responsive. If budget is negative, no limit is applied. + * The caller must already hold the PATREF_LOCK on <ref>. The function will + * take the PATEXP_LOCK on all expressions of the pattern as needed. It returns + * non-zero on completion, or zero if it had to stop before the end after + * <budget> was depleted. + */ +static inline int pat_ref_purge_older(struct pat_ref *ref, uint oldest, int budget) +{ + return pat_ref_purge_range(ref, oldest + 1, oldest - 1, budget); +} + + /* * pattern_head manipulation. */ |
