]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-spop/mux-fcgi: Add support of the debug string for logs
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 5 Feb 2025 15:04:26 +0000 (16:04 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 6 Feb 2025 10:19:32 +0000 (11:19 +0100)
Now it is possible to have debug info about FCGI and SPOP multiplexers. To do
so, the support for the MUX_SCTL_DBG_STR command was implemented for these
muxes.

The have this log message, the log-format must be set to:

  log-format "$HAPROXY_HTTP_LOG_FMT bs=<%[bs.debug_str]>"

src/mux_fcgi.c
src/mux_spop.c

index 0de2875071bdd1359b1ad9e909c5dfd5474aca9a..289c85c238ed77de699c7f91ae4a8c719e3de8ab 100644 (file)
@@ -299,6 +299,8 @@ static void fcgi_strm_notify_recv(struct fcgi_strm *fstrm);
 static void fcgi_strm_notify_send(struct fcgi_strm *fstrm);
 static void fcgi_strm_alert(struct fcgi_strm *fstrm);
 static int fcgi_strm_send_abort(struct fcgi_conn *fconn, struct fcgi_strm *fstrm);
+static int fcgi_dump_fcgi_conn_info(struct buffer *msg, struct fcgi_conn *fconn, const char *pfx);
+static int fcgi_dump_fcgi_strm_info(struct buffer *msg, const struct fcgi_strm *fstrm, const char *pfx);
 
 /* a dummy closed endpoint */
 static const struct sedesc closed_ep = {
@@ -3233,12 +3235,32 @@ static int fcgi_sctl(struct stconn *sc, enum mux_sctl_type mux_sctl, void *outpu
 {
        int ret = 0;
        struct fcgi_strm *fstrm = __sc_mux_strm(sc);
+       union mux_sctl_dbg_str_ctx *dbg_ctx;
+       struct buffer *buf;
 
        switch (mux_sctl) {
        case MUX_SCTL_SID:
                if (output)
                        *((int64_t *)output) = fstrm->id;
                return ret;
+       case MUX_SCTL_DBG_STR:
+               dbg_ctx = output;
+               buf = get_trash_chunk();
+
+               if (dbg_ctx->arg.debug_flags & MUX_SCTL_DBG_STR_L_MUXS)
+                       fcgi_dump_fcgi_strm_info(buf, fstrm, NULL);
+
+               if (dbg_ctx->arg.debug_flags & MUX_SCTL_DBG_STR_L_MUXC)
+                       fcgi_dump_fcgi_conn_info(buf, fstrm->fconn, NULL);
+
+               if (dbg_ctx->arg.debug_flags & MUX_SCTL_DBG_STR_L_CONN)
+                       chunk_appendf(buf, " conn.flg=%#08x conn.err_code=%u conn.evts=%s",
+                                     fstrm->fconn->conn->flags, fstrm->fconn->conn->err_code,
+                                     tevt_evts2str(fstrm->fconn->conn->term_evts_log));
+
+               /* other layers not implemented */
+               dbg_ctx->ret.buf = *buf;
+               return ret;
        case MUX_SCTL_TEVTS:
                return fstrm->sd->term_evts_log;
        default:
index 4667f6c2788ed6ff41239248e33944b06ad8a1fd..6f47946763b0dd23e220f3fa67b28364aa5f030e 100644 (file)
@@ -266,6 +266,8 @@ static void spop_strm_notify_send(struct spop_strm *spop_strm);
 static void spop_strm_alert(struct spop_strm *spop_strm);
 static inline void spop_remove_from_list(struct spop_strm *spop_strm);
 static inline void spop_conn_restart_reading(const struct spop_conn *spop_conn, int consider_buffer);
+static int spop_dump_spop_conn_info(struct buffer *msg, struct spop_conn *spop_conn, const char *pfx);
+static int spop_dump_spop_strm_info(struct buffer *msg, const struct spop_strm *spop_strm, const char *pfx);
 
 /* a dummy closed endpoint */
 static const struct sedesc closed_ep = {
@@ -2671,12 +2673,32 @@ static int spop_sctl(struct stconn *sc, enum mux_sctl_type mux_sctl, void *outpu
 {
        int ret = 0;
        struct spop_strm *spop_strm = __sc_mux_strm(sc);
+       union mux_sctl_dbg_str_ctx *dbg_ctx;
+       struct buffer *buf;
 
        switch (mux_sctl) {
        case MUX_SCTL_SID:
                if (output)
                        *((int64_t *)output) = spop_strm->id;
                return ret;
+       case MUX_SCTL_DBG_STR:
+               dbg_ctx = output;
+               buf = get_trash_chunk();
+
+               if (dbg_ctx->arg.debug_flags & MUX_SCTL_DBG_STR_L_MUXS)
+                       spop_dump_spop_strm_info(buf, spop_strm, NULL);
+
+               if (dbg_ctx->arg.debug_flags & MUX_SCTL_DBG_STR_L_MUXC)
+                       spop_dump_spop_conn_info(buf, spop_strm->spop_conn, NULL);
+
+               if (dbg_ctx->arg.debug_flags & MUX_SCTL_DBG_STR_L_CONN)
+                       chunk_appendf(buf, " conn.flg=%#08x conn.err_code=%u conn.evts=%s",
+                                     spop_strm->spop_conn->conn->flags, spop_strm->spop_conn->conn->err_code,
+                                     tevt_evts2str(spop_strm->spop_conn->conn->term_evts_log));
+
+               /* other layers not implemented */
+               dbg_ctx->ret.buf = *buf;
+               return ret;
        case MUX_SCTL_TEVTS:
                return spop_strm->sd->term_evts_log;
        default: