~ubuntu-branches/debian/sid/haproxy/sid

« back to all changes in this revision

Viewing changes to debian/patches/from-upstream/0006-BUG-MEDIUM-pattern-don-t-load-more-than-once-a-patte.patch

  • Committer: Package Import Robot
  • Author(s): Vincent Bernat
  • Date: 2014-12-07 11:11:21 UTC
  • Revision ID: package-import@ubuntu.com-20141207111121-qgifv7nl6eoi3lek
Tags: 1.5.8-2
* Cherry-pick the following patches from 1.5.9 release:
    - 8a0b93bde77e BUG/MAJOR: sessions: unlink session from list on out
                              of memory
    - bae03eaad40a BUG/MEDIUM: pattern: don't load more than once a pattern
                               list.
    - 93637b6e8503 BUG/MEDIUM: connection: sanitize PPv2 header length before
                               parsing address information
    - 8ba50128832b BUG/MAJOR: frontend: initialize capture pointers earlier
    - 1f96a87c4e14 BUG/MEDIUM: checks: fix conflicts between agent checks and
                               ssl healthchecks
    - 9bcc01ae2598 BUG/MEDIUM: ssl: force a full GC in case of memory shortage
    - 909514970089 BUG/MEDIUM: ssl: fix bad ssl context init can cause
                               segfault in case of OOM.
* Cherry-pick the following patches from future 1.5.10 release:
    - 1e89acb6be9b BUG/MEDIUM: payload: ensure that a request channel is
                               available
    - bad3c6f1b6d7 BUG/MEDIUM: patterns: previous fix was incomplete

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From a0e753b688853c7ac751bcb183978eba063e68f1 Mon Sep 17 00:00:00 2001
 
2
From: Thierry FOURNIER <tfournier@exceliance.fr>
 
3
Date: Mon, 24 Nov 2014 11:14:42 +0100
 
4
Subject: [PATCH 6/9] BUG/MEDIUM: pattern: don't load more than once a pattern
 
5
 list.
 
6
 
 
7
A memory optimization can use the same pattern expression for many
 
8
equal pattern list (same parse method, index method and index_smp
 
9
method).
 
10
 
 
11
The pattern expression is returned by "pattern_new_expr", but this
 
12
function dont indicate if the returned pattern is already in use.
 
13
 
 
14
So, the caller function reload the list of patterns in addition with
 
15
the existing patterns. This behavior is not a problem with tree indexed
 
16
pattern, but it grows the lists indexed patterns.
 
17
 
 
18
This fix add a "reuse" flag in return of the function "pattern_new_expr".
 
19
If the flag is set, I suppose that the patterns are already loaded.
 
20
 
 
21
This fix must be backported into 1.5.
 
22
(cherry picked from commit 315ec4217f912f6cc8fcf98624d852f9cd8399f9)
 
23
---
 
24
 include/proto/pattern.h |  3 ++-
 
25
 src/acl.c               |  2 +-
 
26
 src/pattern.c           | 22 ++++++++++++++++++++--
 
27
 3 files changed, 23 insertions(+), 4 deletions(-)
 
28
 
 
29
diff --git a/include/proto/pattern.h b/include/proto/pattern.h
 
30
index 4a969ac199e4..7855474e5b44 100644
 
31
--- a/include/proto/pattern.h
 
32
+++ b/include/proto/pattern.h
 
33
@@ -206,7 +206,8 @@ int pattern_read_from_file(struct pattern_head *head, unsigned int refflags, con
 
34
  */
 
35
 void pattern_init_expr(struct pattern_expr *expr);
 
36
 struct pattern_expr *pattern_lookup_expr(struct pattern_head *head, struct pat_ref *ref);
 
37
-struct pattern_expr *pattern_new_expr(struct pattern_head *head, struct pat_ref *ref, char **err);
 
38
+struct pattern_expr *pattern_new_expr(struct pattern_head *head, struct pat_ref *ref,
 
39
+                                      char **err, int *reuse);
 
40
 struct sample_storage **pattern_find_smp(struct pattern_expr *expr, struct pat_ref_elt *elt);
 
41
 int pattern_delete(struct pattern_expr *expr, struct pat_ref_elt *ref);
 
42
 
 
43
diff --git a/src/acl.c b/src/acl.c
 
44
index 8f3fd9eaa746..d8b3000c0c36 100644
 
45
--- a/src/acl.c
 
46
+++ b/src/acl.c
 
47
@@ -532,7 +532,7 @@ struct acl_expr *parse_acl_expr(const char **args, char **err, struct arg_list *
 
48
        }
 
49
 
 
50
        /* Create new pattern expression associated to this reference. */
 
51
-       pattern_expr = pattern_new_expr(&expr->pat, ref, err);
 
52
+       pattern_expr = pattern_new_expr(&expr->pat, ref, err, NULL);
 
53
        if (!pattern_expr)
 
54
                goto out_free_expr;
 
55
 
 
56
diff --git a/src/pattern.c b/src/pattern.c
 
57
index c63365d74bf7..20547f9607be 100644
 
58
--- a/src/pattern.c
 
59
+++ b/src/pattern.c
 
60
@@ -1855,12 +1855,19 @@ struct pattern_expr *pattern_lookup_expr(struct pattern_head *head, struct pat_r
 
61
  * <ref> can be NULL. If an error is occured, the function returns NULL and
 
62
  * <err> is filled. Otherwise, the function returns new pattern_expr linked
 
63
  * with <head> and <ref>.
 
64
+ *
 
65
+ * The returned value can be a alredy filled pattern list, in this case the
 
66
+ * flag <reuse> is set.
 
67
  */
 
68
-struct pattern_expr *pattern_new_expr(struct pattern_head *head, struct pat_ref *ref, char **err)
 
69
+struct pattern_expr *pattern_new_expr(struct pattern_head *head, struct pat_ref *ref,
 
70
+                                      char **err, int *reuse)
 
71
 {
 
72
        struct pattern_expr *expr;
 
73
        struct pattern_expr_list *list;
 
74
 
 
75
+       if (reuse)
 
76
+               *reuse = 0;
 
77
+
 
78
        /* Memory and initialization of the chain element. */
 
79
        list = malloc(sizeof(*list));
 
80
        if (!list) {
 
81
@@ -1915,6 +1922,8 @@ struct pattern_expr *pattern_new_expr(struct pattern_head *head, struct pat_ref
 
82
                 * with ref and we must not free it.
 
83
                 */
 
84
                list->do_free = 0;
 
85
+               if (reuse)
 
86
+                       *reuse = 1;
 
87
        }
 
88
 
 
89
        /* The new list element reference the pattern_expr. */
 
90
@@ -2087,6 +2096,7 @@ int pattern_read_from_file(struct pattern_head *head, unsigned int refflags,
 
91
        struct pat_ref *ref;
 
92
        struct pattern_expr *expr;
 
93
        struct pat_ref_elt *elt;
 
94
+       int reuse;
 
95
 
 
96
        /* Lookup for the existing reference. */
 
97
        ref = pat_ref_lookup(filename);
 
98
@@ -2161,12 +2171,20 @@ int pattern_read_from_file(struct pattern_head *head, unsigned int refflags,
 
99
         */
 
100
        expr = pattern_lookup_expr(head, ref);
 
101
        if (!expr || (expr->mflags != patflags)) {
 
102
-               expr = pattern_new_expr(head, ref, err);
 
103
+               expr = pattern_new_expr(head, ref, err, &reuse);
 
104
                if (!expr)
 
105
                        return 0;
 
106
                expr->mflags = patflags;
 
107
        }
 
108
 
 
109
+       /* The returned expression may be not empty, because the function
 
110
+        * "pattern_new_expr" lookup for similar pattern list and can
 
111
+        * reuse a already filled pattern list. In this case, we can not
 
112
+        * reload the patterns.
 
113
+        */
 
114
+       if (reuse)
 
115
+               return 1;
 
116
+
 
117
        /* Load reference content in the pattern expression. */
 
118
        list_for_each_entry(elt, &ref->head, list) {
 
119
                if (!pat_ref_push(elt, expr, patflags, err)) {
 
120
-- 
 
121
2.1.3
 
122