Since emission may stop on a partial write, the last record of a
response can remain in the QMux Tx buffer after its stream is freed.
The connection then looks idle: http-keep-alive is armed and
qcc_is_dead() may release it, e.g. on soft-stop with close-spread-time,
truncating the response.

Treat pending QMux data as pending output in qcc_refresh_timeout() and
qcc_is_dead(), unless on error or timeout. Also refresh the timeout
after a flush attempt in qcc_io_cb(), as qcc_io_send() does not count
these bytes and the idle timeout would not be rearmed otherwise.

This must be backported along with "BUG/MEDIUM: qmux: retry on partial
write instead of aborting".

Signed-off-by: William Dauchy <[email protected]>
---
 src/mux_quic.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/mux_quic.c b/src/mux_quic.c
index cef7567f8..52a407c75 100644
--- a/src/mux_quic.c
+++ b/src/mux_quic.c
@@ -324,6 +324,11 @@ static inline int qcc_is_dead(const struct qcc *qcc)
        if (qcc->nb_hreq)
                return 0;
 
+       /* Wait for QMux record data to be flushed, unless on error or timeout. 
*/
+       if (qcc_qmux_pending(qcc) && qcc->task &&
+           !(qcc->flags & (QC_CF_ERR_CONN|QC_CF_ERRL)))
+               return 0;
+
        if (!conn_is_back(qcc->conn)) {
                /* FE conn considered dead if either :
                 * - transport or local error reported
@@ -370,7 +375,8 @@ static void qcc_refresh_timeout(struct qcc *qcc)
         * If proxy stop-stop in progress, immediate or spread close will be
         * processed if shutdown already one or connection is idle.
         */
-       if (!LIST_ISEMPTY(&qcc->send_list) || !LIST_ISEMPTY(&qcc->tx.frms)) {
+       if (!LIST_ISEMPTY(&qcc->send_list) || !LIST_ISEMPTY(&qcc->tx.frms) ||
+           qcc_qmux_pending(qcc)) {
                TRACE_DEVEL("pending output data", QMUX_EV_QCC_WAKE, qcc->conn);
                qcc->task->expire = tick_add_ifset(now_ms, qcc->timeout);
        }
@@ -3860,7 +3866,7 @@ struct task *qcc_io_cb(struct task *t, void *ctx, 
unsigned int state)
 {
        struct qcc *qcc = ctx;
        struct connection *conn;
-       int total = 0, conn_in_list;
+       int total = 0, conn_in_list, qmux_pending = 0;
 
        if (state & TASK_F_USR1) {
                /* the tasklet was idling on an idle connection, it might have
@@ -3907,8 +3913,10 @@ struct task *qcc_io_cb(struct task *t, void *ctx, 
unsigned int state)
                conn_in_list = 0;
        }
 
-       if (!(qcc->wait_event.events & SUB_RETRY_SEND))
+       if (!(qcc->wait_event.events & SUB_RETRY_SEND)) {
+               qmux_pending = qcc_qmux_pending(qcc);
                total += qcc_io_send(qcc);
+       }
 
        total += qcc_io_recv(qcc);
 
@@ -3917,7 +3925,8 @@ struct task *qcc_io_cb(struct task *t, void *ctx, 
unsigned int state)
                goto release;
        }
 
-       if (total)
+       /* QMux record data flushed are not accounted in <total>. */
+       if (total || qmux_pending)
                qcc_refresh_timeout(qcc);
 
        /* Trigger pacing task is emission should be retried after some delay. 
*/
-- 
2.56.1



Reply via email to