summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmaury Denoyelle <adenoyelle@haproxy.com>2023-05-03 09:50:25 +0200
committerAmaury Denoyelle <adenoyelle@haproxy.com>2023-05-11 14:04:51 +0200
commitb35e32e43b98f900771b119621ec83ff36f02c12 (patch)
treefb3c459c9317d32428235329307e9fc96553dc98
parent04b2208aa0768bb7f69dc4a286e7e059409bdf09 (diff)
downloadhaproxy-b35e32e43b98f900771b119621ec83ff36f02c12.tar.gz
MINOR: mux-quic: factorize send subscribing
Factorize code for send subscribing on the lower layer in a dedicated function qcc_subscribe_send(). This allows to call the lower layer only if not already subscribed and print a trace in this case. This should help to understand when subscribing is really performed. In the future, this function may be extended to avoid subscribing under new conditions, such as connection already on error. This should be backported up to 2.7.
-rw-r--r--src/mux_quic.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/mux_quic.c b/src/mux_quic.c
index 297d2adaa..6230f6d3d 100644
--- a/src/mux_quic.c
+++ b/src/mux_quic.c
@@ -1655,6 +1655,18 @@ void qcc_streams_sent_done(struct qcs *qcs, uint64_t data, uint64_t offset)
TRACE_LEAVE(QMUX_EV_QCS_SEND, qcc->conn, qcs);
}
+/* Returns true if subscribe set, false otherwise. */
+static int qcc_subscribe_send(struct qcc *qcc)
+{
+ struct connection *conn = qcc->conn;
+ if (qcc->wait_event.events & SUB_RETRY_SEND)
+ return 1;
+
+ TRACE_DEVEL("subscribe for send", QMUX_EV_QCC_SEND, qcc->conn);
+ conn->xprt->subscribe(conn, conn->xprt_ctx, SUB_RETRY_SEND, &qcc->wait_event);
+ return 1;
+}
+
/* Wrapper for send on transport layer. Send a list of frames <frms> for the
* connection <qcc>.
*
@@ -1670,10 +1682,9 @@ static int qc_send_frames(struct qcc *qcc, struct list *frms)
}
if (!qc_send_mux(qcc->conn->handle.qc, frms)) {
+ TRACE_DEVEL("error on sending", QMUX_EV_QCC_SEND, qcc->conn);
/* TODO should subscribe only for a transient send error */
- TRACE_DEVEL("error on send, subscribing", QMUX_EV_QCC_SEND, qcc->conn);
- qcc->conn->xprt->subscribe(qcc->conn, qcc->conn->xprt_ctx,
- SUB_RETRY_SEND, &qcc->wait_event);
+ qcc_subscribe_send(qcc);
goto err;
}
@@ -1681,9 +1692,8 @@ static int qc_send_frames(struct qcc *qcc, struct list *frms)
* Subscribe on it to retry later.
*/
if (!LIST_ISEMPTY(frms)) {
- TRACE_DEVEL("remaining frames to send, subscribing", QMUX_EV_QCC_SEND, qcc->conn);
- qcc->conn->xprt->subscribe(qcc->conn, qcc->conn->xprt_ctx,
- SUB_RETRY_SEND, &qcc->wait_event);
+ TRACE_DEVEL("remaining frames to send", QMUX_EV_QCC_SEND, qcc->conn);
+ qcc_subscribe_send(qcc);
goto err;
}