MEDIUM: mux-quic: handle when sending buffer is full

Handle the case when the app layer sending buffer is full. A new flag
QC_SF_BLK_MROOM is set in this case and the transfer is interrupted. It
is expected that then the conn-stream layer will subscribe to SEND.

The MROOM flag is reset each time the muxer transfer data from the app
layer to its own buffer. If the app layer has been subscribed on SEND it
is woken up.
This commit is contained in:
Amaury Denoyelle 2021-12-03 14:40:01 +01:00
parent e257d9e8ec
commit 84ea8dcbc4
4 changed files with 13 additions and 6 deletions

View File

@ -55,6 +55,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
#define QC_SF_BLK_MROOM 0x00000002 // app layer is blocked waiting for room in the qcs.tx.buf
struct qcs {
struct qcc *qcc;

View File

@ -534,11 +534,14 @@ static int h3_resp_data_send(struct qcs *qcs, struct buffer *buf, size_t count)
b_slow_realign(res, trash.area, b_data(res));
}
/* not enough room for headers and at least one data byte, block the
* stream
/* Not enough room for headers and at least one data byte, block the
* stream. It is expected that the conn-stream layer will subscribe on
* SEND.
*/
if (b_size(&outbuf) <= hsize)
ABORT_NOW();
if (b_size(&outbuf) <= hsize) {
qcs->flags |= QC_SF_BLK_MROOM;
goto end;
}
if (b_size(&outbuf) < hsize + fsize)
fsize = b_size(&outbuf) - hsize;
@ -579,7 +582,7 @@ size_t h3_snd_buf(struct conn_stream *cs, struct buffer *buf, size_t count, int
htx = htx_from_buf(buf);
while (count && !htx_is_empty(htx)) {
while (count && !htx_is_empty(htx) && !(qcs->flags & QC_SF_BLK_MROOM)) {
idx = htx_get_head(htx);
blk = htx_get_blk(htx, idx);
btype = htx_get_blk_type(blk);

View File

@ -81,7 +81,7 @@ static size_t hq_interop_snd_buf(struct conn_stream *cs, struct buffer *buf,
res = mux_get_buf(qcs);
outbuf = b_make(b_tail(res), b_contig_space(res), 0, 0);
while (count && !htx_is_empty(htx)) {
while (count && !htx_is_empty(htx) && !(qcs->flags & QC_SF_BLK_MROOM)) {
/* Not implemented : QUIC on backend side */
idx = htx_get_head(htx);
blk = htx_get_blk(htx, idx);

View File

@ -193,6 +193,9 @@ static int qc_send(struct qcc *qcc)
if (ret > 0) {
qcs_notify_send(qcs);
if (qcs->flags & QC_SF_BLK_MROOM)
qcs->flags &= ~QC_SF_BLK_MROOM;
xprt_wake = 1;
}