mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -05:00
deps: update nghttp3 to 1.15.0
PR-URL: https://github.com/nodejs/node/pull/61512 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Richard Lau <richard.lau@ibm.com>
This commit is contained in:
1 parent
a999edd8fd
commit
2eb8e9d760
10 files changed
+184
-191
No files matched your search
+2
-2
@@ -31,7 +31,7 @@
|
||||
*
|
||||
* Version number of the nghttp3 library release.
|
||||
*/
|
||||
#define NGHTTP3_VERSION "1.14.0"
|
||||
#define NGHTTP3_VERSION "1.15.0"
|
||||
|
||||
/**
|
||||
* @macro
|
||||
@@ -41,6 +41,6 @@
|
||||
* number, 8 bits for minor and 8 bits for patch. Version 1.2.3
|
||||
* becomes 0x010203.
|
||||
*/
|
||||
#define NGHTTP3_VERSION_NUM 0x010e00
|
||||
#define NGHTTP3_VERSION_NUM 0x010f00
|
||||
|
||||
#endif /* !defined(NGHTTP3_VERSION_H) */
|
||||
+28
-26
@@ -2142,7 +2142,7 @@ nghttp3_stream *nghttp3_conn_find_stream(nghttp3_conn *conn,
|
||||
|
||||
int nghttp3_conn_bind_control_stream(nghttp3_conn *conn, int64_t stream_id) {
|
||||
nghttp3_stream *stream;
|
||||
nghttp3_frame_entry frent;
|
||||
nghttp3_frame fr;
|
||||
int rv;
|
||||
|
||||
assert(stream_id >= 0);
|
||||
@@ -2168,10 +2168,12 @@ int nghttp3_conn_bind_control_stream(nghttp3_conn *conn, int64_t stream_id) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
frent.fr.settings.type = NGHTTP3_FRAME_SETTINGS;
|
||||
frent.aux.settings.local_settings = &conn->local.settings;
|
||||
fr.settings = (nghttp3_frame_settings){
|
||||
.type = NGHTTP3_FRAME_SETTINGS,
|
||||
.local_settings = &conn->local.settings,
|
||||
};
|
||||
|
||||
rv = nghttp3_stream_frq_add(stream, &frent);
|
||||
rv = nghttp3_stream_frq_add(stream, &fr);
|
||||
if (rv != 0) {
|
||||
return rv;
|
||||
}
|
||||
@@ -2179,12 +2181,12 @@ int nghttp3_conn_bind_control_stream(nghttp3_conn *conn, int64_t stream_id) {
|
||||
if (conn->local.settings.origin_list) {
|
||||
assert(conn->server);
|
||||
|
||||
frent.fr.origin = (nghttp3_frame_origin){
|
||||
fr.origin = (nghttp3_frame_origin){
|
||||
.type = NGHTTP3_FRAME_ORIGIN,
|
||||
.origin_list = *conn->local.settings.origin_list,
|
||||
};
|
||||
|
||||
rv = nghttp3_stream_frq_add(stream, &frent);
|
||||
rv = nghttp3_stream_frq_add(stream, &fr);
|
||||
if (rv != 0) {
|
||||
return rv;
|
||||
}
|
||||
@@ -2414,32 +2416,32 @@ static int conn_submit_headers_data(nghttp3_conn *conn, nghttp3_stream *stream,
|
||||
const nghttp3_data_reader *dr) {
|
||||
int rv;
|
||||
nghttp3_nv *nnva;
|
||||
nghttp3_frame_entry frent;
|
||||
nghttp3_frame fr;
|
||||
|
||||
rv = nghttp3_nva_copy(&nnva, nva, nvlen, conn->mem);
|
||||
if (rv != 0) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
frent.fr.headers = (nghttp3_frame_headers){
|
||||
fr.headers = (nghttp3_frame_headers){
|
||||
.type = NGHTTP3_FRAME_HEADERS,
|
||||
.nva = nnva,
|
||||
.nvlen = nvlen,
|
||||
};
|
||||
|
||||
rv = nghttp3_stream_frq_add(stream, &frent);
|
||||
rv = nghttp3_stream_frq_add(stream, &fr);
|
||||
if (rv != 0) {
|
||||
nghttp3_nva_del(nnva, conn->mem);
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (dr) {
|
||||
frent.fr.data = (nghttp3_frame_data){
|
||||
fr.data = (nghttp3_frame_data){
|
||||
.type = NGHTTP3_FRAME_DATA,
|
||||
.dr = *dr,
|
||||
};
|
||||
frent.aux.data.dr = *dr;
|
||||
|
||||
rv = nghttp3_stream_frq_add(stream, &frent);
|
||||
rv = nghttp3_stream_frq_add(stream, &fr);
|
||||
if (rv != 0) {
|
||||
return rv;
|
||||
}
|
||||
@@ -2493,7 +2495,6 @@ int nghttp3_conn_submit_request(nghttp3_conn *conn, int64_t stream_id,
|
||||
|
||||
assert(!conn->server);
|
||||
assert(conn->tx.qenc);
|
||||
|
||||
assert(stream_id >= 0);
|
||||
assert(stream_id <= (int64_t)NGHTTP3_MAX_VARINT);
|
||||
assert(nghttp3_client_stream_bidi(stream_id));
|
||||
@@ -2515,6 +2516,7 @@ int nghttp3_conn_submit_request(nghttp3_conn *conn, int64_t stream_id,
|
||||
}
|
||||
stream->rx.hstate = NGHTTP3_HTTP_STATE_RESP_INITIAL;
|
||||
stream->user_data = stream_user_data;
|
||||
stream->node.pri.inc = 1;
|
||||
|
||||
nghttp3_http_record_request_method(stream, nva, nvlen);
|
||||
|
||||
@@ -2585,51 +2587,51 @@ int nghttp3_conn_submit_trailers(nghttp3_conn *conn, int64_t stream_id,
|
||||
}
|
||||
|
||||
int nghttp3_conn_submit_shutdown_notice(nghttp3_conn *conn) {
|
||||
nghttp3_frame_entry frent;
|
||||
nghttp3_frame fr;
|
||||
int rv;
|
||||
|
||||
assert(conn->tx.ctrl);
|
||||
|
||||
frent.fr.goaway = (nghttp3_frame_goaway){
|
||||
fr.goaway = (nghttp3_frame_goaway){
|
||||
.type = NGHTTP3_FRAME_GOAWAY,
|
||||
.id = conn->server ? NGHTTP3_SHUTDOWN_NOTICE_STREAM_ID
|
||||
: NGHTTP3_SHUTDOWN_NOTICE_PUSH_ID,
|
||||
};
|
||||
|
||||
assert(frent.fr.goaway.id <= conn->tx.goaway_id);
|
||||
assert(fr.goaway.id <= conn->tx.goaway_id);
|
||||
|
||||
rv = nghttp3_stream_frq_add(conn->tx.ctrl, &frent);
|
||||
rv = nghttp3_stream_frq_add(conn->tx.ctrl, &fr);
|
||||
if (rv != 0) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
conn->tx.goaway_id = frent.fr.goaway.id;
|
||||
conn->tx.goaway_id = fr.goaway.id;
|
||||
conn->flags |= NGHTTP3_CONN_FLAG_GOAWAY_QUEUED;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nghttp3_conn_shutdown(nghttp3_conn *conn) {
|
||||
nghttp3_frame_entry frent;
|
||||
nghttp3_frame fr;
|
||||
int rv;
|
||||
|
||||
assert(conn->tx.ctrl);
|
||||
|
||||
frent.fr.goaway = (nghttp3_frame_goaway){
|
||||
fr.goaway = (nghttp3_frame_goaway){
|
||||
.type = NGHTTP3_FRAME_GOAWAY,
|
||||
.id = conn->server ? nghttp3_min_int64((1ll << 62) - 4,
|
||||
conn->rx.max_stream_id_bidi + 4)
|
||||
: 0,
|
||||
};
|
||||
|
||||
assert(frent.fr.goaway.id <= conn->tx.goaway_id);
|
||||
assert(fr.goaway.id <= conn->tx.goaway_id);
|
||||
|
||||
rv = nghttp3_stream_frq_add(conn->tx.ctrl, &frent);
|
||||
rv = nghttp3_stream_frq_add(conn->tx.ctrl, &fr);
|
||||
if (rv != 0) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
conn->tx.goaway_id = frent.fr.goaway.id;
|
||||
conn->tx.goaway_id = fr.goaway.id;
|
||||
conn->flags |=
|
||||
NGHTTP3_CONN_FLAG_GOAWAY_QUEUED | NGHTTP3_CONN_FLAG_SHUTDOWN_COMMENCED;
|
||||
|
||||
@@ -2870,7 +2872,7 @@ int nghttp3_conn_set_client_stream_priority(nghttp3_conn *conn,
|
||||
const uint8_t *data,
|
||||
size_t datalen) {
|
||||
nghttp3_stream *stream;
|
||||
nghttp3_frame_entry frent;
|
||||
nghttp3_frame fr;
|
||||
uint8_t *buf = NULL;
|
||||
|
||||
assert(!conn->server);
|
||||
@@ -2895,14 +2897,14 @@ int nghttp3_conn_set_client_stream_priority(nghttp3_conn *conn,
|
||||
memcpy(buf, data, datalen);
|
||||
}
|
||||
|
||||
frent.fr.priority_update = (nghttp3_frame_priority_update){
|
||||
fr.priority_update = (nghttp3_frame_priority_update){
|
||||
.type = NGHTTP3_FRAME_PRIORITY_UPDATE,
|
||||
.pri_elem_id = stream_id,
|
||||
.data = buf,
|
||||
.datalen = datalen,
|
||||
};
|
||||
|
||||
return nghttp3_stream_frq_add(conn->tx.ctrl, &frent);
|
||||
return nghttp3_stream_frq_add(conn->tx.ctrl, &fr);
|
||||
}
|
||||
|
||||
int nghttp3_conn_set_server_stream_priority_versioned(nghttp3_conn *conn,
|
||||
|
||||
+6
@@ -60,6 +60,9 @@ typedef struct nghttp3_frame_hd {
|
||||
|
||||
typedef struct nghttp3_frame_data {
|
||||
int64_t type;
|
||||
/* dr is set when sending DATA frame. It is not used on
|
||||
reception. */
|
||||
nghttp3_data_reader dr;
|
||||
} nghttp3_frame_data;
|
||||
|
||||
typedef struct nghttp3_frame_headers {
|
||||
@@ -88,6 +91,9 @@ typedef struct nghttp3_frame_settings {
|
||||
int64_t type;
|
||||
size_t niv;
|
||||
nghttp3_settings_entry *iv;
|
||||
/* local_settings is set when sending SETTINGS frame. It is not
|
||||
used on reception. */
|
||||
const nghttp3_settings *local_settings;
|
||||
} nghttp3_frame_settings;
|
||||
|
||||
typedef struct nghttp3_frame_goaway {
|
||||
|
||||
+2
-1
@@ -59,7 +59,8 @@ static int memieq(const void *a, const void *b, size_t n) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define lstrieq(A, B, N) ((sizeof((A)) - 1) == (N) && memieq((A), (B), (N)))
|
||||
#define lstrieq(A, B, N) \
|
||||
(nghttp3_strlen_lit((A)) == (N) && memieq((A), (B), (N)))
|
||||
|
||||
static int64_t parse_uint(const uint8_t *s, size_t len) {
|
||||
int64_t n = 0;
|
||||
|
||||
+81
-86
@@ -59,11 +59,13 @@ void nghttp3_ksl_init(nghttp3_ksl *ksl, nghttp3_ksl_compar compar,
|
||||
|
||||
aligned_keylen = (keylen + 0x7u) & ~0x7u;
|
||||
|
||||
assert(aligned_keylen <= UINT16_MAX);
|
||||
|
||||
nghttp3_objalloc_init(&ksl->blkalloc,
|
||||
(ksl_blklen(aligned_keylen) + 0xfu) & ~(uintptr_t)0xfu,
|
||||
mem);
|
||||
|
||||
ksl->head = NULL;
|
||||
ksl->root = NULL;
|
||||
ksl->front = ksl->back = NULL;
|
||||
ksl->compar = compar;
|
||||
ksl->search = search;
|
||||
@@ -81,6 +83,7 @@ static nghttp3_ksl_blk *ksl_blk_objalloc_new(nghttp3_ksl *ksl) {
|
||||
}
|
||||
|
||||
blk->keys = (uint8_t *)blk + sizeof(*blk);
|
||||
blk->aligned_keylen = (uint16_t)ksl->aligned_keylen;
|
||||
|
||||
return blk;
|
||||
}
|
||||
@@ -89,19 +92,19 @@ static void ksl_blk_objalloc_del(nghttp3_ksl *ksl, nghttp3_ksl_blk *blk) {
|
||||
nghttp3_objalloc_ksl_blk_release(&ksl->blkalloc, blk);
|
||||
}
|
||||
|
||||
static int ksl_head_init(nghttp3_ksl *ksl) {
|
||||
nghttp3_ksl_blk *head = ksl_blk_objalloc_new(ksl);
|
||||
static int ksl_root_init(nghttp3_ksl *ksl) {
|
||||
nghttp3_ksl_blk *root = ksl_blk_objalloc_new(ksl);
|
||||
|
||||
if (!head) {
|
||||
if (!root) {
|
||||
return NGHTTP3_ERR_NOMEM;
|
||||
}
|
||||
|
||||
head->next = head->prev = NULL;
|
||||
head->n = 0;
|
||||
head->leaf = 1;
|
||||
root->next = root->prev = NULL;
|
||||
root->n = 0;
|
||||
root->leaf = 1;
|
||||
|
||||
ksl->head = head;
|
||||
ksl->front = ksl->back = head;
|
||||
ksl->root = root;
|
||||
ksl->front = ksl->back = root;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -124,12 +127,12 @@ static void ksl_free_blk(nghttp3_ksl *ksl, nghttp3_ksl_blk *blk) {
|
||||
#endif /* defined(NOMEMPOOL) */
|
||||
|
||||
void nghttp3_ksl_free(nghttp3_ksl *ksl) {
|
||||
if (!ksl || !ksl->head) {
|
||||
if (!ksl || !ksl->root) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef NOMEMPOOL
|
||||
ksl_free_blk(ksl, ksl->head);
|
||||
ksl_free_blk(ksl, ksl->root);
|
||||
#endif /* defined(NOMEMPOOL) */
|
||||
|
||||
nghttp3_objalloc_free(&ksl->blkalloc);
|
||||
@@ -199,22 +202,21 @@ static int ksl_split_node(nghttp3_ksl *ksl, nghttp3_ksl_blk *blk, size_t i) {
|
||||
memmove(blk->nodes + (i + 2), blk->nodes + (i + 1),
|
||||
(blk->n - (i + 1)) * sizeof(nghttp3_ksl_node));
|
||||
|
||||
memmove(blk->keys + (i + 2) * ksl->aligned_keylen,
|
||||
blk->keys + (i + 1) * ksl->aligned_keylen,
|
||||
(blk->n - (i + 1)) * ksl->aligned_keylen);
|
||||
memmove(blk->keys + (i + 1) * ksl->aligned_keylen,
|
||||
blk->keys + i * ksl->aligned_keylen,
|
||||
(blk->n - i) * ksl->aligned_keylen);
|
||||
|
||||
blk->nodes[i + 1].blk = rblk;
|
||||
++blk->n;
|
||||
ksl_set_nth_key(ksl, blk, i + 1, nghttp3_ksl_nth_key(ksl, rblk, rblk->n - 1));
|
||||
|
||||
ksl_set_nth_key(ksl, blk, i, nghttp3_ksl_nth_key(ksl, lblk, lblk->n - 1));
|
||||
ksl_set_nth_key(ksl, blk, i, nghttp3_ksl_blk_nth_key(lblk, lblk->n - 1));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* ksl_split_head splits a head (root) block. It increases the height
|
||||
* of skip list by 1.
|
||||
* ksl_split_root splits a root block. It increases the height of
|
||||
* skip list by 1.
|
||||
*
|
||||
* It returns 0 if it succeeds, or one of the following negative error
|
||||
* codes:
|
||||
@@ -222,34 +224,34 @@ static int ksl_split_node(nghttp3_ksl *ksl, nghttp3_ksl_blk *blk, size_t i) {
|
||||
* NGHTTP3_ERR_NOMEM
|
||||
* Out of memory.
|
||||
*/
|
||||
static int ksl_split_head(nghttp3_ksl *ksl) {
|
||||
nghttp3_ksl_blk *rblk = NULL, *lblk, *nhead = NULL;
|
||||
static int ksl_split_root(nghttp3_ksl *ksl) {
|
||||
nghttp3_ksl_blk *rblk = NULL, *lblk, *nroot = NULL;
|
||||
|
||||
rblk = ksl_split_blk(ksl, ksl->head);
|
||||
rblk = ksl_split_blk(ksl, ksl->root);
|
||||
if (rblk == NULL) {
|
||||
return NGHTTP3_ERR_NOMEM;
|
||||
}
|
||||
|
||||
lblk = ksl->head;
|
||||
lblk = ksl->root;
|
||||
|
||||
nhead = ksl_blk_objalloc_new(ksl);
|
||||
nroot = ksl_blk_objalloc_new(ksl);
|
||||
|
||||
if (nhead == NULL) {
|
||||
if (nroot == NULL) {
|
||||
ksl_blk_objalloc_del(ksl, rblk);
|
||||
return NGHTTP3_ERR_NOMEM;
|
||||
}
|
||||
|
||||
nhead->next = nhead->prev = NULL;
|
||||
nhead->n = 2;
|
||||
nhead->leaf = 0;
|
||||
nroot->next = nroot->prev = NULL;
|
||||
nroot->n = 2;
|
||||
nroot->leaf = 0;
|
||||
|
||||
ksl_set_nth_key(ksl, nhead, 0, nghttp3_ksl_nth_key(ksl, lblk, lblk->n - 1));
|
||||
nhead->nodes[0].blk = lblk;
|
||||
ksl_set_nth_key(ksl, nroot, 0, nghttp3_ksl_blk_nth_key(lblk, lblk->n - 1));
|
||||
nroot->nodes[0].blk = lblk;
|
||||
|
||||
ksl_set_nth_key(ksl, nhead, 1, nghttp3_ksl_nth_key(ksl, rblk, rblk->n - 1));
|
||||
nhead->nodes[1].blk = rblk;
|
||||
ksl_set_nth_key(ksl, nroot, 1, nghttp3_ksl_blk_nth_key(rblk, rblk->n - 1));
|
||||
nroot->nodes[1].blk = rblk;
|
||||
|
||||
ksl->head = nhead;
|
||||
ksl->root = nroot;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -284,27 +286,27 @@ int nghttp3_ksl_insert(nghttp3_ksl *ksl, nghttp3_ksl_it *it,
|
||||
size_t i;
|
||||
int rv;
|
||||
|
||||
if (!ksl->head) {
|
||||
rv = ksl_head_init(ksl);
|
||||
if (!ksl->root) {
|
||||
rv = ksl_root_init(ksl);
|
||||
if (rv != 0) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
if (ksl->head->n == NGHTTP3_KSL_MAX_NBLK) {
|
||||
rv = ksl_split_head(ksl);
|
||||
if (ksl->root->n == NGHTTP3_KSL_MAX_NBLK) {
|
||||
rv = ksl_split_root(ksl);
|
||||
if (rv != 0) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
blk = ksl->head;
|
||||
blk = ksl->root;
|
||||
|
||||
for (;;) {
|
||||
i = ksl->search(ksl, blk, key);
|
||||
|
||||
if (blk->leaf) {
|
||||
if (i < blk->n && !ksl->compar(key, nghttp3_ksl_nth_key(ksl, blk, i))) {
|
||||
if (i < blk->n && !ksl->compar(key, nghttp3_ksl_blk_nth_key(blk, i))) {
|
||||
if (it) {
|
||||
*it = nghttp3_ksl_end(ksl);
|
||||
}
|
||||
@@ -316,7 +318,7 @@ int nghttp3_ksl_insert(nghttp3_ksl *ksl, nghttp3_ksl_it *it,
|
||||
++ksl->n;
|
||||
|
||||
if (it) {
|
||||
nghttp3_ksl_it_init(it, ksl, blk, i);
|
||||
nghttp3_ksl_it_init(it, blk, i);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -343,7 +345,7 @@ int nghttp3_ksl_insert(nghttp3_ksl *ksl, nghttp3_ksl_it *it,
|
||||
++ksl->n;
|
||||
|
||||
if (it) {
|
||||
nghttp3_ksl_it_init(it, ksl, blk, blk->n - 1);
|
||||
nghttp3_ksl_it_init(it, blk, blk->n - 1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -357,12 +359,8 @@ int nghttp3_ksl_insert(nghttp3_ksl *ksl, nghttp3_ksl_it *it,
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (ksl->compar(nghttp3_ksl_nth_key(ksl, blk, i), key)) {
|
||||
if (ksl->compar(nghttp3_ksl_blk_nth_key(blk, i), key)) {
|
||||
node = &blk->nodes[i + 1];
|
||||
|
||||
if (ksl->compar(nghttp3_ksl_nth_key(ksl, blk, i + 1), key)) {
|
||||
ksl_set_nth_key(ksl, blk, i + 1, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -389,9 +387,9 @@ static void ksl_remove_node(nghttp3_ksl *ksl, nghttp3_ksl_blk *blk, size_t i) {
|
||||
* ksl_merge_node merges 2 nodes which are the nodes at the index of
|
||||
* |i| and |i + 1|.
|
||||
*
|
||||
* If |blk| is the head (root) block and it contains just 2 nodes
|
||||
* before merging nodes, the merged block becomes head block, which
|
||||
* decreases the height of |ksl| by 1.
|
||||
* If |blk| is the root block and it contains just 2 nodes before
|
||||
* merging nodes, the merged block becomes root block, which decreases
|
||||
* the height of |ksl| by 1.
|
||||
*
|
||||
* This function returns the pointer to the merged block.
|
||||
*/
|
||||
@@ -407,7 +405,7 @@ static nghttp3_ksl_blk *ksl_merge_node(nghttp3_ksl *ksl, nghttp3_ksl_blk *blk,
|
||||
lblk = lnode->blk;
|
||||
rblk = blk->nodes[i + 1].blk;
|
||||
|
||||
assert(lblk->n + rblk->n < NGHTTP3_KSL_MAX_NBLK);
|
||||
assert(lblk->n + rblk->n <= NGHTTP3_KSL_MAX_NBLK);
|
||||
|
||||
memcpy(lblk->nodes + lblk->n, rblk->nodes,
|
||||
rblk->n * sizeof(nghttp3_ksl_node));
|
||||
@@ -426,12 +424,12 @@ static nghttp3_ksl_blk *ksl_merge_node(nghttp3_ksl *ksl, nghttp3_ksl_blk *blk,
|
||||
|
||||
ksl_blk_objalloc_del(ksl, rblk);
|
||||
|
||||
if (ksl->head == blk && blk->n == 2) {
|
||||
ksl_blk_objalloc_del(ksl, ksl->head);
|
||||
ksl->head = lblk;
|
||||
if (ksl->root == blk && blk->n == 2) {
|
||||
ksl_blk_objalloc_del(ksl, ksl->root);
|
||||
ksl->root = lblk;
|
||||
} else {
|
||||
ksl_remove_node(ksl, blk, i + 1);
|
||||
ksl_set_nth_key(ksl, blk, i, nghttp3_ksl_nth_key(ksl, lblk, lblk->n - 1));
|
||||
ksl_set_nth_key(ksl, blk, i, nghttp3_ksl_blk_nth_key(lblk, lblk->n - 1));
|
||||
}
|
||||
|
||||
return lblk;
|
||||
@@ -472,7 +470,7 @@ static void ksl_shift_left(nghttp3_ksl *ksl, nghttp3_ksl_blk *blk, size_t i) {
|
||||
lblk->n += (uint32_t)n;
|
||||
rblk->n -= (uint32_t)n;
|
||||
|
||||
ksl_set_nth_key(ksl, blk, i - 1, nghttp3_ksl_nth_key(ksl, lblk, lblk->n - 1));
|
||||
ksl_set_nth_key(ksl, blk, i - 1, nghttp3_ksl_blk_nth_key(lblk, lblk->n - 1));
|
||||
|
||||
memmove(rblk->nodes, rblk->nodes + n, rblk->n * sizeof(nghttp3_ksl_node));
|
||||
|
||||
@@ -520,7 +518,7 @@ static void ksl_shift_right(nghttp3_ksl *ksl, nghttp3_ksl_blk *blk, size_t i) {
|
||||
memcpy(rblk->keys, lblk->keys + lblk->n * ksl->aligned_keylen,
|
||||
n * ksl->aligned_keylen);
|
||||
|
||||
ksl_set_nth_key(ksl, blk, i, nghttp3_ksl_nth_key(ksl, lblk, lblk->n - 1));
|
||||
ksl_set_nth_key(ksl, blk, i, nghttp3_ksl_blk_nth_key(lblk, lblk->n - 1));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -537,9 +535,9 @@ int nghttp3_ksl_remove_hint(nghttp3_ksl *ksl, nghttp3_ksl_it *it,
|
||||
const nghttp3_ksl_key *key) {
|
||||
nghttp3_ksl_blk *blk = hint->blk;
|
||||
|
||||
assert(ksl->head);
|
||||
assert(ksl->root);
|
||||
|
||||
if (blk->n <= NGHTTP3_KSL_MIN_NBLK) {
|
||||
if (blk != ksl->root && blk->n == NGHTTP3_KSL_MIN_NBLK) {
|
||||
return nghttp3_ksl_remove(ksl, it, key);
|
||||
}
|
||||
|
||||
@@ -549,9 +547,9 @@ int nghttp3_ksl_remove_hint(nghttp3_ksl *ksl, nghttp3_ksl_it *it,
|
||||
|
||||
if (it) {
|
||||
if (hint->i == blk->n && blk->next) {
|
||||
nghttp3_ksl_it_init(it, ksl, blk->next, 0);
|
||||
nghttp3_ksl_it_init(it, blk->next, 0);
|
||||
} else {
|
||||
nghttp3_ksl_it_init(it, ksl, blk, hint->i);
|
||||
nghttp3_ksl_it_init(it, blk, hint->i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -560,7 +558,7 @@ int nghttp3_ksl_remove_hint(nghttp3_ksl *ksl, nghttp3_ksl_it *it,
|
||||
|
||||
int nghttp3_ksl_remove(nghttp3_ksl *ksl, nghttp3_ksl_it *it,
|
||||
const nghttp3_ksl_key *key) {
|
||||
nghttp3_ksl_blk *blk = ksl->head;
|
||||
nghttp3_ksl_blk *blk = ksl->root;
|
||||
nghttp3_ksl_node *node;
|
||||
size_t i;
|
||||
|
||||
@@ -586,7 +584,7 @@ int nghttp3_ksl_remove(nghttp3_ksl *ksl, nghttp3_ksl_it *it,
|
||||
}
|
||||
|
||||
if (blk->leaf) {
|
||||
if (ksl->compar(key, nghttp3_ksl_nth_key(ksl, blk, i))) {
|
||||
if (ksl->compar(key, nghttp3_ksl_blk_nth_key(blk, i))) {
|
||||
if (it) {
|
||||
*it = nghttp3_ksl_end(ksl);
|
||||
}
|
||||
@@ -599,9 +597,9 @@ int nghttp3_ksl_remove(nghttp3_ksl *ksl, nghttp3_ksl_it *it,
|
||||
|
||||
if (it) {
|
||||
if (blk->n == i && blk->next) {
|
||||
nghttp3_ksl_it_init(it, ksl, blk->next, 0);
|
||||
nghttp3_ksl_it_init(it, blk->next, 0);
|
||||
} else {
|
||||
nghttp3_ksl_it_init(it, ksl, blk, i);
|
||||
nghttp3_ksl_it_init(it, blk, i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -650,12 +648,12 @@ nghttp3_ksl_it nghttp3_ksl_lower_bound(const nghttp3_ksl *ksl,
|
||||
nghttp3_ksl_it nghttp3_ksl_lower_bound_search(const nghttp3_ksl *ksl,
|
||||
const nghttp3_ksl_key *key,
|
||||
nghttp3_ksl_search search) {
|
||||
nghttp3_ksl_blk *blk = ksl->head;
|
||||
nghttp3_ksl_blk *blk = ksl->root;
|
||||
nghttp3_ksl_it it;
|
||||
size_t i;
|
||||
|
||||
if (!blk) {
|
||||
nghttp3_ksl_it_init(&it, ksl, &null_blk, 0);
|
||||
nghttp3_ksl_it_init(&it, &null_blk, 0);
|
||||
return it;
|
||||
}
|
||||
|
||||
@@ -668,7 +666,7 @@ nghttp3_ksl_it nghttp3_ksl_lower_bound_search(const nghttp3_ksl *ksl,
|
||||
i = 0;
|
||||
}
|
||||
|
||||
nghttp3_ksl_it_init(&it, ksl, blk, i);
|
||||
nghttp3_ksl_it_init(&it, blk, i);
|
||||
|
||||
return it;
|
||||
}
|
||||
@@ -686,7 +684,7 @@ nghttp3_ksl_it nghttp3_ksl_lower_bound_search(const nghttp3_ksl *ksl,
|
||||
i = blk->n;
|
||||
}
|
||||
|
||||
nghttp3_ksl_it_init(&it, ksl, blk, i);
|
||||
nghttp3_ksl_it_init(&it, blk, i);
|
||||
|
||||
return it;
|
||||
}
|
||||
@@ -697,19 +695,19 @@ nghttp3_ksl_it nghttp3_ksl_lower_bound_search(const nghttp3_ksl *ksl,
|
||||
|
||||
void nghttp3_ksl_update_key(nghttp3_ksl *ksl, const nghttp3_ksl_key *old_key,
|
||||
const nghttp3_ksl_key *new_key) {
|
||||
nghttp3_ksl_blk *blk = ksl->head;
|
||||
nghttp3_ksl_blk *blk = ksl->root;
|
||||
nghttp3_ksl_node *node;
|
||||
const nghttp3_ksl_key *node_key;
|
||||
size_t i;
|
||||
|
||||
assert(ksl->head);
|
||||
assert(ksl->root);
|
||||
|
||||
for (;;) {
|
||||
i = ksl->search(ksl, blk, old_key);
|
||||
|
||||
assert(i < blk->n);
|
||||
node = &blk->nodes[i];
|
||||
node_key = nghttp3_ksl_nth_key(ksl, blk, i);
|
||||
node_key = nghttp3_ksl_blk_nth_key(blk, i);
|
||||
|
||||
if (blk->leaf) {
|
||||
assert(key_equal(ksl->compar, node_key, old_key));
|
||||
@@ -730,15 +728,15 @@ void nghttp3_ksl_update_key(nghttp3_ksl *ksl, const nghttp3_ksl_key *old_key,
|
||||
size_t nghttp3_ksl_len(const nghttp3_ksl *ksl) { return ksl->n; }
|
||||
|
||||
void nghttp3_ksl_clear(nghttp3_ksl *ksl) {
|
||||
if (!ksl->head) {
|
||||
if (!ksl->root) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef NOMEMPOOL
|
||||
ksl_free_blk(ksl, ksl->head);
|
||||
ksl_free_blk(ksl, ksl->root);
|
||||
#endif /* defined(NOMEMPOOL) */
|
||||
|
||||
ksl->front = ksl->back = ksl->head = NULL;
|
||||
ksl->front = ksl->back = ksl->root = NULL;
|
||||
ksl->n = 0;
|
||||
|
||||
nghttp3_objalloc_clear(&ksl->blkalloc);
|
||||
@@ -753,8 +751,7 @@ static void ksl_print(const nghttp3_ksl *ksl, nghttp3_ksl_blk *blk,
|
||||
|
||||
if (blk->leaf) {
|
||||
for (i = 0; i < blk->n; ++i) {
|
||||
fprintf(stderr, " %" PRId64,
|
||||
*(int64_t *)nghttp3_ksl_nth_key(ksl, blk, i));
|
||||
fprintf(stderr, " %" PRId64, *(int64_t *)nghttp3_ksl_blk_nth_key(blk, i));
|
||||
}
|
||||
|
||||
fprintf(stderr, "\n");
|
||||
@@ -768,21 +765,21 @@ static void ksl_print(const nghttp3_ksl *ksl, nghttp3_ksl_blk *blk,
|
||||
}
|
||||
|
||||
void nghttp3_ksl_print(const nghttp3_ksl *ksl) {
|
||||
if (!ksl->head) {
|
||||
if (!ksl->root) {
|
||||
return;
|
||||
}
|
||||
|
||||
ksl_print(ksl, ksl->head, 0);
|
||||
ksl_print(ksl, ksl->root, 0);
|
||||
}
|
||||
#endif /* !defined(WIN32) */
|
||||
|
||||
nghttp3_ksl_it nghttp3_ksl_begin(const nghttp3_ksl *ksl) {
|
||||
nghttp3_ksl_it it;
|
||||
|
||||
if (ksl->head) {
|
||||
nghttp3_ksl_it_init(&it, ksl, ksl->front, 0);
|
||||
if (ksl->root) {
|
||||
nghttp3_ksl_it_init(&it, ksl->front, 0);
|
||||
} else {
|
||||
nghttp3_ksl_it_init(&it, ksl, &null_blk, 0);
|
||||
nghttp3_ksl_it_init(&it, &null_blk, 0);
|
||||
}
|
||||
|
||||
return it;
|
||||
@@ -791,18 +788,16 @@ nghttp3_ksl_it nghttp3_ksl_begin(const nghttp3_ksl *ksl) {
|
||||
nghttp3_ksl_it nghttp3_ksl_end(const nghttp3_ksl *ksl) {
|
||||
nghttp3_ksl_it it;
|
||||
|
||||
if (ksl->head) {
|
||||
nghttp3_ksl_it_init(&it, ksl, ksl->back, ksl->back->n);
|
||||
if (ksl->root) {
|
||||
nghttp3_ksl_it_init(&it, ksl->back, ksl->back->n);
|
||||
} else {
|
||||
nghttp3_ksl_it_init(&it, ksl, &null_blk, 0);
|
||||
nghttp3_ksl_it_init(&it, &null_blk, 0);
|
||||
}
|
||||
|
||||
return it;
|
||||
}
|
||||
|
||||
void nghttp3_ksl_it_init(nghttp3_ksl_it *it, const nghttp3_ksl *ksl,
|
||||
nghttp3_ksl_blk *blk, size_t i) {
|
||||
it->ksl = ksl;
|
||||
void nghttp3_ksl_it_init(nghttp3_ksl_it *it, nghttp3_ksl_blk *blk, size_t i) {
|
||||
it->blk = blk;
|
||||
it->i = i;
|
||||
}
|
||||
|
||||
+17
-17
@@ -39,10 +39,10 @@
|
||||
#define NGHTTP3_KSL_DEGR 16
|
||||
/* NGHTTP3_KSL_MAX_NBLK is the maximum number of nodes which a single
|
||||
block can contain. */
|
||||
#define NGHTTP3_KSL_MAX_NBLK (2 * NGHTTP3_KSL_DEGR - 1)
|
||||
#define NGHTTP3_KSL_MAX_NBLK (2 * NGHTTP3_KSL_DEGR)
|
||||
/* NGHTTP3_KSL_MIN_NBLK is the minimum number of nodes which a single
|
||||
block other than root must contain. */
|
||||
#define NGHTTP3_KSL_MIN_NBLK (NGHTTP3_KSL_DEGR - 1)
|
||||
#define NGHTTP3_KSL_MIN_NBLK NGHTTP3_KSL_DEGR
|
||||
|
||||
/*
|
||||
* nghttp3_ksl_key represents key in nghttp3_ksl.
|
||||
@@ -76,16 +76,19 @@ struct nghttp3_ksl_blk {
|
||||
/* prev points to the previous block if leaf field is
|
||||
nonzero. */
|
||||
nghttp3_ksl_blk *prev;
|
||||
/* n is the number of nodes this object contains in nodes. */
|
||||
uint32_t n;
|
||||
/* leaf is nonzero if this block contains leaf nodes. */
|
||||
uint32_t leaf;
|
||||
nghttp3_ksl_node nodes[NGHTTP3_KSL_MAX_NBLK];
|
||||
/* keys is a pointer to the buffer to include
|
||||
NGHTTP3_KSL_MAX_NBLK keys. Because the length of key is
|
||||
unknown until nghttp3_ksl_init is called, the actual buffer
|
||||
will be allocated after this field. */
|
||||
will be allocated after this object. */
|
||||
uint8_t *keys;
|
||||
/* n is the number of nodes this object contains in nodes. */
|
||||
uint32_t n;
|
||||
/* aligned_keylen is the length of the single key including
|
||||
alignment. */
|
||||
uint16_t aligned_keylen;
|
||||
/* leaf is nonzero if this block contains leaf nodes. */
|
||||
uint8_t leaf;
|
||||
};
|
||||
|
||||
nghttp3_opl_entry oplent;
|
||||
@@ -137,7 +140,6 @@ typedef struct nghttp3_ksl_it nghttp3_ksl_it;
|
||||
* nghttp3_ksl_it is a bidirectional iterator to iterate nodes.
|
||||
*/
|
||||
struct nghttp3_ksl_it {
|
||||
const nghttp3_ksl *ksl;
|
||||
nghttp3_ksl_blk *blk;
|
||||
size_t i;
|
||||
};
|
||||
@@ -147,8 +149,8 @@ struct nghttp3_ksl_it {
|
||||
*/
|
||||
struct nghttp3_ksl {
|
||||
nghttp3_objalloc blkalloc;
|
||||
/* head points to the root block. */
|
||||
nghttp3_ksl_blk *head;
|
||||
/* root points to the root block. */
|
||||
nghttp3_ksl_blk *root;
|
||||
/* front points to the first leaf block. */
|
||||
nghttp3_ksl_blk *front;
|
||||
/* back points to the last leaf block. */
|
||||
@@ -278,12 +280,11 @@ size_t nghttp3_ksl_len(const nghttp3_ksl *ksl);
|
||||
void nghttp3_ksl_clear(nghttp3_ksl *ksl);
|
||||
|
||||
/*
|
||||
* nghttp3_ksl_nth_key returns the |n|th key under |blk|.
|
||||
* nghttp3_ksl_blk_nth_key returns the |n|th key under |blk|.
|
||||
*/
|
||||
static inline const nghttp3_ksl_key *
|
||||
nghttp3_ksl_nth_key(const nghttp3_ksl *ksl, const nghttp3_ksl_blk *blk,
|
||||
size_t n) {
|
||||
return blk->keys + n * ksl->aligned_keylen;
|
||||
nghttp3_ksl_blk_nth_key(const nghttp3_ksl_blk *blk, size_t n) {
|
||||
return blk->keys + n * blk->aligned_keylen;
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
@@ -298,8 +299,7 @@ void nghttp3_ksl_print(const nghttp3_ksl *ksl);
|
||||
/*
|
||||
* nghttp3_ksl_it_init initializes |it|.
|
||||
*/
|
||||
void nghttp3_ksl_it_init(nghttp3_ksl_it *it, const nghttp3_ksl *ksl,
|
||||
nghttp3_ksl_blk *blk, size_t i);
|
||||
void nghttp3_ksl_it_init(nghttp3_ksl_it *it, nghttp3_ksl_blk *blk, size_t i);
|
||||
|
||||
/*
|
||||
* nghttp3_ksl_it_get returns the data associated to the node which
|
||||
@@ -351,7 +351,7 @@ int nghttp3_ksl_it_begin(const nghttp3_ksl_it *it);
|
||||
*/
|
||||
static inline const nghttp3_ksl_key *
|
||||
nghttp3_ksl_it_key(const nghttp3_ksl_it *it) {
|
||||
return nghttp3_ksl_nth_key(it->ksl, it->blk, it->i);
|
||||
return nghttp3_ksl_blk_nth_key(it->blk, it->i);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+9
-1
@@ -39,7 +39,15 @@
|
||||
|
||||
#define nghttp3_arraylen(A) (sizeof(A) / sizeof(*(A)))
|
||||
|
||||
#define lstreq(A, B, N) ((sizeof((A)) - 1) == (N) && memcmp((A), (B), (N)) == 0)
|
||||
/*
|
||||
* nghttp3_strlen_lit returns the length of string literal |S|. This
|
||||
* macro assumes |S| is NULL-terminated string literal. It must not
|
||||
* be used with pointers.
|
||||
*/
|
||||
#define nghttp3_strlen_lit(S) (sizeof(S) - 1)
|
||||
|
||||
#define lstreq(A, B, N) \
|
||||
(nghttp3_strlen_lit((A)) == (N) && memcmp((A), (B), (N)) == 0)
|
||||
|
||||
/* NGHTTP3_MAX_VARINT` is the maximum value which can be encoded in
|
||||
variable-length integer encoding. */
|
||||
|
||||
+2
-2
@@ -174,13 +174,13 @@ static nghttp3_qpack_static_entry token_stable[] = {
|
||||
.name = \
|
||||
{ \
|
||||
.base = (uint8_t *)(N), \
|
||||
.len = sizeof((N)) - 1, \
|
||||
.len = nghttp3_strlen_lit((N)), \
|
||||
.ref = -1, \
|
||||
}, \
|
||||
.value = \
|
||||
{ \
|
||||
.base = (uint8_t *)(V), \
|
||||
.len = sizeof((V)) - 1, \
|
||||
.len = nghttp3_strlen_lit((V)), \
|
||||
.ref = -1, \
|
||||
}, \
|
||||
.token = T, \
|
||||
|
||||
+29
-35
@@ -73,7 +73,7 @@ int nghttp3_stream_new(nghttp3_stream **pstream, int64_t stream_id,
|
||||
|
||||
nghttp3_tnode_init(&stream->node, stream_id);
|
||||
|
||||
nghttp3_ringbuf_init(&stream->frq, 0, sizeof(nghttp3_frame_entry), mem);
|
||||
nghttp3_ringbuf_init(&stream->frq, 0, sizeof(nghttp3_frame), mem);
|
||||
nghttp3_ringbuf_init(&stream->chunks, 0, sizeof(nghttp3_buf), mem);
|
||||
nghttp3_ringbuf_init(&stream->outq, 0, sizeof(nghttp3_typed_buf), mem);
|
||||
nghttp3_ringbuf_init(&stream->inq, 0, sizeof(nghttp3_buf), mem);
|
||||
@@ -136,17 +136,17 @@ static void delete_out_chunks(nghttp3_ringbuf *chunks,
|
||||
}
|
||||
|
||||
static void delete_frq(nghttp3_ringbuf *frq, const nghttp3_mem *mem) {
|
||||
nghttp3_frame_entry *frent;
|
||||
nghttp3_frame *fr;
|
||||
size_t i, len = nghttp3_ringbuf_len(frq);
|
||||
|
||||
for (i = 0; i < len; ++i) {
|
||||
frent = nghttp3_ringbuf_get(frq, i);
|
||||
switch (frent->fr.hd.type) {
|
||||
fr = nghttp3_ringbuf_get(frq, i);
|
||||
switch (fr->hd.type) {
|
||||
case NGHTTP3_FRAME_HEADERS:
|
||||
nghttp3_frame_headers_free(&frent->fr.headers, mem);
|
||||
nghttp3_frame_headers_free(&fr->headers, mem);
|
||||
break;
|
||||
case NGHTTP3_FRAME_PRIORITY_UPDATE:
|
||||
nghttp3_frame_priority_update_free(&frent->fr.priority_update, mem);
|
||||
nghttp3_frame_priority_update_free(&fr->priority_update, mem);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -223,10 +223,9 @@ nghttp3_ssize nghttp3_read_varint(nghttp3_varint_read_state *rvint,
|
||||
return (nghttp3_ssize)len;
|
||||
}
|
||||
|
||||
int nghttp3_stream_frq_add(nghttp3_stream *stream,
|
||||
const nghttp3_frame_entry *frent) {
|
||||
int nghttp3_stream_frq_add(nghttp3_stream *stream, const nghttp3_frame *fr) {
|
||||
nghttp3_ringbuf *frq = &stream->frq;
|
||||
nghttp3_frame_entry *dest;
|
||||
nghttp3_frame *dest;
|
||||
int rv;
|
||||
|
||||
if (nghttp3_ringbuf_full(frq)) {
|
||||
@@ -239,37 +238,37 @@ int nghttp3_stream_frq_add(nghttp3_stream *stream,
|
||||
}
|
||||
|
||||
dest = nghttp3_ringbuf_push_back(frq);
|
||||
*dest = *frent;
|
||||
*dest = *fr;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nghttp3_stream_fill_outq(nghttp3_stream *stream) {
|
||||
nghttp3_ringbuf *frq = &stream->frq;
|
||||
nghttp3_frame_entry *frent;
|
||||
nghttp3_frame *fr;
|
||||
int data_eof;
|
||||
int rv;
|
||||
|
||||
for (; nghttp3_ringbuf_len(frq) &&
|
||||
stream->unsent_bytes < NGHTTP3_MIN_UNSENT_BYTES;) {
|
||||
frent = nghttp3_ringbuf_get(frq, 0);
|
||||
fr = nghttp3_ringbuf_get(frq, 0);
|
||||
|
||||
switch (frent->fr.hd.type) {
|
||||
switch (fr->hd.type) {
|
||||
case NGHTTP3_FRAME_SETTINGS:
|
||||
rv = nghttp3_stream_write_settings(stream, frent);
|
||||
rv = nghttp3_stream_write_settings(stream, &fr->settings);
|
||||
if (rv != 0) {
|
||||
return rv;
|
||||
}
|
||||
break;
|
||||
case NGHTTP3_FRAME_HEADERS:
|
||||
rv = nghttp3_stream_write_headers(stream, frent);
|
||||
rv = nghttp3_stream_write_headers(stream, &fr->headers);
|
||||
if (rv != 0) {
|
||||
return rv;
|
||||
}
|
||||
nghttp3_frame_headers_free(&frent->fr.headers, stream->mem);
|
||||
nghttp3_frame_headers_free(&fr->headers, stream->mem);
|
||||
break;
|
||||
case NGHTTP3_FRAME_DATA:
|
||||
rv = nghttp3_stream_write_data(stream, &data_eof, frent);
|
||||
rv = nghttp3_stream_write_data(stream, &data_eof, &fr->data);
|
||||
if (rv != 0) {
|
||||
return rv;
|
||||
}
|
||||
@@ -281,21 +280,20 @@ int nghttp3_stream_fill_outq(nghttp3_stream *stream) {
|
||||
}
|
||||
break;
|
||||
case NGHTTP3_FRAME_GOAWAY:
|
||||
rv = nghttp3_stream_write_goaway(stream, frent);
|
||||
rv = nghttp3_stream_write_goaway(stream, &fr->goaway);
|
||||
if (rv != 0) {
|
||||
return rv;
|
||||
}
|
||||
break;
|
||||
case NGHTTP3_FRAME_PRIORITY_UPDATE:
|
||||
rv = nghttp3_stream_write_priority_update(stream, frent);
|
||||
rv = nghttp3_stream_write_priority_update(stream, &fr->priority_update);
|
||||
if (rv != 0) {
|
||||
return rv;
|
||||
}
|
||||
nghttp3_frame_priority_update_free(&frent->fr.priority_update,
|
||||
stream->mem);
|
||||
nghttp3_frame_priority_update_free(&fr->priority_update, stream->mem);
|
||||
break;
|
||||
case NGHTTP3_FRAME_ORIGIN:
|
||||
rv = nghttp3_stream_write_origin(stream, frent);
|
||||
rv = nghttp3_stream_write_origin(stream, &fr->origin);
|
||||
if (rv != 0) {
|
||||
return rv;
|
||||
}
|
||||
@@ -333,7 +331,7 @@ int nghttp3_stream_write_stream_type(nghttp3_stream *stream) {
|
||||
}
|
||||
|
||||
int nghttp3_stream_write_settings(nghttp3_stream *stream,
|
||||
nghttp3_frame_entry *frent) {
|
||||
const nghttp3_frame_settings *infr) {
|
||||
size_t len;
|
||||
int rv;
|
||||
nghttp3_buf *chunk;
|
||||
@@ -344,7 +342,7 @@ int nghttp3_stream_write_settings(nghttp3_stream *stream,
|
||||
.niv = 3,
|
||||
.iv = ents,
|
||||
};
|
||||
nghttp3_settings *local_settings = frent->aux.settings.local_settings;
|
||||
const nghttp3_settings *local_settings = infr->local_settings;
|
||||
int64_t payloadlen;
|
||||
|
||||
ents[0] = (nghttp3_settings_entry){
|
||||
@@ -396,8 +394,7 @@ int nghttp3_stream_write_settings(nghttp3_stream *stream,
|
||||
}
|
||||
|
||||
int nghttp3_stream_write_goaway(nghttp3_stream *stream,
|
||||
nghttp3_frame_entry *frent) {
|
||||
nghttp3_frame_goaway *fr = &frent->fr.goaway;
|
||||
const nghttp3_frame_goaway *fr) {
|
||||
size_t len;
|
||||
int rv;
|
||||
nghttp3_buf *chunk;
|
||||
@@ -421,9 +418,8 @@ int nghttp3_stream_write_goaway(nghttp3_stream *stream,
|
||||
return nghttp3_stream_outq_add(stream, &tbuf);
|
||||
}
|
||||
|
||||
int nghttp3_stream_write_priority_update(nghttp3_stream *stream,
|
||||
nghttp3_frame_entry *frent) {
|
||||
nghttp3_frame_priority_update *fr = &frent->fr.priority_update;
|
||||
int nghttp3_stream_write_priority_update(
|
||||
nghttp3_stream *stream, const nghttp3_frame_priority_update *fr) {
|
||||
size_t len;
|
||||
int rv;
|
||||
nghttp3_buf *chunk;
|
||||
@@ -449,8 +445,7 @@ int nghttp3_stream_write_priority_update(nghttp3_stream *stream,
|
||||
}
|
||||
|
||||
int nghttp3_stream_write_origin(nghttp3_stream *stream,
|
||||
nghttp3_frame_entry *frent) {
|
||||
nghttp3_frame_origin *fr = &frent->fr.origin;
|
||||
const nghttp3_frame_origin *fr) {
|
||||
nghttp3_buf *chunk;
|
||||
nghttp3_buf buf;
|
||||
nghttp3_typed_buf tbuf;
|
||||
@@ -488,8 +483,7 @@ int nghttp3_stream_write_origin(nghttp3_stream *stream,
|
||||
}
|
||||
|
||||
int nghttp3_stream_write_headers(nghttp3_stream *stream,
|
||||
nghttp3_frame_entry *frent) {
|
||||
nghttp3_frame_headers *fr = &frent->fr.headers;
|
||||
const nghttp3_frame_headers *fr) {
|
||||
nghttp3_conn *conn = stream->conn;
|
||||
|
||||
assert(conn);
|
||||
@@ -610,13 +604,13 @@ int nghttp3_stream_write_header_block(nghttp3_stream *stream,
|
||||
}
|
||||
|
||||
int nghttp3_stream_write_data(nghttp3_stream *stream, int *peof,
|
||||
nghttp3_frame_entry *frent) {
|
||||
const nghttp3_frame_data *fr) {
|
||||
int rv;
|
||||
size_t len;
|
||||
nghttp3_typed_buf tbuf;
|
||||
nghttp3_buf buf;
|
||||
nghttp3_buf *chunk;
|
||||
nghttp3_read_data_callback read_data = frent->aux.data.dr.read_data;
|
||||
nghttp3_read_data_callback read_data = fr->dr.read_data;
|
||||
nghttp3_conn *conn = stream->conn;
|
||||
int64_t datalen;
|
||||
uint32_t flags = 0;
|
||||
|
||||
+8
-21
@@ -246,18 +246,6 @@ struct nghttp3_stream {
|
||||
|
||||
nghttp3_objalloc_decl(stream, nghttp3_stream, oplent)
|
||||
|
||||
typedef struct nghttp3_frame_entry {
|
||||
nghttp3_frame fr;
|
||||
union {
|
||||
struct {
|
||||
nghttp3_settings *local_settings;
|
||||
} settings;
|
||||
struct {
|
||||
nghttp3_data_reader dr;
|
||||
} data;
|
||||
} aux;
|
||||
} nghttp3_frame_entry;
|
||||
|
||||
int nghttp3_stream_new(nghttp3_stream **pstream, int64_t stream_id,
|
||||
const nghttp3_stream_callbacks *callbacks,
|
||||
nghttp3_objalloc *out_chunk_objalloc,
|
||||
@@ -274,8 +262,7 @@ nghttp3_ssize nghttp3_read_varint(nghttp3_varint_read_state *rvint,
|
||||
const uint8_t *begin, const uint8_t *end,
|
||||
int fin);
|
||||
|
||||
int nghttp3_stream_frq_add(nghttp3_stream *stream,
|
||||
const nghttp3_frame_entry *frent);
|
||||
int nghttp3_stream_frq_add(nghttp3_stream *stream, const nghttp3_frame *fr);
|
||||
|
||||
int nghttp3_stream_fill_outq(nghttp3_stream *stream);
|
||||
|
||||
@@ -290,7 +277,7 @@ int nghttp3_stream_outq_add(nghttp3_stream *stream,
|
||||
const nghttp3_typed_buf *tbuf);
|
||||
|
||||
int nghttp3_stream_write_headers(nghttp3_stream *stream,
|
||||
nghttp3_frame_entry *frent);
|
||||
const nghttp3_frame_headers *fr);
|
||||
|
||||
int nghttp3_stream_write_header_block(nghttp3_stream *stream,
|
||||
nghttp3_qpack_encoder *qenc,
|
||||
@@ -300,19 +287,19 @@ int nghttp3_stream_write_header_block(nghttp3_stream *stream,
|
||||
size_t nvlen);
|
||||
|
||||
int nghttp3_stream_write_data(nghttp3_stream *stream, int *peof,
|
||||
nghttp3_frame_entry *frent);
|
||||
const nghttp3_frame_data *fr);
|
||||
|
||||
int nghttp3_stream_write_settings(nghttp3_stream *stream,
|
||||
nghttp3_frame_entry *frent);
|
||||
const nghttp3_frame_settings *fr);
|
||||
|
||||
int nghttp3_stream_write_goaway(nghttp3_stream *stream,
|
||||
nghttp3_frame_entry *frent);
|
||||
const nghttp3_frame_goaway *fr);
|
||||
|
||||
int nghttp3_stream_write_priority_update(nghttp3_stream *stream,
|
||||
nghttp3_frame_entry *frent);
|
||||
int nghttp3_stream_write_priority_update(
|
||||
nghttp3_stream *stream, const nghttp3_frame_priority_update *fr);
|
||||
|
||||
int nghttp3_stream_write_origin(nghttp3_stream *stream,
|
||||
nghttp3_frame_entry *frent);
|
||||
const nghttp3_frame_origin *fr);
|
||||
|
||||
int nghttp3_stream_ensure_chunk(nghttp3_stream *stream, size_t need);
|
||||
|
||||
|
||||
Reference in new issue
Block a user