BUG/MEDIUM: connections: Don't assume we have a mux in connect_server().

When dealing with the previous connection, don't assume it has a mux, as it
may not yet be the case if we're waiting for the ALPN.
This commit is contained in:
Olivier Houchard 2018-11-29 18:03:21 +01:00 committed by Willy Tarreau
parent 14547b2e1c
commit a49d41a9af

View File

@ -1106,8 +1106,8 @@ int connect_server(struct stream *s)
old_conn = srv_conn = s->sess->srv_conn; old_conn = srv_conn = s->sess->srv_conn;
if (srv_conn) if (srv_conn)
reuse = (s->target == srv_conn->target) && reuse = (s->target == srv_conn->target) &&
(srv_conn->mux->avail_streams(srv_conn) > 0) && conn_xprt_ready(srv_conn) && srv_conn->mux &&
conn_xprt_ready(srv_conn); (srv_conn->mux->avail_streams(srv_conn) > 0);
if (srv && !reuse) { if (srv && !reuse) {
srv_conn = NULL; srv_conn = NULL;
@ -1195,15 +1195,16 @@ int connect_server(struct stream *s)
LIST_DEL(&sess->conn_list); LIST_DEL(&sess->conn_list);
if (old_conn && if (old_conn &&
!(old_conn->flags & CO_FL_PRIVATE) && !(old_conn->flags & CO_FL_PRIVATE) &&
old_conn->mux != NULL &&
(old_conn->mux->avail_streams(old_conn) > 0) && (old_conn->mux->avail_streams(old_conn) > 0) &&
(srv_conn->mux->avail_streams(srv_conn) == 1)) { (srv_conn->mux->avail_streams(srv_conn) == 1)) {
LIST_ADDQ(&old_conn->session_list, &sess->conn_list); LIST_ADDQ(&old_conn->session_list, &sess->conn_list);
sess->srv_conn = old_conn; sess->srv_conn = old_conn;
did_switch = 1;
} else { } else {
LIST_INIT(&sess->conn_list); LIST_INIT(&sess->conn_list);
sess->srv_conn = NULL; sess->srv_conn = NULL;
} }
did_switch = 1;
} }
} }