]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: log: Try to get the status code when MUX_EXIT_STATUS is retrieved
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 28 Sep 2021 09:36:28 +0000 (11:36 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 28 Sep 2021 11:52:25 +0000 (13:52 +0200)
The mux .ctl callback can provide some information about the mux to the
caller if the third parameter is provided. Thus, when MUX_EXIT_STATUS is
retrieved, a pointer on the status is now passed. The mux may fill it. It
will be pretty handy to provide custom error code from h1 mux instead of
default ones (400/408/500/501).

src/log.c

index 87590510216f8b60e6149a38ef9eab2224f7092d..dbbbace454460bd18f8dab9b242babbb09592760 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -2008,28 +2008,28 @@ int sess_build_logline(struct session *sess, struct stream *s, char *dst, size_t
                logs = &tmp_strm_log;
 
                if ((fe->mode == PR_MODE_HTTP) && fe_conn && fe_conn->mux && fe_conn->mux->ctl) {
-                       enum mux_exit_status es = fe_conn->mux->ctl(fe_conn, MUX_EXIT_STATUS, NULL);
+                       enum mux_exit_status es = fe_conn->mux->ctl(fe_conn, MUX_EXIT_STATUS, &status);
 
                        switch (es) {
                        case MUX_ES_SUCCESS:
                                break;
                        case MUX_ES_INVALID_ERR:
-                               status = 400;
+                               status = (status ? status : 400);
                                if ((fe_conn->flags & CO_FL_ERROR) || conn_xprt_read0_pending(fe_conn))
                                        s_flags = SF_ERR_CLICL | SF_FINST_R;
                                else
                                        s_flags = SF_ERR_PRXCOND | SF_FINST_R;
                                break;
                        case MUX_ES_TOUT_ERR:
-                               status = 408;
+                               status = (status ? status : 408);
                                s_flags = SF_ERR_CLITO | SF_FINST_R;
                                break;
                        case MUX_ES_NOTIMPL_ERR:
-                               status = 501;
+                               status = (status ? status : 501);
                                s_flags = SF_ERR_PRXCOND | SF_FINST_R;
                                break;
                        case MUX_ES_INTERNAL_ERR:
-                               status = 500;
+                               status = (status ? status : 500);
                                s_flags = SF_ERR_INTERNAL | SF_FINST_R;
                                break;
                        default: