BUG/MEDIUM: filters: Fix channels synchronization in flt_end_analyze
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 10 Mar 2017 10:52:44 +0000 (11:52 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 15 Mar 2017 18:09:06 +0000 (19:09 +0100)
commite6006245de214fa6689bbddb5463867452575b35
tree46f44692e97405c883026db3d0106e9bcf66233e
parenta5938f71e4b621e78ca44bd9191d695d5c7fbb05
BUG/MEDIUM: filters: Fix channels synchronization in flt_end_analyze

When a filter is used, there are 2 channel's analyzers to surround all the
others, flt_start_analyze and flt_end_analyze. This is the good place to acquire
and release resources used by filters, when needed. In addition, the last one is
used to synchronize the both channels, especially for HTTP streams. We must wait
that the analyze is finished for the both channels for an HTTP transaction
before restarting it for the next one.

But this part was buggy, leading to unexpected behaviours. First, depending on
which channel ends first, the request or the response can be switch in a
"forward forever" mode. Then, the HTTP transaction can be cleaned up too early,
while a processing is still in progress on a channel.

To fix the bug, the flag CF_FLT_ANALYZE has been added. It is set on channels in
flt_start_analyze and is kept if at least one filter is still analyzing the
channel. So, we can trigger the channel syncrhonization if this flag was removed
on the both channels. In addition, the flag TX_WAIT_CLEANUP has been added on
the transaction to know if the transaction must be cleaned up or not during
channels syncrhonization. This way, we are sure to reset everything once all the
processings are finished.

This patch should be backported in 1.7.
include/types/channel.h
include/types/proto_http.h
src/filters.c
src/proto_http.c