Add set_nghttp2_debug_callback to take advantage of DEBUGF statements in
when building DEBUGBUILD.
This commit is contained in:
parent
3c3267ea7d
commit
bc3dc6b765
|
@ -23,6 +23,7 @@ set(NGHTTP2_SOURCES
|
||||||
nghttp2_mem.c
|
nghttp2_mem.c
|
||||||
nghttp2_http.c
|
nghttp2_http.c
|
||||||
nghttp2_rcbuf.c
|
nghttp2_rcbuf.c
|
||||||
|
nghttp2_debug.c
|
||||||
)
|
)
|
||||||
|
|
||||||
# Public shared library
|
# Public shared library
|
||||||
|
|
|
@ -45,6 +45,7 @@ extern "C" {
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#endif /* !defined(_MSC_VER) || (_MSC_VER >= 1800) */
|
#endif /* !defined(_MSC_VER) || (_MSC_VER >= 1800) */
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include <nghttp2/nghttp2ver.h>
|
#include <nghttp2/nghttp2ver.h>
|
||||||
|
|
||||||
|
@ -5238,6 +5239,16 @@ NGHTTP2_EXTERN int32_t nghttp2_stream_get_weight(nghttp2_stream *stream);
|
||||||
NGHTTP2_EXTERN int32_t
|
NGHTTP2_EXTERN int32_t
|
||||||
nghttp2_stream_get_sum_dependency_weight(nghttp2_stream *stream);
|
nghttp2_stream_get_sum_dependency_weight(nghttp2_stream *stream);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
*
|
||||||
|
* Sets a debug callback called by nghttp2 when built when DEBUGBUILD is
|
||||||
|
* defined. The function is called with arguments suitable for vfprintf.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef void (*nghttp2_debug_cb)(const char *format, va_list args);
|
||||||
|
NGHTTP2_EXTERN void set_nghttp2_debug_callback(nghttp2_debug_cb cb);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -316,9 +316,8 @@ static int bufs_alloc_chain(nghttp2_bufs *bufs) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr,
|
DEBUGF("new buffer %zu bytes allocated for bufs %p, used %zu\n",
|
||||||
"new buffer %zu bytes allocated for bufs %p, used %zu\n",
|
bufs->chunk_length, bufs, bufs->chunk_used);
|
||||||
bufs->chunk_length, bufs, bufs->chunk_used));
|
|
||||||
|
|
||||||
++bufs->chunk_used;
|
++bufs->chunk_used;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
/*
|
||||||
|
* nghttp2 - HTTP/2 C Library
|
||||||
|
*
|
||||||
|
* Copyright (c) 2012 Tatsuhiro Tsujikawa
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
#include <time.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "config.h"
|
||||||
|
#include <nghttp2/nghttp2.h>
|
||||||
|
#include "nghttp2_int.h"
|
||||||
|
|
||||||
|
static void nghttp2_debug_cb_default(const char *fmt, va_list args)
|
||||||
|
{
|
||||||
|
vfprintf(stderr, fmt, args);
|
||||||
|
}
|
||||||
|
static nghttp2_debug_cb static_debug_callback = &nghttp2_debug_cb_default;
|
||||||
|
|
||||||
|
#ifdef DEBUGBUILD
|
||||||
|
void nghttp2_debug(const char *format, ...)
|
||||||
|
{
|
||||||
|
if (static_debug_callback) {
|
||||||
|
va_list args;
|
||||||
|
va_start(args, format);
|
||||||
|
static_debug_callback(format, args);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void set_nghttp2_debug_callback(nghttp2_debug_cb cb)
|
||||||
|
{
|
||||||
|
static_debug_callback = cb;
|
||||||
|
}
|
|
@ -252,8 +252,7 @@ static int frame_pack_headers_shared(nghttp2_bufs *bufs,
|
||||||
hd = *frame_hd;
|
hd = *frame_hd;
|
||||||
hd.length = nghttp2_buf_len(buf);
|
hd.length = nghttp2_buf_len(buf);
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "send: HEADERS/PUSH_PROMISE, payloadlen=%zu\n",
|
DEBUGF("send: HEADERS/PUSH_PROMISE, payloadlen=%zu\n", hd.length);
|
||||||
hd.length));
|
|
||||||
|
|
||||||
/* We have multiple frame buffers, which means one or more
|
/* We have multiple frame buffers, which means one or more
|
||||||
CONTINUATION frame is involved. Remove END_HEADERS flag from the
|
CONTINUATION frame is involved. Remove END_HEADERS flag from the
|
||||||
|
@ -278,8 +277,7 @@ static int frame_pack_headers_shared(nghttp2_bufs *bufs,
|
||||||
|
|
||||||
hd.length = nghttp2_buf_len(buf);
|
hd.length = nghttp2_buf_len(buf);
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "send: int CONTINUATION, payloadlen=%zu\n",
|
DEBUGF("send: int CONTINUATION, payloadlen=%zu\n", hd.length);
|
||||||
hd.length));
|
|
||||||
|
|
||||||
buf->pos -= NGHTTP2_FRAME_HDLEN;
|
buf->pos -= NGHTTP2_FRAME_HDLEN;
|
||||||
nghttp2_frame_pack_frame_hd(buf->pos, &hd);
|
nghttp2_frame_pack_frame_hd(buf->pos, &hd);
|
||||||
|
@ -290,8 +288,7 @@ static int frame_pack_headers_shared(nghttp2_bufs *bufs,
|
||||||
/* Set END_HEADERS flag for last CONTINUATION */
|
/* Set END_HEADERS flag for last CONTINUATION */
|
||||||
hd.flags = NGHTTP2_FLAG_END_HEADERS;
|
hd.flags = NGHTTP2_FLAG_END_HEADERS;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "send: last CONTINUATION, payloadlen=%zu\n",
|
DEBUGF("send: last CONTINUATION, payloadlen=%zu\n", hd.length);
|
||||||
hd.length));
|
|
||||||
|
|
||||||
buf->pos -= NGHTTP2_FRAME_HDLEN;
|
buf->pos -= NGHTTP2_FRAME_HDLEN;
|
||||||
nghttp2_frame_pack_frame_hd(buf->pos, &hd);
|
nghttp2_frame_pack_frame_hd(buf->pos, &hd);
|
||||||
|
@ -930,7 +927,7 @@ static void frame_set_pad(nghttp2_buf *buf, size_t padlen, int framehd_only) {
|
||||||
size_t trail_padlen;
|
size_t trail_padlen;
|
||||||
size_t newlen;
|
size_t newlen;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "send: padlen=%zu, shift left 1 bytes\n", padlen));
|
DEBUGF("send: padlen=%zu, shift left 1 bytes\n", padlen);
|
||||||
|
|
||||||
memmove(buf->pos - 1, buf->pos, NGHTTP2_FRAME_HDLEN);
|
memmove(buf->pos - 1, buf->pos, NGHTTP2_FRAME_HDLEN);
|
||||||
|
|
||||||
|
@ -960,7 +957,7 @@ int nghttp2_frame_add_pad(nghttp2_bufs *bufs, nghttp2_frame_hd *hd,
|
||||||
nghttp2_buf *buf;
|
nghttp2_buf *buf;
|
||||||
|
|
||||||
if (padlen == 0) {
|
if (padlen == 0) {
|
||||||
DEBUGF(fprintf(stderr, "send: padlen = 0, nothing to do\n"));
|
DEBUGF("send: padlen = 0, nothing to do\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -994,8 +991,7 @@ int nghttp2_frame_add_pad(nghttp2_bufs *bufs, nghttp2_frame_hd *hd,
|
||||||
hd->length += padlen;
|
hd->length += padlen;
|
||||||
hd->flags |= NGHTTP2_FLAG_PADDED;
|
hd->flags |= NGHTTP2_FLAG_PADDED;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "send: final payloadlen=%zu, padlen=%zu\n", hd->length,
|
DEBUGF("send: final payloadlen=%zu, padlen=%zu\n", hd->length, padlen);
|
||||||
padlen));
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
129
lib/nghttp2_hd.c
129
lib/nghttp2_hd.c
|
@ -769,8 +769,8 @@ static size_t entry_room(size_t namelen, size_t valuelen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void emit_header(nghttp2_hd_nv *nv_out, nghttp2_hd_nv *nv) {
|
static void emit_header(nghttp2_hd_nv *nv_out, nghttp2_hd_nv *nv) {
|
||||||
DEBUGF(fprintf(stderr, "inflatehd: header emission: %s: %s\n", nv->name->base,
|
DEBUGF("inflatehd: header emission: %s: %s\n", nv->name->base,
|
||||||
nv->value->base));
|
nv->value->base);
|
||||||
/* ent->ref may be 0. This happens if the encoder emits literal
|
/* ent->ref may be 0. This happens if the encoder emits literal
|
||||||
block larger than header table capacity with indexing. */
|
block larger than header table capacity with indexing. */
|
||||||
*nv_out = *nv;
|
*nv_out = *nv;
|
||||||
|
@ -864,14 +864,14 @@ static ssize_t decode_length(uint32_t *res, size_t *shift_ptr, int *final,
|
||||||
uint32_t add = *in & 0x7f;
|
uint32_t add = *in & 0x7f;
|
||||||
|
|
||||||
if ((UINT32_MAX >> shift) < add) {
|
if ((UINT32_MAX >> shift) < add) {
|
||||||
DEBUGF(fprintf(stderr, "inflate: integer overflow on shift\n"));
|
DEBUGF("inflate: integer overflow on shift\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
add <<= shift;
|
add <<= shift;
|
||||||
|
|
||||||
if (UINT32_MAX - add < n) {
|
if (UINT32_MAX - add < n) {
|
||||||
DEBUGF(fprintf(stderr, "inflate: integer overflow on addition\n"));
|
DEBUGF("inflate: integer overflow on addition\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -900,7 +900,7 @@ static int emit_table_size(nghttp2_bufs *bufs, size_t table_size) {
|
||||||
size_t blocklen;
|
size_t blocklen;
|
||||||
uint8_t sb[16];
|
uint8_t sb[16];
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "deflatehd: emit table_size=%zu\n", table_size));
|
DEBUGF("deflatehd: emit table_size=%zu\n", table_size);
|
||||||
|
|
||||||
blocklen = count_encoded_length(table_size, 5);
|
blocklen = count_encoded_length(table_size, 5);
|
||||||
|
|
||||||
|
@ -930,8 +930,7 @@ static int emit_indexed_block(nghttp2_bufs *bufs, size_t idx) {
|
||||||
|
|
||||||
blocklen = count_encoded_length(idx + 1, 7);
|
blocklen = count_encoded_length(idx + 1, 7);
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "deflatehd: emit indexed index=%zu, %zu bytes\n", idx,
|
DEBUGF("deflatehd: emit indexed index=%zu, %zu bytes\n", idx, blocklen);
|
||||||
blocklen));
|
|
||||||
|
|
||||||
if (sizeof(sb) < blocklen) {
|
if (sizeof(sb) < blocklen) {
|
||||||
return NGHTTP2_ERR_HEADER_COMP;
|
return NGHTTP2_ERR_HEADER_COMP;
|
||||||
|
@ -967,10 +966,8 @@ static int emit_string(nghttp2_bufs *bufs, const uint8_t *str, size_t len) {
|
||||||
|
|
||||||
blocklen = count_encoded_length(enclen, 7);
|
blocklen = count_encoded_length(enclen, 7);
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "deflatehd: emit string str="));
|
DEBUGF("deflatehd: emit string str=%.*s, length=%zu, huffman=%d, encoded_length=%zu\n",
|
||||||
DEBUGF(fwrite(str, 1, len, stderr));
|
(int)len, (const char*)str, len, huffman, enclen);
|
||||||
DEBUGF(fprintf(stderr, ", length=%zu, huffman=%d, encoded_length=%zu\n", len,
|
|
||||||
huffman, enclen));
|
|
||||||
|
|
||||||
if (sizeof(sb) < blocklen) {
|
if (sizeof(sb) < blocklen) {
|
||||||
return NGHTTP2_ERR_HEADER_COMP;
|
return NGHTTP2_ERR_HEADER_COMP;
|
||||||
|
@ -1025,9 +1022,9 @@ static int emit_indname_block(nghttp2_bufs *bufs, size_t idx,
|
||||||
prefixlen = 4;
|
prefixlen = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "deflatehd: emit indname index=%zu, valuelen=%zu, "
|
DEBUGF("deflatehd: emit indname index=%zu, valuelen=%zu, "
|
||||||
"indexing_mode=%d\n",
|
"indexing_mode=%d\n",
|
||||||
idx, nv->valuelen, indexing_mode));
|
idx, nv->valuelen, indexing_mode);
|
||||||
|
|
||||||
blocklen = count_encoded_length(idx + 1, prefixlen);
|
blocklen = count_encoded_length(idx + 1, prefixlen);
|
||||||
|
|
||||||
|
@ -1058,9 +1055,9 @@ static int emit_newname_block(nghttp2_bufs *bufs, const nghttp2_nv *nv,
|
||||||
int indexing_mode) {
|
int indexing_mode) {
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "deflatehd: emit newname namelen=%zu, valuelen=%zu, "
|
DEBUGF("deflatehd: emit newname namelen=%zu, valuelen=%zu, "
|
||||||
"indexing_mode=%d\n",
|
"indexing_mode=%d\n",
|
||||||
nv->namelen, nv->valuelen, indexing_mode));
|
nv->namelen, nv->valuelen, indexing_mode);
|
||||||
|
|
||||||
rv = nghttp2_bufs_addb(bufs, pack_first_byte(indexing_mode));
|
rv = nghttp2_bufs_addb(bufs, pack_first_byte(indexing_mode));
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
|
@ -1100,8 +1097,8 @@ static int add_hd_table_incremental(nghttp2_hd_context *context,
|
||||||
context->hd_table_bufsize -=
|
context->hd_table_bufsize -=
|
||||||
entry_room(ent->nv.name->len, ent->nv.value->len);
|
entry_room(ent->nv.name->len, ent->nv.value->len);
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "hpack: remove item from header table: %s: %s\n",
|
DEBUGF("hpack: remove item from header table: %s: %s\n",
|
||||||
(char *)ent->nv.name->base, (char *)ent->nv.value->base));
|
(char *)ent->nv.name->base, (char *)ent->nv.value->base);
|
||||||
|
|
||||||
hd_ringbuf_pop_back(&context->hd_table);
|
hd_ringbuf_pop_back(&context->hd_table);
|
||||||
if (map) {
|
if (map) {
|
||||||
|
@ -1329,8 +1326,8 @@ static int deflate_nv(nghttp2_hd_deflater *deflater, nghttp2_bufs *bufs,
|
||||||
nghttp2_mem *mem;
|
nghttp2_mem *mem;
|
||||||
uint32_t hash = 0;
|
uint32_t hash = 0;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "deflatehd: deflating %.*s: %.*s\n", (int)nv->namelen,
|
DEBUGF("deflatehd: deflating %.*s: %.*s\n", (int)nv->namelen,
|
||||||
nv->name, (int)nv->valuelen, nv->value));
|
nv->name, (int)nv->valuelen, nv->value);
|
||||||
|
|
||||||
mem = deflater->ctx.mem;
|
mem = deflater->ctx.mem;
|
||||||
|
|
||||||
|
@ -1359,7 +1356,7 @@ static int deflate_nv(nghttp2_hd_deflater *deflater, nghttp2_bufs *bufs,
|
||||||
|
|
||||||
if (res.name_value_match) {
|
if (res.name_value_match) {
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "deflatehd: name/value match index=%zd\n", idx));
|
DEBUGF("deflatehd: name/value match index=%zd\n", idx);
|
||||||
|
|
||||||
rv = emit_indexed_block(bufs, (size_t)idx);
|
rv = emit_indexed_block(bufs, (size_t)idx);
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
|
@ -1370,7 +1367,7 @@ static int deflate_nv(nghttp2_hd_deflater *deflater, nghttp2_bufs *bufs,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res.index != -1) {
|
if (res.index != -1) {
|
||||||
DEBUGF(fprintf(stderr, "deflatehd: name match index=%zd\n", res.index));
|
DEBUGF("deflatehd: name match index=%zd\n", res.index);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (indexing_mode == NGHTTP2_HD_WITH_INDEXING) {
|
if (indexing_mode == NGHTTP2_HD_WITH_INDEXING) {
|
||||||
|
@ -1458,12 +1455,11 @@ int nghttp2_hd_deflate_hd_bufs(nghttp2_hd_deflater *deflater,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUGF(
|
DEBUGF("deflatehd: all input name/value pairs were deflated\n");
|
||||||
fprintf(stderr, "deflatehd: all input name/value pairs were deflated\n"));
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
fail:
|
fail:
|
||||||
DEBUGF(fprintf(stderr, "deflatehd: error return %d\n", rv));
|
DEBUGF("deflatehd: error return %d\n", rv);
|
||||||
|
|
||||||
deflater->ctx.bad = 1;
|
deflater->ctx.bad = 1;
|
||||||
return rv;
|
return rv;
|
||||||
|
@ -1635,19 +1631,18 @@ static ssize_t hd_inflate_read_len(nghttp2_hd_inflater *inflater, int *rfin,
|
||||||
inflater->shift, in, last, prefix);
|
inflater->shift, in, last, prefix);
|
||||||
|
|
||||||
if (rv == -1) {
|
if (rv == -1) {
|
||||||
DEBUGF(fprintf(stderr, "inflatehd: integer decoding failed\n"));
|
DEBUGF("inflatehd: integer decoding failed\n");
|
||||||
return NGHTTP2_ERR_HEADER_COMP;
|
return NGHTTP2_ERR_HEADER_COMP;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (out > maxlen) {
|
if (out > maxlen) {
|
||||||
DEBUGF(fprintf(
|
DEBUGF("inflatehd: integer exceeded the maximum value %zu\n", maxlen);
|
||||||
stderr, "inflatehd: integer exceeded the maximum value %zu\n", maxlen));
|
|
||||||
return NGHTTP2_ERR_HEADER_COMP;
|
return NGHTTP2_ERR_HEADER_COMP;
|
||||||
}
|
}
|
||||||
|
|
||||||
inflater->left = out;
|
inflater->left = out;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "inflatehd: decoded integer is %u\n", out));
|
DEBUGF("inflatehd: decoded integer is %u\n", out);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -1678,7 +1673,7 @@ static ssize_t hd_inflate_read_huff(nghttp2_hd_inflater *inflater,
|
||||||
(size_t)(last - in), final);
|
(size_t)(last - in), final);
|
||||||
|
|
||||||
if (readlen < 0) {
|
if (readlen < 0) {
|
||||||
DEBUGF(fprintf(stderr, "inflatehd: huffman decoding failed\n"));
|
DEBUGF("inflatehd: huffman decoding failed\n");
|
||||||
return readlen;
|
return readlen;
|
||||||
}
|
}
|
||||||
inflater->left -= (size_t)readlen;
|
inflater->left -= (size_t)readlen;
|
||||||
|
@ -1859,7 +1854,7 @@ ssize_t nghttp2_hd_inflate_hd_nv(nghttp2_hd_inflater *inflater,
|
||||||
return NGHTTP2_ERR_HEADER_COMP;
|
return NGHTTP2_ERR_HEADER_COMP;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "inflatehd: start state=%d\n", inflater->state));
|
DEBUGF("inflatehd: start state=%d\n", inflater->state);
|
||||||
hd_inflate_keep_free(inflater);
|
hd_inflate_keep_free(inflater);
|
||||||
*inflate_flags = NGHTTP2_HD_INFLATE_NONE;
|
*inflate_flags = NGHTTP2_HD_INFLATE_NONE;
|
||||||
for (; in != last || busy;) {
|
for (; in != last || busy;) {
|
||||||
|
@ -1867,9 +1862,8 @@ ssize_t nghttp2_hd_inflate_hd_nv(nghttp2_hd_inflater *inflater,
|
||||||
switch (inflater->state) {
|
switch (inflater->state) {
|
||||||
case NGHTTP2_HD_STATE_EXPECT_TABLE_SIZE:
|
case NGHTTP2_HD_STATE_EXPECT_TABLE_SIZE:
|
||||||
if ((*in & 0xe0u) != 0x20u) {
|
if ((*in & 0xe0u) != 0x20u) {
|
||||||
DEBUGF(fprintf(stderr, "inflatehd: header table size change was "
|
DEBUGF("inflatehd: header table size change was "
|
||||||
"expected, but saw 0x%02x as first byte",
|
"expected, but saw 0x%02x as first byte", *in);
|
||||||
*in));
|
|
||||||
rv = NGHTTP2_ERR_HEADER_COMP;
|
rv = NGHTTP2_ERR_HEADER_COMP;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
@ -1877,35 +1871,33 @@ ssize_t nghttp2_hd_inflate_hd_nv(nghttp2_hd_inflater *inflater,
|
||||||
case NGHTTP2_HD_STATE_INFLATE_START:
|
case NGHTTP2_HD_STATE_INFLATE_START:
|
||||||
case NGHTTP2_HD_STATE_OPCODE:
|
case NGHTTP2_HD_STATE_OPCODE:
|
||||||
if ((*in & 0xe0u) == 0x20u) {
|
if ((*in & 0xe0u) == 0x20u) {
|
||||||
DEBUGF(fprintf(stderr, "inflatehd: header table size change\n"));
|
DEBUGF("inflatehd: header table size change\n");
|
||||||
if (inflater->state == NGHTTP2_HD_STATE_OPCODE) {
|
if (inflater->state == NGHTTP2_HD_STATE_OPCODE) {
|
||||||
DEBUGF(fprintf(stderr, "inflatehd: header table size change must "
|
DEBUGF("inflatehd: header table size change must "
|
||||||
"appear at the head of header block\n"));
|
"appear at the head of header block\n");
|
||||||
rv = NGHTTP2_ERR_HEADER_COMP;
|
rv = NGHTTP2_ERR_HEADER_COMP;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
inflater->opcode = NGHTTP2_HD_OPCODE_INDEXED;
|
inflater->opcode = NGHTTP2_HD_OPCODE_INDEXED;
|
||||||
inflater->state = NGHTTP2_HD_STATE_READ_TABLE_SIZE;
|
inflater->state = NGHTTP2_HD_STATE_READ_TABLE_SIZE;
|
||||||
} else if (*in & 0x80u) {
|
} else if (*in & 0x80u) {
|
||||||
DEBUGF(fprintf(stderr, "inflatehd: indexed repr\n"));
|
DEBUGF("inflatehd: indexed repr\n");
|
||||||
inflater->opcode = NGHTTP2_HD_OPCODE_INDEXED;
|
inflater->opcode = NGHTTP2_HD_OPCODE_INDEXED;
|
||||||
inflater->state = NGHTTP2_HD_STATE_READ_INDEX;
|
inflater->state = NGHTTP2_HD_STATE_READ_INDEX;
|
||||||
} else {
|
} else {
|
||||||
if (*in == 0x40u || *in == 0 || *in == 0x10u) {
|
if (*in == 0x40u || *in == 0 || *in == 0x10u) {
|
||||||
DEBUGF(
|
DEBUGF("inflatehd: literal header repr - new name\n");
|
||||||
fprintf(stderr, "inflatehd: literal header repr - new name\n"));
|
|
||||||
inflater->opcode = NGHTTP2_HD_OPCODE_NEWNAME;
|
inflater->opcode = NGHTTP2_HD_OPCODE_NEWNAME;
|
||||||
inflater->state = NGHTTP2_HD_STATE_NEWNAME_CHECK_NAMELEN;
|
inflater->state = NGHTTP2_HD_STATE_NEWNAME_CHECK_NAMELEN;
|
||||||
} else {
|
} else {
|
||||||
DEBUGF(fprintf(stderr,
|
DEBUGF("inflatehd: literal header repr - indexed name\n");
|
||||||
"inflatehd: literal header repr - indexed name\n"));
|
|
||||||
inflater->opcode = NGHTTP2_HD_OPCODE_INDNAME;
|
inflater->opcode = NGHTTP2_HD_OPCODE_INDNAME;
|
||||||
inflater->state = NGHTTP2_HD_STATE_READ_INDEX;
|
inflater->state = NGHTTP2_HD_STATE_READ_INDEX;
|
||||||
}
|
}
|
||||||
inflater->index_required = (*in & 0x40) != 0;
|
inflater->index_required = (*in & 0x40) != 0;
|
||||||
inflater->no_index = (*in & 0xf0u) == 0x10u;
|
inflater->no_index = (*in & 0xf0u) == 0x10u;
|
||||||
DEBUGF(fprintf(stderr, "inflatehd: indexing required=%d, no_index=%d\n",
|
DEBUGF("inflatehd: indexing required=%d, no_index=%d\n",
|
||||||
inflater->index_required, inflater->no_index));
|
inflater->index_required, inflater->no_index);
|
||||||
if (inflater->opcode == NGHTTP2_HD_OPCODE_NEWNAME) {
|
if (inflater->opcode == NGHTTP2_HD_OPCODE_NEWNAME) {
|
||||||
++in;
|
++in;
|
||||||
}
|
}
|
||||||
|
@ -1926,7 +1918,7 @@ ssize_t nghttp2_hd_inflate_hd_nv(nghttp2_hd_inflater *inflater,
|
||||||
if (!rfin) {
|
if (!rfin) {
|
||||||
goto almost_ok;
|
goto almost_ok;
|
||||||
}
|
}
|
||||||
DEBUGF(fprintf(stderr, "inflatehd: table_size=%zu\n", inflater->left));
|
DEBUGF("inflatehd: table_size=%zu\n", inflater->left);
|
||||||
inflater->min_hd_table_bufsize_max = UINT32_MAX;
|
inflater->min_hd_table_bufsize_max = UINT32_MAX;
|
||||||
inflater->ctx.hd_table_bufsize_max = inflater->left;
|
inflater->ctx.hd_table_bufsize_max = inflater->left;
|
||||||
hd_context_shrink_table_size(&inflater->ctx, NULL);
|
hd_context_shrink_table_size(&inflater->ctx, NULL);
|
||||||
|
@ -1961,7 +1953,7 @@ ssize_t nghttp2_hd_inflate_hd_nv(nghttp2_hd_inflater *inflater,
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "inflatehd: index=%zu\n", inflater->left));
|
DEBUGF("inflatehd: index=%zu\n", inflater->left);
|
||||||
if (inflater->opcode == NGHTTP2_HD_OPCODE_INDEXED) {
|
if (inflater->opcode == NGHTTP2_HD_OPCODE_INDEXED) {
|
||||||
inflater->index = inflater->left;
|
inflater->index = inflater->left;
|
||||||
--inflater->index;
|
--inflater->index;
|
||||||
|
@ -1984,8 +1976,8 @@ ssize_t nghttp2_hd_inflate_hd_nv(nghttp2_hd_inflater *inflater,
|
||||||
inflater->state = NGHTTP2_HD_STATE_NEWNAME_READ_NAMELEN;
|
inflater->state = NGHTTP2_HD_STATE_NEWNAME_READ_NAMELEN;
|
||||||
inflater->left = 0;
|
inflater->left = 0;
|
||||||
inflater->shift = 0;
|
inflater->shift = 0;
|
||||||
DEBUGF(fprintf(stderr, "inflatehd: huffman encoded=%d\n",
|
DEBUGF("inflatehd: huffman encoded=%d\n",
|
||||||
inflater->huffman_encoded != 0));
|
inflater->huffman_encoded != 0);
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
case NGHTTP2_HD_STATE_NEWNAME_READ_NAMELEN:
|
case NGHTTP2_HD_STATE_NEWNAME_READ_NAMELEN:
|
||||||
rfin = 0;
|
rfin = 0;
|
||||||
|
@ -1995,9 +1987,7 @@ ssize_t nghttp2_hd_inflate_hd_nv(nghttp2_hd_inflater *inflater,
|
||||||
}
|
}
|
||||||
in += rv;
|
in += rv;
|
||||||
if (!rfin) {
|
if (!rfin) {
|
||||||
DEBUGF(fprintf(stderr,
|
DEBUGF("inflatehd: integer not fully decoded. current=%zu\n", inflater->left);
|
||||||
"inflatehd: integer not fully decoded. current=%zu\n",
|
|
||||||
inflater->left));
|
|
||||||
|
|
||||||
goto almost_ok;
|
goto almost_ok;
|
||||||
}
|
}
|
||||||
|
@ -2030,11 +2020,10 @@ ssize_t nghttp2_hd_inflate_hd_nv(nghttp2_hd_inflater *inflater,
|
||||||
|
|
||||||
in += rv;
|
in += rv;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "inflatehd: %zd bytes read\n", rv));
|
DEBUGF("inflatehd: %zd bytes read\n", rv);
|
||||||
|
|
||||||
if (inflater->left) {
|
if (inflater->left) {
|
||||||
DEBUGF(fprintf(stderr, "inflatehd: still %zu bytes to go\n",
|
DEBUGF("inflatehd: still %zu bytes to go\n", inflater->left);
|
||||||
inflater->left));
|
|
||||||
|
|
||||||
goto almost_ok;
|
goto almost_ok;
|
||||||
}
|
}
|
||||||
|
@ -2053,10 +2042,9 @@ ssize_t nghttp2_hd_inflate_hd_nv(nghttp2_hd_inflater *inflater,
|
||||||
|
|
||||||
in += rv;
|
in += rv;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "inflatehd: %zd bytes read\n", rv));
|
DEBUGF("inflatehd: %zd bytes read\n", rv);
|
||||||
if (inflater->left) {
|
if (inflater->left) {
|
||||||
DEBUGF(fprintf(stderr, "inflatehd: still %zu bytes to go\n",
|
DEBUGF("inflatehd: still %zu bytes to go\n", inflater->left);
|
||||||
inflater->left));
|
|
||||||
|
|
||||||
goto almost_ok;
|
goto almost_ok;
|
||||||
}
|
}
|
||||||
|
@ -2072,8 +2060,7 @@ ssize_t nghttp2_hd_inflate_hd_nv(nghttp2_hd_inflater *inflater,
|
||||||
inflater->state = NGHTTP2_HD_STATE_READ_VALUELEN;
|
inflater->state = NGHTTP2_HD_STATE_READ_VALUELEN;
|
||||||
inflater->left = 0;
|
inflater->left = 0;
|
||||||
inflater->shift = 0;
|
inflater->shift = 0;
|
||||||
DEBUGF(fprintf(stderr, "inflatehd: huffman encoded=%d\n",
|
DEBUGF("inflatehd: huffman encoded=%d\n", inflater->huffman_encoded != 0);
|
||||||
inflater->huffman_encoded != 0));
|
|
||||||
/* Fall through */
|
/* Fall through */
|
||||||
case NGHTTP2_HD_STATE_READ_VALUELEN:
|
case NGHTTP2_HD_STATE_READ_VALUELEN:
|
||||||
rfin = 0;
|
rfin = 0;
|
||||||
|
@ -2088,7 +2075,7 @@ ssize_t nghttp2_hd_inflate_hd_nv(nghttp2_hd_inflater *inflater,
|
||||||
goto almost_ok;
|
goto almost_ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "inflatehd: valuelen=%zu\n", inflater->left));
|
DEBUGF("inflatehd: valuelen=%zu\n", inflater->left);
|
||||||
|
|
||||||
if (inflater->huffman_encoded) {
|
if (inflater->huffman_encoded) {
|
||||||
nghttp2_hd_huff_decode_context_init(&inflater->huff_decode_ctx);
|
nghttp2_hd_huff_decode_context_init(&inflater->huff_decode_ctx);
|
||||||
|
@ -2121,11 +2108,10 @@ ssize_t nghttp2_hd_inflate_hd_nv(nghttp2_hd_inflater *inflater,
|
||||||
|
|
||||||
in += rv;
|
in += rv;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "inflatehd: %zd bytes read\n", rv));
|
DEBUGF("inflatehd: %zd bytes read\n", rv);
|
||||||
|
|
||||||
if (inflater->left) {
|
if (inflater->left) {
|
||||||
DEBUGF(fprintf(stderr, "inflatehd: still %zu bytes to go\n",
|
DEBUGF("inflatehd: still %zu bytes to go\n", inflater->left);
|
||||||
inflater->left));
|
|
||||||
|
|
||||||
goto almost_ok;
|
goto almost_ok;
|
||||||
}
|
}
|
||||||
|
@ -2150,18 +2136,16 @@ ssize_t nghttp2_hd_inflate_hd_nv(nghttp2_hd_inflater *inflater,
|
||||||
case NGHTTP2_HD_STATE_READ_VALUE:
|
case NGHTTP2_HD_STATE_READ_VALUE:
|
||||||
rv = hd_inflate_read(inflater, &inflater->valuebuf, in, last);
|
rv = hd_inflate_read(inflater, &inflater->valuebuf, in, last);
|
||||||
if (rv < 0) {
|
if (rv < 0) {
|
||||||
DEBUGF(fprintf(stderr, "inflatehd: value read failure %zd: %s\n", rv,
|
DEBUGF("inflatehd: value read failure %zd: %s\n", rv, nghttp2_strerror((int)rv));
|
||||||
nghttp2_strerror((int)rv)));
|
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
in += rv;
|
in += rv;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "inflatehd: %zd bytes read\n", rv));
|
DEBUGF("inflatehd: %zd bytes read\n", rv);
|
||||||
|
|
||||||
if (inflater->left) {
|
if (inflater->left) {
|
||||||
DEBUGF(fprintf(stderr, "inflatehd: still %zu bytes to go\n",
|
DEBUGF("inflatehd: still %zu bytes to go\n", inflater->left);
|
||||||
inflater->left));
|
|
||||||
goto almost_ok;
|
goto almost_ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2187,15 +2171,14 @@ ssize_t nghttp2_hd_inflate_hd_nv(nghttp2_hd_inflater *inflater,
|
||||||
|
|
||||||
assert(in == last);
|
assert(in == last);
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "inflatehd: all input bytes were processed\n"));
|
DEBUGF("inflatehd: all input bytes were processed\n");
|
||||||
|
|
||||||
if (in_final) {
|
if (in_final) {
|
||||||
DEBUGF(fprintf(stderr, "inflatehd: in_final set\n"));
|
DEBUGF("inflatehd: in_final set\n");
|
||||||
|
|
||||||
if (inflater->state != NGHTTP2_HD_STATE_OPCODE &&
|
if (inflater->state != NGHTTP2_HD_STATE_OPCODE &&
|
||||||
inflater->state != NGHTTP2_HD_STATE_INFLATE_START) {
|
inflater->state != NGHTTP2_HD_STATE_INFLATE_START) {
|
||||||
DEBUGF(fprintf(stderr, "inflatehd: unacceptable state=%d\n",
|
DEBUGF("inflatehd: unacceptable state=%d\n", inflater->state);
|
||||||
inflater->state));
|
|
||||||
rv = NGHTTP2_ERR_HEADER_COMP;
|
rv = NGHTTP2_ERR_HEADER_COMP;
|
||||||
|
|
||||||
goto fail;
|
goto fail;
|
||||||
|
@ -2206,7 +2189,7 @@ ssize_t nghttp2_hd_inflate_hd_nv(nghttp2_hd_inflater *inflater,
|
||||||
|
|
||||||
almost_ok:
|
almost_ok:
|
||||||
if (in_final) {
|
if (in_final) {
|
||||||
DEBUGF(fprintf(stderr, "inflatehd: input ended prematurely\n"));
|
DEBUGF("inflatehd: input ended prematurely\n");
|
||||||
|
|
||||||
rv = NGHTTP2_ERR_HEADER_COMP;
|
rv = NGHTTP2_ERR_HEADER_COMP;
|
||||||
|
|
||||||
|
@ -2215,7 +2198,7 @@ almost_ok:
|
||||||
return (ssize_t)(in - first);
|
return (ssize_t)(in - first);
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
DEBUGF(fprintf(stderr, "inflatehd: error return %zd\n", rv));
|
DEBUGF("inflatehd: error return %zd\n", rv);
|
||||||
|
|
||||||
inflater->ctx.bad = 1;
|
inflater->ctx.bad = 1;
|
||||||
return rv;
|
return rv;
|
||||||
|
|
|
@ -32,9 +32,10 @@
|
||||||
/* Macros, types and constants for internal use */
|
/* Macros, types and constants for internal use */
|
||||||
|
|
||||||
#ifdef DEBUGBUILD
|
#ifdef DEBUGBUILD
|
||||||
#define DEBUGF(x) x
|
void nghttp2_debug(const char *format, ...);
|
||||||
|
#define DEBUGF(...) nghttp2_debug(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define DEBUGF(x) \
|
#define DEBUGF(...) \
|
||||||
do { \
|
do { \
|
||||||
} while (0)
|
} while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -184,9 +184,7 @@ static int session_call_error_callback(nghttp2_session *session,
|
||||||
/* vsnprintf may return error because of various things we can
|
/* vsnprintf may return error because of various things we can
|
||||||
imagine, but typically we don't want to drop session just for
|
imagine, but typically we don't want to drop session just for
|
||||||
debug callback. */
|
debug callback. */
|
||||||
DEBUGF(fprintf(stderr,
|
DEBUGF("error_callback: vsnprintf failed. The template was %s\n", fmt);
|
||||||
"error_callback: vsnprintf failed. The template was %s\n",
|
|
||||||
fmt));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,8 +371,8 @@ static void init_settings(nghttp2_settings_storage *settings) {
|
||||||
|
|
||||||
static void active_outbound_item_reset(nghttp2_active_outbound_item *aob,
|
static void active_outbound_item_reset(nghttp2_active_outbound_item *aob,
|
||||||
nghttp2_mem *mem) {
|
nghttp2_mem *mem) {
|
||||||
DEBUGF(fprintf(stderr, "send: reset nghttp2_active_outbound_item\n"));
|
DEBUGF("send: reset nghttp2_active_outbound_item\n");
|
||||||
DEBUGF(fprintf(stderr, "send: aob->item = %p\n", aob->item));
|
DEBUGF("send: aob->item = %p\n", aob->item);
|
||||||
nghttp2_outbound_item_free(aob->item, mem);
|
nghttp2_outbound_item_free(aob->item, mem);
|
||||||
nghttp2_mem_free(mem, aob->item);
|
nghttp2_mem_free(mem, aob->item);
|
||||||
aob->item = NULL;
|
aob->item = NULL;
|
||||||
|
@ -773,10 +771,10 @@ int nghttp2_session_reprioritize_stream(
|
||||||
if (pri_spec->stream_id == 0) {
|
if (pri_spec->stream_id == 0) {
|
||||||
dep_stream = &session->root;
|
dep_stream = &session->root;
|
||||||
} else if (nghttp2_stream_dep_find_ancestor(dep_stream, stream)) {
|
} else if (nghttp2_stream_dep_find_ancestor(dep_stream, stream)) {
|
||||||
DEBUGF(fprintf(stderr, "stream: cycle detected, dep_stream(%p)=%d "
|
DEBUGF("stream: cycle detected, dep_stream(%p)=%d "
|
||||||
"stream(%p)=%d\n",
|
"stream(%p)=%d\n",
|
||||||
dep_stream, dep_stream->stream_id, stream,
|
dep_stream, dep_stream->stream_id, stream,
|
||||||
stream->stream_id));
|
stream->stream_id);
|
||||||
|
|
||||||
nghttp2_stream_dep_remove_subtree(dep_stream);
|
nghttp2_stream_dep_remove_subtree(dep_stream);
|
||||||
rv = nghttp2_stream_dep_add_subtree(stream->dep_prev, dep_stream);
|
rv = nghttp2_stream_dep_add_subtree(stream->dep_prev, dep_stream);
|
||||||
|
@ -1125,8 +1123,8 @@ int nghttp2_session_close_stream(nghttp2_session *session, int32_t stream_id,
|
||||||
return NGHTTP2_ERR_INVALID_ARGUMENT;
|
return NGHTTP2_ERR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "stream: stream(%p)=%d close\n", stream,
|
DEBUGF("stream: stream(%p)=%d close\n", stream,
|
||||||
stream->stream_id));
|
stream->stream_id);
|
||||||
|
|
||||||
if (stream->item) {
|
if (stream->item) {
|
||||||
nghttp2_outbound_item *item;
|
nghttp2_outbound_item *item;
|
||||||
|
@ -1204,8 +1202,8 @@ int nghttp2_session_destroy_stream(nghttp2_session *session,
|
||||||
nghttp2_mem *mem;
|
nghttp2_mem *mem;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "stream: destroy closed stream(%p)=%d\n", stream,
|
DEBUGF("stream: destroy closed stream(%p)=%d\n", stream,
|
||||||
stream->stream_id));
|
stream->stream_id);
|
||||||
|
|
||||||
mem = &session->mem;
|
mem = &session->mem;
|
||||||
|
|
||||||
|
@ -1225,8 +1223,8 @@ int nghttp2_session_destroy_stream(nghttp2_session *session,
|
||||||
|
|
||||||
void nghttp2_session_keep_closed_stream(nghttp2_session *session,
|
void nghttp2_session_keep_closed_stream(nghttp2_session *session,
|
||||||
nghttp2_stream *stream) {
|
nghttp2_stream *stream) {
|
||||||
DEBUGF(fprintf(stderr, "stream: keep closed stream(%p)=%d, state=%d\n",
|
DEBUGF("stream: keep closed stream(%p)=%d, state=%d\n",
|
||||||
stream, stream->stream_id, stream->state));
|
stream, stream->stream_id, stream->state);
|
||||||
|
|
||||||
if (session->closed_stream_tail) {
|
if (session->closed_stream_tail) {
|
||||||
session->closed_stream_tail->closed_next = stream;
|
session->closed_stream_tail->closed_next = stream;
|
||||||
|
@ -1241,8 +1239,8 @@ void nghttp2_session_keep_closed_stream(nghttp2_session *session,
|
||||||
|
|
||||||
void nghttp2_session_keep_idle_stream(nghttp2_session *session,
|
void nghttp2_session_keep_idle_stream(nghttp2_session *session,
|
||||||
nghttp2_stream *stream) {
|
nghttp2_stream *stream) {
|
||||||
DEBUGF(fprintf(stderr, "stream: keep idle stream(%p)=%d, state=%d\n", stream,
|
DEBUGF("stream: keep idle stream(%p)=%d, state=%d\n", stream,
|
||||||
stream->stream_id, stream->state));
|
stream->stream_id, stream->state);
|
||||||
|
|
||||||
if (session->idle_stream_tail) {
|
if (session->idle_stream_tail) {
|
||||||
session->idle_stream_tail->closed_next = stream;
|
session->idle_stream_tail->closed_next = stream;
|
||||||
|
@ -1259,8 +1257,8 @@ void nghttp2_session_detach_idle_stream(nghttp2_session *session,
|
||||||
nghttp2_stream *stream) {
|
nghttp2_stream *stream) {
|
||||||
nghttp2_stream *prev_stream, *next_stream;
|
nghttp2_stream *prev_stream, *next_stream;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "stream: detach idle stream(%p)=%d, state=%d\n",
|
DEBUGF("stream: detach idle stream(%p)=%d, state=%d\n",
|
||||||
stream, stream->stream_id, stream->state));
|
stream, stream->stream_id, stream->state);
|
||||||
|
|
||||||
prev_stream = stream->closed_prev;
|
prev_stream = stream->closed_prev;
|
||||||
next_stream = stream->closed_next;
|
next_stream = stream->closed_next;
|
||||||
|
@ -1294,11 +1292,11 @@ int nghttp2_session_adjust_closed_stream(nghttp2_session *session) {
|
||||||
num_stream_max = session->local_settings.max_concurrent_streams;
|
num_stream_max = session->local_settings.max_concurrent_streams;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "stream: adjusting kept closed streams "
|
DEBUGF("stream: adjusting kept closed streams "
|
||||||
"num_closed_streams=%zu, num_incoming_streams=%zu, "
|
"num_closed_streams=%zu, num_incoming_streams=%zu, "
|
||||||
"max_concurrent_streams=%zu\n",
|
"max_concurrent_streams=%zu\n",
|
||||||
session->num_closed_streams, session->num_incoming_streams,
|
session->num_closed_streams, session->num_incoming_streams,
|
||||||
num_stream_max));
|
num_stream_max);
|
||||||
|
|
||||||
while (session->num_closed_streams > 0 &&
|
while (session->num_closed_streams > 0 &&
|
||||||
session->num_closed_streams + session->num_incoming_streams >
|
session->num_closed_streams + session->num_incoming_streams >
|
||||||
|
@ -1344,9 +1342,9 @@ int nghttp2_session_adjust_idle_stream(nghttp2_session *session) {
|
||||||
16, nghttp2_min(session->local_settings.max_concurrent_streams,
|
16, nghttp2_min(session->local_settings.max_concurrent_streams,
|
||||||
session->pending_local_max_concurrent_stream)));
|
session->pending_local_max_concurrent_stream)));
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "stream: adjusting kept idle streams "
|
DEBUGF("stream: adjusting kept idle streams "
|
||||||
"num_idle_streams=%zu, max=%zu\n",
|
"num_idle_streams=%zu, max=%zu\n",
|
||||||
session->num_idle_streams, max));
|
session->num_idle_streams, max);
|
||||||
|
|
||||||
while (session->num_idle_streams > max) {
|
while (session->num_idle_streams > max) {
|
||||||
nghttp2_stream *head;
|
nghttp2_stream *head;
|
||||||
|
@ -1741,11 +1739,11 @@ static ssize_t
|
||||||
nghttp2_session_enforce_flow_control_limits(nghttp2_session *session,
|
nghttp2_session_enforce_flow_control_limits(nghttp2_session *session,
|
||||||
nghttp2_stream *stream,
|
nghttp2_stream *stream,
|
||||||
ssize_t requested_window_size) {
|
ssize_t requested_window_size) {
|
||||||
DEBUGF(fprintf(stderr, "send: remote windowsize connection=%d, "
|
DEBUGF("send: remote windowsize connection=%d, "
|
||||||
"remote maxframsize=%u, stream(id %d)=%d\n",
|
"remote maxframsize=%u, stream(id %d)=%d\n",
|
||||||
session->remote_window_size,
|
session->remote_window_size,
|
||||||
session->remote_settings.max_frame_size, stream->stream_id,
|
session->remote_settings.max_frame_size, stream->stream_id,
|
||||||
stream->remote_window_size));
|
stream->remote_window_size);
|
||||||
|
|
||||||
return nghttp2_min(nghttp2_min(nghttp2_min(requested_window_size,
|
return nghttp2_min(nghttp2_min(nghttp2_min(requested_window_size,
|
||||||
stream->remote_window_size),
|
stream->remote_window_size),
|
||||||
|
@ -1766,7 +1764,7 @@ static size_t nghttp2_session_next_data_read(nghttp2_session *session,
|
||||||
window_size = nghttp2_session_enforce_flow_control_limits(
|
window_size = nghttp2_session_enforce_flow_control_limits(
|
||||||
session, stream, NGHTTP2_DATA_PAYLOADLEN);
|
session, stream, NGHTTP2_DATA_PAYLOADLEN);
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "send: available window=%zd\n", window_size));
|
DEBUGF("send: available window=%zd\n", window_size);
|
||||||
|
|
||||||
return window_size > 0 ? (size_t)window_size : 0;
|
return window_size > 0 ? (size_t)window_size : 0;
|
||||||
}
|
}
|
||||||
|
@ -1873,8 +1871,8 @@ static int session_headers_add_pad(nghttp2_session *session,
|
||||||
|
|
||||||
padlen = (size_t)padded_payloadlen - frame->hd.length;
|
padlen = (size_t)padded_payloadlen - frame->hd.length;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "send: padding selected: payloadlen=%zd, padlen=%zu\n",
|
DEBUGF("send: padding selected: payloadlen=%zd, padlen=%zu\n",
|
||||||
padded_payloadlen, padlen));
|
padded_payloadlen, padlen);
|
||||||
|
|
||||||
rv = nghttp2_frame_add_pad(framebufs, &frame->hd, padlen, 0);
|
rv = nghttp2_frame_add_pad(framebufs, &frame->hd, padlen, 0);
|
||||||
|
|
||||||
|
@ -2122,9 +2120,8 @@ static int session_prep_frame(nghttp2_session *session,
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr,
|
DEBUGF("send: before padding, HEADERS serialized in %zd bytes\n",
|
||||||
"send: before padding, HEADERS serialized in %zd bytes\n",
|
nghttp2_bufs_len(&session->aob.framebufs));
|
||||||
nghttp2_bufs_len(&session->aob.framebufs)));
|
|
||||||
|
|
||||||
rv = session_headers_add_pad(session, frame);
|
rv = session_headers_add_pad(session, frame);
|
||||||
|
|
||||||
|
@ -2132,8 +2129,8 @@ static int session_prep_frame(nghttp2_session *session,
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "send: HEADERS finally serialized in %zd bytes\n",
|
DEBUGF("send: HEADERS finally serialized in %zd bytes\n",
|
||||||
nghttp2_bufs_len(&session->aob.framebufs)));
|
nghttp2_bufs_len(&session->aob.framebufs));
|
||||||
|
|
||||||
if (frame->headers.cat == NGHTTP2_HCAT_REQUEST) {
|
if (frame->headers.cat == NGHTTP2_HCAT_REQUEST) {
|
||||||
assert(session->last_sent_stream_id < frame->hd.stream_id);
|
assert(session->last_sent_stream_id < frame->hd.stream_id);
|
||||||
|
@ -2559,7 +2556,7 @@ static int session_after_frame_sent1(nghttp2_session *session) {
|
||||||
if (frame->hd.type == NGHTTP2_HEADERS ||
|
if (frame->hd.type == NGHTTP2_HEADERS ||
|
||||||
frame->hd.type == NGHTTP2_PUSH_PROMISE) {
|
frame->hd.type == NGHTTP2_PUSH_PROMISE) {
|
||||||
if (nghttp2_bufs_next_present(framebufs)) {
|
if (nghttp2_bufs_next_present(framebufs)) {
|
||||||
DEBUGF(fprintf(stderr, "send: CONTINUATION exists, just return\n"));
|
DEBUGF("send: CONTINUATION exists, just return\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2775,8 +2772,8 @@ static int session_after_frame_sent2(nghttp2_session *session) {
|
||||||
if (nghttp2_bufs_next_present(framebufs)) {
|
if (nghttp2_bufs_next_present(framebufs)) {
|
||||||
framebufs->cur = framebufs->cur->next;
|
framebufs->cur = framebufs->cur->next;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "send: next CONTINUATION frame, %zu bytes\n",
|
DEBUGF("send: next CONTINUATION frame, %zu bytes\n",
|
||||||
nghttp2_buf_len(&framebufs->cur->buf)));
|
nghttp2_buf_len(&framebufs->cur->buf));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2892,15 +2889,15 @@ static ssize_t nghttp2_session_mem_send_internal(nghttp2_session *session,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (rv == NGHTTP2_ERR_DEFERRED) {
|
if (rv == NGHTTP2_ERR_DEFERRED) {
|
||||||
DEBUGF(fprintf(stderr, "send: frame transmission deferred\n"));
|
DEBUGF("send: frame transmission deferred\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (rv < 0) {
|
if (rv < 0) {
|
||||||
int32_t opened_stream_id = 0;
|
int32_t opened_stream_id = 0;
|
||||||
uint32_t error_code = NGHTTP2_INTERNAL_ERROR;
|
uint32_t error_code = NGHTTP2_INTERNAL_ERROR;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "send: frame preparation failed with %s\n",
|
DEBUGF("send: frame preparation failed with %s\n",
|
||||||
nghttp2_strerror(rv)));
|
nghttp2_strerror(rv));
|
||||||
/* TODO If the error comes from compressor, the connection
|
/* TODO If the error comes from compressor, the connection
|
||||||
must be closed. */
|
must be closed. */
|
||||||
if (item->frame.hd.type != NGHTTP2_DATA &&
|
if (item->frame.hd.type != NGHTTP2_DATA &&
|
||||||
|
@ -2974,10 +2971,10 @@ static ssize_t nghttp2_session_mem_send_internal(nghttp2_session *session,
|
||||||
|
|
||||||
frame = &item->frame;
|
frame = &item->frame;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "send: next frame: payloadlen=%zu, type=%u, "
|
DEBUGF("send: next frame: payloadlen=%zu, type=%u, "
|
||||||
"flags=0x%02x, stream_id=%d\n",
|
"flags=0x%02x, stream_id=%d\n",
|
||||||
frame->hd.length, frame->hd.type, frame->hd.flags,
|
frame->hd.length, frame->hd.type, frame->hd.flags,
|
||||||
frame->hd.stream_id));
|
frame->hd.stream_id);
|
||||||
|
|
||||||
rv = session_call_before_frame_send(session, frame);
|
rv = session_call_before_frame_send(session, frame);
|
||||||
if (nghttp2_is_fatal(rv)) {
|
if (nghttp2_is_fatal(rv)) {
|
||||||
|
@ -3029,7 +3026,7 @@ static ssize_t nghttp2_session_mem_send_internal(nghttp2_session *session,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DEBUGF(fprintf(stderr, "send: next frame: DATA\n"));
|
DEBUGF("send: next frame: DATA\n");
|
||||||
|
|
||||||
if (item->aux_data.data.no_copy) {
|
if (item->aux_data.data.no_copy) {
|
||||||
aob->state = NGHTTP2_OB_SEND_NO_COPY;
|
aob->state = NGHTTP2_OB_SEND_NO_COPY;
|
||||||
|
@ -3037,10 +3034,9 @@ static ssize_t nghttp2_session_mem_send_internal(nghttp2_session *session,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr,
|
DEBUGF("send: start transmitting frame type=%u, length=%zd\n",
|
||||||
"send: start transmitting frame type=%u, length=%zd\n",
|
|
||||||
framebufs->cur->buf.pos[3],
|
framebufs->cur->buf.pos[3],
|
||||||
framebufs->cur->buf.last - framebufs->cur->buf.pos));
|
framebufs->cur->buf.last - framebufs->cur->buf.pos);
|
||||||
|
|
||||||
aob->state = NGHTTP2_OB_SEND_DATA;
|
aob->state = NGHTTP2_OB_SEND_DATA;
|
||||||
|
|
||||||
|
@ -3053,7 +3049,7 @@ static ssize_t nghttp2_session_mem_send_internal(nghttp2_session *session,
|
||||||
buf = &framebufs->cur->buf;
|
buf = &framebufs->cur->buf;
|
||||||
|
|
||||||
if (buf->pos == buf->last) {
|
if (buf->pos == buf->last) {
|
||||||
DEBUGF(fprintf(stderr, "send: end transmission of a frame\n"));
|
DEBUGF("send: end transmission of a frame\n");
|
||||||
|
|
||||||
/* Frame has completely sent */
|
/* Frame has completely sent */
|
||||||
if (fast_cb) {
|
if (fast_cb) {
|
||||||
|
@ -3090,15 +3086,13 @@ static ssize_t nghttp2_session_mem_send_internal(nghttp2_session *session,
|
||||||
nghttp2_frame *frame;
|
nghttp2_frame *frame;
|
||||||
int pause;
|
int pause;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "send: no copy DATA\n"));
|
DEBUGF("send: no copy DATA\n");
|
||||||
|
|
||||||
frame = &aob->item->frame;
|
frame = &aob->item->frame;
|
||||||
|
|
||||||
stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
|
stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
|
||||||
if (stream == NULL) {
|
if (stream == NULL) {
|
||||||
DEBUGF(fprintf(
|
DEBUGF("send: no copy DATA cancelled because stream was closed\n");
|
||||||
stderr,
|
|
||||||
"send: no copy DATA cancelled because stream was closed\n"));
|
|
||||||
|
|
||||||
active_outbound_item_reset(aob, mem);
|
active_outbound_item_reset(aob, mem);
|
||||||
|
|
||||||
|
@ -3160,7 +3154,7 @@ static ssize_t nghttp2_session_mem_send_internal(nghttp2_session *session,
|
||||||
buf = &framebufs->cur->buf;
|
buf = &framebufs->cur->buf;
|
||||||
|
|
||||||
if (buf->pos == buf->last) {
|
if (buf->pos == buf->last) {
|
||||||
DEBUGF(fprintf(stderr, "send: end transmission of client magic\n"));
|
DEBUGF("send: end transmission of client magic\n");
|
||||||
active_outbound_item_reset(aob, mem);
|
active_outbound_item_reset(aob, mem);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3280,8 +3274,7 @@ static int session_call_on_frame_received(nghttp2_session *session,
|
||||||
static int session_call_on_begin_headers(nghttp2_session *session,
|
static int session_call_on_begin_headers(nghttp2_session *session,
|
||||||
nghttp2_frame *frame) {
|
nghttp2_frame *frame) {
|
||||||
int rv;
|
int rv;
|
||||||
DEBUGF(fprintf(stderr, "recv: call on_begin_headers callback stream_id=%d\n",
|
DEBUGF("recv: call on_begin_headers callback stream_id=%d\n", frame->hd.stream_id);
|
||||||
frame->hd.stream_id));
|
|
||||||
if (session->callbacks.on_begin_headers_callback) {
|
if (session->callbacks.on_begin_headers_callback) {
|
||||||
rv = session->callbacks.on_begin_headers_callback(session, frame,
|
rv = session->callbacks.on_begin_headers_callback(session, frame,
|
||||||
session->user_data);
|
session->user_data);
|
||||||
|
@ -3537,7 +3530,7 @@ static int inflate_header_block(nghttp2_session *session, nghttp2_frame *frame,
|
||||||
trailer = session_trailer_headers(session, stream, frame);
|
trailer = session_trailer_headers(session, stream, frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "recv: decoding header block %zu bytes\n", inlen));
|
DEBUGF("recv: decoding header block %zu bytes\n", inlen);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
inflate_flags = 0;
|
inflate_flags = 0;
|
||||||
proclen = nghttp2_hd_inflate_hd_nv(&session->hd_inflater, &nv,
|
proclen = nghttp2_hd_inflate_hd_nv(&session->hd_inflater, &nv,
|
||||||
|
@ -3571,7 +3564,7 @@ static int inflate_header_block(nghttp2_session *session, nghttp2_frame *frame,
|
||||||
inlen -= (size_t)proclen;
|
inlen -= (size_t)proclen;
|
||||||
*readlen_ptr += (size_t)proclen;
|
*readlen_ptr += (size_t)proclen;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "recv: proclen=%zd\n", proclen));
|
DEBUGF("recv: proclen=%zd\n", proclen);
|
||||||
|
|
||||||
if (call_header_cb && (inflate_flags & NGHTTP2_HD_INFLATE_EMIT)) {
|
if (call_header_cb && (inflate_flags & NGHTTP2_HD_INFLATE_EMIT)) {
|
||||||
rv = 0;
|
rv = 0;
|
||||||
|
@ -3579,10 +3572,9 @@ static int inflate_header_block(nghttp2_session *session, nghttp2_frame *frame,
|
||||||
rv = nghttp2_http_on_header(session, subject_stream, frame, &nv,
|
rv = nghttp2_http_on_header(session, subject_stream, frame, &nv,
|
||||||
trailer);
|
trailer);
|
||||||
if (rv == NGHTTP2_ERR_HTTP_HEADER) {
|
if (rv == NGHTTP2_ERR_HTTP_HEADER) {
|
||||||
DEBUGF(fprintf(
|
DEBUGF("recv: HTTP error: type=%u, id=%d, header %.*s: %.*s\n",
|
||||||
stderr, "recv: HTTP error: type=%u, id=%d, header %.*s: %.*s\n",
|
|
||||||
frame->hd.type, frame->hd.stream_id, (int)nv.name->len,
|
frame->hd.type, frame->hd.stream_id, (int)nv.name->len,
|
||||||
nv.name->base, (int)nv.value->len, nv.value->base));
|
nv.name->base, (int)nv.value->len, nv.value->base);
|
||||||
|
|
||||||
rv = session_call_error_callback(
|
rv = session_call_error_callback(
|
||||||
session, "Invalid HTTP header field was received: frame type: "
|
session, "Invalid HTTP header field was received: frame type: "
|
||||||
|
@ -3615,10 +3607,9 @@ static int inflate_header_block(nghttp2_session *session, nghttp2_frame *frame,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* header is ignored */
|
/* header is ignored */
|
||||||
DEBUGF(fprintf(
|
DEBUGF("recv: HTTP ignored: type=%u, id=%d, header %.*s: %.*s\n",
|
||||||
stderr, "recv: HTTP ignored: type=%u, id=%d, header %.*s: %.*s\n",
|
|
||||||
frame->hd.type, frame->hd.stream_id, (int)nv.name->len,
|
frame->hd.type, frame->hd.stream_id, (int)nv.name->len,
|
||||||
nv.name->base, (int)nv.value->len, nv.value->base));
|
nv.name->base, (int)nv.value->len, nv.value->base);
|
||||||
|
|
||||||
rv2 = session_call_error_callback(
|
rv2 = session_call_error_callback(
|
||||||
session,
|
session,
|
||||||
|
@ -5173,8 +5164,7 @@ static void inbound_frame_set_settings_entry(nghttp2_inbound_frame *iframe) {
|
||||||
case NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE:
|
case NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DEBUGF(
|
DEBUGF("recv: unknown settings id=0x%02x\n", iv.settings_id);
|
||||||
fprintf(stderr, "recv: unknown settings id=0x%02x\n", iv.settings_id));
|
|
||||||
|
|
||||||
iframe->iv[iframe->niv++] = iv;
|
iframe->iv[iframe->niv++] = iv;
|
||||||
|
|
||||||
|
@ -5216,7 +5206,7 @@ static int inbound_frame_handle_pad(nghttp2_inbound_frame *iframe,
|
||||||
inbound_frame_set_mark(iframe, 1);
|
inbound_frame_set_mark(iframe, 1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
DEBUGF(fprintf(stderr, "recv: no padding in payload\n"));
|
DEBUGF("recv: no padding in payload\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5230,7 +5220,7 @@ static ssize_t inbound_frame_compute_pad(nghttp2_inbound_frame *iframe) {
|
||||||
/* 1 for Pad Length field */
|
/* 1 for Pad Length field */
|
||||||
padlen = (size_t)(iframe->sbuf.pos[0] + 1);
|
padlen = (size_t)(iframe->sbuf.pos[0] + 1);
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "recv: padlen=%zu\n", padlen));
|
DEBUGF("recv: padlen=%zu\n", padlen);
|
||||||
|
|
||||||
/* We cannot use iframe->frame.hd.length because of CONTINUATION */
|
/* We cannot use iframe->frame.hd.length because of CONTINUATION */
|
||||||
if (padlen - 1 > iframe->payloadleft) {
|
if (padlen - 1 > iframe->payloadleft) {
|
||||||
|
@ -5278,9 +5268,8 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
size_t pri_fieldlen;
|
size_t pri_fieldlen;
|
||||||
nghttp2_mem *mem;
|
nghttp2_mem *mem;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr,
|
DEBUGF("recv: connection recv_window_size=%d, local_window=%d\n",
|
||||||
"recv: connection recv_window_size=%d, local_window=%d\n",
|
session->recv_window_size, session->local_window_size);
|
||||||
session->recv_window_size, session->local_window_size));
|
|
||||||
|
|
||||||
mem = &session->mem;
|
mem = &session->mem;
|
||||||
|
|
||||||
|
@ -5313,7 +5302,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NGHTTP2_IB_READ_FIRST_SETTINGS:
|
case NGHTTP2_IB_READ_FIRST_SETTINGS:
|
||||||
DEBUGF(fprintf(stderr, "recv: [IB_READ_FIRST_SETTINGS]\n"));
|
DEBUGF("recv: [IB_READ_FIRST_SETTINGS]\n");
|
||||||
|
|
||||||
readlen = inbound_frame_buf_read(iframe, in, last);
|
readlen = inbound_frame_buf_read(iframe, in, last);
|
||||||
in += readlen;
|
in += readlen;
|
||||||
|
@ -5352,7 +5341,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
case NGHTTP2_IB_READ_HEAD: {
|
case NGHTTP2_IB_READ_HEAD: {
|
||||||
int on_begin_frame_called = 0;
|
int on_begin_frame_called = 0;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "recv: [IB_READ_HEAD]\n"));
|
DEBUGF("recv: [IB_READ_HEAD]\n");
|
||||||
|
|
||||||
readlen = inbound_frame_buf_read(iframe, in, last);
|
readlen = inbound_frame_buf_read(iframe, in, last);
|
||||||
in += readlen;
|
in += readlen;
|
||||||
|
@ -5364,15 +5353,15 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
nghttp2_frame_unpack_frame_hd(&iframe->frame.hd, iframe->sbuf.pos);
|
nghttp2_frame_unpack_frame_hd(&iframe->frame.hd, iframe->sbuf.pos);
|
||||||
iframe->payloadleft = iframe->frame.hd.length;
|
iframe->payloadleft = iframe->frame.hd.length;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "recv: payloadlen=%zu, type=%u, flags=0x%02x, "
|
DEBUGF("recv: payloadlen=%zu, type=%u, flags=0x%02x, "
|
||||||
"stream_id=%d\n",
|
"stream_id=%d\n",
|
||||||
iframe->frame.hd.length, iframe->frame.hd.type,
|
iframe->frame.hd.length, iframe->frame.hd.type,
|
||||||
iframe->frame.hd.flags, iframe->frame.hd.stream_id));
|
iframe->frame.hd.flags, iframe->frame.hd.stream_id);
|
||||||
|
|
||||||
if (iframe->frame.hd.length > session->local_settings.max_frame_size) {
|
if (iframe->frame.hd.length > session->local_settings.max_frame_size) {
|
||||||
DEBUGF(fprintf(stderr, "recv: length is too large %zu > %u\n",
|
DEBUGF("recv: length is too large %zu > %u\n",
|
||||||
iframe->frame.hd.length,
|
iframe->frame.hd.length,
|
||||||
session->local_settings.max_frame_size));
|
session->local_settings.max_frame_size);
|
||||||
|
|
||||||
busy = 1;
|
busy = 1;
|
||||||
|
|
||||||
|
@ -5390,7 +5379,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
|
|
||||||
switch (iframe->frame.hd.type) {
|
switch (iframe->frame.hd.type) {
|
||||||
case NGHTTP2_DATA: {
|
case NGHTTP2_DATA: {
|
||||||
DEBUGF(fprintf(stderr, "recv: DATA\n"));
|
DEBUGF("recv: DATA\n");
|
||||||
|
|
||||||
iframe->frame.hd.flags &=
|
iframe->frame.hd.flags &=
|
||||||
(NGHTTP2_FLAG_END_STREAM | NGHTTP2_FLAG_PADDED);
|
(NGHTTP2_FLAG_END_STREAM | NGHTTP2_FLAG_PADDED);
|
||||||
|
@ -5400,8 +5389,8 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
|
|
||||||
rv = session_on_data_received_fail_fast(session);
|
rv = session_on_data_received_fail_fast(session);
|
||||||
if (rv == NGHTTP2_ERR_IGN_PAYLOAD) {
|
if (rv == NGHTTP2_ERR_IGN_PAYLOAD) {
|
||||||
DEBUGF(fprintf(stderr, "recv: DATA not allowed stream_id=%d\n",
|
DEBUGF("recv: DATA not allowed stream_id=%d\n",
|
||||||
iframe->frame.hd.stream_id));
|
iframe->frame.hd.stream_id);
|
||||||
iframe->state = NGHTTP2_IB_IGN_DATA;
|
iframe->state = NGHTTP2_IB_IGN_DATA;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -5433,7 +5422,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
}
|
}
|
||||||
case NGHTTP2_HEADERS:
|
case NGHTTP2_HEADERS:
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "recv: HEADERS\n"));
|
DEBUGF("recv: HEADERS\n");
|
||||||
|
|
||||||
iframe->frame.hd.flags &=
|
iframe->frame.hd.flags &=
|
||||||
(NGHTTP2_FLAG_END_STREAM | NGHTTP2_FLAG_END_HEADERS |
|
(NGHTTP2_FLAG_END_STREAM | NGHTTP2_FLAG_END_HEADERS |
|
||||||
|
@ -5512,7 +5501,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NGHTTP2_PRIORITY:
|
case NGHTTP2_PRIORITY:
|
||||||
DEBUGF(fprintf(stderr, "recv: PRIORITY\n"));
|
DEBUGF("recv: PRIORITY\n");
|
||||||
|
|
||||||
iframe->frame.hd.flags = NGHTTP2_FLAG_NONE;
|
iframe->frame.hd.flags = NGHTTP2_FLAG_NONE;
|
||||||
|
|
||||||
|
@ -5534,10 +5523,10 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
#ifdef DEBUGBUILD
|
#ifdef DEBUGBUILD
|
||||||
switch (iframe->frame.hd.type) {
|
switch (iframe->frame.hd.type) {
|
||||||
case NGHTTP2_RST_STREAM:
|
case NGHTTP2_RST_STREAM:
|
||||||
DEBUGF(fprintf(stderr, "recv: RST_STREAM\n"));
|
DEBUGF("recv: RST_STREAM\n");
|
||||||
break;
|
break;
|
||||||
case NGHTTP2_WINDOW_UPDATE:
|
case NGHTTP2_WINDOW_UPDATE:
|
||||||
DEBUGF(fprintf(stderr, "recv: WINDOW_UPDATE\n"));
|
DEBUGF("recv: WINDOW_UPDATE\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif /* DEBUGBUILD */
|
#endif /* DEBUGBUILD */
|
||||||
|
@ -5556,7 +5545,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NGHTTP2_SETTINGS:
|
case NGHTTP2_SETTINGS:
|
||||||
DEBUGF(fprintf(stderr, "recv: SETTINGS\n"));
|
DEBUGF("recv: SETTINGS\n");
|
||||||
|
|
||||||
iframe->frame.hd.flags &= NGHTTP2_FLAG_ACK;
|
iframe->frame.hd.flags &= NGHTTP2_FLAG_ACK;
|
||||||
|
|
||||||
|
@ -5600,7 +5589,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NGHTTP2_PUSH_PROMISE:
|
case NGHTTP2_PUSH_PROMISE:
|
||||||
DEBUGF(fprintf(stderr, "recv: PUSH_PROMISE\n"));
|
DEBUGF("recv: PUSH_PROMISE\n");
|
||||||
|
|
||||||
iframe->frame.hd.flags &=
|
iframe->frame.hd.flags &=
|
||||||
(NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_PADDED);
|
(NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_PADDED);
|
||||||
|
@ -5635,7 +5624,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NGHTTP2_PING:
|
case NGHTTP2_PING:
|
||||||
DEBUGF(fprintf(stderr, "recv: PING\n"));
|
DEBUGF("recv: PING\n");
|
||||||
|
|
||||||
iframe->frame.hd.flags &= NGHTTP2_FLAG_ACK;
|
iframe->frame.hd.flags &= NGHTTP2_FLAG_ACK;
|
||||||
|
|
||||||
|
@ -5650,7 +5639,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NGHTTP2_GOAWAY:
|
case NGHTTP2_GOAWAY:
|
||||||
DEBUGF(fprintf(stderr, "recv: GOAWAY\n"));
|
DEBUGF("recv: GOAWAY\n");
|
||||||
|
|
||||||
iframe->frame.hd.flags = NGHTTP2_FLAG_NONE;
|
iframe->frame.hd.flags = NGHTTP2_FLAG_NONE;
|
||||||
|
|
||||||
|
@ -5665,7 +5654,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NGHTTP2_CONTINUATION:
|
case NGHTTP2_CONTINUATION:
|
||||||
DEBUGF(fprintf(stderr, "recv: unexpected CONTINUATION\n"));
|
DEBUGF("recv: unexpected CONTINUATION\n");
|
||||||
|
|
||||||
/* Receiving CONTINUATION in this state are subject to
|
/* Receiving CONTINUATION in this state are subject to
|
||||||
connection error of type PROTOCOL_ERROR */
|
connection error of type PROTOCOL_ERROR */
|
||||||
|
@ -5681,7 +5670,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DEBUGF(fprintf(stderr, "recv: extension frame\n"));
|
DEBUGF("recv: extension frame\n");
|
||||||
|
|
||||||
if (check_ext_type_set(session->user_recv_ext_types,
|
if (check_ext_type_set(session->user_recv_ext_types,
|
||||||
iframe->frame.hd.type)) {
|
iframe->frame.hd.type)) {
|
||||||
|
@ -5710,7 +5699,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "recv: ALTSVC\n"));
|
DEBUGF("recv: ALTSVC\n");
|
||||||
|
|
||||||
iframe->frame.hd.flags = NGHTTP2_FLAG_NONE;
|
iframe->frame.hd.flags = NGHTTP2_FLAG_NONE;
|
||||||
iframe->frame.ext.payload = &iframe->ext_frame_payload.altsvc;
|
iframe->frame.ext.payload = &iframe->ext_frame_payload.altsvc;
|
||||||
|
@ -5762,15 +5751,15 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case NGHTTP2_IB_READ_NBYTE:
|
case NGHTTP2_IB_READ_NBYTE:
|
||||||
DEBUGF(fprintf(stderr, "recv: [IB_READ_NBYTE]\n"));
|
DEBUGF("recv: [IB_READ_NBYTE]\n");
|
||||||
|
|
||||||
readlen = inbound_frame_buf_read(iframe, in, last);
|
readlen = inbound_frame_buf_read(iframe, in, last);
|
||||||
in += readlen;
|
in += readlen;
|
||||||
iframe->payloadleft -= readlen;
|
iframe->payloadleft -= readlen;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "recv: readlen=%zu, payloadleft=%zu, left=%zd\n",
|
DEBUGF("recv: readlen=%zu, payloadleft=%zu, left=%zd\n",
|
||||||
readlen, iframe->payloadleft,
|
readlen, iframe->payloadleft,
|
||||||
nghttp2_buf_mark_avail(&iframe->sbuf)));
|
nghttp2_buf_mark_avail(&iframe->sbuf));
|
||||||
|
|
||||||
if (nghttp2_buf_mark_avail(&iframe->sbuf)) {
|
if (nghttp2_buf_mark_avail(&iframe->sbuf)) {
|
||||||
return in - first;
|
return in - first;
|
||||||
|
@ -5955,7 +5944,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
|
|
||||||
origin_len = nghttp2_get_uint16(iframe->sbuf.pos);
|
origin_len = nghttp2_get_uint16(iframe->sbuf.pos);
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "recv: origin_len=%zu\n", origin_len));
|
DEBUGF("recv: origin_len=%zu\n", origin_len);
|
||||||
|
|
||||||
if (2 + origin_len > iframe->payloadleft) {
|
if (2 + origin_len > iframe->payloadleft) {
|
||||||
busy = 1;
|
busy = 1;
|
||||||
|
@ -5995,16 +5984,16 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
int final;
|
int final;
|
||||||
#ifdef DEBUGBUILD
|
#ifdef DEBUGBUILD
|
||||||
if (iframe->state == NGHTTP2_IB_READ_HEADER_BLOCK) {
|
if (iframe->state == NGHTTP2_IB_READ_HEADER_BLOCK) {
|
||||||
fprintf(stderr, "recv: [IB_READ_HEADER_BLOCK]\n");
|
DEBUGF("recv: [IB_READ_HEADER_BLOCK]\n");
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "recv: [IB_IGN_HEADER_BLOCK]\n");
|
DEBUGF("recv: [IB_IGN_HEADER_BLOCK]\n");
|
||||||
}
|
}
|
||||||
#endif /* DEBUGBUILD */
|
#endif /* DEBUGBUILD */
|
||||||
|
|
||||||
readlen = inbound_frame_payload_readlen(iframe, in, last);
|
readlen = inbound_frame_payload_readlen(iframe, in, last);
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "recv: readlen=%zu, payloadleft=%zu\n", readlen,
|
DEBUGF("recv: readlen=%zu, payloadleft=%zu\n", readlen,
|
||||||
iframe->payloadleft - readlen));
|
iframe->payloadleft - readlen);
|
||||||
|
|
||||||
data_readlen = inbound_frame_effective_readlen(
|
data_readlen = inbound_frame_effective_readlen(
|
||||||
iframe, iframe->payloadleft - readlen, readlen);
|
iframe, iframe->payloadleft - readlen, readlen);
|
||||||
|
@ -6016,7 +6005,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
if (data_readlen > 0 || (data_readlen == 0 && final)) {
|
if (data_readlen > 0 || (data_readlen == 0 && final)) {
|
||||||
size_t hd_proclen = 0;
|
size_t hd_proclen = 0;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "recv: block final=%d\n", final));
|
DEBUGF("recv: block final=%d\n", final);
|
||||||
|
|
||||||
rv =
|
rv =
|
||||||
inflate_header_block(session, &iframe->frame, &hd_proclen,
|
inflate_header_block(session, &iframe->frame, &hd_proclen,
|
||||||
|
@ -6100,14 +6089,14 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case NGHTTP2_IB_IGN_PAYLOAD:
|
case NGHTTP2_IB_IGN_PAYLOAD:
|
||||||
DEBUGF(fprintf(stderr, "recv: [IB_IGN_PAYLOAD]\n"));
|
DEBUGF("recv: [IB_IGN_PAYLOAD]\n");
|
||||||
|
|
||||||
readlen = inbound_frame_payload_readlen(iframe, in, last);
|
readlen = inbound_frame_payload_readlen(iframe, in, last);
|
||||||
iframe->payloadleft -= readlen;
|
iframe->payloadleft -= readlen;
|
||||||
in += readlen;
|
in += readlen;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "recv: readlen=%zu, payloadleft=%zu\n", readlen,
|
DEBUGF("recv: readlen=%zu, payloadleft=%zu\n", readlen,
|
||||||
iframe->payloadleft));
|
iframe->payloadleft);
|
||||||
|
|
||||||
if (iframe->payloadleft) {
|
if (iframe->payloadleft) {
|
||||||
break;
|
break;
|
||||||
|
@ -6128,7 +6117,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NGHTTP2_IB_FRAME_SIZE_ERROR:
|
case NGHTTP2_IB_FRAME_SIZE_ERROR:
|
||||||
DEBUGF(fprintf(stderr, "recv: [IB_FRAME_SIZE_ERROR]\n"));
|
DEBUGF("recv: [IB_FRAME_SIZE_ERROR]\n");
|
||||||
|
|
||||||
rv = session_handle_frame_size_error(session, &iframe->frame);
|
rv = session_handle_frame_size_error(session, &iframe->frame);
|
||||||
if (nghttp2_is_fatal(rv)) {
|
if (nghttp2_is_fatal(rv)) {
|
||||||
|
@ -6141,14 +6130,13 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NGHTTP2_IB_READ_SETTINGS:
|
case NGHTTP2_IB_READ_SETTINGS:
|
||||||
DEBUGF(fprintf(stderr, "recv: [IB_READ_SETTINGS]\n"));
|
DEBUGF("recv: [IB_READ_SETTINGS]\n");
|
||||||
|
|
||||||
readlen = inbound_frame_buf_read(iframe, in, last);
|
readlen = inbound_frame_buf_read(iframe, in, last);
|
||||||
iframe->payloadleft -= readlen;
|
iframe->payloadleft -= readlen;
|
||||||
in += readlen;
|
in += readlen;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "recv: readlen=%zu, payloadleft=%zu\n", readlen,
|
DEBUGF("recv: readlen=%zu, payloadleft=%zu\n", readlen, iframe->payloadleft);
|
||||||
iframe->payloadleft));
|
|
||||||
|
|
||||||
if (nghttp2_buf_mark_avail(&iframe->sbuf)) {
|
if (nghttp2_buf_mark_avail(&iframe->sbuf)) {
|
||||||
break;
|
break;
|
||||||
|
@ -6172,7 +6160,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NGHTTP2_IB_READ_GOAWAY_DEBUG:
|
case NGHTTP2_IB_READ_GOAWAY_DEBUG:
|
||||||
DEBUGF(fprintf(stderr, "recv: [IB_READ_GOAWAY_DEBUG]\n"));
|
DEBUGF("recv: [IB_READ_GOAWAY_DEBUG]\n");
|
||||||
|
|
||||||
readlen = inbound_frame_payload_readlen(iframe, in, last);
|
readlen = inbound_frame_payload_readlen(iframe, in, last);
|
||||||
|
|
||||||
|
@ -6183,8 +6171,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
in += readlen;
|
in += readlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "recv: readlen=%zu, payloadleft=%zu\n", readlen,
|
DEBUGF("recv: readlen=%zu, payloadleft=%zu\n", readlen, iframe->payloadleft);
|
||||||
iframe->payloadleft));
|
|
||||||
|
|
||||||
if (iframe->payloadleft) {
|
if (iframe->payloadleft) {
|
||||||
assert(nghttp2_buf_avail(&iframe->lbuf) > 0);
|
assert(nghttp2_buf_avail(&iframe->lbuf) > 0);
|
||||||
|
@ -6221,17 +6208,17 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
nghttp2_frame_unpack_frame_hd(&cont_hd, iframe->sbuf.pos);
|
nghttp2_frame_unpack_frame_hd(&cont_hd, iframe->sbuf.pos);
|
||||||
iframe->payloadleft = cont_hd.length;
|
iframe->payloadleft = cont_hd.length;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "recv: payloadlen=%zu, type=%u, flags=0x%02x, "
|
DEBUGF("recv: payloadlen=%zu, type=%u, flags=0x%02x, "
|
||||||
"stream_id=%d\n",
|
"stream_id=%d\n",
|
||||||
cont_hd.length, cont_hd.type, cont_hd.flags,
|
cont_hd.length, cont_hd.type, cont_hd.flags,
|
||||||
cont_hd.stream_id));
|
cont_hd.stream_id);
|
||||||
|
|
||||||
if (cont_hd.type != NGHTTP2_CONTINUATION ||
|
if (cont_hd.type != NGHTTP2_CONTINUATION ||
|
||||||
cont_hd.stream_id != iframe->frame.hd.stream_id) {
|
cont_hd.stream_id != iframe->frame.hd.stream_id) {
|
||||||
DEBUGF(fprintf(stderr, "recv: expected stream_id=%d, type=%d, but "
|
DEBUGF("recv: expected stream_id=%d, type=%d, but "
|
||||||
"got stream_id=%d, type=%u\n",
|
"got stream_id=%d, type=%u\n",
|
||||||
iframe->frame.hd.stream_id, NGHTTP2_CONTINUATION,
|
iframe->frame.hd.stream_id, NGHTTP2_CONTINUATION,
|
||||||
cont_hd.stream_id, cont_hd.type));
|
cont_hd.stream_id, cont_hd.type);
|
||||||
rv = nghttp2_session_terminate_session_with_reason(
|
rv = nghttp2_session_terminate_session_with_reason(
|
||||||
session, NGHTTP2_PROTOCOL_ERROR,
|
session, NGHTTP2_PROTOCOL_ERROR,
|
||||||
"unexpected non-CONTINUATION frame or stream_id is invalid");
|
"unexpected non-CONTINUATION frame or stream_id is invalid");
|
||||||
|
@ -6268,15 +6255,15 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NGHTTP2_IB_READ_PAD_DATA:
|
case NGHTTP2_IB_READ_PAD_DATA:
|
||||||
DEBUGF(fprintf(stderr, "recv: [IB_READ_PAD_DATA]\n"));
|
DEBUGF("recv: [IB_READ_PAD_DATA]\n");
|
||||||
|
|
||||||
readlen = inbound_frame_buf_read(iframe, in, last);
|
readlen = inbound_frame_buf_read(iframe, in, last);
|
||||||
in += readlen;
|
in += readlen;
|
||||||
iframe->payloadleft -= readlen;
|
iframe->payloadleft -= readlen;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "recv: readlen=%zu, payloadleft=%zu, left=%zu\n",
|
DEBUGF("recv: readlen=%zu, payloadleft=%zu, left=%zu\n",
|
||||||
readlen, iframe->payloadleft,
|
readlen, iframe->payloadleft,
|
||||||
nghttp2_buf_mark_avail(&iframe->sbuf)));
|
nghttp2_buf_mark_avail(&iframe->sbuf));
|
||||||
|
|
||||||
if (nghttp2_buf_mark_avail(&iframe->sbuf)) {
|
if (nghttp2_buf_mark_avail(&iframe->sbuf)) {
|
||||||
return in - first;
|
return in - first;
|
||||||
|
@ -6334,14 +6321,13 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "recv: [IB_READ_DATA]\n"));
|
DEBUGF("recv: [IB_READ_DATA]\n");
|
||||||
|
|
||||||
readlen = inbound_frame_payload_readlen(iframe, in, last);
|
readlen = inbound_frame_payload_readlen(iframe, in, last);
|
||||||
iframe->payloadleft -= readlen;
|
iframe->payloadleft -= readlen;
|
||||||
in += readlen;
|
in += readlen;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "recv: readlen=%zu, payloadleft=%zu\n", readlen,
|
DEBUGF("recv: readlen=%zu, payloadleft=%zu\n", readlen, iframe->payloadleft);
|
||||||
iframe->payloadleft));
|
|
||||||
|
|
||||||
if (readlen > 0) {
|
if (readlen > 0) {
|
||||||
ssize_t data_readlen;
|
ssize_t data_readlen;
|
||||||
|
@ -6379,7 +6365,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "recv: data_readlen=%zd\n", data_readlen));
|
DEBUGF("recv: data_readlen=%zd\n", data_readlen);
|
||||||
|
|
||||||
if (data_readlen > 0) {
|
if (data_readlen > 0) {
|
||||||
if (session_enforce_http_messaging(session)) {
|
if (session_enforce_http_messaging(session)) {
|
||||||
|
@ -6432,14 +6418,13 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NGHTTP2_IB_IGN_DATA:
|
case NGHTTP2_IB_IGN_DATA:
|
||||||
DEBUGF(fprintf(stderr, "recv: [IB_IGN_DATA]\n"));
|
DEBUGF("recv: [IB_IGN_DATA]\n");
|
||||||
|
|
||||||
readlen = inbound_frame_payload_readlen(iframe, in, last);
|
readlen = inbound_frame_payload_readlen(iframe, in, last);
|
||||||
iframe->payloadleft -= readlen;
|
iframe->payloadleft -= readlen;
|
||||||
in += readlen;
|
in += readlen;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "recv: readlen=%zu, payloadleft=%zu\n", readlen,
|
DEBUGF("recv: readlen=%zu, payloadleft=%zu\n", readlen, iframe->payloadleft);
|
||||||
iframe->payloadleft));
|
|
||||||
|
|
||||||
if (readlen > 0) {
|
if (readlen > 0) {
|
||||||
/* Update connection-level flow control window for ignored
|
/* Update connection-level flow control window for ignored
|
||||||
|
@ -6470,14 +6455,13 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
case NGHTTP2_IB_IGN_ALL:
|
case NGHTTP2_IB_IGN_ALL:
|
||||||
return (ssize_t)inlen;
|
return (ssize_t)inlen;
|
||||||
case NGHTTP2_IB_READ_EXTENSION_PAYLOAD:
|
case NGHTTP2_IB_READ_EXTENSION_PAYLOAD:
|
||||||
DEBUGF(fprintf(stderr, "recv: [IB_READ_EXTENSION_PAYLOAD]\n"));
|
DEBUGF("recv: [IB_READ_EXTENSION_PAYLOAD]\n");
|
||||||
|
|
||||||
readlen = inbound_frame_payload_readlen(iframe, in, last);
|
readlen = inbound_frame_payload_readlen(iframe, in, last);
|
||||||
iframe->payloadleft -= readlen;
|
iframe->payloadleft -= readlen;
|
||||||
in += readlen;
|
in += readlen;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "recv: readlen=%zu, payloadleft=%zu\n", readlen,
|
DEBUGF("recv: readlen=%zu, payloadleft=%zu\n", readlen, iframe->payloadleft);
|
||||||
iframe->payloadleft));
|
|
||||||
|
|
||||||
if (readlen > 0) {
|
if (readlen > 0) {
|
||||||
rv = session_call_on_extension_chunk_recv_callback(
|
rv = session_call_on_extension_chunk_recv_callback(
|
||||||
|
@ -6508,7 +6492,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case NGHTTP2_IB_READ_ALTSVC_PAYLOAD:
|
case NGHTTP2_IB_READ_ALTSVC_PAYLOAD:
|
||||||
DEBUGF(fprintf(stderr, "recv: [IB_READ_ALTSVC_PAYLOAD]\n"));
|
DEBUGF("recv: [IB_READ_ALTSVC_PAYLOAD]\n");
|
||||||
|
|
||||||
readlen = inbound_frame_payload_readlen(iframe, in, last);
|
readlen = inbound_frame_payload_readlen(iframe, in, last);
|
||||||
|
|
||||||
|
@ -6519,8 +6503,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||||
in += readlen;
|
in += readlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "recv: readlen=%zu, payloadleft=%zu\n", readlen,
|
DEBUGF("recv: readlen=%zu, payloadleft=%zu\n", readlen, iframe->payloadleft);
|
||||||
iframe->payloadleft));
|
|
||||||
|
|
||||||
if (iframe->payloadleft) {
|
if (iframe->payloadleft) {
|
||||||
assert(nghttp2_buf_avail(&iframe->lbuf) > 0);
|
assert(nghttp2_buf_avail(&iframe->lbuf) > 0);
|
||||||
|
@ -6891,14 +6874,12 @@ int nghttp2_session_pack_data(nghttp2_session *session, nghttp2_bufs *bufs,
|
||||||
stream->remote_window_size, session->remote_settings.max_frame_size,
|
stream->remote_window_size, session->remote_settings.max_frame_size,
|
||||||
session->user_data);
|
session->user_data);
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "send: read_length_callback=%zd\n", payloadlen));
|
DEBUGF("send: read_length_callback=%zd\n", payloadlen);
|
||||||
|
|
||||||
payloadlen = nghttp2_session_enforce_flow_control_limits(session, stream,
|
payloadlen = nghttp2_session_enforce_flow_control_limits(session, stream,
|
||||||
payloadlen);
|
payloadlen);
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr,
|
DEBUGF("send: read_length_callback after flow control=%zd\n", payloadlen);
|
||||||
"send: read_length_callback after flow control=%zd\n",
|
|
||||||
payloadlen));
|
|
||||||
|
|
||||||
if (payloadlen <= 0) {
|
if (payloadlen <= 0) {
|
||||||
return NGHTTP2_ERR_CALLBACK_FAILURE;
|
return NGHTTP2_ERR_CALLBACK_FAILURE;
|
||||||
|
@ -6911,13 +6892,12 @@ int nghttp2_session_pack_data(nghttp2_session *session, nghttp2_bufs *bufs,
|
||||||
(size_t)(NGHTTP2_FRAME_HDLEN + 1 + payloadlen));
|
(size_t)(NGHTTP2_FRAME_HDLEN + 1 + payloadlen));
|
||||||
|
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
DEBUGF(fprintf(stderr, "send: realloc buffer failed rv=%d", rv));
|
DEBUGF("send: realloc buffer failed rv=%d", rv);
|
||||||
/* If reallocation failed, old buffers are still in tact. So
|
/* If reallocation failed, old buffers are still in tact. So
|
||||||
use safe limit. */
|
use safe limit. */
|
||||||
payloadlen = (ssize_t)datamax;
|
payloadlen = (ssize_t)datamax;
|
||||||
|
|
||||||
DEBUGF(
|
DEBUGF("send: use safe limit payloadlen=%zd", payloadlen);
|
||||||
fprintf(stderr, "send: use safe limit payloadlen=%zd", payloadlen));
|
|
||||||
} else {
|
} else {
|
||||||
assert(&session->aob.framebufs == bufs);
|
assert(&session->aob.framebufs == bufs);
|
||||||
|
|
||||||
|
@ -6938,8 +6918,7 @@ int nghttp2_session_pack_data(nghttp2_session *session, nghttp2_bufs *bufs,
|
||||||
if (payloadlen == NGHTTP2_ERR_DEFERRED ||
|
if (payloadlen == NGHTTP2_ERR_DEFERRED ||
|
||||||
payloadlen == NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE ||
|
payloadlen == NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE ||
|
||||||
payloadlen == NGHTTP2_ERR_PAUSE) {
|
payloadlen == NGHTTP2_ERR_PAUSE) {
|
||||||
DEBUGF(fprintf(stderr, "send: DATA postponed due to %s\n",
|
DEBUGF("send: DATA postponed due to %s\n", nghttp2_strerror((int)payloadlen));
|
||||||
nghttp2_strerror((int)payloadlen)));
|
|
||||||
|
|
||||||
return (int)payloadlen;
|
return (int)payloadlen;
|
||||||
}
|
}
|
||||||
|
@ -6968,9 +6947,7 @@ int nghttp2_session_pack_data(nghttp2_session *session, nghttp2_bufs *bufs,
|
||||||
|
|
||||||
if (data_flags & NGHTTP2_DATA_FLAG_NO_COPY) {
|
if (data_flags & NGHTTP2_DATA_FLAG_NO_COPY) {
|
||||||
if (session->callbacks.send_data_callback == NULL) {
|
if (session->callbacks.send_data_callback == NULL) {
|
||||||
DEBUGF(fprintf(
|
DEBUGF("NGHTTP2_DATA_FLAG_NO_COPY requires send_data_callback set\n");
|
||||||
stderr,
|
|
||||||
"NGHTTP2_DATA_FLAG_NO_COPY requires send_data_callback set\n"));
|
|
||||||
|
|
||||||
return NGHTTP2_ERR_CALLBACK_FAILURE;
|
return NGHTTP2_ERR_CALLBACK_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,11 +152,10 @@ static int stream_obq_push(nghttp2_stream *dep_stream, nghttp2_stream *stream) {
|
||||||
stream_next_cycle(stream, dep_stream->descendant_last_cycle);
|
stream_next_cycle(stream, dep_stream->descendant_last_cycle);
|
||||||
stream->seq = dep_stream->descendant_next_seq++;
|
stream->seq = dep_stream->descendant_next_seq++;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "stream: stream=%d obq push cycle=%d\n",
|
DEBUGF("stream: stream=%d obq push cycle=%d\n", stream->stream_id, stream->cycle);
|
||||||
stream->stream_id, stream->cycle));
|
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "stream: push stream %d to stream %d\n",
|
DEBUGF("stream: push stream %d to stream %d\n",
|
||||||
stream->stream_id, dep_stream->stream_id));
|
stream->stream_id, dep_stream->stream_id);
|
||||||
|
|
||||||
rv = nghttp2_pq_push(&dep_stream->obq, &stream->pq_entry);
|
rv = nghttp2_pq_push(&dep_stream->obq, &stream->pq_entry);
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
|
@ -183,8 +182,8 @@ static void stream_obq_remove(nghttp2_stream *stream) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; dep_stream; stream = dep_stream, dep_stream = dep_stream->dep_prev) {
|
for (; dep_stream; stream = dep_stream, dep_stream = dep_stream->dep_prev) {
|
||||||
DEBUGF(fprintf(stderr, "stream: remove stream %d from stream %d\n",
|
DEBUGF("stream: remove stream %d from stream %d\n",
|
||||||
stream->stream_id, dep_stream->stream_id));
|
stream->stream_id, dep_stream->stream_id);
|
||||||
|
|
||||||
nghttp2_pq_remove(&dep_stream->obq, &stream->pq_entry);
|
nghttp2_pq_remove(&dep_stream->obq, &stream->pq_entry);
|
||||||
|
|
||||||
|
@ -214,8 +213,8 @@ static int stream_obq_move(nghttp2_stream *dest, nghttp2_stream *src,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "stream: remove stream %d from stream %d (move)\n",
|
DEBUGF("stream: remove stream %d from stream %d (move)\n",
|
||||||
stream->stream_id, src->stream_id));
|
stream->stream_id, src->stream_id);
|
||||||
|
|
||||||
nghttp2_pq_remove(&src->obq, &stream->pq_entry);
|
nghttp2_pq_remove(&src->obq, &stream->pq_entry);
|
||||||
stream->queued = 0;
|
stream->queued = 0;
|
||||||
|
@ -238,8 +237,8 @@ void nghttp2_stream_reschedule(nghttp2_stream *stream) {
|
||||||
|
|
||||||
nghttp2_pq_push(&dep_stream->obq, &stream->pq_entry);
|
nghttp2_pq_push(&dep_stream->obq, &stream->pq_entry);
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "stream: stream=%d obq resched cycle=%d\n",
|
DEBUGF("stream: stream=%d obq resched cycle=%d\n",
|
||||||
stream->stream_id, stream->cycle));
|
stream->stream_id, stream->cycle);
|
||||||
|
|
||||||
dep_stream->last_writelen = stream->last_writelen;
|
dep_stream->last_writelen = stream->last_writelen;
|
||||||
}
|
}
|
||||||
|
@ -298,8 +297,8 @@ void nghttp2_stream_change_weight(nghttp2_stream *stream, int32_t weight) {
|
||||||
|
|
||||||
nghttp2_pq_push(&dep_stream->obq, &stream->pq_entry);
|
nghttp2_pq_push(&dep_stream->obq, &stream->pq_entry);
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "stream: stream=%d obq resched cycle=%d\n",
|
DEBUGF("stream: stream=%d obq resched cycle=%d\n",
|
||||||
stream->stream_id, stream->cycle));
|
stream->stream_id, stream->cycle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static nghttp2_stream *stream_last_sib(nghttp2_stream *stream) {
|
static nghttp2_stream *stream_last_sib(nghttp2_stream *stream) {
|
||||||
|
@ -481,8 +480,7 @@ int nghttp2_stream_attach_item(nghttp2_stream *stream,
|
||||||
assert((stream->flags & NGHTTP2_STREAM_FLAG_DEFERRED_ALL) == 0);
|
assert((stream->flags & NGHTTP2_STREAM_FLAG_DEFERRED_ALL) == 0);
|
||||||
assert(stream->item == NULL);
|
assert(stream->item == NULL);
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "stream: stream=%d attach item=%p\n",
|
DEBUGF("stream: stream=%d attach item=%p\n", stream->stream_id, item);
|
||||||
stream->stream_id, item));
|
|
||||||
|
|
||||||
stream->item = item;
|
stream->item = item;
|
||||||
|
|
||||||
|
@ -500,8 +498,7 @@ int nghttp2_stream_attach_item(nghttp2_stream *stream,
|
||||||
}
|
}
|
||||||
|
|
||||||
int nghttp2_stream_detach_item(nghttp2_stream *stream) {
|
int nghttp2_stream_detach_item(nghttp2_stream *stream) {
|
||||||
DEBUGF(fprintf(stderr, "stream: stream=%d detach item=%p\n",
|
DEBUGF("stream: stream=%d detach item=%p\n", stream->stream_id, stream->item);
|
||||||
stream->stream_id, stream->item));
|
|
||||||
|
|
||||||
stream->item = NULL;
|
stream->item = NULL;
|
||||||
stream->flags = (uint8_t)(stream->flags & ~NGHTTP2_STREAM_FLAG_DEFERRED_ALL);
|
stream->flags = (uint8_t)(stream->flags & ~NGHTTP2_STREAM_FLAG_DEFERRED_ALL);
|
||||||
|
@ -512,8 +509,8 @@ int nghttp2_stream_detach_item(nghttp2_stream *stream) {
|
||||||
int nghttp2_stream_defer_item(nghttp2_stream *stream, uint8_t flags) {
|
int nghttp2_stream_defer_item(nghttp2_stream *stream, uint8_t flags) {
|
||||||
assert(stream->item);
|
assert(stream->item);
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "stream: stream=%d defer item=%p cause=%02x\n",
|
DEBUGF("stream: stream=%d defer item=%p cause=%02x\n",
|
||||||
stream->stream_id, stream->item, flags));
|
stream->stream_id, stream->item, flags);
|
||||||
|
|
||||||
stream->flags |= flags;
|
stream->flags |= flags;
|
||||||
|
|
||||||
|
@ -523,8 +520,8 @@ int nghttp2_stream_defer_item(nghttp2_stream *stream, uint8_t flags) {
|
||||||
int nghttp2_stream_resume_deferred_item(nghttp2_stream *stream, uint8_t flags) {
|
int nghttp2_stream_resume_deferred_item(nghttp2_stream *stream, uint8_t flags) {
|
||||||
assert(stream->item);
|
assert(stream->item);
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "stream: stream=%d resume item=%p flags=%02x\n",
|
DEBUGF("stream: stream=%d resume item=%p flags=%02x\n",
|
||||||
stream->stream_id, stream->item, flags));
|
stream->stream_id, stream->item, flags);
|
||||||
|
|
||||||
stream->flags = (uint8_t)(stream->flags & ~flags);
|
stream->flags = (uint8_t)(stream->flags & ~flags);
|
||||||
|
|
||||||
|
@ -593,9 +590,8 @@ int nghttp2_stream_dep_insert(nghttp2_stream *dep_stream,
|
||||||
nghttp2_stream *si;
|
nghttp2_stream *si;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr,
|
DEBUGF("stream: dep_insert dep_stream(%p)=%d, stream(%p)=%d\n",
|
||||||
"stream: dep_insert dep_stream(%p)=%d, stream(%p)=%d\n",
|
dep_stream, dep_stream->stream_id, stream, stream->stream_id);
|
||||||
dep_stream, dep_stream->stream_id, stream, stream->stream_id));
|
|
||||||
|
|
||||||
stream->sum_dep_weight = dep_stream->sum_dep_weight;
|
stream->sum_dep_weight = dep_stream->sum_dep_weight;
|
||||||
dep_stream->sum_dep_weight = stream->weight;
|
dep_stream->sum_dep_weight = stream->weight;
|
||||||
|
@ -740,8 +736,8 @@ static void unlink_dep(nghttp2_stream *stream) {
|
||||||
|
|
||||||
void nghttp2_stream_dep_add(nghttp2_stream *dep_stream,
|
void nghttp2_stream_dep_add(nghttp2_stream *dep_stream,
|
||||||
nghttp2_stream *stream) {
|
nghttp2_stream *stream) {
|
||||||
DEBUGF(fprintf(stderr, "stream: dep_add dep_stream(%p)=%d, stream(%p)=%d\n",
|
DEBUGF("stream: dep_add dep_stream(%p)=%d, stream(%p)=%d\n",
|
||||||
dep_stream, dep_stream->stream_id, stream, stream->stream_id));
|
dep_stream, dep_stream->stream_id, stream, stream->stream_id);
|
||||||
|
|
||||||
dep_stream->sum_dep_weight += stream->weight;
|
dep_stream->sum_dep_weight += stream->weight;
|
||||||
|
|
||||||
|
@ -759,8 +755,7 @@ int nghttp2_stream_dep_remove(nghttp2_stream *stream) {
|
||||||
int32_t sum_dep_weight_delta;
|
int32_t sum_dep_weight_delta;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "stream: dep_remove stream(%p)=%d\n", stream,
|
DEBUGF("stream: dep_remove stream(%p)=%d\n", stream, stream->stream_id);
|
||||||
stream->stream_id));
|
|
||||||
|
|
||||||
/* Distribute weight of |stream| to direct descendants */
|
/* Distribute weight of |stream| to direct descendants */
|
||||||
sum_dep_weight_delta = -stream->weight;
|
sum_dep_weight_delta = -stream->weight;
|
||||||
|
@ -813,9 +808,9 @@ int nghttp2_stream_dep_insert_subtree(nghttp2_stream *dep_stream,
|
||||||
nghttp2_stream *si;
|
nghttp2_stream *si;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "stream: dep_insert_subtree dep_stream(%p)=%d "
|
DEBUGF("stream: dep_insert_subtree dep_stream(%p)=%d "
|
||||||
"stream(%p)=%d\n",
|
"stream(%p)=%d\n",
|
||||||
dep_stream, dep_stream->stream_id, stream, stream->stream_id));
|
dep_stream, dep_stream->stream_id, stream, stream->stream_id);
|
||||||
|
|
||||||
stream->sum_dep_weight += dep_stream->sum_dep_weight;
|
stream->sum_dep_weight += dep_stream->sum_dep_weight;
|
||||||
dep_stream->sum_dep_weight = stream->weight;
|
dep_stream->sum_dep_weight = stream->weight;
|
||||||
|
@ -862,9 +857,9 @@ int nghttp2_stream_dep_add_subtree(nghttp2_stream *dep_stream,
|
||||||
nghttp2_stream *stream) {
|
nghttp2_stream *stream) {
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "stream: dep_add_subtree dep_stream(%p)=%d "
|
DEBUGF("stream: dep_add_subtree dep_stream(%p)=%d "
|
||||||
"stream(%p)=%d\n",
|
"stream(%p)=%d\n",
|
||||||
dep_stream, dep_stream->stream_id, stream, stream->stream_id));
|
dep_stream, dep_stream->stream_id, stream, stream->stream_id);
|
||||||
|
|
||||||
dep_stream->sum_dep_weight += stream->weight;
|
dep_stream->sum_dep_weight += stream->weight;
|
||||||
|
|
||||||
|
@ -889,8 +884,7 @@ int nghttp2_stream_dep_add_subtree(nghttp2_stream *dep_stream,
|
||||||
void nghttp2_stream_dep_remove_subtree(nghttp2_stream *stream) {
|
void nghttp2_stream_dep_remove_subtree(nghttp2_stream *stream) {
|
||||||
nghttp2_stream *next, *dep_prev;
|
nghttp2_stream *next, *dep_prev;
|
||||||
|
|
||||||
DEBUGF(fprintf(stderr, "stream: dep_remove_subtree stream(%p)=%d\n", stream,
|
DEBUGF("stream: dep_remove_subtree stream(%p)=%d\n", stream, stream->stream_id);
|
||||||
stream->stream_id));
|
|
||||||
|
|
||||||
assert(stream->dep_prev);
|
assert(stream->dep_prev);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue