]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: backend: Don't get proto to use for webscoket if there is no server
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 6 Mar 2026 08:24:29 +0000 (09:24 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 6 Mar 2026 08:24:32 +0000 (09:24 +0100)
In connect_server(), it is possible to have no server defined (dispatch mode
or transparent backend). In that case, we must be carefull to check the srv
variable in all calls involving the server. It was not perform at one place,
when the protocol to use for websocket is retrieved. This must not be done
when there is no server.

This patch should fix the first report in #3144. It must be backported to
all stable version.

src/backend.c

index 2034b2dd39987446a807b76f14b6b62f50bae0af..428036ddeff0a9396845f4abf4cdee9508741fe9 100644 (file)
@@ -2204,7 +2204,7 @@ int connect_server(struct stream *s)
         */
        if (may_start_mux_now) {
                const struct mux_ops *alt_mux =
-                 likely(!(s->flags & SF_WEBSOCKET)) ? NULL : srv_get_ws_proto(srv);
+                 likely(!(s->flags & SF_WEBSOCKET) || !srv) ? NULL : srv_get_ws_proto(srv);
                if (conn_install_mux_be(srv_conn, s->scb, s->sess, alt_mux) < 0) {
                        conn_full_close(srv_conn);
                        return SF_ERR_INTERNAL;