]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: compression: release the zlib pools between keep-alive requests
authorWilly Tarreau <w@1wt.eu>
Thu, 15 Nov 2012 15:41:22 +0000 (16:41 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 15 Nov 2012 15:41:22 +0000 (16:41 +0100)
There was a possible memory leak in the zlib code when the first response of
a keep-alive session was compressed, because the next request would reset the
compression algo, preventing a later call to session_free() from releasing it.
The reason is that it is necessary to release the assigned resources in
http_end_txn_clean_session().

src/proto_http.c
src/session.c

index 18364052c8be9b053c19fa31ff9453731b3edd95..b2ae01cc1a989b18282639fd23585c108aecbfba 100644 (file)
@@ -4085,6 +4085,12 @@ void http_end_txn_clean_session(struct session *s)
        s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT);
        s->flags &= ~(SN_DIRECT|SN_ASSIGNED|SN_ADDR_SET|SN_BE_ASSIGNED|SN_FORCE_PRST|SN_IGNORE_PRST);
        s->flags &= ~(SN_CURR_SESS|SN_REDIRECTABLE);
+
+       if (s->flags & SN_COMP_READY)
+               s->comp_algo->end(&s->comp_ctx);
+       s->comp_algo = NULL;
+       s->flags &= ~SN_COMP_READY;
+
        s->txn.meth = 0;
        http_reset_txn(s);
        s->txn.flags |= TX_NOT_FIRST | TX_WAIT_NEXT_RQ;
index f42f94293763e10858bbdefa95ecfe2e93957034..9827eb82e6422640a13545273e133eaefdb36040 100644 (file)
@@ -565,11 +565,10 @@ static void session_free(struct session *s)
                sess_change_server(s, NULL);
        }
 
-       if (s->flags & SN_COMP_READY) {
+       if (s->flags & SN_COMP_READY)
                s->comp_algo->end(&s->comp_ctx);
-               s->comp_algo = NULL;
-               s->flags &= ~SN_COMP_READY;
-       }
+       s->comp_algo = NULL;
+       s->flags &= ~SN_COMP_READY;
 
        if (s->req->pipe)
                put_pipe(s->req->pipe);