BUG: compression: do not always increment the round counter on allocation failure

Zlib (at least 1.2 and 1.3) aborts when it fails to allocate the state, so we
must not count a round on this event. If the state succeeds, then it allocates
all the 4 remaining counters at once.
This commit is contained in:
Willy Tarreau 2012-11-15 14:57:56 +01:00
parent 4663577e24
commit 4690985fca

View File

@ -393,7 +393,13 @@ static void *alloc_zlib(void *opaque, unsigned int items, unsigned int size)
end:
round = (round + 1) % 5; /* there are 5 zalloc call in deflateInit2 */
/* deflateInit2() first allocates and checks the deflate_state, then if
* it succeeds, it allocates all other 4 areas at ones and checks them
* at the end. So we want to correctly count the rounds depending on when
* zlib is supposed to abort.
*/
if (buf || round)
round = (round + 1) % 5;
return buf;
}