]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: muxes: Add ctl commands to get info on streams for a connection
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 30 Apr 2024 14:18:07 +0000 (16:18 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 6 May 2024 20:00:00 +0000 (22:00 +0200)
There are 2 new ctl commands that may be used to retrieve the current number
of streams openned for a connection and its limit (the maximum number of
streams a mux connection supports).

For the PT and H1 muxes, the limit is always 1 and the current number of
streams is 0 for idle connections, otherwise 1 is returned.

For the H2 and the FCGI muxes, info are already available in the mux
connection.

For the QUIC mux, the limit is also directly available. It is the maximum
initial sub-ID of bidirectional stream allowed for the connection. For the
current number of streams, it is the number of SC attached on the connection
and the number of not already attached streams present in the "opening_list"
list.

include/haproxy/connection-t.h
src/mux_fcgi.c
src/mux_h1.c
src/mux_h2.c
src/mux_pt.c
src/mux_quic.c

index aad813e0cb29ab0d52ecd590b2c340277fe644b8..6ee0940be4bb00a0720700a1c4b2a9bc7e931b06 100644 (file)
@@ -323,6 +323,8 @@ enum mux_ctl_type {
        MUX_CTL_REVERSE_CONN, /* Notify about an active reverse connection accepted. */
        MUX_CTL_SUBS_RECV, /* Notify the mux it must wait for read events again  */
        MUX_CTL_GET_GLITCHES, /* returns number of glitches on the connection */
+       MUX_CTL_GET_NBSTRM, /* Return the current number of streams on the connection */
+       MUX_CTL_GET_MAXSTRM, /* Return the max number of streams supported by the connection */
 };
 
 /* sctl command used by mux->sctl() */
index a611c0a7e70cd1f8be2b07878815155bb96d3c1e..fb8517982c159c6582158f0a8cd43fd425b9ec2e 100644 (file)
@@ -3089,7 +3089,9 @@ static int fcgi_wake(struct connection *conn)
 
 static int fcgi_ctl(struct connection *conn, enum mux_ctl_type mux_ctl, void *output)
 {
+       struct fcgi_conn *fconn = conn->ctx;
        int ret = 0;
+
        switch (mux_ctl) {
        case MUX_CTL_STATUS:
                if (!(conn->flags & CO_FL_WAIT_XPRT))
@@ -3097,6 +3099,10 @@ static int fcgi_ctl(struct connection *conn, enum mux_ctl_type mux_ctl, void *ou
                return ret;
        case MUX_CTL_EXIT_STATUS:
                return MUX_ES_UNKNOWN;
+       case MUX_CTL_GET_NBSTRM:
+               return fconn->nb_streams;
+       case MUX_CTL_GET_MAXSTRM:
+               return fconn->streams_limit;
        default:
                return -1;
        }
index 39e23956c912bb4669a3c7b42f53d7f6cbb8efa8..85ba0c5fa8732d540182a53aa9b7b9c49fb94710 100644 (file)
@@ -5025,6 +5025,10 @@ static int h1_ctl(struct connection *conn, enum mux_ctl_type mux_ctl, void *outp
                if (!(h1c->wait_event.events & SUB_RETRY_RECV))
                        h1c->conn->xprt->subscribe(h1c->conn, h1c->conn->xprt_ctx, SUB_RETRY_RECV, &h1c->wait_event);
                return 0;
+       case MUX_CTL_GET_NBSTRM:
+               return h1_used_streams(conn);
+       case MUX_CTL_GET_MAXSTRM:
+               return 1;
        default:
                return -1;
        }
index f567ea5228b7ef4ceb98f3667ebb6f005d1dbff7..c8eb1b0c48731c4fdcc5cfc9cdebb37f664cf663 100644 (file)
@@ -4729,6 +4729,12 @@ static int h2_ctl(struct connection *conn, enum mux_ctl_type mux_ctl, void *outp
        case MUX_CTL_GET_GLITCHES:
                return h2c->glitches;
 
+       case MUX_CTL_GET_NBSTRM:
+               return h2c->nb_streams;
+
+       case MUX_CTL_GET_MAXSTRM:
+               return h2c->streams_limit;
+
        default:
                return -1;
        }
index dc9702eb0b6d63cf14dc98c56c9e6fa7b2d38782..6dbbe04cd17a482b6a2429c5fb9dcc0acb7e8c37 100644 (file)
@@ -781,6 +781,7 @@ static int mux_pt_unsubscribe(struct stconn *sc, int event_type, struct wait_eve
 static int mux_pt_ctl(struct connection *conn, enum mux_ctl_type mux_ctl, void *output)
 {
        int ret = 0;
+
        switch (mux_ctl) {
        case MUX_CTL_STATUS:
                if (!(conn->flags & CO_FL_WAIT_XPRT))
@@ -788,6 +789,10 @@ static int mux_pt_ctl(struct connection *conn, enum mux_ctl_type mux_ctl, void *
                return ret;
        case MUX_CTL_EXIT_STATUS:
                return MUX_ES_UNKNOWN;
+       case MUX_CTL_GET_NBSTRM:
+               return mux_pt_used_streams(conn);
+       case MUX_CTL_GET_MAXSTRM:
+               return 1;
        default:
                return -1;
        }
index 4c12c7e1b19a2ead48b9854ebc5eb1ee736b90cf..b7f3f9ca26eeb2159b2f08dfadf4e593a40447eb 100644 (file)
@@ -3144,6 +3144,18 @@ static int qmux_ctl(struct connection *conn, enum mux_ctl_type mux_ctl, void *ou
        case MUX_CTL_EXIT_STATUS:
                return MUX_ES_UNKNOWN;
 
+       case MUX_CTL_GET_NBSTRM: {
+               struct qcs *qcs;
+               unsigned int nb_strm = qcc->nb_sc;
+
+               list_for_each_entry(qcs, &qcc->opening_list, el_opening)
+                       nb_strm++;
+               return nb_strm;
+       }
+
+       case MUX_CTL_GET_MAXSTRM:
+               return qcc->lfctl.ms_bidi_init;
+
        default:
                return -1;
        }