MEDIUM: quic: detect the stream FIN

Set the QC_SF_FIN_STREAM on the app layers (h3 / hq-interop) when
reaching the HTX EOM. This is used to warn the mux layer to set the FIN
on the QUIC stream.
This commit is contained in:
Amaury Denoyelle 2021-12-03 15:03:36 +01:00
parent 916f0ac1e7
commit c2025c1ec6
4 changed files with 18 additions and 2 deletions

View File

@ -54,6 +54,7 @@ struct qcc {
};
#define QC_SF_NONE 0x00000000
#define QC_SF_FIN_STREAM 0x00000001 // FIN bit must be set for last frame of the stream
struct qcs {
struct qcc *qcc;

View File

@ -620,6 +620,9 @@ size_t h3_snd_buf(struct conn_stream *cs, struct buffer *buf, size_t count, int
}
}
if ((htx->flags & HTX_FL_EOM) && htx_is_empty(htx))
qcs->flags |= QC_SF_FIN_STREAM;
out:
if (total) {
if (!(qcs->qcc->wait_event.events & SUB_RETRY_SEND))

View File

@ -116,6 +116,9 @@ static size_t hq_interop_snd_buf(struct conn_stream *cs, struct buffer *buf,
}
}
if ((htx->flags & HTX_FL_EOM) && htx_is_empty(htx))
qcs->flags |= QC_SF_FIN_STREAM;
b_add(res, b_data(&outbuf));
if (total) {

View File

@ -143,8 +143,17 @@ static int qc_send(struct qcc *qcc)
struct qcs *qcs = container_of(node, struct qcs, by_id);
struct buffer *buf = &qcs->tx.buf;
if (b_data(buf)) {
/* TODO handle the FIN parameter */
ret = qcs_push_frame(qcs, buf, 0, qcs->tx.offset);
char fin = 0;
/* if FIN is activated, ensure the buffer to
* send is the last
*/
if (qcs->flags & QC_SF_FIN_STREAM) {
BUG_ON(b_data(&qcs->tx.buf) < b_data(buf));
fin = (b_data(&qcs->tx.buf) - b_data(buf) == 0);
}
ret = qcs_push_frame(qcs, buf, fin, qcs->tx.offset);
if (ret < 0)
ABORT_NOW();