Skip to content

Commit 80eb7af

Browse files
committed
MEDIUM: mux_quic: preserve connection while stream requests are present
1 parent b0a48e8 commit 80eb7af

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
@@ -97,9 +97,8 @@ static inline char *qcs_st_to_str(enum qcs_state st)
9797

9898
int qcc_install_app_ops(struct qcc *qcc);
9999

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

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

123132
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);
@@ -265,17 +270,10 @@ static forceinline void qcc_rm_sc(struct qcc *qcc)
265270
--qcc->nb_sc;
266271
}
267272

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

281279
/* Connection considered dead if either :
@@ -287,8 +285,8 @@ static inline int qcc_is_dead(const struct qcc *qcc)
287285
*/
288286
if (qcc->flags & (QC_CF_ERR_CONN|QC_CF_ERRL_DONE) ||
289287
!qcc->task ||
290-
(!conn_is_back(qcc->conn) && !qcc->nb_hreq && qcc->app_st == QCC_APP_ST_SHUT) ||
291-
(conn_is_back(qcc->conn) && !qcc->nb_hreq && (qcc->flags & QC_CF_CONN_SHUT))) {
288+
(!conn_is_back(qcc->conn) && qcc->app_st == QCC_APP_ST_SHUT) ||
289+
(conn_is_back(qcc->conn) && (qcc->flags & QC_CF_CONN_SHUT))) {
292290
return 1;
293291
}
294292

@@ -431,9 +429,6 @@ void qcs_close_local(struct qcs *qcs)
431429

432430
if (quic_stream_is_bidi(qcs->id)) {
433431
qcs->st = (qcs->st == QC_SS_HREM) ? QC_SS_CLO : QC_SS_HLOC;
434-
435-
if (qcs->flags & QC_SF_HREQ_RECV)
436-
qcc_rm_hreq(qcs->qcc);
437432
}
438433
else {
439434
/* Only local uni streams are valid for this operation. */
@@ -1007,13 +1002,8 @@ int qcs_attach_sc(struct qcs *qcs, struct buffer *buf, char fin)
10071002
return -1;
10081003
}
10091004

1010-
/* QC_SF_HREQ_RECV must be set once for a stream. Else, nb_hreq counter
1011-
* will be incorrect for the connection.
1012-
*/
1013-
BUG_ON_HOT(qcs->flags & QC_SF_HREQ_RECV);
1014-
qcs->flags |= QC_SF_HREQ_RECV;
1005+
BUG_ON(!(qcs->flags & QC_SF_HREQ_RECV));
10151006
++qcc->nb_sc;
1016-
++qcc->nb_hreq;
10171007
++qcc->tot_sc;
10181008

10191009
/* TODO duplicated from mux_h2 */

0 commit comments

Comments
 (0)