]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: compression: deinit zlib only when required
authorWilliam Lallemand <wlallemand@exceliance.fr>
Mon, 12 Nov 2012 16:02:18 +0000 (17:02 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 15 Nov 2012 14:42:17 +0000 (15:42 +0100)
The zlib stream was deinitialized even when the init failed.

include/types/session.h
src/proto_http.c
src/session.c

index f0a5be645b591763de0c473d2be494ff6d237f15..284b7e892bb62458d602b291c59b5416f70701f2 100644 (file)
@@ -89,6 +89,8 @@
 #define SN_BE_TRACK_SC1 0x00100000     /* backend tracks stick-counter 1 */
 #define SN_BE_TRACK_SC2 0x00200000     /* backend tracks stick-counter 2 */
 
+#define SN_COMP_READY   0x00400000     /* the compression is initialized */
+
 
 /* WARNING: if new fields are added, they must be initialized in event_accept()
  * and freed in session_free() !
index 4fc37ed5da56bac26bfaa025afd58568649e531d..18364052c8be9b053c19fa31ff9453731b3edd95 100644 (file)
@@ -2103,6 +2103,8 @@ int select_compression_response_header(struct session *s, struct buffer *res)
        if (s->comp_algo->init(&s->comp_ctx, global.tune.comp_maxlevel) < 0)
                goto fail;
 
+       s->flags |= SN_COMP_READY;
+
        s->comp_ctx.cur_lvl = global.tune.comp_maxlevel;
 
        /* remove Content-Length header */
@@ -2131,9 +2133,10 @@ int select_compression_response_header(struct session *s, struct buffer *res)
        return 1;
 
 fail:
-       if (s->comp_algo) {
+       if (s->flags & SN_COMP_READY) {
                s->comp_algo->end(&s->comp_ctx);
                s->comp_algo = NULL;
+               s->flags &= ~SN_COMP_READY;
        }
        return 0;
 }
index 0b0a4ec5f03bd6665d4e2694a89c41946f3fb02c..f42f94293763e10858bbdefa95ecfe2e93957034 100644 (file)
@@ -565,9 +565,10 @@ static void session_free(struct session *s)
                sess_change_server(s, NULL);
        }
 
-       if (s->comp_algo) {
+       if (s->flags & SN_COMP_READY) {
                s->comp_algo->end(&s->comp_ctx);
                s->comp_algo = NULL;
+               s->flags &= ~SN_COMP_READY;
        }
 
        if (s->req->pipe)