Skip to content

Commit 757bac6

Browse files
committed
deps: update nghttp3
Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #34752 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent c788be2 commit 757bac6

11 files changed

+308
-117
lines changed

deps/nghttp3/lib/nghttp3_conn.c

+8-7
Original file line numberDiff line numberDiff line change
@@ -2351,12 +2351,13 @@ int nghttp3_conn_create_stream(nghttp3_conn *conn, nghttp3_stream **pstream,
23512351

23522352
int nghttp3_conn_create_push_promise(nghttp3_conn *conn,
23532353
nghttp3_push_promise **ppp,
2354-
int64_t push_id, nghttp3_tnode *parent) {
2354+
int64_t push_id,
2355+
nghttp3_tnode *assoc_tnode) {
23552356
nghttp3_push_promise *pp;
23562357
int rv;
23572358

2358-
rv =
2359-
nghttp3_push_promise_new(&pp, push_id, conn->next_seq, parent, conn->mem);
2359+
rv = nghttp3_push_promise_new(&pp, push_id, conn->next_seq, assoc_tnode,
2360+
conn->mem);
23602361
if (rv != 0) {
23612362
return rv;
23622363
}
@@ -3204,7 +3205,7 @@ void nghttp3_conn_settings_default(nghttp3_conn_settings *settings) {
32043205
}
32053206

32063207
int nghttp3_push_promise_new(nghttp3_push_promise **ppp, int64_t push_id,
3207-
uint64_t seq, nghttp3_tnode *parent,
3208+
uint64_t seq, nghttp3_tnode *assoc_tnode,
32083209
const nghttp3_mem *mem) {
32093210
nghttp3_push_promise *pp;
32103211
nghttp3_node_id nid;
@@ -3223,10 +3224,10 @@ int nghttp3_push_promise_new(nghttp3_push_promise **ppp, int64_t push_id,
32233224
pp->http.status_code = -1;
32243225
pp->http.content_length = -1;
32253226

3226-
if (parent) {
3227-
assert(parent->nid.type == NGHTTP3_NODE_ID_TYPE_STREAM);
3227+
if (assoc_tnode) {
3228+
assert(assoc_tnode->nid.type == NGHTTP3_NODE_ID_TYPE_STREAM);
32283229

3229-
pp->stream_id = parent->nid.id;
3230+
pp->stream_id = assoc_tnode->nid.id;
32303231
pp->flags |= NGHTTP3_PUSH_PROMISE_FLAG_BOUND;
32313232
} else {
32323233
pp->stream_id = -1;

deps/nghttp3/lib/nghttp3_conn.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ int nghttp3_conn_create_stream(nghttp3_conn *conn, nghttp3_stream **pstream,
180180

181181
int nghttp3_conn_create_push_promise(nghttp3_conn *conn,
182182
nghttp3_push_promise **ppp,
183-
int64_t push_id, nghttp3_tnode *parent);
183+
int64_t push_id,
184+
nghttp3_tnode *assoc_tnode);
184185

185186
nghttp3_ssize nghttp3_conn_read_bidi(nghttp3_conn *conn, size_t *pnproc,
186187
nghttp3_stream *stream, const uint8_t *src,
@@ -254,7 +255,7 @@ void nghttp3_conn_unschedule_stream(nghttp3_conn *conn, nghttp3_stream *stream);
254255
nghttp3_stream *nghttp3_conn_get_next_tx_stream(nghttp3_conn *conn);
255256

256257
int nghttp3_push_promise_new(nghttp3_push_promise **ppp, int64_t push_id,
257-
uint64_t seq, nghttp3_tnode *parent,
258+
uint64_t seq, nghttp3_tnode *assoc_tnode,
258259
const nghttp3_mem *mem);
259260

260261
void nghttp3_push_promise_del(nghttp3_push_promise *pp, const nghttp3_mem *mem);

deps/nghttp3/lib/nghttp3_conv.h

+19-5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
# include <netinet/in.h>
3939
#endif /* HAVE_NETINET_IN_H */
4040

41+
#ifdef HAVE_BYTESWAP_H
42+
# include <byteswap.h>
43+
#endif /* HAVE_BYTESWAP_H */
44+
4145
#ifdef HAVE_ENDIAN_H
4246
# include <endian.h>
4347
#endif /* HAVE_ENDIAN_H */
@@ -48,15 +52,25 @@
4852

4953
#include <nghttp3/nghttp3.h>
5054

55+
#if defined HAVE_BSWAP_64 || HAVE_DECL_BSWAP_64
56+
# define nghttp3_bswap64 bswap_64
57+
#else /* !HAVE_BSWAP_64 */
58+
# define nghttp3_bswap64(N) \
59+
((uint64_t)(ntohl((uint32_t)(N))) << 32 | ntohl((uint32_t)((N) >> 32)))
60+
#endif /* !HAVE_BSWAP_64 */
61+
5162
#if defined HAVE_BE64TOH || HAVE_DECL_BE64TOH
5263
# define nghttp3_ntohl64(N) be64toh(N)
5364
# define nghttp3_htonl64(N) htobe64(N)
5465
#else /* !HAVE_BE64TOH */
55-
# define nghttp3_bswap64(N) \
56-
((uint64_t)(ntohl((uint32_t)(N))) << 32 | ntohl((uint32_t)((N) >> 32)))
57-
# define nghttp3_ntohl64(N) nghttp3_bswap64(N)
58-
# define nghttp3_htonl64(N) nghttp3_bswap64(N)
59-
#endif /* !HAVE_BE64TOH */
66+
# if defined WORDS_BIGENDIAN
67+
# define nghttp3_ntohl64(N) (N)
68+
# define nghttp3_htonl64(N) (N)
69+
# else /* !WORDS_BIGENDIAN */
70+
# define nghttp3_ntohl64(N) nghttp3_bswap64(N)
71+
# define nghttp3_htonl64(N) nghttp3_bswap64(N)
72+
# endif /* !WORDS_BIGENDIAN */
73+
#endif /* !HAVE_BE64TOH */
6074

6175
#if defined(WIN32)
6276
/* Windows requires ws2_32 library for ntonl family of functions. We

deps/nghttp3/lib/nghttp3_ksl.c

+22-5
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,13 @@ int nghttp3_ksl_insert(nghttp3_ksl *ksl, nghttp3_ksl_it *it,
281281
i = ksl_bsearch(ksl, blk, key, ksl->compar);
282282

283283
if (blk->leaf) {
284+
if (i < blk->n &&
285+
!ksl->compar(key, nghttp3_ksl_nth_node(ksl, blk, i)->key)) {
286+
if (it) {
287+
*it = nghttp3_ksl_end(ksl);
288+
}
289+
return NGHTTP3_ERR_INVALID_ARGUMENT;
290+
}
284291
ksl_insert_node(ksl, blk, i, key, data);
285292
++ksl->n;
286293
if (it) {
@@ -453,8 +460,8 @@ static int key_equal(nghttp3_ksl_compar compar, const nghttp3_ksl_key *lhs,
453460
return !compar(lhs, rhs) && !compar(rhs, lhs);
454461
}
455462

456-
void nghttp3_ksl_remove(nghttp3_ksl *ksl, nghttp3_ksl_it *it,
457-
const nghttp3_ksl_key *key) {
463+
int nghttp3_ksl_remove(nghttp3_ksl *ksl, nghttp3_ksl_it *it,
464+
const nghttp3_ksl_key *key) {
458465
nghttp3_ksl_blk *blk = ksl->head;
459466
nghttp3_ksl_node *node;
460467
size_t i;
@@ -468,10 +475,20 @@ void nghttp3_ksl_remove(nghttp3_ksl *ksl, nghttp3_ksl_it *it,
468475
for (;;) {
469476
i = ksl_bsearch(ksl, blk, key, ksl->compar);
470477

471-
assert(i < blk->n);
478+
if (i == blk->n) {
479+
if (it) {
480+
*it = nghttp3_ksl_end(ksl);
481+
}
482+
return NGHTTP3_ERR_INVALID_ARGUMENT;
483+
}
472484

473485
if (blk->leaf) {
474-
assert(i < blk->n);
486+
if (ksl->compar(key, nghttp3_ksl_nth_node(ksl, blk, i)->key)) {
487+
if (it) {
488+
*it = nghttp3_ksl_end(ksl);
489+
}
490+
return NGHTTP3_ERR_INVALID_ARGUMENT;
491+
}
475492
ksl_remove_node(ksl, blk, i);
476493
--ksl->n;
477494
if (it) {
@@ -481,7 +498,7 @@ void nghttp3_ksl_remove(nghttp3_ksl *ksl, nghttp3_ksl_it *it,
481498
nghttp3_ksl_it_init(it, ksl, blk, i);
482499
}
483500
}
484-
return;
501+
return 0;
485502
}
486503

487504
node = nghttp3_ksl_nth_node(ksl, blk, i);

deps/nghttp3/lib/nghttp3_ksl.h

+13-7
Original file line numberDiff line numberDiff line change
@@ -168,27 +168,33 @@ void nghttp3_ksl_free(nghttp3_ksl *ksl);
168168
* successful insertion, the iterator points to the inserted node is
169169
* stored in |*it|.
170170
*
171-
* This function assumes that |key| does not exist in |ksl|.
172-
*
173171
* This function returns 0 if it succeeds, or one of the following
174172
* negative error codes:
175173
*
176174
* NGHTTP3_ERR_NOMEM
177175
* Out of memory.
176+
* NGHTTP3_ERR_INVALID_ARGUMENT
177+
* |key| already exists.
178178
*/
179179
int nghttp3_ksl_insert(nghttp3_ksl *ksl, nghttp3_ksl_it *it,
180180
const nghttp3_ksl_key *key, void *data);
181181

182182
/*
183-
* nghttp3_ksl_remove removes the |key| from |ksl|. It assumes such
184-
* the key is included in |ksl|.
183+
* nghttp3_ksl_remove removes the |key| from |ksl|.
185184
*
186185
* This function assigns the iterator to |*it|, which points to the
187186
* node which is located at the right next of the removed node if |it|
188-
* is not NULL.
187+
* is not NULL. If |key| is not found, no deletion takes place and
188+
* the return value of nghttp3_ksl_end(ksl) is assigned to |*it|.
189+
*
190+
* This function returns 0 if it succeeds, or one of the following
191+
* negative error codes:
192+
*
193+
* NGHTTP3_ERR_INVALID_ARGUMENT
194+
* |key| does not exist.
189195
*/
190-
void nghttp3_ksl_remove(nghttp3_ksl *ksl, nghttp3_ksl_it *it,
191-
const nghttp3_ksl_key *key);
196+
int nghttp3_ksl_remove(nghttp3_ksl *ksl, nghttp3_ksl_it *it,
197+
const nghttp3_ksl_key *key);
192198

193199
/*
194200
* nghttp3_ksl_lower_bound returns the iterator which points to the

0 commit comments

Comments
 (0)