From: Christopher Faulet Date: Wed, 5 Feb 2025 15:04:26 +0000 (+0100) Subject: MINOR: mux-spop/mux-fcgi: Add support of the debug string for logs X-Git-Tag: v3.2-dev5~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0aa69e78656f48256798686f7ee06eb3ba3e5004;p=thirdparty%2Fhaproxy.git MINOR: mux-spop/mux-fcgi: Add support of the debug string for logs 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]>" --- diff --git a/src/mux_fcgi.c b/src/mux_fcgi.c index 0de287507..289c85c23 100644 --- a/src/mux_fcgi.c +++ b/src/mux_fcgi.c @@ -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: diff --git a/src/mux_spop.c b/src/mux_spop.c index 4667f6c27..6f4794676 100644 --- a/src/mux_spop.c +++ b/src/mux_spop.c @@ -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: