Allow servers to select compression level via initial MD.

Setting the newly added compression_level field of
grpc_op::send_initial_metadata by a server now has the effect of
applying that compression level for the subsequent call messages leaving
the server. The ultimate meaning of the level depends on the client's
supported compression algorithms.
pull/6481/head
David Garcia Quintas 9 years ago
parent c916c1ce17
commit a301eaade8
  1. 1
      grpc.def
  2. 6
      include/grpc++/impl/codegen/call.h
  3. 7
      include/grpc/compression.h
  4. 1
      include/grpc/impl/codegen/grpc_types.h
  5. 56
      src/core/lib/compression/compression_algorithm.c
  6. 159
      src/core/lib/surface/call.c
  7. 11
      src/csharp/ext/grpc_csharp_ext.c
  8. 1
      src/objective-c/GRPCClient/private/GRPCWrappedCall.m
  9. 1
      src/php/ext/grpc/call.c
  10. 2
      src/python/grpcio/grpc/_cython/imports.generated.c
  11. 3
      src/python/grpcio/grpc/_cython/imports.generated.h
  12. 2
      src/ruby/ext/grpc/rb_grpc_imports.generated.c
  13. 3
      src/ruby/ext/grpc/rb_grpc_imports.generated.h
  14. 1
      test/core/bad_ssl/bad_ssl_test.c
  15. 3
      test/core/client_config/lb_policies_test.c
  16. 1
      test/core/client_config/set_initial_connect_string_test.c
  17. 97
      test/core/compression/compression_test.c
  18. 2
      test/core/end2end/dualstack_socket_test.c
  19. 1
      test/core/end2end/fixtures/h2_ssl_cert.c
  20. 2
      test/core/end2end/fixtures/proxy.c
  21. 3
      test/core/end2end/fuzzers/client_fuzzer.c
  22. 6
      test/core/end2end/goaway_server_test.c
  23. 7
      test/core/end2end/invalid_call_argument_test.c
  24. 4
      test/core/end2end/no_server_test.c
  25. 1
      test/core/end2end/tests/bad_hostname.c
  26. 3
      test/core/end2end/tests/binary_metadata.c
  27. 4
      test/core/end2end/tests/call_creds.c
  28. 2
      test/core/end2end/tests/cancel_after_accept.c
  29. 2
      test/core/end2end/tests/cancel_after_client_done.c
  30. 1
      test/core/end2end/tests/cancel_after_invoke.c
  31. 1
      test/core/end2end/tests/cancel_before_invoke.c
  32. 1
      test/core/end2end/tests/cancel_with_status.c
  33. 199
      test/core/end2end/tests/compressed_payload.c
  34. 2
      test/core/end2end/tests/default_host.c
  35. 2
      test/core/end2end/tests/disappearing_server.c
  36. 1
      test/core/end2end/tests/filter_causes_close.c
  37. 2
      test/core/end2end/tests/graceful_server_shutdown.c
  38. 2
      test/core/end2end/tests/high_initial_seqno.c
  39. 2
      test/core/end2end/tests/hpack_size.c
  40. 2
      test/core/end2end/tests/idempotent_request.c
  41. 3
      test/core/end2end/tests/invoke_large_request.c
  42. 3
      test/core/end2end/tests/large_metadata.c
  43. 8
      test/core/end2end/tests/max_concurrent_streams.c
  44. 2
      test/core/end2end/tests/max_message_length.c
  45. 1
      test/core/end2end/tests/negative_deadline.c
  46. 3
      test/core/end2end/tests/payload.c
  47. 7
      test/core/end2end/tests/ping_pong_streaming.c
  48. 2
      test/core/end2end/tests/registered_call.c
  49. 1
      test/core/end2end/tests/request_with_flags.c
  50. 3
      test/core/end2end/tests/request_with_payload.c
  51. 2
      test/core/end2end/tests/server_finishes_request.c
  52. 2
      test/core/end2end/tests/shutdown_finishes_calls.c
  53. 2
      test/core/end2end/tests/simple_delayed_request.c
  54. 3
      test/core/end2end/tests/simple_metadata.c
  55. 2
      test/core/end2end/tests/simple_request.c
  56. 3
      test/core/end2end/tests/trailing_metadata.c
  57. 1
      test/core/fling/client.c
  58. 2
      test/core/surface/lame_client_test.c

@ -34,7 +34,6 @@ EXPORTS
census_view_reset
grpc_compression_algorithm_parse
grpc_compression_algorithm_name
grpc_compression_algorithm_for_level
grpc_compression_options_init
grpc_compression_options_enable_algorithm
grpc_compression_options_disable_algorithm

@ -47,7 +47,9 @@
#include <grpc++/impl/codegen/serialization_traits.h>
#include <grpc++/impl/codegen/status.h>
#include <grpc++/impl/codegen/string_ref.h>
#include <grpc/impl/codegen/alloc.h>
#include <grpc/impl/codegen/compression_types.h>
#include <grpc/impl/codegen/grpc_types.h>
struct grpc_byte_buffer;
@ -187,6 +189,8 @@ class CallOpSendInitialMetadata {
flags_ = flags;
initial_metadata_count_ = metadata.size();
initial_metadata_ = FillMetadataArray(metadata);
// TODO(dgq): expose compression level in API so it can be properly set.
compression_level_ = GRPC_COMPRESS_LEVEL_NONE;
}
protected:
@ -198,6 +202,7 @@ class CallOpSendInitialMetadata {
op->reserved = NULL;
op->data.send_initial_metadata.count = initial_metadata_count_;
op->data.send_initial_metadata.metadata = initial_metadata_;
op->data.send_initial_metadata.compression_level = compression_level_;
}
void FinishOp(bool* status, int max_message_size) {
if (!send_) return;
@ -209,6 +214,7 @@ class CallOpSendInitialMetadata {
uint32_t flags_;
size_t initial_metadata_count_;
grpc_metadata* initial_metadata_;
grpc_compression_level compression_level_;
};
class CallOpSendMessage {

@ -55,13 +55,6 @@ GRPCAPI int grpc_compression_algorithm_parse(
GRPCAPI int grpc_compression_algorithm_name(
grpc_compression_algorithm algorithm, char **name);
/** Returns the compression algorithm corresponding to \a level for the
* compression algorithms encoded in the \a accepted_encodings bitset.
*
* It abort()s for unknown levels . */
GRPCAPI grpc_compression_algorithm grpc_compression_algorithm_for_level(
grpc_compression_level level, uint32_t accepted_encodings);
GRPCAPI void grpc_compression_options_init(grpc_compression_options *opts);
/** Mark \a algorithm as enabled in \a opts. */

@ -330,6 +330,7 @@ typedef struct grpc_op {
struct {
size_t count;
grpc_metadata *metadata;
grpc_compression_level compression_level;
} send_initial_metadata;
grpc_byte_buffer *send_message;
struct {

@ -125,62 +125,6 @@ grpc_mdelem *grpc_compression_encoding_mdelem(
return NULL;
}
/* TODO(dgq): Add the ability to specify parameters to the individual
* compression algorithms */
grpc_compression_algorithm grpc_compression_algorithm_for_level(
grpc_compression_level level, uint32_t accepted_encodings) {
GRPC_API_TRACE("grpc_compression_algorithm_for_level(level=%d)", 1,
((int)level));
if (level > GRPC_COMPRESS_LEVEL_HIGH) {
gpr_log(GPR_ERROR, "Unknown compression level %d.", (int)level);
abort();
}
const size_t num_supported =
GPR_BITCOUNT(accepted_encodings) - 1; /* discard NONE */
if (level == GRPC_COMPRESS_LEVEL_NONE || num_supported == 0) {
return GRPC_COMPRESS_NONE;
}
GPR_ASSERT(level > 0);
/* Establish a "ranking" or compression algorithms in increasing order of
* compression.
* This is simplistic and we will probably want to introduce other dimensions
* in the future (cpu/memory cost, etc). */
const grpc_compression_algorithm algos_ranking[] = {GRPC_COMPRESS_GZIP,
GRPC_COMPRESS_DEFLATE};
/* intersect algos_ranking with the supported ones keeping the ranked order */
grpc_compression_algorithm
sorted_supported_algos[GRPC_COMPRESS_ALGORITHMS_COUNT];
size_t algos_supported_idx = 0;
for (size_t i = 0; i < GPR_ARRAY_SIZE(algos_ranking); i++) {
const grpc_compression_algorithm alg = algos_ranking[i];
for (size_t j = 0; j < num_supported; j++) {
if (GPR_BITGET(accepted_encodings, alg) == 1) {
/* if \a alg in supported */
sorted_supported_algos[algos_supported_idx++] = alg;
break;
}
}
if (algos_supported_idx == num_supported) break;
}
switch (level) {
case GRPC_COMPRESS_LEVEL_NONE:
abort(); /* should have been handled already */
case GRPC_COMPRESS_LEVEL_LOW:
return sorted_supported_algos[0];
case GRPC_COMPRESS_LEVEL_MED:
return sorted_supported_algos[num_supported / 2];
case GRPC_COMPRESS_LEVEL_HIGH:
return sorted_supported_algos[num_supported - 1];
default:
abort();
};
}
void grpc_compression_options_init(grpc_compression_options *opts) {
opts->enabled_algorithms_bitset = (1u << GRPC_COMPRESS_ALGORITHMS_COUNT) - 1;
opts->default_compression_algorithm = GRPC_COMPRESS_NONE;

@ -420,6 +420,65 @@ grpc_compression_algorithm grpc_call_test_only_get_compression_algorithm(
return algorithm;
}
static grpc_compression_algorithm compression_algorithm_for_level_locked(
grpc_call *call, grpc_compression_level level) {
/* Establish a "ranking" or compression algorithms in increasing order of
* compression.
* This is simplistic and we will probably want to introduce other
* dimensions
* in the future (cpu/memory cost, etc). */
const grpc_compression_algorithm algos_ranking[] = {GRPC_COMPRESS_GZIP,
GRPC_COMPRESS_DEFLATE};
const uint32_t accepted_encodings = call->encodings_accepted_by_peer;
if (level > GRPC_COMPRESS_LEVEL_HIGH) {
extern int grpc_compress_filter_trace;
if (grpc_compress_filter_trace) {
gpr_log(GPR_ERROR,
"Unknown compression level %d. Compression will be disabled.",
(int)level);
}
return GRPC_COMPRESS_NONE;
}
const size_t num_supported =
GPR_BITCOUNT(accepted_encodings) - 1; /* discard NONE */
if (level == GRPC_COMPRESS_LEVEL_NONE || num_supported == 0) {
return GRPC_COMPRESS_NONE;
}
GPR_ASSERT(level > 0);
/* intersect algos_ranking with the supported ones keeping the ranked order
*/
grpc_compression_algorithm
sorted_supported_algos[GRPC_COMPRESS_ALGORITHMS_COUNT];
size_t algos_supported_idx = 0;
for (size_t i = 0; i < GPR_ARRAY_SIZE(algos_ranking); i++) {
const grpc_compression_algorithm alg = algos_ranking[i];
for (size_t j = 0; j < num_supported; j++) {
if (GPR_BITGET(accepted_encodings, alg) == 1) {
/* if \a alg in supported */
sorted_supported_algos[algos_supported_idx++] = alg;
break;
}
}
if (algos_supported_idx == num_supported) break;
}
switch (level) {
case GRPC_COMPRESS_LEVEL_NONE:
abort(); /* should have been handled already */
case GRPC_COMPRESS_LEVEL_LOW:
return sorted_supported_algos[0];
case GRPC_COMPRESS_LEVEL_MED:
return sorted_supported_algos[num_supported / 2];
case GRPC_COMPRESS_LEVEL_HIGH:
return sorted_supported_algos[num_supported - 1];
default:
abort();
};
}
uint32_t grpc_call_test_only_get_message_flags(grpc_call *call) {
uint32_t flags;
gpr_mu_lock(&call->mu);
@ -545,15 +604,28 @@ static grpc_linked_mdelem *linked_from_md(grpc_metadata *md) {
return (grpc_linked_mdelem *)&md->internal_data;
}
static grpc_metadata *get_md_elem(grpc_metadata *metadata,
grpc_metadata *additional_metadata, int i,
int count) {
grpc_metadata *res =
i < count ? &metadata[i] : &additional_metadata[i - count];
GPR_ASSERT(res);
return res;
}
static int prepare_application_metadata(grpc_call *call, int count,
grpc_metadata *metadata,
int is_trailing,
int prepend_extra_metadata) {
int prepend_extra_metadata,
grpc_metadata *additional_metadata,
int additional_metadata_count) {
int total_count = count + additional_metadata_count;
int i;
grpc_metadata_batch *batch =
&call->metadata_batch[0 /* is_receiving */][is_trailing];
for (i = 0; i < count; i++) {
grpc_metadata *md = &metadata[i];
for (i = 0; i < total_count; i++) {
const grpc_metadata *md =
get_md_elem(metadata, additional_metadata, i, count);
grpc_linked_mdelem *l = (grpc_linked_mdelem *)&md->internal_data;
GPR_ASSERT(sizeof(grpc_linked_mdelem) == sizeof(md->internal_data));
l->md = grpc_mdelem_from_string_and_buffer(
@ -572,9 +644,10 @@ static int prepare_application_metadata(grpc_call *call, int count,
break;
}
}
if (i != count) {
if (i != total_count) {
for (int j = 0; j <= i; j++) {
grpc_metadata *md = &metadata[j];
const grpc_metadata *md =
get_md_elem(metadata, additional_metadata, j, count);
grpc_linked_mdelem *l = (grpc_linked_mdelem *)&md->internal_data;
GRPC_MDELEM_UNREF(l->md);
}
@ -595,24 +668,36 @@ static int prepare_application_metadata(grpc_call *call, int count,
}
}
}
for (i = 1; i < count; i++) {
linked_from_md(&metadata[i])->prev = linked_from_md(&metadata[i - 1]);
for (i = 1; i < total_count; i++) {
grpc_metadata *md = get_md_elem(metadata, additional_metadata, i, count);
grpc_metadata *prev_md =
get_md_elem(metadata, additional_metadata, i - 1, count);
linked_from_md(md)->prev = linked_from_md(prev_md);
}
for (i = 0; i < count - 1; i++) {
linked_from_md(&metadata[i])->next = linked_from_md(&metadata[i + 1]);
for (i = 0; i < total_count - 1; i++) {
grpc_metadata *md = get_md_elem(metadata, additional_metadata, i, count);
grpc_metadata *next_md =
get_md_elem(metadata, additional_metadata, i + 1, count);
linked_from_md(md)->next = linked_from_md(next_md);
}
switch (prepend_extra_metadata * 2 + (count != 0)) {
switch (prepend_extra_metadata * 2 + (total_count != 0)) {
case 0:
/* no prepend, no metadata => nothing to do */
batch->list.head = batch->list.tail = NULL;
break;
case 1:
case 1: {
/* metadata, but no prepend */
batch->list.head = linked_from_md(&metadata[0]);
batch->list.tail = linked_from_md(&metadata[count - 1]);
grpc_metadata *first_md =
get_md_elem(metadata, additional_metadata, 0, count);
grpc_metadata *last_md =
get_md_elem(metadata, additional_metadata, total_count - 1, count);
batch->list.head = linked_from_md(first_md);
batch->list.tail = linked_from_md(last_md);
batch->list.head->prev = NULL;
batch->list.tail->next = NULL;
break;
}
case 2:
/* prepend, but no md */
batch->list.head = &call->send_extra_metadata[0];
@ -621,17 +706,22 @@ static int prepare_application_metadata(grpc_call *call, int count,
batch->list.head->prev = NULL;
batch->list.tail->next = NULL;
break;
case 3:
case 3: {
/* prepend AND md */
grpc_metadata *first_md =
get_md_elem(metadata, additional_metadata, 0, count);
grpc_metadata *last_md =
get_md_elem(metadata, additional_metadata, total_count - 1, count);
batch->list.head = &call->send_extra_metadata[0];
call->send_extra_metadata[call->send_extra_metadata_count - 1].next =
linked_from_md(&metadata[0]);
linked_from_md(&metadata[0])->prev =
linked_from_md(first_md);
linked_from_md(first_md)->prev =
&call->send_extra_metadata[call->send_extra_metadata_count - 1];
batch->list.tail = linked_from_md(&metadata[count - 1]);
batch->list.tail = linked_from_md(last_md);
batch->list.head->prev = NULL;
batch->list.tail->next = NULL;
break;
}
default:
GPR_UNREACHABLE_CODE(return 0);
}
@ -1229,7 +1319,29 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx,
error = GRPC_CALL_ERROR_TOO_MANY_OPERATIONS;
goto done_with_error;
}
if (op->data.send_initial_metadata.count > INT_MAX) {
/* process compression level */
grpc_metadata compression_md;
memset(&compression_md, 0, sizeof(grpc_metadata));
size_t additional_metadata_count = 0;
if (op->data.send_initial_metadata.compression_level >
GRPC_COMPRESS_LEVEL_NONE) {
if (call->is_client) {
error = GRPC_CALL_ERROR_NOT_ON_CLIENT;
goto done_with_error;
}
const grpc_compression_algorithm calgo =
compression_algorithm_for_level_locked(
call, op->data.send_initial_metadata.compression_level);
char *calgo_name;
grpc_compression_algorithm_name(calgo, &calgo_name);
compression_md.key = "grpc-internal-encoding-request";
compression_md.value = calgo_name;
compression_md.value_length = strlen(calgo_name);
additional_metadata_count++;
}
if (op->data.send_initial_metadata.count + additional_metadata_count >
INT_MAX) {
error = GRPC_CALL_ERROR_INVALID_METADATA;
goto done_with_error;
}
@ -1237,7 +1349,8 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx,
call->sent_initial_metadata = 1;
if (!prepare_application_metadata(
call, (int)op->data.send_initial_metadata.count,
op->data.send_initial_metadata.metadata, 0, call->is_client)) {
op->data.send_initial_metadata.metadata, 0, call->is_client,
&compression_md, (int)additional_metadata_count)) {
error = GRPC_CALL_ERROR_INVALID_METADATA;
goto done_with_error;
}
@ -1325,7 +1438,8 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx,
if (!prepare_application_metadata(
call,
(int)op->data.send_status_from_server.trailing_metadata_count,
op->data.send_status_from_server.trailing_metadata, 1, 1)) {
op->data.send_status_from_server.trailing_metadata, 1, 1, NULL,
0)) {
error = GRPC_CALL_ERROR_INVALID_METADATA;
goto done_with_error;
}
@ -1513,9 +1627,10 @@ uint8_t grpc_call_is_client(grpc_call *call) { return call->is_client; }
grpc_compression_algorithm grpc_call_compression_for_level(
grpc_call *call, grpc_compression_level level) {
gpr_mu_lock(&call->mu);
const uint32_t accepted_encodings = call->encodings_accepted_by_peer;
grpc_compression_algorithm algo =
compression_algorithm_for_level_locked(call, level);
gpr_mu_unlock(&call->mu);
return grpc_compression_algorithm_for_level(level, accepted_encodings);
return algo;
}
const char *grpc_call_error_to_string(grpc_call_error error) {

@ -503,6 +503,7 @@ grpcsharp_call_start_unary(grpc_call *call, grpcsharp_batch_context *ctx,
grpc_metadata_array *initial_metadata, uint32_t write_flags) {
/* TODO: don't use magic number */
grpc_op ops[6];
memset(ops, 0, sizeof(ops));
ops[0].op = GRPC_OP_SEND_INITIAL_METADATA;
grpcsharp_metadata_array_move(&(ctx->send_initial_metadata),
initial_metadata);
@ -555,6 +556,7 @@ grpcsharp_call_start_client_streaming(grpc_call *call,
grpc_metadata_array *initial_metadata) {
/* TODO: don't use magic number */
grpc_op ops[4];
memset(ops, 0, sizeof(ops));
ops[0].op = GRPC_OP_SEND_INITIAL_METADATA;
grpcsharp_metadata_array_move(&(ctx->send_initial_metadata),
initial_metadata);
@ -596,6 +598,7 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_start_server_streaming(
size_t send_buffer_len, grpc_metadata_array *initial_metadata, uint32_t write_flags) {
/* TODO: don't use magic number */
grpc_op ops[4];
memset(ops, 0, sizeof(ops));
ops[0].op = GRPC_OP_SEND_INITIAL_METADATA;
grpcsharp_metadata_array_move(&(ctx->send_initial_metadata),
initial_metadata);
@ -638,6 +641,7 @@ grpcsharp_call_start_duplex_streaming(grpc_call *call,
grpc_metadata_array *initial_metadata) {
/* TODO: don't use magic number */
grpc_op ops[2];
memset(ops, 0, sizeof(ops));
ops[0].op = GRPC_OP_SEND_INITIAL_METADATA;
grpcsharp_metadata_array_move(&(ctx->send_initial_metadata),
initial_metadata);
@ -684,6 +688,7 @@ grpcsharp_call_send_message(grpc_call *call, grpcsharp_batch_context *ctx,
int32_t send_empty_initial_metadata) {
/* TODO: don't use magic number */
grpc_op ops[2];
memset(ops, 0, sizeof(ops));
size_t nops = send_empty_initial_metadata ? 2 : 1;
ops[0].op = GRPC_OP_SEND_MESSAGE;
ctx->send_message = string_to_byte_buffer(send_buffer, send_buffer_len);
@ -691,8 +696,6 @@ grpcsharp_call_send_message(grpc_call *call, grpcsharp_batch_context *ctx,
ops[0].flags = write_flags;
ops[0].reserved = NULL;
ops[1].op = GRPC_OP_SEND_INITIAL_METADATA;
ops[1].data.send_initial_metadata.count = 0;
ops[1].data.send_initial_metadata.metadata = NULL;
ops[1].flags = 0;
ops[1].reserved = NULL;
@ -719,6 +722,7 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_send_status_from_server(
size_t optional_send_buffer_len, uint32_t write_flags) {
/* TODO: don't use magic number */
grpc_op ops[3];
memset(ops, 0, sizeof(ops));
size_t nops = 1;
ops[0].op = GRPC_OP_SEND_STATUS_FROM_SERVER;
ops[0].data.send_status_from_server.status = status_code;
@ -743,8 +747,6 @@ GPR_EXPORT grpc_call_error GPR_CALLTYPE grpcsharp_call_send_status_from_server(
}
if (send_empty_initial_metadata) {
ops[nops].op = GRPC_OP_SEND_INITIAL_METADATA;
ops[nops].data.send_initial_metadata.count = 0;
ops[nops].data.send_initial_metadata.metadata = NULL;
ops[nops].flags = 0;
ops[nops].reserved = NULL;
nops++;
@ -784,6 +786,7 @@ grpcsharp_call_send_initial_metadata(grpc_call *call,
grpc_metadata_array *initial_metadata) {
/* TODO: don't use magic number */
grpc_op ops[1];
memset(ops, 0, sizeof(ops));
ops[0].op = GRPC_OP_SEND_INITIAL_METADATA;
grpcsharp_metadata_array_move(&(ctx->send_initial_metadata),
initial_metadata);

@ -72,6 +72,7 @@
_op.op = GRPC_OP_SEND_INITIAL_METADATA;
_op.data.send_initial_metadata.count = metadata.count;
_op.data.send_initial_metadata.metadata = metadata.grpc_metadataArray;
_op.data.send_initial_metadata.compression_level = 0;
_handler = handler;
}
return self;

@ -291,6 +291,7 @@ PHP_METHOD(Call, startBatch) {
grpc_metadata_array_init(&recv_trailing_metadata);
MAKE_STD_ZVAL(result);
object_init(result);
memset(ops, 0, sizeof(ops));
/* "a" == 1 array */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &array) ==
FAILURE) {

@ -72,7 +72,6 @@ census_view_get_data_type census_view_get_data_import;
census_view_reset_type census_view_reset_import;
grpc_compression_algorithm_parse_type grpc_compression_algorithm_parse_import;
grpc_compression_algorithm_name_type grpc_compression_algorithm_name_import;
grpc_compression_algorithm_for_level_type grpc_compression_algorithm_for_level_import;
grpc_compression_options_init_type grpc_compression_options_init_import;
grpc_compression_options_enable_algorithm_type grpc_compression_options_enable_algorithm_import;
grpc_compression_options_disable_algorithm_type grpc_compression_options_disable_algorithm_import;
@ -343,7 +342,6 @@ void pygrpc_load_imports(HMODULE library) {
census_view_reset_import = (census_view_reset_type) GetProcAddress(library, "census_view_reset");
grpc_compression_algorithm_parse_import = (grpc_compression_algorithm_parse_type) GetProcAddress(library, "grpc_compression_algorithm_parse");
grpc_compression_algorithm_name_import = (grpc_compression_algorithm_name_type) GetProcAddress(library, "grpc_compression_algorithm_name");
grpc_compression_algorithm_for_level_import = (grpc_compression_algorithm_for_level_type) GetProcAddress(library, "grpc_compression_algorithm_for_level");
grpc_compression_options_init_import = (grpc_compression_options_init_type) GetProcAddress(library, "grpc_compression_options_init");
grpc_compression_options_enable_algorithm_import = (grpc_compression_options_enable_algorithm_type) GetProcAddress(library, "grpc_compression_options_enable_algorithm");
grpc_compression_options_disable_algorithm_import = (grpc_compression_options_disable_algorithm_type) GetProcAddress(library, "grpc_compression_options_disable_algorithm");

@ -167,9 +167,6 @@ extern grpc_compression_algorithm_parse_type grpc_compression_algorithm_parse_im
typedef int(*grpc_compression_algorithm_name_type)(grpc_compression_algorithm algorithm, char **name);
extern grpc_compression_algorithm_name_type grpc_compression_algorithm_name_import;
#define grpc_compression_algorithm_name grpc_compression_algorithm_name_import
typedef grpc_compression_algorithm(*grpc_compression_algorithm_for_level_type)(grpc_compression_level level, uint32_t accepted_encodings);
extern grpc_compression_algorithm_for_level_type grpc_compression_algorithm_for_level_import;
#define grpc_compression_algorithm_for_level grpc_compression_algorithm_for_level_import
typedef void(*grpc_compression_options_init_type)(grpc_compression_options *opts);
extern grpc_compression_options_init_type grpc_compression_options_init_import;
#define grpc_compression_options_init grpc_compression_options_init_import

@ -72,7 +72,6 @@ census_view_get_data_type census_view_get_data_import;
census_view_reset_type census_view_reset_import;
grpc_compression_algorithm_parse_type grpc_compression_algorithm_parse_import;
grpc_compression_algorithm_name_type grpc_compression_algorithm_name_import;
grpc_compression_algorithm_for_level_type grpc_compression_algorithm_for_level_import;
grpc_compression_options_init_type grpc_compression_options_init_import;
grpc_compression_options_enable_algorithm_type grpc_compression_options_enable_algorithm_import;
grpc_compression_options_disable_algorithm_type grpc_compression_options_disable_algorithm_import;
@ -339,7 +338,6 @@ void grpc_rb_load_imports(HMODULE library) {
census_view_reset_import = (census_view_reset_type) GetProcAddress(library, "census_view_reset");
grpc_compression_algorithm_parse_import = (grpc_compression_algorithm_parse_type) GetProcAddress(library, "grpc_compression_algorithm_parse");
grpc_compression_algorithm_name_import = (grpc_compression_algorithm_name_type) GetProcAddress(library, "grpc_compression_algorithm_name");
grpc_compression_algorithm_for_level_import = (grpc_compression_algorithm_for_level_type) GetProcAddress(library, "grpc_compression_algorithm_for_level");
grpc_compression_options_init_import = (grpc_compression_options_init_type) GetProcAddress(library, "grpc_compression_options_init");
grpc_compression_options_enable_algorithm_import = (grpc_compression_options_enable_algorithm_type) GetProcAddress(library, "grpc_compression_options_enable_algorithm");
grpc_compression_options_disable_algorithm_import = (grpc_compression_options_disable_algorithm_type) GetProcAddress(library, "grpc_compression_options_disable_algorithm");

@ -167,9 +167,6 @@ extern grpc_compression_algorithm_parse_type grpc_compression_algorithm_parse_im
typedef int(*grpc_compression_algorithm_name_type)(grpc_compression_algorithm algorithm, char **name);
extern grpc_compression_algorithm_name_type grpc_compression_algorithm_name_import;
#define grpc_compression_algorithm_name grpc_compression_algorithm_name_import
typedef grpc_compression_algorithm(*grpc_compression_algorithm_for_level_type)(grpc_compression_level level, uint32_t accepted_encodings);
extern grpc_compression_algorithm_for_level_type grpc_compression_algorithm_for_level_import;
#define grpc_compression_algorithm_for_level grpc_compression_algorithm_for_level_import
typedef void(*grpc_compression_options_init_type)(grpc_compression_options *opts);
extern grpc_compression_options_init_type grpc_compression_options_init_import;
#define grpc_compression_options_init grpc_compression_options_init_import

@ -84,6 +84,7 @@ static void run_test(const char *target, size_t nops) {
"/foo", "foo.test.google.fr:1234", deadline,
NULL);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;

@ -275,6 +275,7 @@ static int *perform_request(servers_fixture *f, grpc_channel *client,
GPR_ASSERT(c);
completed_client = 0;
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -327,6 +328,7 @@ static int *perform_request(servers_fixture *f, grpc_channel *client,
}
if (s_idx >= 0) {
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -415,6 +417,7 @@ static grpc_call **perform_multirequest(servers_fixture *f,
kill_server(f, i);
}
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;

@ -133,6 +133,7 @@ static void start_rpc(int use_creds, int target_port) {
state.call = grpc_channel_create_call(
state.channel, NULL, GRPC_PROPAGATE_DEFAULTS, state.cq, "/Service/Method",
"localhost", gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
memset(&state.op, 0, sizeof(state.op));
state.op.op = GRPC_OP_SEND_INITIAL_METADATA;
state.op.data.send_initial_metadata.count = 0;
state.op.flags = 0;

@ -92,102 +92,6 @@ static void test_compression_algorithm_name(void) {
/* the value of "name" is undefined upon failure */
}
static void test_compression_algorithm_for_level(void) {
gpr_log(GPR_DEBUG, "test_compression_algorithm_for_level");
{
/* accept only identity (aka none) */
uint32_t accepted_encodings = 0;
GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_NONE); /* always */
GPR_ASSERT(GRPC_COMPRESS_NONE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_NONE,
accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_NONE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_LOW,
accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_NONE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MED,
accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_NONE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH,
accepted_encodings));
}
{
/* accept only gzip */
uint32_t accepted_encodings = 0;
GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_NONE); /* always */
GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_GZIP);
GPR_ASSERT(GRPC_COMPRESS_NONE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_NONE,
accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_GZIP ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_LOW,
accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_GZIP ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MED,
accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_GZIP ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH,
accepted_encodings));
}
{
/* accept only deflate */
uint32_t accepted_encodings = 0;
GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_NONE); /* always */
GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_DEFLATE);
GPR_ASSERT(GRPC_COMPRESS_NONE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_NONE,
accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_DEFLATE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_LOW,
accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_DEFLATE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MED,
accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_DEFLATE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH,
accepted_encodings));
}
{
/* accept gzip and deflate */
uint32_t accepted_encodings = 0;
GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_NONE); /* always */
GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_GZIP);
GPR_BITSET(&accepted_encodings, GRPC_COMPRESS_DEFLATE);
GPR_ASSERT(GRPC_COMPRESS_NONE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_NONE,
accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_GZIP ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_LOW,
accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_DEFLATE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_MED,
accepted_encodings));
GPR_ASSERT(GRPC_COMPRESS_DEFLATE ==
grpc_compression_algorithm_for_level(GRPC_COMPRESS_LEVEL_HIGH,
accepted_encodings));
}
}
static void test_compression_enable_disable_algorithm(void) {
grpc_compression_options options;
grpc_compression_algorithm algorithm;
@ -221,7 +125,6 @@ int main(int argc, char **argv) {
grpc_init();
test_compression_algorithm_parse();
test_compression_algorithm_name();
test_compression_algorithm_for_level();
test_compression_enable_disable_algorithm();
grpc_shutdown();

@ -165,6 +165,7 @@ void test_connect(const char *server_host, const char *client_host, int port,
"/foo", "foo.test.google.fr", deadline, NULL);
GPR_ASSERT(c);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -199,6 +200,7 @@ void test_connect(const char *server_host, const char *client_host, int port,
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;

@ -321,6 +321,7 @@ static void simple_request_body(grpc_end2end_test_fixture f,
NULL);
GPR_ASSERT(c);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;

@ -169,6 +169,7 @@ static void on_p2s_recv_initial_metadata(void *arg, int success) {
grpc_op op;
grpc_call_error err;
memset(&op, 0, sizeof(op));
if (!pc->proxy->shutdown) {
op.op = GRPC_OP_SEND_INITIAL_METADATA;
op.flags = 0;
@ -326,6 +327,7 @@ static void on_new_call(void *arg, int success) {
if (success) {
grpc_op op;
memset(&op, 0, sizeof(op));
proxy_call *pc = gpr_malloc(sizeof(*pc));
memset(pc, 0, sizeof(*pc));
pc->proxy = proxy;

@ -31,6 +31,8 @@
*
*/
#include <string.h>
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
@ -78,6 +80,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
size_t details_capacity = 0;
grpc_op ops[6];
memset(ops, 0, sizeof(ops));
grpc_op *op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;

@ -132,6 +132,7 @@ int main(int argc, char **argv) {
chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq, "/foo", "127.0.0.1",
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20), NULL);
/* send initial metadata to probe connectivity */
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -142,6 +143,7 @@ int main(int argc, char **argv) {
(size_t)(op - ops),
tag(0x101), NULL));
/* and receive status to probe termination */
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv1;
@ -183,6 +185,7 @@ int main(int argc, char **argv) {
tag(0x9999));
/* listen for close on the server call to probe for finishing */
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled1;
@ -205,6 +208,7 @@ int main(int argc, char **argv) {
chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq, "/foo", "127.0.0.1",
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20), NULL);
/* send initial metadata to probe connectivity */
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -215,6 +219,7 @@ int main(int argc, char **argv) {
(size_t)(op - ops),
tag(0x201), NULL));
/* and receive status to probe termination */
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv2;
@ -249,6 +254,7 @@ int main(int argc, char **argv) {
cq_verify(cqv);
/* listen for close on the server call to probe for finishing */
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled2;

@ -30,11 +30,15 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <limits.h>
#include <string.h>
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/host_port.h>
#include <grpc/support/log.h>
#include <limits.h>
#include "test/core/end2end/cq_verifier.h"
#include "test/core/util/port.h"
#include "test/core/util/test_config.h"
@ -74,6 +78,7 @@ static void prepare_test(int is_client) {
g_state.cqv = cq_verifier_create(g_state.cq);
g_state.details = NULL;
g_state.details_capacity = 0;
memset(g_state.ops, 0, sizeof(g_state.ops));
if (is_client) {
/* create a call, channel to a non existant server */

@ -31,9 +31,12 @@
*
*/
#include <string.h>
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "test/core/end2end/cq_verifier.h"
#include "test/core/util/test_config.h"
@ -65,6 +68,7 @@ int main(int argc, char **argv) {
call = grpc_channel_create_call(chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq,
"/Foo", "nonexistant", deadline, NULL);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;

@ -123,6 +123,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;

@ -157,6 +157,7 @@ static void test_request_response_with_metadata_and_payload(
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 2;
@ -201,6 +202,7 @@ static void test_request_response_with_metadata_and_payload(
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 2;
@ -219,6 +221,7 @@ static void test_request_response_with_metadata_and_payload(
cq_expect_completion(cqv, tag(102), 1);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;

@ -193,6 +193,7 @@ static void request_response_with_payload_and_call_creds(
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -248,6 +249,7 @@ static void request_response_with_payload_and_call_creds(
/* Cannot set creds on the server call object. */
GPR_ASSERT(grpc_call_set_credentials(s, NULL) != GRPC_CALL_OK);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -265,6 +267,7 @@ static void request_response_with_payload_and_call_creds(
cq_expect_completion(cqv, tag(102), 1);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
@ -410,6 +413,7 @@ static void test_request_with_server_rejecting_client_creds(
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;

@ -136,6 +136,7 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
@ -174,6 +175,7 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
cq_expect_completion(cqv, tag(2), 1);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message = &request_payload_recv;

@ -136,6 +136,7 @@ static void test_cancel_after_accept_and_writes_closed(
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
@ -178,6 +179,7 @@ static void test_cancel_after_accept_and_writes_closed(
cq_expect_completion(cqv, tag(2), 1);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message = &request_payload_recv;

@ -131,6 +131,7 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config,
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;

@ -131,6 +131,7 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config,
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;

@ -122,6 +122,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, size_t num_ops) {
grpc_metadata_array_init(&initial_metadata_recv);
grpc_metadata_array_init(&trailing_metadata_recv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;

@ -45,6 +45,7 @@
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/channel/compress_filter.h"
#include "src/core/lib/surface/call.h"
#include "src/core/lib/surface/call_test_only.h"
#include "test/core/end2end/cq_verifier.h"
@ -104,10 +105,13 @@ static void end_test(grpc_end2end_test_fixture *f) {
static void request_with_payload_template(
grpc_end2end_test_config config, const char *test_name,
uint32_t send_flags_bitmask,
grpc_compression_algorithm requested_compression_algorithm,
grpc_compression_algorithm expected_compression_algorithm,
grpc_metadata *client_metadata) {
uint32_t client_send_flags_bitmask,
grpc_compression_algorithm default_client_channel_compression_algorithm,
grpc_compression_algorithm default_server_channel_compression_algorithm,
grpc_compression_algorithm expected_algorithm_from_client,
grpc_compression_algorithm expected_algorithm_from_server,
grpc_metadata *client_init_metadata,
grpc_compression_level server_compression_level) {
grpc_call *c;
grpc_call *s;
gpr_slice request_payload_slice;
@ -122,6 +126,8 @@ static void request_with_payload_template(
grpc_metadata_array trailing_metadata_recv;
grpc_metadata_array request_metadata_recv;
grpc_byte_buffer *request_payload_recv = NULL;
grpc_byte_buffer *response_payload;
grpc_byte_buffer *response_payload_recv;
grpc_call_details call_details;
grpc_status_code status;
grpc_call_error error;
@ -129,17 +135,22 @@ static void request_with_payload_template(
size_t details_capacity = 0;
int was_cancelled = 2;
cq_verifier *cqv;
char str[1024];
char request_str[1024];
char response_str[1024];
memset(str, 'x', 1023);
str[1023] = '\0';
request_payload_slice = gpr_slice_from_copied_string(str);
request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1);
memset(request_str, 'x', 1023);
request_str[1023] = '\0';
memset(response_str, 'y', 1023);
response_str[1023] = '\0';
request_payload_slice = gpr_slice_from_copied_string(request_str);
gpr_slice response_payload_slice = gpr_slice_from_copied_string(response_str);
client_args = grpc_channel_args_set_compression_algorithm(
NULL, requested_compression_algorithm);
NULL, default_client_channel_compression_algorithm);
server_args = grpc_channel_args_set_compression_algorithm(
NULL, requested_compression_algorithm);
NULL, default_server_channel_compression_algorithm);
f = begin_test(config, test_name, client_args, server_args);
cqv = cq_verifier_create(f.cq);
@ -153,26 +164,18 @@ static void request_with_payload_template(
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
if (client_metadata != NULL) {
if (client_init_metadata != NULL) {
op->data.send_initial_metadata.count = 1;
op->data.send_initial_metadata.metadata = client_metadata;
op->data.send_initial_metadata.metadata = client_init_metadata;
} else {
op->data.send_initial_metadata.count = 0;
}
op->flags = 0;
op->reserved = NULL;
op++;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message = request_payload;
op->flags = send_flags_bitmask;
op->reserved = NULL;
op++;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
op->reserved = NULL;
op++;
op->op = GRPC_OP_RECV_INITIAL_METADATA;
op->data.recv_initial_metadata = &initial_metadata_recv;
op->flags = 0;
@ -191,9 +194,9 @@ static void request_with_payload_template(
error =
grpc_server_request_call(f.server, &s, &call_details,
&request_metadata_recv, f.cq, f.cq, tag(101));
&request_metadata_recv, f.cq, f.cq, tag(100));
GPR_ASSERT(GRPC_CALL_OK == error);
cq_expect_completion(cqv, tag(101), 1);
cq_expect_completion(cqv, tag(100), 1);
cq_verify(cqv);
GPR_ASSERT(
@ -205,29 +208,103 @@ static void request_with_payload_template(
GPR_ASSERT(GPR_BITGET(grpc_call_test_only_get_encodings_accepted_by_peer(s),
GRPC_COMPRESS_GZIP) != 0);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op->data.send_initial_metadata.compression_level = server_compression_level;
op->flags = 0;
op->reserved = NULL;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message = &request_payload_recv;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
op->reserved = NULL;
op++;
error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(101), NULL);
GPR_ASSERT(GRPC_CALL_OK == error);
cq_expect_completion(cqv, tag(102), 1);
cq_verify(cqv);
for (int i = 0; i < 2; i++) {
request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1);
response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message = request_payload;
op->flags = client_send_flags_bitmask;
op->reserved = NULL;
op++;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message = &response_payload_recv;
op->flags = 0;
op->reserved = NULL;
op++;
error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), NULL);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message = &request_payload_recv;
op->flags = 0;
op->reserved = NULL;
op++;
error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
GPR_ASSERT(GRPC_CALL_OK == error);
cq_expect_completion(cqv, tag(102), 1);
cq_verify(cqv);
GPR_ASSERT(request_payload_recv->type == GRPC_BB_RAW);
GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, request_str));
GPR_ASSERT(request_payload_recv->data.raw.compression ==
expected_algorithm_from_client);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message = response_payload;
op->flags = 0;
op->reserved = NULL;
op++;
error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
GPR_ASSERT(GRPC_CALL_OK == error);
cq_expect_completion(cqv, tag(103), 1);
cq_expect_completion(cqv, tag(2), 1);
cq_verify(cqv);
GPR_ASSERT(response_payload_recv->type == GRPC_BB_RAW);
GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, response_str));
if (server_compression_level > GRPC_COMPRESS_LEVEL_NONE) {
const grpc_compression_algorithm algo_for_server_level =
grpc_call_compression_for_level(s, server_compression_level);
GPR_ASSERT(response_payload_recv->data.raw.compression ==
algo_for_server_level);
} else {
GPR_ASSERT(response_payload_recv->data.raw.compression ==
expected_algorithm_from_server);
}
grpc_byte_buffer_destroy(request_payload);
grpc_byte_buffer_destroy(response_payload);
grpc_byte_buffer_destroy(request_payload_recv);
grpc_byte_buffer_destroy(response_payload_recv);
}
gpr_slice_unref(request_payload_slice);
gpr_slice_unref(response_payload_slice);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
op->reserved = NULL;
op++;
error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), NULL);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;
op->data.send_status_from_server.status = GRPC_STATUS_OK;
@ -235,11 +312,13 @@ static void request_with_payload_template(
op->flags = 0;
op->reserved = NULL;
op++;
error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL);
error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), NULL);
GPR_ASSERT(GRPC_CALL_OK == error);
cq_expect_completion(cqv, tag(103), 1);
cq_expect_completion(cqv, tag(1), 1);
cq_expect_completion(cqv, tag(3), 1);
cq_expect_completion(cqv, tag(101), 1);
cq_expect_completion(cqv, tag(104), 1);
cq_verify(cqv);
GPR_ASSERT(status == GRPC_STATUS_OK);
@ -248,12 +327,6 @@ static void request_with_payload_template(
GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr"));
GPR_ASSERT(was_cancelled == 0);
GPR_ASSERT(request_payload_recv->type == GRPC_BB_RAW);
GPR_ASSERT(request_payload_recv->data.raw.compression ==
expected_compression_algorithm);
GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, str));
gpr_free(details);
grpc_metadata_array_destroy(&initial_metadata_recv);
grpc_metadata_array_destroy(&trailing_metadata_recv);
@ -265,10 +338,6 @@ static void request_with_payload_template(
cq_verifier_destroy(cqv);
gpr_slice_unref(request_payload_slice);
grpc_byte_buffer_destroy(request_payload);
grpc_byte_buffer_destroy(request_payload_recv);
grpc_channel_args_destroy(client_args);
grpc_channel_args_destroy(server_args);
@ -280,60 +349,78 @@ static void test_invoke_request_with_exceptionally_uncompressed_payload(
grpc_end2end_test_config config) {
request_with_payload_template(
config, "test_invoke_request_with_exceptionally_uncompressed_payload",
GRPC_WRITE_NO_COMPRESS, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_NONE, NULL);
GRPC_WRITE_NO_COMPRESS, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP,
GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, NULL, GRPC_COMPRESS_LEVEL_NONE);
}
static void test_invoke_request_with_uncompressed_payload(
grpc_end2end_test_config config) {
request_with_payload_template(
config, "test_invoke_request_with_uncompressed_payload", 0,
GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, NULL);
GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE,
GRPC_COMPRESS_NONE, NULL, GRPC_COMPRESS_LEVEL_NONE);
}
static void test_invoke_request_with_compressed_payload(
grpc_end2end_test_config config) {
request_with_payload_template(
config, "test_invoke_request_with_compressed_payload", 0,
GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, NULL);
GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP,
GRPC_COMPRESS_GZIP, NULL, GRPC_COMPRESS_LEVEL_NONE);
}
static void test_invoke_request_with_server_level(
grpc_end2end_test_config config) {
request_with_payload_template(
config, "test_invoke_request_with_server_level", 0, GRPC_COMPRESS_NONE,
GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE /* ignored */,
NULL, GRPC_COMPRESS_LEVEL_HIGH);
}
static void test_invoke_request_with_compressed_payload_md_override(
grpc_end2end_test_config config) {
grpc_metadata gzip_compression_override;
grpc_metadata none_compression_override;
grpc_metadata identity_compression_override;
gzip_compression_override.key = GRPC_COMPRESS_REQUEST_ALGORITHM_KEY;
gzip_compression_override.value = "gzip";
gzip_compression_override.value_length = 4;
gzip_compression_override.value_length =
strlen(gzip_compression_override.value);
memset(&gzip_compression_override.internal_data, 0,
sizeof(gzip_compression_override.internal_data));
none_compression_override.key = GRPC_COMPRESS_REQUEST_ALGORITHM_KEY;
none_compression_override.value = "identity";
none_compression_override.value_length = 4;
memset(&none_compression_override.internal_data, 0,
sizeof(none_compression_override.internal_data));
identity_compression_override.key = GRPC_COMPRESS_REQUEST_ALGORITHM_KEY;
identity_compression_override.value = "identity";
identity_compression_override.value_length =
strlen(identity_compression_override.value);
memset(&identity_compression_override.internal_data, 0,
sizeof(identity_compression_override.internal_data));
/* Channel default NONE (aka IDENTITY), call override to GZIP */
request_with_payload_template(
config, "test_invoke_request_with_compressed_payload_md_override_1", 0,
GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, &gzip_compression_override);
GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP,
GRPC_COMPRESS_NONE, &gzip_compression_override, GRPC_COMPRESS_LEVEL_NONE);
/* Channel default DEFLATE, call override to GZIP */
request_with_payload_template(
config, "test_invoke_request_with_compressed_payload_md_override_2", 0,
GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_GZIP, &gzip_compression_override);
GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP,
GRPC_COMPRESS_NONE, &gzip_compression_override, GRPC_COMPRESS_LEVEL_NONE);
/* Channel default DEFLATE, call override to NONE (aka IDENTITY) */
request_with_payload_template(
config, "test_invoke_request_with_compressed_payload_md_override_3", 0,
GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_NONE, &none_compression_override);
GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE,
GRPC_COMPRESS_NONE, &identity_compression_override,
GRPC_COMPRESS_LEVEL_NONE);
}
void compressed_payload(grpc_end2end_test_config config) {
test_invoke_request_with_exceptionally_uncompressed_payload(config);
test_invoke_request_with_uncompressed_payload(config);
test_invoke_request_with_compressed_payload(config);
test_invoke_request_with_server_level(config);
test_invoke_request_with_compressed_payload_md_override(config);
}

@ -131,6 +131,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -173,6 +174,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
gpr_log(GPR_DEBUG, "client_peer=%s", peer);
gpr_free(peer);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;

@ -108,6 +108,7 @@ static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f,
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -145,6 +146,7 @@ static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f,
- and still complete the request */
grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000));
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;

@ -134,6 +134,7 @@ static void test_request(grpc_end2end_test_config config) {
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;

@ -122,6 +122,7 @@ static void test_early_server_shutdown_finishes_inflight_calls(
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -160,6 +161,7 @@ static void test_early_server_shutdown_finishes_inflight_calls(
grpc_server_shutdown_and_notify(f.server, f.cq, tag(0xdead));
cq_verify_empty(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;

@ -128,6 +128,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -161,6 +162,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;

@ -323,6 +323,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, size_t index) {
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = GPR_ARRAY_SIZE(extra_metadata);
@ -357,6 +358,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, size_t index) {
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;

@ -132,6 +132,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -174,6 +175,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
gpr_log(GPR_DEBUG, "client_peer=%s", peer);
gpr_free(peer);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;

@ -138,6 +138,7 @@ static void test_invoke_large_request(grpc_end2end_test_config config) {
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -181,6 +182,7 @@ static void test_invoke_large_request(grpc_end2end_test_config config) {
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -198,6 +200,7 @@ static void test_invoke_large_request(grpc_end2end_test_config config) {
cq_expect_completion(cqv, tag(102), 1);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;

@ -138,6 +138,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) {
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 1;
@ -177,6 +178,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) {
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -194,6 +196,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) {
cq_expect_completion(cqv, tag(102), 1);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;

@ -124,6 +124,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -157,6 +158,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -270,6 +272,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
f.server, &s1, &call_details,
&request_metadata_recv, f.cq, f.cq, tag(101)));
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -283,6 +286,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(301), NULL);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv1;
@ -300,6 +304,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(302), NULL);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -313,6 +318,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(401), NULL);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv2;
@ -354,6 +360,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
}
GPR_ASSERT(live_call == 300 || live_call == 400);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -388,6 +395,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) {
cq_expect_completion(cqv, tag(201), 1);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;

@ -140,6 +140,7 @@ static void test_max_message_length(grpc_end2end_test_config config) {
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -178,6 +179,7 @@ static void test_max_message_length(grpc_end2end_test_config config) {
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;

@ -122,6 +122,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, size_t num_ops) {
grpc_metadata_array_init(&initial_metadata_recv);
grpc_metadata_array_init(&trailing_metadata_recv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;

@ -131,6 +131,7 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) {
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -174,6 +175,7 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) {
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -191,6 +193,7 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) {
cq_expect_completion(cqv, tag(102), 1);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;

@ -135,6 +135,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -164,6 +165,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
cq_expect_completion(cqv, tag(100), 1);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -182,6 +184,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1);
response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message = request_payload;
@ -196,6 +199,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), NULL);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_MESSAGE;
op->data.recv_message = &request_payload_recv;
@ -207,6 +211,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
cq_expect_completion(cqv, tag(102), 1);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message = response_payload;
@ -228,6 +233,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
gpr_slice_unref(request_payload_slice);
gpr_slice_unref(response_payload_slice);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT;
op->flags = 0;
@ -236,6 +242,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config,
error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), NULL);
GPR_ASSERT(GRPC_CALL_OK == error);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER;
op->data.send_status_from_server.trailing_metadata_count = 0;

@ -125,6 +125,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, void *rc) {
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -158,6 +159,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, void *rc) {
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;

@ -131,6 +131,7 @@ static void test_invoke_request_with_flags(
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;

@ -130,6 +130,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -167,6 +168,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -184,6 +186,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) {
cq_expect_completion(cqv, tag(102), 1);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;

@ -126,6 +126,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -155,6 +156,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;

@ -115,6 +115,7 @@ static void test_early_server_shutdown_finishes_inflight_calls(
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -149,6 +150,7 @@ static void test_early_server_shutdown_finishes_inflight_calls(
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;

@ -117,6 +117,7 @@ static void simple_delayed_request_body(grpc_end2end_test_config config,
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -152,6 +153,7 @@ static void simple_delayed_request_body(grpc_end2end_test_config config,
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;

@ -141,6 +141,7 @@ static void test_request_response_with_metadata_and_payload(
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 2;
@ -185,6 +186,7 @@ static void test_request_response_with_metadata_and_payload(
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 2;
@ -203,6 +205,7 @@ static void test_request_response_with_metadata_and_payload(
cq_expect_completion(cqv, tag(102), 1);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;

@ -132,6 +132,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -174,6 +175,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) {
gpr_log(GPR_DEBUG, "client_peer=%s", peer);
gpr_free(peer);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;

@ -144,6 +144,7 @@ static void test_request_response_with_metadata_and_payload(
grpc_metadata_array_init(&request_metadata_recv);
grpc_call_details_init(&call_details);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 2;
@ -188,6 +189,7 @@ static void test_request_response_with_metadata_and_payload(
cq_expect_completion(cqv, tag(101), 1);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 2;
@ -206,6 +208,7 @@ static void test_request_response_with_metadata_and_payload(
cq_expect_completion(cqv, tag(102), 1);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER;
op->data.recv_close_on_server.cancelled = &was_cancelled;

@ -65,6 +65,7 @@ static void init_ping_pong_request(void) {
grpc_metadata_array_init(&initial_metadata_recv);
grpc_metadata_array_init(&trailing_metadata_recv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;

@ -115,6 +115,7 @@ int main(int argc, char **argv) {
GPR_ASSERT(call);
cqv = cq_verifier_create(cq);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
@ -133,6 +134,7 @@ int main(int argc, char **argv) {
cq_expect_completion(cqv, tag(1), 0);
cq_verify(cqv);
memset(ops, 0, sizeof(ops));
op = ops;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;

Loading…
Cancel
Save