]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: servers: Store the connection in the SI until we have a mux.
authorOlivier Houchard <ohouchard@haproxy.com>
Fri, 23 Nov 2018 16:07:04 +0000 (17:07 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 23 Nov 2018 18:11:14 +0000 (19:11 +0100)
When we create a connection, if we have to defer the conn_stream and the
mux creation until we can decide it (ie until the SSL handshake is done, and
the ALPN is decided), store the connection in the stream_interface, so that
we're sure we can destroy it if needed.

include/proto/stream_interface.h
src/backend.c

index 5568fdb682839844eff0543f57a36701e2a48ded..a091439e429432533ebc5b6b5845077e76657812 100644 (file)
@@ -161,6 +161,7 @@ static inline enum obj_type *si_detach_endpoint(struct stream_interface *si)
  */
 static inline void si_release_endpoint(struct stream_interface *si)
 {
+       struct connection *conn;
        struct conn_stream *cs;
        struct appctx *appctx;
 
@@ -177,7 +178,8 @@ static inline void si_release_endpoint(struct stream_interface *si)
                if (appctx->applet->release && si->state < SI_ST_DIS)
                        appctx->applet->release(appctx);
                appctx_free(appctx); /* we share the connection pool */
-       }
+       } else if ((conn = objt_conn(si->end)))
+               conn_free(conn);
        si_detach_endpoint(si);
 }
 
index 3ab450bcb147dd49694a50df2c838b336fb09ad9..cdc63c6ad625a38745b467afdaaf93d49ef93f3f 100644 (file)
@@ -1279,9 +1279,10 @@ int connect_server(struct stream *s)
                        /* Store the connection into the stream interface,
                         * while we still don't have a mux, so that if the
                         * stream is destroyed before the connection is
-                        * established, and a mux is set, we don't attempt
-                        * to access the stream
+                        * established, we have a chance to destroy it even
+                        * if it is no longer referenced in the session.
                         */
+                       s->si[1].end = &srv_conn->obj_type;
                        conn_set_xprt_done_cb(srv_conn, conn_complete_server);
                }