Fixed bad merge.

pull/2135/head
David Garcia Quintas 10 years ago
parent e75d4c8531
commit 92ce588559
  1. 9
      src/core/channel/compress_filter.c
  2. 14
      src/core/surface/call.c
  3. 47
      test/core/end2end/tests/request_with_compressed_payload.c

@ -166,8 +166,8 @@ static void process_send_ops(grpc_call_element *elem,
sop->data.begin_message.length = calld->slices.length;
sop->data.begin_message.flags |= GRPC_WRITE_INTERNAL_COMPRESS;
} else {
/* either because the user requested the exception or because compressing
* would have resulted in a larger output */
/* either because the user requested the exception or because
* compressing would have resulted in a larger output */
calld->compression_algorithm = GRPC_COMPRESS_NONE;
/* reset the flag compression bit */
sop->data.begin_message.flags &= ~GRPC_WRITE_INTERNAL_COMPRESS;
@ -181,9 +181,10 @@ static void process_send_ops(grpc_call_element *elem,
break;
case GRPC_OP_SLICE:
if (did_compress) {
GPR_ASSERT(j < calld->slices.count);
gpr_slice_unref(sop->data.slice);
sop->data.slice = gpr_slice_ref(calld->slices.slices[j++]);
if (j < calld->slices.count) {
sop->data.slice = gpr_slice_ref(calld->slices.slices[j++]);
}
}
break;
case GRPC_NO_OP:

@ -1207,20 +1207,12 @@ static void destroy_compression(void *ignored) {}
static gpr_uint32 decode_compression(grpc_mdelem *md) {
grpc_compression_level clevel;
void *user_data = grpc_mdelem_get_user_data(md, destroy_status);
void *user_data = grpc_mdelem_get_user_data(md, destroy_compression);
if (user_data) {
clevel = ((grpc_compression_level)(gpr_intptr)user_data) - COMPRESS_OFFSET;
} else {
gpr_uint32 parsed_clevel_bytes;
if (gpr_parse_bytes_to_uint32(grpc_mdstr_as_c_string(md->value),
GPR_SLICE_LENGTH(md->value->slice),
&parsed_clevel_bytes)) {
/* the following cast is safe, as a gpr_uint32 should be able to hold all
* possible values of the grpc_compression_level enum */
clevel = (grpc_compression_level) parsed_clevel_bytes;
} else {
clevel = GRPC_COMPRESS_LEVEL_NONE; /* could not parse, no compression */
}
GPR_ASSERT(sizeof(clevel) == GPR_SLICE_LENGTH(md->value->slice));
memcpy(&clevel, GPR_SLICE_START_PTR(md->value->slice), sizeof(clevel));
grpc_mdelem_set_user_data(md, destroy_compression,
(void *)(gpr_intptr)(clevel + COMPRESS_OFFSET));
}

@ -77,8 +77,8 @@ static void drain_cq(grpc_completion_queue *cq) {
static void shutdown_server(grpc_end2end_test_fixture *f) {
if (!f->server) return;
grpc_server_shutdown_and_notify(f->server, f->server_cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->server_cq, tag(1000),
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000),
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))
.type == GRPC_OP_COMPLETE);
grpc_server_destroy(f->server);
@ -95,12 +95,9 @@ static void end_test(grpc_end2end_test_fixture *f) {
shutdown_server(f);
shutdown_client(f);
grpc_completion_queue_shutdown(f->server_cq);
drain_cq(f->server_cq);
grpc_completion_queue_destroy(f->server_cq);
grpc_completion_queue_shutdown(f->client_cq);
drain_cq(f->client_cq);
grpc_completion_queue_destroy(f->client_cq);
grpc_completion_queue_shutdown(f->cq);
drain_cq(f->cq);
grpc_completion_queue_destroy(f->cq);
}
static void request_with_payload_template(
@ -116,8 +113,6 @@ static void request_with_payload_template(
grpc_channel_args *client_args;
grpc_channel_args *server_args;
grpc_end2end_test_fixture f;
cq_verifier *v_client;
cq_verifier *v_server;
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array initial_metadata_recv;
@ -129,6 +124,7 @@ static void request_with_payload_template(
char *details = NULL;
size_t details_capacity = 0;
int was_cancelled = 2;
cq_verifier *cqv;
char str[1024]; memset(&str[0], 1023, 'x'); str[1023] = '\0';
request_payload_slice = gpr_slice_from_copied_string(str);
@ -140,10 +136,9 @@ static void request_with_payload_template(
NULL, requested_compression_level);
f = begin_test(config, test_name, client_args, server_args);
v_client = cq_verifier_create(f.client_cq);
v_server = cq_verifier_create(f.server_cq);
cqv = cq_verifier_create(f.cq);
c = grpc_channel_create_call(f.client, f.client_cq, "/foo",
c = grpc_channel_create_call(f.client, f.cq, "/foo",
"foo.test.google.fr", deadline);
GPR_ASSERT(c);
@ -179,10 +174,10 @@ static void request_with_payload_template(
GPR_ASSERT(GRPC_CALL_OK ==
grpc_server_request_call(f.server, &s, &call_details,
&request_metadata_recv, f.server_cq,
f.server_cq, tag(101)));
cq_expect_completion(v_server, tag(101), 1);
cq_verify(v_server);
&request_metadata_recv, f.cq,
f.cq, tag(101)));
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
@ -195,8 +190,8 @@ static void request_with_payload_template(
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(s, ops, op - ops, tag(102)));
cq_expect_completion(v_server, tag(102), 1);
cq_verify(v_server);
cq_expect_completion(cqv, tag(102), 1);
cq_verify(cqv);
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
@ -211,11 +206,9 @@ static void request_with_payload_template(
op++;
GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(s, ops, op - ops, tag(103)));
cq_expect_completion(v_server, tag(103), 1);
cq_verify(v_server);
cq_expect_completion(v_client, tag(1), 1);
cq_verify(v_client);
cq_expect_completion(cqv, tag(103), 1);
cq_expect_completion(cqv, tag(1), 1);
cq_verify(cqv);
GPR_ASSERT(status == GRPC_STATUS_OK);
GPR_ASSERT(0 == strcmp(details, "xyz"));
@ -238,8 +231,7 @@ static void request_with_payload_template(
grpc_call_destroy(c);
grpc_call_destroy(s);
cq_verifier_destroy(v_client);
cq_verifier_destroy(v_server);
cq_verifier_destroy(cqv);
grpc_byte_buffer_destroy(request_payload);
grpc_byte_buffer_destroy(request_payload_recv);
@ -274,9 +266,8 @@ static void test_invoke_request_with_uncompressed_payload(
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_NONE));
}
void grpc_end2end_tests(grpc_end2end_test_config config) {
test_invoke_request_with_exceptionally_uncompressed_payload(config);
test_invoke_request_with_compressed_payload(config);
test_invoke_request_with_uncompressed_payload(config);
test_invoke_request_with_compressed_payload(config);
}

Loading…
Cancel
Save