Skip to content

Commit

Permalink
TMP
Browse files Browse the repository at this point in the history
  • Loading branch information
a-denoyelle committed Sep 18, 2024
1 parent 0c742f2 commit 8f7ad61
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
41 changes: 37 additions & 4 deletions src/quic_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ static void qc_stream_buf_free(struct qc_stream_desc *stream,
LIST_DEL_INIT(&(*stream_buf)->list);

/* Reset current buf ptr if deleted instance is the same one. */
if (*stream_buf == stream->buf)
if (*stream_buf == stream->buf) {
stream->buf = NULL;
free_size = b_size(buf);
}
else {
free_size = b_data(buf);
}

free_size = b_size(buf);
if ((*stream_buf)->sbuf) {
pool_free(pool_head_sbuf, buf->area);
}
Expand All @@ -53,7 +57,8 @@ static void qc_stream_buf_free(struct qc_stream_desc *stream,
if (qc->mux_state == QC_MUX_READY) {
if (!(stream->flags & QC_SD_FL_OOB_BUF)) {
/* notify MUX about available buffers. */
qcc_notify_buf(qc->qcc, free_size);
if (free_size)
qcc_notify_buf(qc->qcc, free_size);
}
}
}
Expand Down Expand Up @@ -106,9 +111,13 @@ struct qc_stream_desc *qc_stream_desc_new(uint64_t id, enum qcs_type type, void
void qc_stream_desc_release(struct qc_stream_desc *stream,
uint64_t final_size)
{
struct quic_conn *qc;

if (!stream)
return;

qc = stream->qc;

/* A stream can be released only one time. */
BUG_ON(stream->flags & QC_SD_FL_RELEASE);

Expand All @@ -128,8 +137,14 @@ void qc_stream_desc_release(struct qc_stream_desc *stream,
if (final_size < tail_offset)
b_sub(buf, tail_offset - final_size);

if (!b_data(buf))
if (!b_data(buf)) {
qc_stream_buf_free(stream, &stream_buf);
}
else if (!(stream->flags & QC_SD_FL_OOB_BUF)) {
/* notify MUX about available buffers. */
if (b_room(buf))
qcc_notify_buf(qc->qcc, b_room(buf));
}

/* A released stream does not use <stream.buf>. */
stream->buf = NULL;
Expand All @@ -154,6 +169,7 @@ int qc_stream_desc_ack(struct qc_stream_desc **stream, size_t offset, size_t len
{
struct qc_stream_desc *s = *stream;
struct qc_stream_buf *stream_buf = NULL;
struct quic_conn *qc = s->qc;
struct buffer *buf = NULL;
size_t diff;

Expand All @@ -178,6 +194,13 @@ int qc_stream_desc_ack(struct qc_stream_desc **stream, size_t offset, size_t len
s->ack_offset += diff;
b_del(buf, diff);

if (qc->mux_state == QC_MUX_READY) {
if (s->buf != stream_buf && !(s->flags & QC_SD_FL_OOB_BUF)) {
/* notify MUX about available buffers. */
qcc_notify_buf(qc->qcc, diff);
}
}

/* Free oldest buffer if all data acknowledged. */
if (!b_data(buf)) {
qc_stream_buf_free(s, &stream_buf);
Expand Down Expand Up @@ -335,11 +358,21 @@ struct buffer *qc_stream_buf_realloc(struct qc_stream_desc *stream)
*/
void qc_stream_buf_release(struct qc_stream_desc *stream)
{
struct quic_conn *qc = stream->qc;
struct buffer *buf;

/* current buffer already released */
BUG_ON(!stream->buf);

buf = &stream->buf->buf;
stream->buf = NULL;
stream->buf_offset = 0;

if (!(stream->flags & QC_SD_FL_OOB_BUF)) {
/* notify MUX about available buffers. */
if (b_room(buf))
qcc_notify_buf(qc->qcc, b_room(buf));
}
}

static int create_sbuf_pool(void)
Expand Down
1 change: 1 addition & 0 deletions src/quic_tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ struct quic_cstream *quic_cstream_new(struct quic_conn *qc)
TRACE_ERROR("crypto stream allocation failed", QUIC_EV_CONN_INIT, qc);
goto err;
}
cs->desc->flags |= QC_SD_FL_OOB_BUF;

ret_cs = cs;
leave:
Expand Down

0 comments on commit 8f7ad61

Please sign in to comment.