Skip to content

Commit 41caa21

Browse files
committed
TMP MEDIUM: quic: decount buffer ack for MUX Tx window
1 parent 8dedeb6 commit 41caa21

File tree

2 files changed

+61
-8
lines changed

2 files changed

+61
-8
lines changed

src/quic_rx.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,16 @@ static void qc_handle_newly_acked_frm(struct quic_conn *qc, struct quic_frame *f
353353
qc_release_frm(qc, frm);
354354
}
355355
else {
356+
uint64_t diff = strm_frm->len;
357+
356358
/* Loop until there is no overlap between current frame and a next entry. */
357359
while (more_strm &&
358360
strm_frm->offset.key + strm_frm->len >= more_strm->offset.key) {
359361
struct quic_frame *more_frm;
360362
struct eb64_node *next;
361363

364+
diff = diff - (strm_frm->offset.key + strm_frm->len - more_strm->offset.key);
365+
362366
more_frm = container_of(more_strm, struct quic_frame, stream);
363367
if (strm_frm->offset.key + strm_frm->len < more_strm->offset.key + more_strm->len) {
364368
/* Extend current frame to cover next entry. */
@@ -383,6 +387,8 @@ static void qc_handle_newly_acked_frm(struct quic_conn *qc, struct quic_frame *f
383387
less_strm->offset.key + less_strm->len >= strm_frm->offset.key) {
384388
struct quic_frame *less_frm;
385389

390+
diff = diff - (less_strm->offset.key + less_strm->len - strm_frm->offset.key);
391+
386392
/* Extend previous entry to cover fully the current frame. */
387393
less_strm->len += (strm_frm->offset.key + strm_frm->len) -
388394
(less_strm->offset.key + less_strm->len);
@@ -398,6 +404,9 @@ static void qc_handle_newly_acked_frm(struct quic_conn *qc, struct quic_frame *f
398404
else {
399405
eb64_insert(&stream_buf->acked_frms, &strm_frm->offset);
400406
}
407+
408+
if (stream->notify_room && diff && stream->buf != stream_buf)
409+
stream->notify_room(stream, diff);
401410
}
402411
}
403412
}

src/quic_stream.c

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ struct qc_stream_desc *qc_stream_desc_new(uint64_t id, enum qcs_type type, void
9494
void qc_stream_desc_release(struct qc_stream_desc *stream,
9595
uint64_t final_size, void *new_ctx)
9696
{
97+
struct eb64_node *frm_node;
98+
struct qf_stream *strm_frm;
99+
uint64_t diff;
100+
97101
if (!stream)
98102
return;
99103

@@ -116,9 +120,18 @@ void qc_stream_desc_release(struct qc_stream_desc *stream,
116120
if (final_size < tail_offset)
117121
b_sub(buf, tail_offset - final_size);
118122

119-
if (stream->notify_room && b_room(buf)) {
123+
if (stream->notify_room) {
120124
/* notify MUX about available buffers. */
121-
stream->notify_room(stream, b_room(buf));
125+
diff = b_room(&stream->buf->buf);
126+
frm_node = eb64_first(&stream->buf->acked_frms);
127+
while (frm_node) {
128+
strm_frm = eb64_entry(frm_node, struct qf_stream, offset);
129+
diff += strm_frm->len;
130+
frm_node = eb64_next(frm_node);
131+
}
132+
133+
if (diff)
134+
stream->notify_room(stream, diff);
122135
}
123136

124137
if (!b_data(buf))
@@ -175,7 +188,27 @@ int qc_stream_desc_ack(struct qc_stream_desc *stream, size_t offset, size_t len,
175188
}
176189
else if (stream->buf != stream_buf) {
177190
/* inactive buffer, notify immediately about newly acknowledged data. */
178-
stream->notify_room(stream, diff);
191+
struct qf_stream *strm_frm;
192+
struct eb64_node *frm_node;
193+
uint64_t diff_buffered = 0;
194+
195+
frm_node = eb64_lookup_le(&stream_buf->acked_frms, offset);
196+
if (frm_node) {
197+
strm_frm = eb64_entry(frm_node, struct qf_stream, offset);
198+
if (strm_frm->offset.key + strm_frm->len > offset) {
199+
if (strm_frm->offset.key + strm_frm->len >= offset + len) {
200+
diff_buffered = diff;
201+
}
202+
else {
203+
diff_buffered = strm_frm->offset.key + strm_frm->len - offset;
204+
}
205+
}
206+
}
207+
208+
if (diff_buffered < diff) {
209+
}
210+
211+
stream->notify_room(stream, diff - diff_buffered);
179212
}
180213
}
181214

@@ -333,17 +366,28 @@ struct buffer *qc_stream_buf_realloc(struct qc_stream_desc *stream)
333366
*/
334367
void qc_stream_buf_release(struct qc_stream_desc *stream)
335368
{
336-
struct buffer *buf;
369+
struct qc_stream_buf *stream_buf = stream->buf;
370+
struct eb64_node *frm_node;
371+
struct qf_stream *strm_frm;
372+
size_t diff;
337373

338374
/* current buffer already released */
339-
BUG_ON(!stream->buf);
375+
BUG_ON(!stream_buf);
376+
377+
diff = b_room(&stream_buf->buf);
378+
frm_node = eb64_first(&stream_buf->acked_frms);
379+
while (frm_node) {
380+
strm_frm = eb64_entry(frm_node, struct qf_stream, offset);
381+
BUG_ON(strm_frm->offset.key < stream->ack_offset);
382+
diff += strm_frm->len;
383+
frm_node = eb64_next(frm_node);
384+
}
340385

341-
buf = &stream->buf->buf;
342386
stream->buf = NULL;
343387
stream->buf_offset = 0;
344388

345-
if (stream->notify_room && b_room(buf))
346-
stream->notify_room(stream, b_room(buf));
389+
if (stream->notify_room && diff)
390+
stream->notify_room(stream, diff);
347391
}
348392

349393
static int create_sbuf_pool(void)

0 commit comments

Comments
 (0)