aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/transport
diff options
context:
space:
mode:
authorGravatar ctiller <ctiller@google.com>2015-01-12 11:23:09 -0800
committerGravatar Nicolas Noble <nnoble@google.com>2015-01-12 14:03:28 -0800
commit00297df63b5c2d660dafa5314b3c87a57cfaf0b8 (patch)
treea4c3b1e3f918708c9788df31a8ff5ad8b91f2809 /test/core/transport
parent45fc159eed8d7b9be2277f81e3f43de7e5daabc2 (diff)
Ensure flow control callbacks happen outside the transport lock.
Split encoding into two phases: a collection phase to decide on what is allowed (by flow control) to be sent, and a framing phase when the data is actually sent. Perform the second phase outside of the transport mutex (but serially, guarded by t->writing) and make flow control callbacks during that phase. This will allow us to make further transport level calls in response to flow control callbacks, and will be needed by the forthcoming async api for C++. Change on 2015/01/12 by ctiller <ctiller@google.com> ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=83774409
Diffstat (limited to 'test/core/transport')
-rw-r--r--test/core/transport/chttp2/stream_encoder_test.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/test/core/transport/chttp2/stream_encoder_test.c b/test/core/transport/chttp2/stream_encoder_test.c
index 3ee11d94e8..ba552786db 100644
--- a/test/core/transport/chttp2/stream_encoder_test.c
+++ b/test/core/transport/chttp2/stream_encoder_test.c
@@ -64,15 +64,20 @@ static gpr_slice create_test_slice(size_t length) {
static void verify_sopb(size_t window_available, int eof,
size_t expect_window_used, const char *expected) {
gpr_slice_buffer output;
+ grpc_stream_op_buffer encops;
gpr_slice merged;
gpr_slice expect = parse_hexstring(expected);
gpr_slice_buffer_init(&output);
+ grpc_sopb_init(&encops);
GPR_ASSERT(expect_window_used ==
- grpc_chttp2_encode_some(g_sopb.ops, &g_sopb.nops, eof, &output,
- window_available, 0xdeadbeef,
- &g_compressor));
+ grpc_chttp2_preencode(g_sopb.ops, &g_sopb.nops, window_available,
+ &encops));
+ grpc_chttp2_encode(encops.ops, encops.nops, eof, 0xdeadbeef, &g_compressor,
+ &output);
+ encops.nops = 0;
merged = grpc_slice_merge(output.slices, output.count);
gpr_slice_buffer_destroy(&output);
+ grpc_sopb_destroy(&encops);
if (0 != gpr_slice_cmp(merged, expect)) {
char *expect_str =
@@ -240,21 +245,25 @@ static void test_decode_random_headers_inner(int max_len) {
test_decode_random_header_state st;
gpr_slice_buffer output;
gpr_slice merged;
+ grpc_stream_op_buffer encops;
grpc_chttp2_hpack_parser parser;
grpc_chttp2_hpack_parser_init(&parser, g_mdctx);
+ grpc_sopb_init(&encops);
gpr_log(GPR_INFO, "max_len = %d", max_len);
- for (i = 0; i < 100000; i++) {
+ for (i = 0; i < 10000; i++) {
randstr(st.key, max_len);
randstr(st.value, max_len);
add_sopb_header(st.key, st.value);
gpr_slice_buffer_init(&output);
- GPR_ASSERT(0 == grpc_chttp2_encode_some(g_sopb.ops, &g_sopb.nops, 0,
- &output, 0, 0xdeadbeef,
- &g_compressor));
+ GPR_ASSERT(0 ==
+ grpc_chttp2_preencode(g_sopb.ops, &g_sopb.nops, 0, &encops));
+ grpc_chttp2_encode(encops.ops, encops.nops, 0, 0xdeadbeef, &g_compressor,
+ &output);
+ encops.nops = 0;
merged = grpc_slice_merge(output.slices, output.count);
gpr_slice_buffer_destroy(&output);
@@ -269,6 +278,7 @@ static void test_decode_random_headers_inner(int max_len) {
}
grpc_chttp2_hpack_parser_destroy(&parser);
+ grpc_sopb_destroy(&encops);
}
#define DECL_TEST_DECODE_RANDOM_HEADERS(n) \