]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG: stream_interface: Reuse connection even if the output channel is empty
authorChristopher Faulet <cfaulet@qualys.com>
Wed, 23 Dec 2015 08:33:35 +0000 (09:33 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 3 Feb 2016 13:22:55 +0000 (14:22 +0100)
in function 'si_connect', an existing connection is reused (and considered as
established) only when there are some pending data in the output channel.

This can be problem when filters are used, because a filter can choose to not
forward data immediatly. So when we try to initiate a connection to a server,
the output channel can be empty. In this situation, if the connection already
exists, it is not considered as established and nothing happens. If the stream
interface is in the state SI_ST_ASS, this leads to an infinite loop in
process_stream because it remains in this state.

This patch fixes this problem. Now, in 'si_connect', we always reuse an existing
connection, whether or not there are pending data in the output channel.

include/proto/stream_interface.h

index ed8725710a5990ce98062ed886b2924ca6f32d91..525b6cf2c65229e05767d4266559ded685107c82 100644 (file)
@@ -362,11 +362,12 @@ static inline int si_connect(struct stream_interface *si)
                /* we're in the process of establishing a connection */
                si->state = SI_ST_CON;
        }
-       else if (!channel_is_empty(si_oc(si))) {
-               /* reuse the existing connection, we'll have to send a
-                * request there.
-                */
-               conn_data_want_send(conn);
+       else {
+               /* reuse the existing connection */
+               if (!channel_is_empty(si_oc(si))) {
+                       /* we'll have to send a request there. */
+                       conn_data_want_send(conn);
+               }
 
                /* the connection is established */
                si->state = SI_ST_EST;