]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: muxes: add a "show_sd" helper to complete "show sess" dumps
authorWilly Tarreau <w@1wt.eu>
Fri, 2 Sep 2022 13:00:48 +0000 (15:00 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 2 Sep 2022 13:48:50 +0000 (15:48 +0200)
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).

include/haproxy/connection-t.h
src/stream.c

index 5e107222df96e35ec5c6dfeec401ac1cd059407a..4222d3bd306757e99545f1359a24e153e99ee54d 100644 (file)
@@ -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 <es> to events, such as "being able to send" */
        int (*unsubscribe)(struct stconn *sc, int event_type,  struct wait_event *es); /* Unsubscribe <es> from events */
        int (*avail_streams)(struct connection *conn); /* Returns the number of streams still available for a connection */
index 49844c7f2ff8f687c2fad0798c0b30a9bfc47714..e268d68c6ba835ea653ea5c9cd720395e1d08ac1 100644 (file)
@@ -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,