Skip to content

Commit 1742138

Browse files
committed
MEDIUM: mux_quic: preserve connection while stream requests are present
1 parent b24d465 commit 1742138

2 files changed

Lines changed: 22 additions & 23 deletions

File tree

include/haproxy/mux_quic.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,8 @@ static inline char *qcs_st_to_str(enum qcs_state st)
9898

9999
int qcc_install_app_ops(struct qcc *qcc);
100100

101-
/* Register <qcs> stream for http-request timeout. If the stream is not yet
102-
* attached in the configured delay, qcc timeout task will be triggered. This
103-
* means the full header section was not received in time.
101+
/* Flags <qcs> as a request stream. The connection will be considered as active
102+
* until all request streams are closed or on inactivity timeout.
104103
*
105104
* This function should be called by the application protocol layer on request
106105
* streams initialization.
@@ -109,6 +108,9 @@ static inline void qcs_wait_http_req(struct qcs *qcs)
109108
{
110109
struct qcc *qcc = qcs->qcc;
111110

111+
/* For frontend connections, register the stream in QCC opening_list.
112+
* This is necessary for http-request timeout.
113+
*/
112114
if (!conn_is_back(qcc->conn)) {
113115
/* A stream cannot be registered several times. */
114116
BUG_ON_HOT(tick_isset(qcs->start));
@@ -119,6 +121,13 @@ static inline void qcs_wait_http_req(struct qcs *qcs)
119121
*/
120122
LIST_APPEND(&qcc->opening_list, &qcs->el_opening);
121123
}
124+
125+
/* QC_SF_HREQ_RECV must be set once for a stream. Else, nb_hreq counter
126+
* will be incorrect for the connection.
127+
*/
128+
BUG_ON_HOT(qcs->flags & QC_SF_HREQ_RECV);
129+
qcs->flags |= QC_SF_HREQ_RECV;
130+
++qcc->nb_hreq;
122131
}
123132

124133
void qcc_show_quic(struct qcc *qcc);

src/mux_quic.c

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ static void qcs_free(struct qcs *qcs)
102102
sedesc_free(qcs->sd);
103103
qcs->sd = NULL;
104104

105+
if (qcs->flags & QC_SF_HREQ_RECV) {
106+
BUG_ON(!qcc->nb_hreq);
107+
--qcc->nb_hreq;
108+
}
109+
105110
/* Release app-layer context. */
106111
if (qcs->ctx && qcc->app_ops->detach)
107112
qcc->app_ops->detach(qcs);
@@ -263,17 +268,10 @@ static forceinline void qcc_rm_sc(struct qcc *qcc)
263268
--qcc->nb_sc;
264269
}
265270

266-
/* Decrement <qcc> hreq. */
267-
static forceinline void qcc_rm_hreq(struct qcc *qcc)
268-
{
269-
BUG_ON(!qcc->nb_hreq); /* Ensure http req count is always valid (ie >=0). */
270-
--qcc->nb_hreq;
271-
}
272-
273271
static inline int qcc_is_dead(const struct qcc *qcc)
274272
{
275-
/* Maintain connection if stream endpoints are still active. */
276-
if (qcc->nb_sc)
273+
/* Maintain connection if there is still request streams active. */
274+
if (qcc->nb_hreq)
277275
return 0;
278276

279277
/* Connection considered dead if either :
@@ -285,8 +283,8 @@ static inline int qcc_is_dead(const struct qcc *qcc)
285283
*/
286284
if (qcc->flags & (QC_CF_ERR_CONN|QC_CF_ERRL_DONE) ||
287285
!qcc->task ||
288-
(!conn_is_back(qcc->conn) && !qcc->nb_hreq && qcc->app_st == QCC_APP_ST_SHUT) ||
289-
(conn_is_back(qcc->conn) && !qcc->nb_hreq && (qcc->flags & QC_CF_CONN_SHUT))) {
286+
(!conn_is_back(qcc->conn) && qcc->app_st == QCC_APP_ST_SHUT) ||
287+
(conn_is_back(qcc->conn) && (qcc->flags & QC_CF_CONN_SHUT))) {
290288
return 1;
291289
}
292290

@@ -429,9 +427,6 @@ void qcs_close_local(struct qcs *qcs)
429427

430428
if (quic_stream_is_bidi(qcs->id)) {
431429
qcs->st = (qcs->st == QC_SS_HREM) ? QC_SS_CLO : QC_SS_HLOC;
432-
433-
if (qcs->flags & QC_SF_HREQ_RECV)
434-
qcc_rm_hreq(qcs->qcc);
435430
}
436431
else {
437432
/* Only local uni streams are valid for this operation. */
@@ -1023,13 +1018,8 @@ int qcs_attach_sc(struct qcs *qcs, struct buffer *buf, char fin)
10231018
return -1;
10241019
}
10251020

1026-
/* QC_SF_HREQ_RECV must be set once for a stream. Else, nb_hreq counter
1027-
* will be incorrect for the connection.
1028-
*/
1029-
BUG_ON_HOT(qcs->flags & QC_SF_HREQ_RECV);
1030-
qcs->flags |= QC_SF_HREQ_RECV;
1021+
BUG_ON(!(qcs->flags & QC_SF_HREQ_RECV));
10311022
++qcc->nb_sc;
1032-
++qcc->nb_hreq;
10331023
++qcc->tot_sc;
10341024

10351025
/* TODO duplicated from mux_h2 */

0 commit comments

Comments
 (0)