Use -fvisibility=hidden for internal functions

This will improve performance since we can avoid indirect call of
internal functions.  The downside is we now require libnghttp2 static
library to run unit tests.
This commit is contained in:
Tatsuhiro Tsujikawa 2015-10-22 00:57:00 +09:00
parent 7b35c28c7d
commit ce74a30990
13 changed files with 311 additions and 111 deletions

View File

@ -677,6 +677,11 @@ CFLAGS=$ac_save_CFLAGS
AC_SUBST([WARNCFLAGS])
EXTRACFLAG=
AX_CHECK_COMPILE_FLAG([-fvisibility=hidden], [EXTRACFLAG="-fvisibility=hidden"])
AC_SUBST([EXTRACFLAG])
if test "x$debug" != "xno"; then
AC_DEFINE([DEBUGBUILD], [1], [Define to 1 to enable debug output.])
fi
@ -753,6 +758,7 @@ AC_MSG_NOTICE([summary of build options:
C preprocessor: ${CPP}
CPPFLAGS: ${CPPFLAGS}
WARNCFLAGS: ${WARNCFLAGS}
EXTRACFLAG: ${EXTRACFLAG}
LIBS: ${LIBS}
Library:
Shared: ${enable_shared}

View File

@ -24,7 +24,7 @@ SUBDIRS = includes
EXTRA_DIST = Makefile.msvc
AM_CFLAGS = $(WARNCFLAGS)
AM_CFLAGS = $(WARNCFLAGS) $(EXTRACFLAG)
AM_CPPFLAGS = -I$(srcdir)/includes -I$(builddir)/includes -DBUILDING_NGHTTP2 \
@DEFS@

View File

@ -57,7 +57,11 @@ extern "C" {
#define NGHTTP2_EXTERN __declspec(dllimport)
#endif /* !BUILDING_NGHTTP2 */
#else /* !defined(WIN32) */
#ifdef BUILDING_NGHTTP2
#define NGHTTP2_EXTERN __attribute__((visibility("default")))
#else /* !BUILDING_NGHTTP2 */
#define NGHTTP2_EXTERN
#endif /* !BUILDING_NGHTTP2 */
#endif /* !defined(WIN32) */
/**
@ -3753,6 +3757,48 @@ NGHTTP2_EXTERN size_t nghttp2_hd_deflate_bound(nghttp2_hd_deflater *deflater,
const nghttp2_nv *nva,
size_t nvlen);
/**
* @function
*
* Returns the number of entries that header table of |deflater|
* contains. This is the sum of the number of static table and
* dynamic table, so the return value is at least 61.
*/
NGHTTP2_EXTERN
size_t nghttp2_hd_deflate_get_num_table_entries(nghttp2_hd_deflater *deflater);
/**
* @function
*
* Returns the table entry denoted by |idx| from header table of
* |deflater|. The |idx| is 1-based, and idx=1 returns first entry of
* static table. idx=62 returns first entry of dynamic table if it
* exists. Specifying idx=0 is error, and this function returns NULL.
* If |idx| is strictly greater than the number of entries the tables
* contain, this function returns NULL.
*/
NGHTTP2_EXTERN
const nghttp2_nv *
nghttp2_hd_deflate_get_table_entry(nghttp2_hd_deflater *deflater, size_t idx);
/**
* @function
*
* Returns the used dynamic table size, including the overhead 32
* bytes per entry described in RFC 7541.
*/
NGHTTP2_EXTERN
size_t nghttp2_hd_deflate_get_dynamic_table_size(nghttp2_hd_deflater *deflater);
/**
* @function
*
* Returns the maximum dynamic table size.
*/
NGHTTP2_EXTERN
size_t
nghttp2_hd_deflate_get_max_dynamic_table_size(nghttp2_hd_deflater *deflater);
struct nghttp2_hd_inflater;
/**
@ -3945,6 +3991,48 @@ NGHTTP2_EXTERN ssize_t nghttp2_hd_inflate_hd(nghttp2_hd_inflater *inflater,
NGHTTP2_EXTERN int
nghttp2_hd_inflate_end_headers(nghttp2_hd_inflater *inflater);
/**
* @function
*
* Returns the number of entries that header table of |inflater|
* contains. This is the sum of the number of static table and
* dynamic table, so the return value is at least 61.
*/
NGHTTP2_EXTERN
size_t nghttp2_hd_inflate_get_num_table_entries(nghttp2_hd_inflater *inflater);
/**
* @function
*
* Returns the table entry denoted by |idx| from header table of
* |inflater|. The |idx| is 1-based, and idx=1 returns first entry of
* static table. idx=62 returns first entry of dynamic table if it
* exists. Specifying idx=0 is error, and this function returns NULL.
* If |idx| is strictly greater than the number of entries the tables
* contain, this function returns NULL.
*/
NGHTTP2_EXTERN
const nghttp2_nv *
nghttp2_hd_inflate_get_table_entry(nghttp2_hd_inflater *inflater, size_t idx);
/**
* @function
*
* Returns the used dynamic table size, including the overhead 32
* bytes per entry described in RFC 7541.
*/
NGHTTP2_EXTERN
size_t nghttp2_hd_inflate_get_dynamic_table_size(nghttp2_hd_inflater *inflater);
/**
* @function
*
* Returns the maximum dynamic table size.
*/
NGHTTP2_EXTERN
size_t
nghttp2_hd_inflate_get_max_dynamic_table_size(nghttp2_hd_inflater *inflater);
struct nghttp2_stream;
/**

View File

@ -2498,3 +2498,60 @@ ssize_t nghttp2_hd_decode_length(uint32_t *res, size_t *shift_ptr, int *final,
uint8_t *last, size_t prefix) {
return decode_length(res, shift_ptr, final, initial, shift, in, last, prefix);
}
static size_t hd_get_num_table_entries(nghttp2_hd_context *context) {
return context->hd_table.len + NGHTTP2_STATIC_TABLE_LENGTH;
}
static const nghttp2_nv *hd_get_table_entry(nghttp2_hd_context *context,
size_t idx) {
if (idx == 0) {
return NULL;
}
--idx;
if (!INDEX_RANGE_VALID(context, idx)) {
return NULL;
}
return &nghttp2_hd_table_get(context, idx)->nv;
}
size_t nghttp2_hd_deflate_get_num_table_entries(nghttp2_hd_deflater *deflater) {
return hd_get_num_table_entries(&deflater->ctx);
}
const nghttp2_nv *
nghttp2_hd_deflate_get_table_entry(nghttp2_hd_deflater *deflater, size_t idx) {
return hd_get_table_entry(&deflater->ctx, idx);
}
size_t
nghttp2_hd_deflate_get_dynamic_table_size(nghttp2_hd_deflater *deflater) {
return deflater->ctx.hd_table_bufsize;
}
size_t
nghttp2_hd_deflate_get_max_dynamic_table_size(nghttp2_hd_deflater *deflater) {
return deflater->ctx.hd_table_bufsize_max;
}
size_t nghttp2_hd_inflate_get_num_table_entries(nghttp2_hd_inflater *inflater) {
return hd_get_num_table_entries(&inflater->ctx);
}
const nghttp2_nv *
nghttp2_hd_inflate_get_table_entry(nghttp2_hd_inflater *inflater, size_t idx) {
return hd_get_table_entry(&inflater->ctx, idx);
}
size_t
nghttp2_hd_inflate_get_dynamic_table_size(nghttp2_hd_inflater *inflater) {
return inflater->ctx.hd_table_bufsize;
}
size_t
nghttp2_hd_inflate_get_max_dynamic_table_size(nghttp2_hd_inflater *inflater) {
return inflater->ctx.hd_table_bufsize_max;
}

View File

@ -375,8 +375,8 @@ int nghttp2_hd_emit_newname_block(nghttp2_bufs *bufs, nghttp2_nv *nv,
int nghttp2_hd_emit_table_size(nghttp2_bufs *bufs, size_t table_size);
/* For unittesting purpose */
NGHTTP2_EXTERN nghttp2_hd_entry *
nghttp2_hd_table_get(nghttp2_hd_context *context, size_t index);
nghttp2_hd_entry *nghttp2_hd_table_get(nghttp2_hd_context *context,
size_t index);
/* For unittesting purpose */
ssize_t nghttp2_hd_decode_length(uint32_t *res, size_t *shift_ptr, int *final,

View File

@ -42,8 +42,7 @@
/* The global variable for tests where we want to disable strict
preface handling. */
/* Specify NGHTTP2_EXTERN, so that we can test using Win build dll. */
NGHTTP2_EXTERN extern int nghttp2_enable_strict_preface;
extern int nghttp2_enable_strict_preface;
/*
* Option flags.

View File

@ -316,30 +316,20 @@ cdef extern from 'nghttp2/nghttp2.h':
int nghttp2_hd_inflate_end_headers(nghttp2_hd_inflater *inflater)
cdef extern from 'nghttp2_hd.h':
# This is macro
int NGHTTP2_HD_ENTRY_OVERHEAD
ctypedef enum nghttp2_hd_inflate_flag:
NGHTTP2_HD_INFLATE_EMIT
NGHTTP2_HD_INFLATE_FINAL
ctypedef struct nghttp2_hd_entry:
nghttp2_nv nv
uint8_t flags
ctypedef struct nghttp2_hd_ringbuf:
size_t len
ctypedef struct nghttp2_hd_context:
nghttp2_hd_ringbuf hd_table
ctypedef struct nghttp2_hd_deflater:
nghttp2_hd_context ctx
pass
ctypedef struct nghttp2_hd_inflater:
nghttp2_hd_context ctx
pass
nghttp2_hd_entry* nghttp2_hd_table_get(nghttp2_hd_context *context,
size_t index)
size_t nghttp2_hd_deflate_get_num_table_entries(nghttp2_hd_deflater *deflater)
const nghttp2_nv * nghttp2_hd_deflate_get_table_entry(nghttp2_hd_deflater *deflater, size_t idx)
size_t nghttp2_hd_inflate_get_num_table_entries(nghttp2_hd_inflater *inflater)
const nghttp2_nv *nghttp2_hd_inflate_get_table_entry(nghttp2_hd_inflater *inflater, size_t idx)

View File

@ -31,7 +31,7 @@ import logging
DEFAULT_HEADER_TABLE_SIZE = cnghttp2.NGHTTP2_DEFAULT_HEADER_TABLE_SIZE
DEFLATE_MAX_HEADER_TABLE_SIZE = 4096
HD_ENTRY_OVERHEAD = cnghttp2.NGHTTP2_HD_ENTRY_OVERHEAD
HD_ENTRY_OVERHEAD = 32
class HDTableEntry:
@ -44,18 +44,6 @@ class HDTableEntry:
def space(self):
return self.namelen + self.valuelen + HD_ENTRY_OVERHEAD
cdef _get_hd_table(cnghttp2.nghttp2_hd_context *ctx):
cdef int length = ctx.hd_table.len
cdef cnghttp2.nghttp2_hd_entry *entry
res = []
for i in range(length):
entry = cnghttp2.nghttp2_hd_table_get(ctx, i)
k = _get_pybytes(entry.nv.name, entry.nv.namelen)
v = _get_pybytes(entry.nv.value, entry.nv.valuelen)
res.append(HDTableEntry(k, entry.nv.namelen,
v, entry.nv.valuelen))
return res
cdef _get_pybytes(uint8_t *b, uint16_t blen):
return b[:blen]
@ -157,7 +145,16 @@ cdef class HDDeflater:
def get_hd_table(self):
'''Returns copy of current dynamic header table.'''
return _get_hd_table(&self._deflater.ctx)
cdef size_t length = cnghttp2.nghttp2_hd_deflate_get_num_table_entries(
self._deflater)
cdef const cnghttp2.nghttp2_nv *nv
res = []
for i in range(62, length + 1):
nv = cnghttp2.nghttp2_hd_deflate_get_table_entry(self._deflater, i)
k = _get_pybytes(nv.name, nv.namelen)
v = _get_pybytes(nv.value, nv.valuelen)
res.append(HDTableEntry(k, nv.namelen, v, nv.valuelen))
return res
cdef class HDInflater:
'''Performs header decompression.
@ -224,7 +221,16 @@ cdef class HDInflater:
def get_hd_table(self):
'''Returns copy of current dynamic header table.'''
return _get_hd_table(&self._inflater.ctx)
cdef size_t length = cnghttp2.nghttp2_hd_inflate_get_num_table_entries(
self._inflater)
cdef const cnghttp2.nghttp2_nv *nv
res = []
for i in range(62, length + 1):
nv = cnghttp2.nghttp2_hd_inflate_get_table_entry(self._inflater, i)
k = _get_pybytes(nv.name, nv.namelen)
v = _get_pybytes(nv.value, nv.valuelen)
res.append(HDTableEntry(k, nv.namelen, v, nv.valuelen))
return res
cdef _strerror(int liberror_code):
return cnghttp2.nghttp2_strerror(liberror_code).decode('utf-8')

View File

@ -29,28 +29,69 @@ static void dump_val(json_t *jent, const char *key, uint8_t *val, size_t len) {
json_object_set_new(jent, key, json_pack("s#", val, len));
}
json_t *dump_header_table(nghttp2_hd_context *context) {
#define NGHTTP2_HD_ENTRY_OVERHEAD 32
json_t *dump_deflate_header_table(nghttp2_hd_deflater *deflater) {
json_t *obj, *entries;
size_t i;
size_t len = nghttp2_hd_deflate_get_num_table_entries(deflater);
obj = json_object();
entries = json_array();
for (i = 0; i < context->hd_table.len; ++i) {
nghttp2_hd_entry *ent = nghttp2_hd_table_get(context, i);
/* The first index of dynamic table is 62 */
for (i = 62; i <= len; ++i) {
const nghttp2_nv *nv = nghttp2_hd_deflate_get_table_entry(deflater, i);
json_t *outent = json_object();
json_object_set_new(outent, "index", json_integer((json_int_t)(i + 1)));
dump_val(outent, "name", ent->nv.name, ent->nv.namelen);
dump_val(outent, "value", ent->nv.value, ent->nv.valuelen);
json_object_set_new(outent, "size", json_integer((json_int_t)(
ent->nv.namelen + ent->nv.valuelen +
NGHTTP2_HD_ENTRY_OVERHEAD)));
json_object_set_new(outent, "index", json_integer((json_int_t)i));
dump_val(outent, "name", nv->name, nv->namelen);
dump_val(outent, "value", nv->value, nv->valuelen);
json_object_set_new(outent, "size",
json_integer((json_int_t)(nv->namelen + nv->valuelen +
NGHTTP2_HD_ENTRY_OVERHEAD)));
json_array_append_new(entries, outent);
}
json_object_set_new(obj, "entries", entries);
json_object_set_new(obj, "size",
json_integer((json_int_t)(context->hd_table_bufsize)));
json_object_set_new(obj, "max_size", json_integer((json_int_t)(
context->hd_table_bufsize_max)));
json_object_set_new(
obj, "size",
json_integer(
(json_int_t)nghttp2_hd_deflate_get_dynamic_table_size(deflater)));
json_object_set_new(
obj, "max_size",
json_integer(
(json_int_t)nghttp2_hd_deflate_get_max_dynamic_table_size(deflater)));
return obj;
}
json_t *dump_inflate_header_table(nghttp2_hd_inflater *inflater) {
json_t *obj, *entries;
size_t i;
size_t len = nghttp2_hd_inflate_get_num_table_entries(inflater);
obj = json_object();
entries = json_array();
/* The first index of dynamic table is 62 */
for (i = 62; i <= len; ++i) {
const nghttp2_nv *nv = nghttp2_hd_inflate_get_table_entry(inflater, i);
json_t *outent = json_object();
json_object_set_new(outent, "index", json_integer((json_int_t)i));
dump_val(outent, "name", nv->name, nv->namelen);
dump_val(outent, "value", nv->value, nv->valuelen);
json_object_set_new(outent, "size",
json_integer((json_int_t)(nv->namelen + nv->valuelen +
NGHTTP2_HD_ENTRY_OVERHEAD)));
json_array_append_new(entries, outent);
}
json_object_set_new(obj, "entries", entries);
json_object_set_new(
obj, "size",
json_integer(
(json_int_t)nghttp2_hd_inflate_get_dynamic_table_size(inflater)));
json_object_set_new(
obj, "max_size",
json_integer(
(json_int_t)nghttp2_hd_inflate_get_max_dynamic_table_size(inflater)));
return obj;
}

View File

@ -27,13 +27,19 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif // HAVE_CONFIG_H
#endif /* HAVE_CONFIG_H */
#include <jansson.h>
#include "nghttp2_hd.h"
#include <nghttp2/nghttp2.h>
json_t *dump_header_table(nghttp2_hd_context *context);
#ifdef __cplusplus
extern "C" {
#endif
json_t *dump_deflate_header_table(nghttp2_hd_deflater *deflater);
json_t *dump_inflate_header_table(nghttp2_hd_inflater *inflater);
json_t *dump_header(const uint8_t *name, size_t namelen, const uint8_t *value,
size_t vlauelen);
@ -44,4 +50,8 @@ void output_json_header(void);
void output_json_footer(void);
#endif // NGHTTP2_COMP_HELPER_H
#ifdef __cplusplus
}
#endif
#endif /* NGHTTP2_COMP_HELPER_H */

View File

@ -41,15 +41,10 @@
#include <jansson.h>
extern "C" {
#include "nghttp2_hd.h"
#include "nghttp2_frame.h"
#include "comp_helper.h"
}
#include <nghttp2/nghttp2.h>
#include "template.h"
#include "comp_helper.h"
namespace nghttp2 {
@ -80,30 +75,23 @@ static void to_hex(char *dest, const uint8_t *src, size_t len) {
}
}
static void output_to_json(nghttp2_hd_deflater *deflater, nghttp2_bufs *bufs,
size_t inputlen, const std::vector<nghttp2_nv> &nva,
int seq) {
auto len = nghttp2_bufs_len(bufs);
auto hex = std::vector<char>(len * 2);
static void output_to_json(nghttp2_hd_deflater *deflater, const uint8_t *buf,
size_t buflen, size_t inputlen,
const std::vector<nghttp2_nv> &nva, int seq) {
auto hex = std::vector<char>(buflen * 2);
auto obj = json_object();
auto comp_ratio = inputlen == 0 ? 0.0 : (double)len / inputlen * 100;
auto comp_ratio = inputlen == 0 ? 0.0 : (double)buflen / inputlen * 100;
json_object_set_new(obj, "seq", json_integer(seq));
json_object_set_new(obj, "input_length", json_integer(inputlen));
json_object_set_new(obj, "output_length", json_integer(len));
json_object_set_new(obj, "output_length", json_integer(buflen));
json_object_set_new(obj, "percentage_of_original_size",
json_real(comp_ratio));
auto hexp = hex.data();
for (auto ci = bufs->head; ci; ci = ci->next) {
auto buf = &ci->buf;
to_hex(hexp, buf->pos, nghttp2_buf_len(buf));
hexp += nghttp2_buf_len(buf);
}
if (len == 0) {
if (buflen == 0) {
json_object_set_new(obj, "wire", json_string(""));
} else {
to_hex(hex.data(), buf, buflen);
json_object_set_new(obj, "wire", json_pack("s#", hex.data(), hex.size()));
}
json_object_set_new(obj, "headers", dump_headers(nva.data(), nva.size()));
@ -113,7 +101,8 @@ static void output_to_json(nghttp2_hd_deflater *deflater, nghttp2_bufs *bufs,
json_integer(config.table_size));
}
if (config.dump_header_table) {
json_object_set_new(obj, "header_table", dump_header_table(&deflater->ctx));
json_object_set_new(obj, "header_table",
dump_deflate_header_table(deflater));
}
json_dumpf(obj, stdout, JSON_PRESERVE_ORDER | JSON_INDENT(2));
printf("\n");
@ -124,22 +113,19 @@ static void deflate_hd(nghttp2_hd_deflater *deflater,
const std::vector<nghttp2_nv> &nva, size_t inputlen,
int seq) {
ssize_t rv;
nghttp2_bufs bufs;
std::array<uint8_t, 64_k> buf;
nghttp2_bufs_init2(&bufs, 4_k, 16, 0, nghttp2_mem_default());
rv = nghttp2_hd_deflate_hd_bufs(deflater, &bufs, (nghttp2_nv *)nva.data(),
nva.size());
rv = nghttp2_hd_deflate_hd(deflater, buf.data(), buf.size(),
(nghttp2_nv *)nva.data(), nva.size());
if (rv < 0) {
fprintf(stderr, "deflate failed with error code %zd at %d\n", rv, seq);
exit(EXIT_FAILURE);
}
input_sum += inputlen;
output_sum += nghttp2_bufs_len(&bufs);
output_sum += rv;
output_to_json(deflater, &bufs, inputlen, nva, seq);
nghttp2_bufs_free(&bufs);
output_to_json(deflater, buf.data(), rv, inputlen, nva, seq);
}
static int deflate_hd_json(json_t *obj, nghttp2_hd_deflater *deflater,
@ -394,8 +380,8 @@ static struct option long_options[] = {
int main(int argc, char **argv) {
char *end;
config.table_size = NGHTTP2_HD_DEFAULT_MAX_BUFFER_SIZE;
config.deflate_table_size = NGHTTP2_HD_DEFAULT_MAX_DEFLATE_BUFFER_SIZE;
config.table_size = 4_k;
config.deflate_table_size = 4_k;
config.http1text = 0;
config.dump_header_table = 0;
while (1) {

View File

@ -41,15 +41,10 @@
#include <jansson.h>
extern "C" {
#include "nghttp2_hd.h"
#include "nghttp2_frame.h"
#include "comp_helper.h"
}
#include <nghttp2/nghttp2.h>
#include "template.h"
#include "comp_helper.h"
namespace nghttp2 {
@ -80,12 +75,15 @@ static void to_json(nghttp2_hd_inflater *inflater, json_t *headers,
json_object_set_new(obj, "seq", json_integer(seq));
json_object_set(obj, "wire", wire);
json_object_set(obj, "headers", headers);
if (old_settings_table_size != inflater->settings_hd_table_bufsize_max) {
auto max_dyn_table_size =
nghttp2_hd_inflate_get_max_dynamic_table_size(inflater);
if (old_settings_table_size != max_dyn_table_size) {
json_object_set_new(obj, "header_table_size",
json_integer(inflater->settings_hd_table_bufsize_max));
json_integer(max_dyn_table_size));
}
if (config.dump_header_table) {
json_object_set_new(obj, "header_table", dump_header_table(&inflater->ctx));
json_object_set_new(obj, "header_table",
dump_inflate_header_table(inflater));
}
json_dumpf(obj, stdout, JSON_INDENT(2) | JSON_PRESERVE_ORDER);
json_decref(obj);
@ -96,7 +94,8 @@ static int inflate_hd(json_t *obj, nghttp2_hd_inflater *inflater, int seq) {
ssize_t rv;
nghttp2_nv nv;
int inflate_flags;
size_t old_settings_table_size = inflater->settings_hd_table_bufsize_max;
size_t old_settings_table_size =
nghttp2_hd_inflate_get_max_dynamic_table_size(inflater);
auto wire = json_object_get(obj, "wire");

View File

@ -33,8 +33,6 @@
#include "nghttp2_frame.h"
#include "nghttp2_test_helper.h"
#define GET_TABLE_ENT(context, index) nghttp2_hd_table_get(context, index)
void test_nghttp2_hd_deflate(void) {
nghttp2_hd_deflater deflater;
nghttp2_hd_inflater inflater;
@ -261,6 +259,7 @@ void test_nghttp2_hd_inflate_indname_noinc(void) {
CU_ASSERT(1 == out.nvlen);
assert_nv_equal(&nv[i], out.nva, 1, mem);
CU_ASSERT(0 == inflater.ctx.hd_table.len);
CU_ASSERT(61 == nghttp2_hd_inflate_get_num_table_entries(&inflater));
nva_out_reset(&out, mem);
nghttp2_bufs_reset(&bufs);
@ -295,10 +294,16 @@ void test_nghttp2_hd_inflate_indname_inc(void) {
CU_ASSERT(1 == out.nvlen);
assert_nv_equal(&nv, out.nva, 1, mem);
CU_ASSERT(1 == inflater.ctx.hd_table.len);
assert_nv_equal(
&nv, &GET_TABLE_ENT(&inflater.ctx, NGHTTP2_STATIC_TABLE_LENGTH +
inflater.ctx.hd_table.len - 1)->nv,
1, mem);
CU_ASSERT(62 == nghttp2_hd_inflate_get_num_table_entries(&inflater));
assert_nv_equal(&nv,
&nghttp2_hd_table_get(&inflater.ctx,
NGHTTP2_STATIC_TABLE_LENGTH +
inflater.ctx.hd_table.len - 1)->nv,
1, mem);
assert_nv_equal(&nv, nghttp2_hd_inflate_get_table_entry(
&inflater, NGHTTP2_STATIC_TABLE_LENGTH +
inflater.ctx.hd_table.len),
1, mem);
nva_out_reset(&out, mem);
nghttp2_bufs_free(&bufs);
@ -351,6 +356,7 @@ void test_nghttp2_hd_inflate_indname_inc_eviction(void) {
nghttp2_bufs_reset(&bufs);
CU_ASSERT(3 == inflater.ctx.hd_table.len);
CU_ASSERT(64 == nghttp2_hd_inflate_get_num_table_entries(&inflater));
nghttp2_bufs_free(&bufs);
nghttp2_hd_inflate_free(&inflater);
@ -423,10 +429,11 @@ void test_nghttp2_hd_inflate_newname_inc(void) {
CU_ASSERT(1 == out.nvlen);
assert_nv_equal(&nv, out.nva, 1, mem);
CU_ASSERT(1 == inflater.ctx.hd_table.len);
assert_nv_equal(
&nv, &GET_TABLE_ENT(&inflater.ctx, NGHTTP2_STATIC_TABLE_LENGTH +
inflater.ctx.hd_table.len - 1)->nv,
1, mem);
assert_nv_equal(&nv,
&nghttp2_hd_table_get(&inflater.ctx,
NGHTTP2_STATIC_TABLE_LENGTH +
inflater.ctx.hd_table.len - 1)->nv,
1, mem);
nva_out_reset(&out, mem);
nghttp2_bufs_free(&bufs);
@ -675,10 +682,12 @@ void test_nghttp2_hd_change_table_size(void) {
CU_ASSERT(0 == rv);
CU_ASSERT(blocklen > 0);
CU_ASSERT(2 == deflater.ctx.hd_table.len);
CU_ASSERT(63 == nghttp2_hd_deflate_get_num_table_entries(&deflater));
CU_ASSERT(4096 == deflater.ctx.hd_table_bufsize_max);
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
CU_ASSERT(2 == inflater.ctx.hd_table.len);
CU_ASSERT(63 == nghttp2_hd_inflate_get_num_table_entries(&inflater));
CU_ASSERT(4096 == inflater.ctx.hd_table_bufsize_max);
CU_ASSERT(8000 == inflater.settings_hd_table_bufsize_max);
@ -700,10 +709,12 @@ void test_nghttp2_hd_change_table_size(void) {
CU_ASSERT(0 == rv);
CU_ASSERT(blocklen > 0);
CU_ASSERT(2 == deflater.ctx.hd_table.len);
CU_ASSERT(63 == nghttp2_hd_deflate_get_num_table_entries(&deflater));
CU_ASSERT(1024 == deflater.ctx.hd_table_bufsize_max);
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
CU_ASSERT(2 == inflater.ctx.hd_table.len);
CU_ASSERT(63 == nghttp2_hd_inflate_get_num_table_entries(&inflater));
CU_ASSERT(1024 == inflater.ctx.hd_table_bufsize_max);
CU_ASSERT(1024 == inflater.settings_hd_table_bufsize_max);
@ -715,9 +726,11 @@ void test_nghttp2_hd_change_table_size(void) {
CU_ASSERT(0 == nghttp2_hd_deflate_change_table_size(&deflater, 0));
CU_ASSERT(0 == deflater.ctx.hd_table.len);
CU_ASSERT(61 == nghttp2_hd_deflate_get_num_table_entries(&deflater));
CU_ASSERT(0 == deflater.ctx.hd_table_bufsize_max);
CU_ASSERT(0 == inflater.ctx.hd_table.len);
CU_ASSERT(61 == nghttp2_hd_inflate_get_num_table_entries(&inflater));
CU_ASSERT(0 == inflater.ctx.hd_table_bufsize_max);
CU_ASSERT(0 == inflater.settings_hd_table_bufsize_max);
@ -727,10 +740,12 @@ void test_nghttp2_hd_change_table_size(void) {
CU_ASSERT(0 == rv);
CU_ASSERT(blocklen > 0);
CU_ASSERT(0 == deflater.ctx.hd_table.len);
CU_ASSERT(61 == nghttp2_hd_deflate_get_num_table_entries(&deflater));
CU_ASSERT(0 == deflater.ctx.hd_table_bufsize_max);
CU_ASSERT(blocklen == inflate_hd(&inflater, &out, &bufs, 0, mem));
CU_ASSERT(0 == inflater.ctx.hd_table.len);
CU_ASSERT(61 == nghttp2_hd_inflate_get_num_table_entries(&inflater));
CU_ASSERT(0 == inflater.ctx.hd_table_bufsize_max);
CU_ASSERT(0 == inflater.settings_hd_table_bufsize_max);
@ -752,8 +767,9 @@ void test_nghttp2_hd_change_table_size(void) {
CU_ASSERT(0 == nghttp2_hd_deflate_change_table_size(&deflater, 8000));
CU_ASSERT(8000 == deflater.ctx.hd_table_bufsize_max);
CU_ASSERT(8000 == nghttp2_hd_deflate_get_max_dynamic_table_size(&deflater));
CU_ASSERT(8000 == inflater.ctx.hd_table_bufsize_max);
CU_ASSERT(8000 == nghttp2_hd_inflate_get_max_dynamic_table_size(&inflater));
CU_ASSERT(8000 == inflater.settings_hd_table_bufsize_max);
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva, 2);
@ -776,8 +792,10 @@ void test_nghttp2_hd_change_table_size(void) {
CU_ASSERT(0 == nghttp2_hd_deflate_change_table_size(&deflater, 16383));
CU_ASSERT(8192 == deflater.ctx.hd_table_bufsize_max);
CU_ASSERT(8192 == nghttp2_hd_deflate_get_max_dynamic_table_size(&deflater));
CU_ASSERT(16383 == inflater.ctx.hd_table_bufsize_max);
CU_ASSERT(16383 == nghttp2_hd_inflate_get_max_dynamic_table_size(&inflater));
CU_ASSERT(16383 == inflater.settings_hd_table_bufsize_max);
rv = nghttp2_hd_deflate_hd_bufs(&deflater, &bufs, nva, 2);