mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-05-01 07:18:02 +00:00
MINOR: compression/slz: add support for a pure flush of pending bytes
While HTTP makes no promises of sub-message delivery, haproxy tries to make reasonable efforts to be friendly to applications relying on this, particularly though the "option http-no-delay" statement. However, it was reported that when slz compression is being used, a few bytes can remain pending for more data to complete them in the SLZ queue when built on a 64-bit little endian architecture. This is because aligning blocks on byte boundary is costly (requires to switch to literals and to send 4 bytes of block size), so incomplete bytes are left pending there until they reach at least 32 bits. On other architecture, the queue is only 8 bits long. Robert Newson from Apache's CouchDB project explained that the heartbeat used by CouchDB periodically delivers a single LF character, that it used to work fine before the change enlarging the queue for 64-bit platforms, but only forwards once every 3 LF after the change. This was definitely caused by this incomplete byte sequence queuing. Zlib is not affected, and the code shows that ->flush() is always called. In the case of SLZ, the called function is rfc195x_flush_or_finish() and when its "finish" argument is zero, no flush is performed because there was no such flush() operation. The previous patch implemented a flush() operation in SLZ, and this one makes rfc195x_flush_or_finish() call it when finish==0. This way each delivered data block will now provoke a flush of the queue as is done with zlib. This may very slightly degrade the compression ratio, but another change is needed to condition this on "option http-no-delay" only in order to be consistent with other parts of the code. This patch (and the preceeding slz one) should be backported at least to 2.6, but any further change to depend on http-no-delay should not.
This commit is contained in:
parent
90d18e2006
commit
56f15298d9
@ -350,6 +350,8 @@ static int rfc195x_flush_or_finish(struct comp_ctx *comp_ctx, struct buffer *out
|
||||
|
||||
if (finish)
|
||||
b_add(out, slz_finish(strm, b_tail(out)));
|
||||
else
|
||||
b_add(out, slz_flush(strm, b_tail(out)));
|
||||
|
||||
out_len = b_data(out) - out_len;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user