Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions include/quicly.h
Original file line number Diff line number Diff line change
Expand Up @@ -1299,6 +1299,19 @@ int quicly_can_send_data(quicly_conn_t *conn, quicly_send_context_t *s);
* the responsibility of the stream scheduler to maintain a list of such streams.
*/
quicly_error_t quicly_send_stream(quicly_stream_t *stream, quicly_send_context_t *s);
/**
* This function is same as `quicly_send_stream`, but can be used when the overhead of providing the stream payload can be minimized
* by using scattered I/O.
* @param emit_scattered the emit callback to be called instead of the standard `on_send_emit` callback; the callback returns
* the number of bytes that it has actually written
* @param available_bytes_hint bytes that might be available in the send buffer, starting from
* `stream->sendstate.acked.ranges[0].end`; `quicly_send_stream_scattered` prepares vectors only as
* much as required to send what has been hinted
*/
quicly_error_t quicly_send_stream_scattered(quicly_stream_t *stream, quicly_send_context_t *s,
size_t (*emit_scattered)(quicly_stream_t *stream, size_t off, const ptls_iovec_t *vecs,
size_t num_vecs, int *wrote_all),
size_t available_bytes_hint);
/**
* Builds a Version Negotiation packet. The generated packet might include a greasing version.
* * @param versions zero-terminated list of versions to advertise; use `quicly_supported_versions` for sending the list of
Expand Down
8 changes: 8 additions & 0 deletions include/quicly/defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ extern quicly_now_t quicly_default_now;
*/
extern quicly_crypto_engine_t quicly_default_crypto_engine;

int quicly_default_stream_scheduler_can_send(quicly_stream_scheduler_t *self, quicly_conn_t *conn, int conn_is_saturated);
quicly_error_t quicly_default_stream_scheduler_do_send_with(quicly_stream_scheduler_t *self, quicly_conn_t *conn,
quicly_send_context_t *s,
quicly_error_t (*do_send)(quicly_stream_t *, quicly_send_context_t *));
quicly_error_t quicly_default_stream_scheduler_do_send(quicly_stream_scheduler_t *self, quicly_conn_t *conn,
quicly_send_context_t *s);
void quicly_default_stream_scheduler_update_state(quicly_stream_scheduler_t *self, quicly_stream_t *stream);

#define quicly_default_cc quicly_cc_type_reno
#define quicly_default_init_cc quicly_cc_reno_init

Expand Down
24 changes: 17 additions & 7 deletions lib/defaults.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ void quicly_free_default_cid_encryptor(quicly_cid_encryptor_t *_self)
/**
* See doc-comment of `st_quicly_default_scheduler_state_t` to understand the logic.
*/
static int default_stream_scheduler_can_send(quicly_stream_scheduler_t *self, quicly_conn_t *conn, int conn_is_saturated)
int quicly_default_stream_scheduler_can_send(quicly_stream_scheduler_t *self, quicly_conn_t *conn, int conn_is_saturated)
{
struct st_quicly_default_scheduler_state_t *sched = &((struct _st_quicly_conn_public_t *)conn)->_default_scheduler;

Expand Down Expand Up @@ -313,8 +313,9 @@ static void link_stream(struct st_quicly_default_scheduler_state_t *sched, quicl
/**
* See doc-comment of `st_quicly_default_scheduler_state_t` to understand the logic.
*/
static quicly_error_t default_stream_scheduler_do_send(quicly_stream_scheduler_t *self, quicly_conn_t *conn,
quicly_send_context_t *s)
quicly_error_t quicly_default_stream_scheduler_do_send_with(quicly_stream_scheduler_t *self, quicly_conn_t *conn,
quicly_send_context_t *s,
quicly_error_t (*do_send)(quicly_stream_t *, quicly_send_context_t *))
{
struct st_quicly_default_scheduler_state_t *sched = &((struct _st_quicly_conn_public_t *)conn)->_default_scheduler;
int conn_is_blocked = quicly_is_blocked(conn);
Expand All @@ -334,7 +335,7 @@ static quicly_error_t default_stream_scheduler_do_send(quicly_stream_scheduler_t
continue;
}
/* send! */
if ((ret = quicly_send_stream(stream, s)) != 0) {
if ((ret = do_send(stream, s)) != 0) {
/* FIXME Stop quicly_send_stream emitting SENDBUF_FULL (happens when CWND is congested). Otherwise, we need to make
* adjustments to the scheduler after popping a stream */
if (ret == QUICLY_ERROR_SENDBUF_FULL) {
Expand All @@ -352,10 +353,16 @@ static quicly_error_t default_stream_scheduler_do_send(quicly_stream_scheduler_t
return ret;
}

quicly_error_t quicly_default_stream_scheduler_do_send(quicly_stream_scheduler_t *self, quicly_conn_t *conn,
quicly_send_context_t *s)
{
return quicly_default_stream_scheduler_do_send_with(self, conn, s, quicly_send_stream);
}

/**
* See doc-comment of `st_quicly_default_scheduler_state_t` to understand the logic.
*/
static void default_stream_scheduler_update_state(quicly_stream_scheduler_t *self, quicly_stream_t *stream)
void quicly_default_stream_scheduler_update_state(quicly_stream_scheduler_t *self, quicly_stream_t *stream)
{
struct st_quicly_default_scheduler_state_t *sched = &((struct _st_quicly_conn_public_t *)stream->conn)->_default_scheduler;

Expand All @@ -369,8 +376,11 @@ static void default_stream_scheduler_update_state(quicly_stream_scheduler_t *sel
}
}

quicly_stream_scheduler_t quicly_default_stream_scheduler = {default_stream_scheduler_can_send, default_stream_scheduler_do_send,
default_stream_scheduler_update_state};
quicly_stream_scheduler_t quicly_default_stream_scheduler = {
.can_send = quicly_default_stream_scheduler_can_send,
.do_send = quicly_default_stream_scheduler_do_send,
.update_state = quicly_default_stream_scheduler_update_state,
};

quicly_stream_t *quicly_default_alloc_stream(quicly_context_t *ctx)
{
Expand Down
Loading
Loading