From: Olivier Houchard Date: Thu, 29 Nov 2018 17:01:46 +0000 (+0100) Subject: BUG/MEDIUM: streams: Don't assume we have a CS in sess_update_st_con_tcp. X-Git-Tag: v1.9-dev9~105 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14547b2e1c7e2d7c0b72b60c98059da750e8a8c6;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: streams: Don't assume we have a CS in sess_update_st_con_tcp. 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. --- diff --git a/src/stream.c b/src/stream.c index bba3f674ab..5c5091c405 100644 --- a/src/stream.c +++ b/src/stream.c @@ -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;