Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quic: update ngtcp2 and nghttp3 #34752

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 8 additions & 7 deletions deps/nghttp3/lib/nghttp3_conn.c
Expand Up @@ -2351,12 +2351,13 @@ int nghttp3_conn_create_stream(nghttp3_conn *conn, nghttp3_stream **pstream,

int nghttp3_conn_create_push_promise(nghttp3_conn *conn,
nghttp3_push_promise **ppp,
int64_t push_id, nghttp3_tnode *parent) {
int64_t push_id,
nghttp3_tnode *assoc_tnode) {
nghttp3_push_promise *pp;
int rv;

rv =
nghttp3_push_promise_new(&pp, push_id, conn->next_seq, parent, conn->mem);
rv = nghttp3_push_promise_new(&pp, push_id, conn->next_seq, assoc_tnode,
conn->mem);
if (rv != 0) {
return rv;
}
Expand Down Expand Up @@ -3204,7 +3205,7 @@ void nghttp3_conn_settings_default(nghttp3_conn_settings *settings) {
}

int nghttp3_push_promise_new(nghttp3_push_promise **ppp, int64_t push_id,
uint64_t seq, nghttp3_tnode *parent,
uint64_t seq, nghttp3_tnode *assoc_tnode,
const nghttp3_mem *mem) {
nghttp3_push_promise *pp;
nghttp3_node_id nid;
Expand All @@ -3223,10 +3224,10 @@ int nghttp3_push_promise_new(nghttp3_push_promise **ppp, int64_t push_id,
pp->http.status_code = -1;
pp->http.content_length = -1;

if (parent) {
assert(parent->nid.type == NGHTTP3_NODE_ID_TYPE_STREAM);
if (assoc_tnode) {
assert(assoc_tnode->nid.type == NGHTTP3_NODE_ID_TYPE_STREAM);

pp->stream_id = parent->nid.id;
pp->stream_id = assoc_tnode->nid.id;
pp->flags |= NGHTTP3_PUSH_PROMISE_FLAG_BOUND;
} else {
pp->stream_id = -1;
Expand Down
5 changes: 3 additions & 2 deletions deps/nghttp3/lib/nghttp3_conn.h
Expand Up @@ -180,7 +180,8 @@ int nghttp3_conn_create_stream(nghttp3_conn *conn, nghttp3_stream **pstream,

int nghttp3_conn_create_push_promise(nghttp3_conn *conn,
nghttp3_push_promise **ppp,
int64_t push_id, nghttp3_tnode *parent);
int64_t push_id,
nghttp3_tnode *assoc_tnode);

nghttp3_ssize nghttp3_conn_read_bidi(nghttp3_conn *conn, size_t *pnproc,
nghttp3_stream *stream, const uint8_t *src,
Expand Down Expand Up @@ -254,7 +255,7 @@ void nghttp3_conn_unschedule_stream(nghttp3_conn *conn, nghttp3_stream *stream);
nghttp3_stream *nghttp3_conn_get_next_tx_stream(nghttp3_conn *conn);

int nghttp3_push_promise_new(nghttp3_push_promise **ppp, int64_t push_id,
uint64_t seq, nghttp3_tnode *parent,
uint64_t seq, nghttp3_tnode *assoc_tnode,
const nghttp3_mem *mem);

void nghttp3_push_promise_del(nghttp3_push_promise *pp, const nghttp3_mem *mem);
Expand Down
24 changes: 19 additions & 5 deletions deps/nghttp3/lib/nghttp3_conv.h
Expand Up @@ -38,6 +38,10 @@
# include <netinet/in.h>
#endif /* HAVE_NETINET_IN_H */

#ifdef HAVE_BYTESWAP_H
# include <byteswap.h>
#endif /* HAVE_BYTESWAP_H */

#ifdef HAVE_ENDIAN_H
# include <endian.h>
#endif /* HAVE_ENDIAN_H */
Expand All @@ -48,15 +52,25 @@

#include <nghttp3/nghttp3.h>

#if defined HAVE_BSWAP_64 || HAVE_DECL_BSWAP_64
# define nghttp3_bswap64 bswap_64
#else /* !HAVE_BSWAP_64 */
# define nghttp3_bswap64(N) \
((uint64_t)(ntohl((uint32_t)(N))) << 32 | ntohl((uint32_t)((N) >> 32)))
#endif /* !HAVE_BSWAP_64 */

#if defined HAVE_BE64TOH || HAVE_DECL_BE64TOH
# define nghttp3_ntohl64(N) be64toh(N)
# define nghttp3_htonl64(N) htobe64(N)
#else /* !HAVE_BE64TOH */
# define nghttp3_bswap64(N) \
((uint64_t)(ntohl((uint32_t)(N))) << 32 | ntohl((uint32_t)((N) >> 32)))
# define nghttp3_ntohl64(N) nghttp3_bswap64(N)
# define nghttp3_htonl64(N) nghttp3_bswap64(N)
#endif /* !HAVE_BE64TOH */
# if defined WORDS_BIGENDIAN
# define nghttp3_ntohl64(N) (N)
# define nghttp3_htonl64(N) (N)
# else /* !WORDS_BIGENDIAN */
# define nghttp3_ntohl64(N) nghttp3_bswap64(N)
# define nghttp3_htonl64(N) nghttp3_bswap64(N)
# endif /* !WORDS_BIGENDIAN */
#endif /* !HAVE_BE64TOH */

#if defined(WIN32)
/* Windows requires ws2_32 library for ntonl family of functions. We
Expand Down
27 changes: 22 additions & 5 deletions deps/nghttp3/lib/nghttp3_ksl.c
Expand Up @@ -281,6 +281,13 @@ int nghttp3_ksl_insert(nghttp3_ksl *ksl, nghttp3_ksl_it *it,
i = ksl_bsearch(ksl, blk, key, ksl->compar);

if (blk->leaf) {
if (i < blk->n &&
!ksl->compar(key, nghttp3_ksl_nth_node(ksl, blk, i)->key)) {
if (it) {
*it = nghttp3_ksl_end(ksl);
}
return NGHTTP3_ERR_INVALID_ARGUMENT;
}
ksl_insert_node(ksl, blk, i, key, data);
++ksl->n;
if (it) {
Expand Down Expand Up @@ -453,8 +460,8 @@ static int key_equal(nghttp3_ksl_compar compar, const nghttp3_ksl_key *lhs,
return !compar(lhs, rhs) && !compar(rhs, lhs);
}

void nghttp3_ksl_remove(nghttp3_ksl *ksl, nghttp3_ksl_it *it,
const nghttp3_ksl_key *key) {
int nghttp3_ksl_remove(nghttp3_ksl *ksl, nghttp3_ksl_it *it,
const nghttp3_ksl_key *key) {
nghttp3_ksl_blk *blk = ksl->head;
nghttp3_ksl_node *node;
size_t i;
Expand All @@ -468,10 +475,20 @@ void nghttp3_ksl_remove(nghttp3_ksl *ksl, nghttp3_ksl_it *it,
for (;;) {
i = ksl_bsearch(ksl, blk, key, ksl->compar);

assert(i < blk->n);
if (i == blk->n) {
if (it) {
*it = nghttp3_ksl_end(ksl);
}
return NGHTTP3_ERR_INVALID_ARGUMENT;
}

if (blk->leaf) {
assert(i < blk->n);
if (ksl->compar(key, nghttp3_ksl_nth_node(ksl, blk, i)->key)) {
if (it) {
*it = nghttp3_ksl_end(ksl);
}
return NGHTTP3_ERR_INVALID_ARGUMENT;
}
ksl_remove_node(ksl, blk, i);
--ksl->n;
if (it) {
Expand All @@ -481,7 +498,7 @@ void nghttp3_ksl_remove(nghttp3_ksl *ksl, nghttp3_ksl_it *it,
nghttp3_ksl_it_init(it, ksl, blk, i);
}
}
return;
return 0;
}

node = nghttp3_ksl_nth_node(ksl, blk, i);
Expand Down
20 changes: 13 additions & 7 deletions deps/nghttp3/lib/nghttp3_ksl.h
Expand Up @@ -168,27 +168,33 @@ void nghttp3_ksl_free(nghttp3_ksl *ksl);
* successful insertion, the iterator points to the inserted node is
* stored in |*it|.
*
* This function assumes that |key| does not exist in |ksl|.
*
* This function returns 0 if it succeeds, or one of the following
* negative error codes:
*
* NGHTTP3_ERR_NOMEM
* Out of memory.
* NGHTTP3_ERR_INVALID_ARGUMENT
* |key| already exists.
*/
int nghttp3_ksl_insert(nghttp3_ksl *ksl, nghttp3_ksl_it *it,
const nghttp3_ksl_key *key, void *data);

/*
* nghttp3_ksl_remove removes the |key| from |ksl|. It assumes such
* the key is included in |ksl|.
* nghttp3_ksl_remove removes the |key| from |ksl|.
*
* This function assigns the iterator to |*it|, which points to the
* node which is located at the right next of the removed node if |it|
* is not NULL.
* is not NULL. If |key| is not found, no deletion takes place and
* the return value of nghttp3_ksl_end(ksl) is assigned to |*it|.
*
* This function returns 0 if it succeeds, or one of the following
* negative error codes:
*
* NGHTTP3_ERR_INVALID_ARGUMENT
* |key| does not exist.
*/
void nghttp3_ksl_remove(nghttp3_ksl *ksl, nghttp3_ksl_it *it,
const nghttp3_ksl_key *key);
int nghttp3_ksl_remove(nghttp3_ksl *ksl, nghttp3_ksl_it *it,
const nghttp3_ksl_key *key);

/*
* nghttp3_ksl_lower_bound returns the iterator which points to the
Expand Down