BUG/MEDIUM: compression: release the zlib pools between keep-alive requests

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().
This commit is contained in:
Willy Tarreau 2012-11-15 16:41:22 +01:00
parent ec3e3890f0
commit 543db62e1f
2 changed files with 9 additions and 4 deletions

View 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->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_DIRECT|SN_ASSIGNED|SN_ADDR_SET|SN_BE_ASSIGNED|SN_FORCE_PRST|SN_IGNORE_PRST);
s->flags &= ~(SN_CURR_SESS|SN_REDIRECTABLE); 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; s->txn.meth = 0;
http_reset_txn(s); http_reset_txn(s);
s->txn.flags |= TX_NOT_FIRST | TX_WAIT_NEXT_RQ; s->txn.flags |= TX_NOT_FIRST | TX_WAIT_NEXT_RQ;

View File

@ -565,11 +565,10 @@ static void session_free(struct session *s)
sess_change_server(s, NULL); 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->end(&s->comp_ctx);
s->comp_algo = NULL; s->comp_algo = NULL;
s->flags &= ~SN_COMP_READY; s->flags &= ~SN_COMP_READY;
}
if (s->req->pipe) if (s->req->pipe)
put_pipe(s->req->pipe); put_pipe(s->req->pipe);