From: Willy Tarreau Date: Fri, 2 Sep 2022 13:00:48 +0000 (+0200) Subject: MINOR: muxes: add a "show_sd" helper to complete "show sess" dumps X-Git-Tag: v2.7-dev5~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce57777660cc0048ed0cb57fc8407488fafa64c5;p=thirdparty%2Fhaproxy.git MINOR: muxes: add a "show_sd" helper to complete "show sess" dumps This helper will be called for muxes that provide it and will be used to let the mux provide extra information about the stream attached to a stream descriptor. A line prefix is passed in argument so that the mux is free to break long lines without breaking indent. No prefix means no line breaks should be produced (e.g. for short dumps). --- diff --git a/include/haproxy/connection-t.h b/include/haproxy/connection-t.h index 5e107222df..4222d3bd30 100644 --- a/include/haproxy/connection-t.h +++ b/include/haproxy/connection-t.h @@ -400,6 +400,7 @@ struct mux_ops { struct stconn *(*get_first_sc)(const struct connection *); /* retrieves any valid stconn from this connection */ void (*detach)(struct sedesc *); /* Detach an stconn from the stdesc from an outgoing connection, when the request is done */ int (*show_fd)(struct buffer *, struct connection *); /* append some data about connection into chunk for "show fd"; returns non-zero if suspicious */ + int (*show_sd)(struct buffer *, struct sedesc *, const char *pfx); /* append some data about the mux stream into chunk for "show sess"; returns non-zero if suspicious */ int (*subscribe)(struct stconn *sc, int event_type, struct wait_event *es); /* Subscribe to events, such as "being able to send" */ int (*unsubscribe)(struct stconn *sc, int event_type, struct wait_event *es); /* Unsubscribe from events */ int (*avail_streams)(struct connection *conn); /* Returns the number of streams still available for a connection */ diff --git a/src/stream.c b/src/stream.c index 49844c7f2f..e268d68c6b 100644 --- a/src/stream.c +++ b/src/stream.c @@ -3327,6 +3327,12 @@ static int stats_dump_full_strm_to_buffer(struct stconn *sc, struct stream *strm scf->sedesc->se, sc_ep_get(scf), scf->wait_event.events); if ((conn = sc_conn(scf)) != NULL) { + if (conn->mux && conn->mux->show_sd) { + chunk_appendf(&trash, " "); + conn->mux->show_sd(&trash, scf->sedesc, " "); + chunk_appendf(&trash, "\n"); + } + chunk_appendf(&trash, " co0=%p ctrl=%s xprt=%s mux=%s data=%s target=%s:%p\n", conn, @@ -3344,7 +3350,6 @@ static int stats_dump_full_strm_to_buffer(struct stconn *sc, struct stream *strm conn_fd(conn) >= 0 ? fdtab[conn->handle.fd].state : 0, conn_fd(conn) >= 0 ? !!(fdtab[conn->handle.fd].update_mask & ti->ltid_bit) : 0, conn_fd(conn) >= 0 ? fdtab[conn->handle.fd].thread_mask: 0); - } else if ((tmpctx = sc_appctx(scf)) != NULL) { chunk_appendf(&trash, @@ -3365,6 +3370,12 @@ static int stats_dump_full_strm_to_buffer(struct stconn *sc, struct stream *strm scb->sedesc->se, sc_ep_get(scb), scb->wait_event.events); if ((conn = sc_conn(scb)) != NULL) { + if (conn->mux && conn->mux->show_sd) { + chunk_appendf(&trash, " "); + conn->mux->show_sd(&trash, scb->sedesc, " "); + chunk_appendf(&trash, "\n"); + } + chunk_appendf(&trash, " co1=%p ctrl=%s xprt=%s mux=%s data=%s target=%s:%p\n", conn, @@ -3382,7 +3393,6 @@ static int stats_dump_full_strm_to_buffer(struct stconn *sc, struct stream *strm conn_fd(conn) >= 0 ? fdtab[conn->handle.fd].state : 0, conn_fd(conn) >= 0 ? !!(fdtab[conn->handle.fd].update_mask & ti->ltid_bit) : 0, conn_fd(conn) >= 0 ? fdtab[conn->handle.fd].thread_mask: 0); - } else if ((tmpctx = sc_appctx(scb)) != NULL) { chunk_appendf(&trash,