]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: streams: Don't assume we have a CS in sess_update_st_con_tcp.
authorOlivier Houchard <ohouchard@haproxy.com>
Thu, 29 Nov 2018 17:01:46 +0000 (18:01 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 1 Dec 2018 09:47:16 +0000 (10:47 +0100)
We can reach sess_update_st_con_tcp() while we still have a connection
attached, so take that into account, and free the connection, instead of
assuming it's always a conn_stream.

src/stream.c

index bba3f674ab553f75db7ff1d2f7e67719b9dab0a5..5c5091c4052d26c9cd82def6f7546d6812ddc800 100644 (file)
@@ -613,7 +613,11 @@ static int sess_update_st_con_tcp(struct stream *s)
        struct stream_interface *si = &s->si[1];
        struct channel *req = &s->req;
        struct channel *rep = &s->res;
-       struct conn_stream *srv_cs = __objt_cs(si->end);
+       struct conn_stream *srv_cs = objt_cs(si->end);
+       struct connection *conn = NULL;
+
+       if (!srv_cs)
+               conn = objt_conn(si->end);
 
        /* If we got an error, or if nothing happened and the connection timed
         * out, we must give up. The CER state handler will take care of retry
@@ -635,6 +639,11 @@ static int sess_update_st_con_tcp(struct stream *s)
 
                if (srv_cs)
                        cs_close(srv_cs);
+               else if (conn) {
+                       conn_stop_tracking(conn);
+                       conn_full_close(conn);
+                       conn_free(conn);
+               }
 
                if (si->err_type)
                        return 0;