]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-quic: count in-progress requests
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 25 Jul 2022 09:21:46 +0000 (11:21 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 1 Aug 2022 12:58:41 +0000 (14:58 +0200)
Add a new qcc member named <nb_hreq>. Its purpose is close to <nb_sc>
which represents the number of attached stream connectors. Both are
incremented inside qc_attach_sc().

The difference is on the decrement operation. While <nb_cs> is
decremented on sedesc detach callback, <nb_hreq> is decremented when the
qcs is locally closed.

In most cases, <nb_hreq> will be decremented before <nb_cs>. However, it
will be the reverse if a stream must be kept alive after detach callback.

The main purpose of this field is to implement http-keep-alive timeout.
Both <nb_sc> and <nb_hreq> must be null to activate the http-keep-alive
timeout.

include/haproxy/mux_quic-t.h
include/haproxy/mux_quic.h
src/mux_quic.c

index 748500d67a40d6ca87a449b617f200bb1313a169..f7e538bafa864ef138f35e93d9659fbafbfe82a0 100644 (file)
@@ -33,6 +33,7 @@ enum qcs_type {
 struct qcc {
        struct connection *conn;
        uint64_t nb_sc; /* number of attached stream connectors */
+       uint64_t nb_hreq; /* number of in-progress http requests */
        uint32_t flags; /* QC_CF_* */
 
        struct {
index 0ad94cf32f577ce2aabc288173e0b1f59a1d08b7..bf0a18e4721a6290110970faaf3d8bb62c5a3d1e 100644 (file)
@@ -107,6 +107,7 @@ static inline struct stconn *qc_attach_sc(struct qcs *qcs, struct buffer *buf)
                return NULL;
 
        ++qcc->nb_sc;
+       ++qcc->nb_hreq;
 
        /* TODO duplicated from mux_h2 */
        sess->accept_date = date;
index a801c96258cdf5e52c4e7bbbd80f5abe89f97f15..549bcb0552275bc797bb3dd7b4c82e871eeaa1f4 100644 (file)
@@ -229,6 +229,20 @@ static forceinline struct stconn *qcs_sc(const struct qcs *qcs)
        return qcs->sd ? qcs->sd->sc : NULL;
 }
 
+/* Decrement <qcc> sc. */
+static forceinline void qcc_rm_sc(struct qcc *qcc)
+{
+       BUG_ON_HOT(!qcc->nb_sc);
+       --qcc->nb_sc;
+}
+
+/* Decrement <qcc> hreq. */
+static forceinline void qcc_rm_hreq(struct qcc *qcc)
+{
+       BUG_ON_HOT(!qcc->nb_hreq);
+       --qcc->nb_hreq;
+}
+
 /* Mark a stream as open if it was idle. This can be used on every
  * successful emission/reception operation to update the stream state.
  */
@@ -254,6 +268,7 @@ static void qcs_close_local(struct qcs *qcs)
 
        if (quic_stream_is_bidi(qcs->id)) {
                qcs->st = (qcs->st == QC_SS_HREM) ? QC_SS_CLO : QC_SS_HLOC;
+               qcc_rm_hreq(qcs->qcc);
        }
        else {
                /* Only local uni streams are valid for this operation. */
@@ -1780,7 +1795,7 @@ static int qc_init(struct connection *conn, struct proxy *prx,
 
        qcc->conn = conn;
        conn->ctx = qcc;
-       qcc->nb_sc = 0;
+       qcc->nb_hreq = qcc->nb_sc = 0;
        qcc->flags = 0;
 
        qcc->app_ops = NULL;
@@ -1912,7 +1927,8 @@ static void qc_detach(struct sedesc *sd)
         * BUG_ON_HOT() statement can be adjusted.
         */
        //BUG_ON_HOT(!qcs_is_close_remote(qcs));
-       --qcc->nb_sc;
+
+       qcc_rm_sc(qcc);
 
        if (!qcs_is_close_local(qcs) && !(qcc->conn->flags & CO_FL_ERROR)) {
                TRACE_DEVEL("leaving with remaining data, detaching qcs", QMUX_EV_STRM_END, qcc->conn, qcs);