BUG/MEDIUM: filters: Set CF_FL_ANALYZE on channels when filters are attached
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 8 Mar 2021 12:40:30 +0000 (13:40 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 12 Mar 2021 12:47:13 +0000 (13:47 +0100)
commitbf6811332d4b514f6346a385f6acca9c094d1230
tree789969fb1b44e224767c0776a0169ee798ffa03b
parent946e55d8ebc06f22c774f3439c4c9034c267dde6
BUG/MEDIUM: filters: Set CF_FL_ANALYZE on channels when filters are attached

CF_FL_ANALYZE flag is used to know a channel is filtered. It is important to
synchronize request and response channels when the filtering ends.

However, it is possible to call all request analyzers before starting the
filtering on the response channel. This means flt_end_analyze() may be
called for the request channel before flt_start_analyze() on the response
channel. Thus because CF_FL_ANALYZE flag is not set on the response channel,
we consider the filtering is finished on both sides. The consequence is that
flt_end_analyze() is not called for the response and backend filters are
unregistered before their execution on the response channel.

It is possible to encounter this bug on TCP frontend or CONNECT request on
HTTP frontend if the client shutdown is reveiced with the first read.

To fix this bug, CF_FL_ANALYZE is set when filters are attached to the
stream. It means, on the request channel when the stream is created, in
flt_stream_start(). And on both channels when the backend is set, in
flt_set_stream_backend().

This patch must be backported as far as 1.7.

(cherry picked from commit 5647fbacdf822f2a6812a07dbdf27660f436f103)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 1b89c27781fce9ac83d9bc4d83bcc999bce4e5a0)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit efa89a22c2badcb7dc03c18667509a9b0265e544)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/filters.c