aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2015-11-11 01:14:39 +0000
committerGravatar Craig Tiller <ctiller@google.com>2015-11-11 01:14:39 +0000
commit82e249b8165dbe2ddb6d76bf938a677d85341a8f (patch)
treeb9cb982e819b7a95703f03acdda1aedd5558e133
parent575b4200a72dfdb081fb8c9063cad8d94841dd16 (diff)
Small fixes
-rw-r--r--src/core/transport/chttp2/hpack_table.c11
-rw-r--r--test/core/end2end/fixtures/proxy.c4
-rw-r--r--test/core/transport/chttp2/hpack_parser_test.c7
-rw-r--r--test/core/transport/chttp2/hpack_table_test.c27
4 files changed, 28 insertions, 21 deletions
diff --git a/src/core/transport/chttp2/hpack_table.c b/src/core/transport/chttp2/hpack_table.c
index 0b034b72a4..f2362b056c 100644
--- a/src/core/transport/chttp2/hpack_table.c
+++ b/src/core/transport/chttp2/hpack_table.c
@@ -294,10 +294,10 @@ int grpc_chttp2_hptbl_add(grpc_chttp2_hptbl *tbl, grpc_mdelem *md) {
GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD;
if (tbl->current_table_bytes > tbl->max_bytes) {
- gpr_log(
- GPR_ERROR,
- "HPACK max table size reduced to %d but not reflected by hpack stream",
- tbl->max_bytes);
+ gpr_log(GPR_ERROR,
+ "HPACK max table size reduced to %d but not reflected by hpack "
+ "stream (still at %d)",
+ tbl->max_bytes, tbl->current_table_bytes);
return 0;
}
@@ -324,7 +324,8 @@ int grpc_chttp2_hptbl_add(grpc_chttp2_hptbl *tbl, grpc_mdelem *md) {
}
/* copy the finalized entry in */
- tbl->ents[(tbl->first_ent + tbl->num_ents) % tbl->cap_entries] = GRPC_MDELEM_REF(md);
+ tbl->ents[(tbl->first_ent + tbl->num_ents) % tbl->cap_entries] =
+ GRPC_MDELEM_REF(md);
/* update accounting values */
tbl->num_ents++;
diff --git a/test/core/end2end/fixtures/proxy.c b/test/core/end2end/fixtures/proxy.c
index b793358653..434e75dd15 100644
--- a/test/core/end2end/fixtures/proxy.c
+++ b/test/core/end2end/fixtures/proxy.c
@@ -157,9 +157,7 @@ static void unrefpc(proxy_call *pc, const char *reason) {
}
}
-static void refpc(proxy_call *pc, const char *reason) {
- gpr_ref(&pc->refs);
-}
+static void refpc(proxy_call *pc, const char *reason) { gpr_ref(&pc->refs); }
static void on_c2p_sent_initial_metadata(void *arg, int success) {
proxy_call *pc = arg;
diff --git a/test/core/transport/chttp2/hpack_parser_test.c b/test/core/transport/chttp2/hpack_parser_test.c
index e4cabeae3b..c6b35fba79 100644
--- a/test/core/transport/chttp2/hpack_parser_test.c
+++ b/test/core/transport/chttp2/hpack_parser_test.c
@@ -151,8 +151,8 @@ static void test_vectors(grpc_slice_split_mode mode) {
grpc_chttp2_hpack_parser_destroy(&parser);
grpc_chttp2_hpack_parser_init(&parser, mdctx);
-grpc_chttp2_hptbl_set_max_bytes(&parser.table, 256);
-grpc_chttp2_hptbl_set_current_table_size(&parser.table, 256);
+ grpc_chttp2_hptbl_set_max_bytes(&parser.table, 256);
+ grpc_chttp2_hptbl_set_current_table_size(&parser.table, 256);
/* D.5.1 */
test_vector(&parser, mode,
"4803 3330 3258 0770 7269 7661 7465 611d"
@@ -185,7 +185,8 @@ grpc_chttp2_hptbl_set_current_table_size(&parser.table, 256);
grpc_chttp2_hpack_parser_destroy(&parser);
grpc_chttp2_hpack_parser_init(&parser, mdctx);
- parser.table.max_bytes = 256;
+ grpc_chttp2_hptbl_set_max_bytes(&parser.table, 256);
+ grpc_chttp2_hptbl_set_current_table_size(&parser.table, 256);
/* D.6.1 */
test_vector(&parser, mode,
"4882 6402 5885 aec3 771a 4b61 96d0 7abe"
diff --git a/test/core/transport/chttp2/hpack_table_test.c b/test/core/transport/chttp2/hpack_table_test.c
index 5bdeeafb67..5eb52d6d9a 100644
--- a/test/core/transport/chttp2/hpack_table_test.c
+++ b/test/core/transport/chttp2/hpack_table_test.c
@@ -143,10 +143,12 @@ static void test_many_additions(void) {
grpc_chttp2_hptbl_init(&tbl, mdctx);
for (i = 0; i < 1000000; i++) {
+ grpc_mdelem *elem;
gpr_asprintf(&key, "K:%d", i);
gpr_asprintf(&value, "VALUE:%d", i);
- GPR_ASSERT(grpc_chttp2_hptbl_add(
- &tbl, grpc_mdelem_from_strings(mdctx, key, value)));
+ elem = grpc_mdelem_from_strings(mdctx, key, value);
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem));
+ GRPC_MDELEM_UNREF(elem);
assert_index(&tbl, 1 + GRPC_CHTTP2_LAST_STATIC_ENTRY, key, value);
gpr_free(key);
gpr_free(value);
@@ -177,18 +179,22 @@ static void test_find(void) {
gpr_uint32 i;
char buffer[32];
grpc_mdctx *mdctx;
+ grpc_mdelem *elem;
grpc_chttp2_hptbl_find_result r;
LOG_TEST("test_find");
mdctx = grpc_mdctx_create();
grpc_chttp2_hptbl_init(&tbl, mdctx);
- GPR_ASSERT(grpc_chttp2_hptbl_add(
- &tbl, grpc_mdelem_from_strings(mdctx, "abc", "xyz")));
- GPR_ASSERT(grpc_chttp2_hptbl_add(
- &tbl, grpc_mdelem_from_strings(mdctx, "abc", "123")));
- GPR_ASSERT(
- grpc_chttp2_hptbl_add(&tbl, grpc_mdelem_from_strings(mdctx, "x", "1")));
+ elem = grpc_mdelem_from_strings(mdctx, "abc", "xyz");
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem));
+ GRPC_MDELEM_UNREF(elem);
+ elem = grpc_mdelem_from_strings(mdctx, "abc", "123");
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem));
+ GRPC_MDELEM_UNREF(elem);
+ elem = grpc_mdelem_from_strings(mdctx, "x", "1");
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem));
+ GRPC_MDELEM_UNREF(elem);
r = find_simple(&tbl, "abc", "123");
GPR_ASSERT(r.index == 2 + GRPC_CHTTP2_LAST_STATIC_ENTRY);
@@ -237,8 +243,9 @@ static void test_find(void) {
/* overflow the string buffer, check find still works */
for (i = 0; i < 10000; i++) {
gpr_ltoa(i, buffer);
- GPR_ASSERT(grpc_chttp2_hptbl_add(
- &tbl, grpc_mdelem_from_strings(mdctx, "test", buffer)));
+ elem = grpc_mdelem_from_strings(mdctx, "test", buffer);
+ GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem));
+ GRPC_MDELEM_UNREF(elem);
}
r = find_simple(&tbl, "abc", "123");