BUG/MINOR: session: Emit an HTTP error if accept fails only for H1 connection

If session_accept_fd() fails for a raw HTTP socket, we try to send an HTTP error
500. But, we must also take care it is an HTTP/1 connection. We cannot rely on
the mux at this stage, because the error, if any, happens before or during its
creation. So, instead, we check if the mux_proto is specified or not. Indeed,
the mux h1 cannot be forced on the bind line and there is no ALPN to choose
another mux on a raw socket. So if there is no mux_proto defined for a raw HTTP
socket, we are sure to have an HTTP/1 connection.

This patch must be backported to 2.0 and 1.9.
This commit is contained in:
Christopher Faulet 2019-07-17 16:53:19 +02:00
parent f734638976
commit 76f4c370f1

View File

@ -300,7 +300,8 @@ int session_accept_fd(struct listener *l, int cfd, struct sockaddr_storage *addr
conn_free(cli_conn); conn_free(cli_conn);
out_close: out_close:
listener_release(l); listener_release(l);
if (ret < 0 && l->bind_conf->xprt == xprt_get(XPRT_RAW) && p->mode == PR_MODE_HTTP) { if (ret < 0 && l->bind_conf->xprt == xprt_get(XPRT_RAW) &&
p->mode == PR_MODE_HTTP && l->bind_conf->mux_proto == NULL) {
/* critical error, no more memory, try to emit a 500 response */ /* critical error, no more memory, try to emit a 500 response */
struct buffer *err_msg = &p->errmsg[HTTP_ERR_500]; struct buffer *err_msg = &p->errmsg[HTTP_ERR_500];
if (!err_msg->area) if (!err_msg->area)