]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-quic: use stream states to mark as detached
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 11 Jul 2022 09:23:17 +0000 (11:23 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 11 Jul 2022 14:41:10 +0000 (16:41 +0200)
Adjust condition to detach a qcs instance : if the stream is not locally
close it is not directly free. This should improve stream closing by
ensuring that either FIN or a RESET_STREAM is sent before destroying it.

src/mux_quic.c

index 53d0aab662852bfcf870034f8914bed5b28d1a0b..073fc977f82c3d72947a063aa9c13d93ced256aa 100644 (file)
@@ -1508,8 +1508,7 @@ static int qc_purge_streams(struct qcc *qcc)
 
                /* Release detached streams with empty buffer. */
                if (qcs->flags & QC_SF_DETACH) {
-                       if (!b_data(&qcs->tx.buf) &&
-                           qcs->tx.offset == qcs->tx.sent_offset) {
+                       if (qcs_is_close_local(qcs)) {
                                TRACE_DEVEL("purging detached stream", QMUX_EV_QCC_WAKE, qcs->qcc->conn, qcs);
                                qcs_destroy(qcs);
                                release = 1;
@@ -1734,8 +1733,7 @@ static void qc_detach(struct sedesc *sd)
        //BUG_ON_HOT(!qcs_is_close_remote(qcs));
        --qcc->nb_sc;
 
-       if ((b_data(&qcs->tx.buf) || qcs->tx.offset > qcs->tx.sent_offset) &&
-           !(qcc->conn->flags & CO_FL_ERROR)) {
+       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);
                qcs->flags |= QC_SF_DETACH;
                return;
@@ -1838,7 +1836,6 @@ static size_t qc_snd_buf(struct stconn *sc, struct buffer *buf,
 
        if (qcs_is_close_local(qcs)) {
                ret = count;
-               count = 0;
                goto end;
        }