From: Christopher Faulet Date: Wed, 17 Jul 2019 19:36:33 +0000 (+0200) Subject: BUG/MINOR: session: Send a default HTTP error if accept fails for a H1 socket X-Git-Tag: v2.1-dev2~334 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39566d1892e30711e13ead44824543755f4a5522;p=thirdparty%2Fhaproxy.git BUG/MINOR: session: Send a default HTTP error if accept fails for a H1 socket If session_accept_fd() fails for a raw HTTP socket, we try to send an HTTP error 500. But we must not rely on error messages of the proxy or on the array http_err_chunks because these are HTX messages. And it should be too expensive to convert an HTX message to a raw message at this place. So instead, we send a default HTTP error message from the array http_err_msgs. This patch must be backported to 2.0 and 1.9. --- diff --git a/src/session.c b/src/session.c index f0f2b71b07..f608c46675 100644 --- a/src/session.c +++ b/src/session.c @@ -303,10 +303,7 @@ int session_accept_fd(struct listener *l, int cfd, struct sockaddr_storage *addr 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 */ - struct buffer *err_msg = &p->errmsg[HTTP_ERR_500]; - if (!err_msg->area) - err_msg = &http_err_chunks[HTTP_ERR_500]; - send(cfd, err_msg->area, err_msg->data, + send(cfd, http_err_msgs[HTTP_ERR_500], strlen(http_err_msgs[HTTP_ERR_500]), MSG_DONTWAIT|MSG_NOSIGNAL); }