From 7a4e5b427ccfdef78a170c9e9ba7f04e1f59b0fe Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Fri, 17 Feb 2017 09:28:46 -0800 Subject: Completion queue creation API change (JUST API change. No functionality change) --- include/grpc/grpc.h | 44 ++++++++++++++++++++++++++++++++- src/core/lib/surface/completion_queue.c | 27 ++++++++++++++++---- 2 files changed, 65 insertions(+), 6 deletions(-) diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index 1b33d48c02..5874710bd4 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -93,9 +93,51 @@ GRPCAPI const char *grpc_version_string(void); /** Return a string specifying what the 'g' in gRPC stands for */ GRPCAPI const char *grpc_g_stands_for(void); -/** Create a completion queue */ +/** Specifies the type of APIs to use to pop events from the completion queue */ +typedef enum { + /** Events are popped out by calling grpc_completion_queue_next() API ONLY */ + GRPC_CQ_NEXT = 1, + /** Events are popped out by calling grpc_completion_queue_pluck() API ONLY*/ + GRPC_CQ_PLUCK +} grpc_cq_completion_type; + +/** Completion queues internally MAY maintain a set of file descriptors in a + structure called 'pollset'. This enum specifies if a completion queue has an + associated pollset and any restrictions on the type of file descriptors that + can be present in the pollset. + + I/O progress can only be made when grpc_completion_queue_next() or + grpc_completion_queue_pluck() are called on the completion queue (unless the + grpc_cq_polling_type is NON_POLLING) and hence it is very important to + actively call these APIs */ +typedef enum { + /** The completion queue will have an associated pollset and there is no + restriction on the type of file descriptors the pollset may contain */ + DEFAULT_POLLING, + + /** Similar to DEFAULT_POLLING except that the completion queues will not + contain any 'listening file descriptors' (i.e file descriptors used to + listen to incoming channels */ + NON_LISTENING, + + /** The completion queue will not have an associated pollset. Note that + grpc_completion_queue_next() or grpc_completion_queue_pluck() MUST still + be called to pop events from the completion queue; it is not required to + call them actively to make I/O progress */ + NON_POLLING +} grpc_cq_polling_type; + +/** Create a completion queue. + + WARNING: This API is deprecated and will soon be deleted and replaced with + completion_queue_create_ex() */ GRPCAPI grpc_completion_queue *grpc_completion_queue_create(void *reserved); +/** Create a completion queue */ +GRPCAPI grpc_completion_queue *grpc_completion_queue_create_ex( + grpc_cq_completion_type completion_type, grpc_cq_polling_type polling_type, + void *reserved); + /** Blocks until an event is available, the completion queue is being shut down, or deadline is reached. diff --git a/src/core/lib/surface/completion_queue.c b/src/core/lib/surface/completion_queue.c index b4594817e4..59148fa6a5 100644 --- a/src/core/lib/surface/completion_queue.c +++ b/src/core/lib/surface/completion_queue.c @@ -64,6 +64,10 @@ typedef struct { struct grpc_completion_queue { /** owned by pollset */ gpr_mu *mu; + + grpc_cq_completion_type completion_type; + grpc_cq_polling_type polling_type; + /** completed events */ grpc_cq_completion completed_head; grpc_cq_completion *completed_tail; @@ -79,6 +83,7 @@ struct grpc_completion_queue { int shutdown_called; int is_server_cq; /** Can the server cq accept incoming channels */ + /* TODO: sreek - This will no longer be needed. Use polling_type set */ int is_non_listening_server_cq; int num_pluckers; plucker pluckers[GRPC_MAX_COMPLETION_QUEUE_PLUCKERS]; @@ -110,7 +115,9 @@ int grpc_cq_event_timeout_trace; static void on_pollset_shutdown_done(grpc_exec_ctx *exec_ctx, void *cc, grpc_error *error); -grpc_completion_queue *grpc_completion_queue_create(void *reserved) { +grpc_completion_queue *grpc_completion_queue_create_ex( + grpc_cq_completion_type completion_type, grpc_cq_polling_type polling_type, + void *reserved) { grpc_completion_queue *cc; GPR_ASSERT(!reserved); @@ -148,6 +155,10 @@ grpc_completion_queue *grpc_completion_queue_create(void *reserved) { return cc; } +grpc_completion_queue *grpc_completion_queue_create(void *reserved) { + return grpc_completion_queue_create_ex(0, DEFAULT_POLLING, reserved); +} + #ifdef GRPC_CQ_REF_COUNT_DEBUG void grpc_cq_internal_ref(grpc_completion_queue *cc, const char *reason, const char *file, int line) { @@ -356,8 +367,9 @@ grpc_event grpc_completion_queue_next(grpc_completion_queue *cc, "deadline=gpr_timespec { tv_sec: %" PRId64 ", tv_nsec: %d, clock_type: %d }, " "reserved=%p)", - 5, (cc, deadline.tv_sec, deadline.tv_nsec, (int)deadline.clock_type, - reserved)); + 5, + (cc, deadline.tv_sec, deadline.tv_nsec, (int)deadline.clock_type, + reserved)); GPR_ASSERT(!reserved); dump_pending_tags(cc); @@ -524,8 +536,9 @@ grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cc, void *tag, "deadline=gpr_timespec { tv_sec: %" PRId64 ", tv_nsec: %d, clock_type: %d }, " "reserved=%p)", - 6, (cc, tag, deadline.tv_sec, deadline.tv_nsec, - (int)deadline.clock_type, reserved)); + 6, + (cc, tag, deadline.tv_sec, deadline.tv_nsec, (int)deadline.clock_type, + reserved)); } GPR_ASSERT(!reserved); @@ -681,10 +694,14 @@ grpc_completion_queue *grpc_cq_from_pollset(grpc_pollset *ps) { } void grpc_cq_mark_non_listening_server_cq(grpc_completion_queue *cc) { + /* TODO: sreek - use cc->polling_type field here and add a validation check + (i.e grpc_cq_mark_non_listening_server_cq can only be called on a cc whose + polling_type is set to NON_LISTENING */ cc->is_non_listening_server_cq = 1; } bool grpc_cq_is_non_listening_server_cq(grpc_completion_queue *cc) { + /* TODO (sreek) - return (cc->polling_type == NON_LISTENING) */ return (cc->is_non_listening_server_cq == 1); } -- cgit v1.2.3 From 321881d07f7806601bbf6d7929f4e4e58bc1e913 Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Mon, 27 Feb 2017 11:25:28 -0800 Subject: Change Core to use the new completion_queue_create API --- include/grpc/grpc.h | 8 +- src/core/lib/surface/completion_queue.c | 27 ++- src/core/lib/surface/completion_queue.h | 3 + src/core/lib/surface/server.c | 18 +- test/core/bad_client/bad_client.c | 10 +- test/core/bad_ssl/bad_ssl_test.c | 3 +- test/core/bad_ssl/server_common.c | 22 ++- test/core/client_channel/lb_policies_test.c | 24 +-- .../set_initial_connect_string_test.c | 2 +- test/core/end2end/bad_server_response_test.c | 2 +- test/core/end2end/connection_refused_test.c | 2 +- test/core/end2end/dualstack_socket_test.c | 12 +- test/core/end2end/end2end_tests.h | 1 + test/core/end2end/fixtures/h2_census.c | 11 +- test/core/end2end/fixtures/h2_compress.c | 11 +- test/core/end2end/fixtures/h2_fakesec.c | 4 +- test/core/end2end/fixtures/h2_fd.c | 4 +- test/core/end2end/fixtures/h2_full+pipe.c | 11 +- test/core/end2end/fixtures/h2_full+trace.c | 11 +- test/core/end2end/fixtures/h2_full.c | 11 +- test/core/end2end/fixtures/h2_http_proxy.c | 11 +- test/core/end2end/fixtures/h2_load_reporting.c | 4 +- test/core/end2end/fixtures/h2_oauth2.c | 4 +- test/core/end2end/fixtures/h2_proxy.c | 13 +- test/core/end2end/fixtures/h2_sockpair+trace.c | 4 +- test/core/end2end/fixtures/h2_sockpair.c | 4 +- test/core/end2end/fixtures/h2_sockpair_1byte.c | 4 +- test/core/end2end/fixtures/h2_ssl.c | 4 +- test/core/end2end/fixtures/h2_ssl_cert.c | 32 ++-- test/core/end2end/fixtures/h2_ssl_proxy.c | 4 +- test/core/end2end/fixtures/h2_uds.c | 11 +- test/core/end2end/fixtures/proxy.c | 2 +- test/core/end2end/fuzzers/api_fuzzer.c | 28 +-- test/core/end2end/fuzzers/client_fuzzer.c | 3 +- test/core/end2end/fuzzers/server_fuzzer.c | 3 +- test/core/end2end/goaway_server_test.c | 2 +- test/core/end2end/invalid_call_argument_test.c | 11 +- test/core/end2end/multiple_server_queues_test.c | 14 +- test/core/end2end/no_server_test.c | 2 +- test/core/end2end/tests/authority_not_supported.c | 8 +- test/core/end2end/tests/bad_hostname.c | 8 +- test/core/end2end/tests/binary_metadata.c | 8 +- test/core/end2end/tests/call_creds.c | 5 +- test/core/end2end/tests/cancel_after_accept.c | 8 +- test/core/end2end/tests/cancel_after_client_done.c | 8 +- test/core/end2end/tests/cancel_after_invoke.c | 8 +- test/core/end2end/tests/cancel_before_invoke.c | 8 +- test/core/end2end/tests/cancel_in_a_vacuum.c | 8 +- test/core/end2end/tests/cancel_with_status.c | 8 +- test/core/end2end/tests/compressed_payload.c | 8 +- test/core/end2end/tests/connectivity.c | 3 + test/core/end2end/tests/default_host.c | 8 +- test/core/end2end/tests/disappearing_server.c | 3 + test/core/end2end/tests/empty_batch.c | 8 +- test/core/end2end/tests/filter_call_init_fails.c | 8 +- test/core/end2end/tests/filter_causes_close.c | 8 +- test/core/end2end/tests/filter_latency.c | 8 +- test/core/end2end/tests/graceful_server_shutdown.c | 2 + test/core/end2end/tests/high_initial_seqno.c | 8 +- test/core/end2end/tests/hpack_size.c | 8 +- test/core/end2end/tests/idempotent_request.c | 8 +- test/core/end2end/tests/invoke_large_request.c | 8 +- test/core/end2end/tests/large_metadata.c | 8 +- test/core/end2end/tests/load_reporting_hook.c | 8 +- test/core/end2end/tests/max_concurrent_streams.c | 8 +- test/core/end2end/tests/max_message_length.c | 8 +- test/core/end2end/tests/negative_deadline.c | 8 +- test/core/end2end/tests/network_status_change.c | 8 +- test/core/end2end/tests/no_logging.c | 8 +- test/core/end2end/tests/no_op.c | 8 +- test/core/end2end/tests/payload.c | 8 +- test/core/end2end/tests/ping.c | 3 + test/core/end2end/tests/ping_pong_streaming.c | 8 +- test/core/end2end/tests/registered_call.c | 8 +- test/core/end2end/tests/request_with_flags.c | 8 +- test/core/end2end/tests/request_with_payload.c | 8 +- test/core/end2end/tests/resource_quota_server.c | 8 +- test/core/end2end/tests/server_finishes_request.c | 8 +- test/core/end2end/tests/shutdown_finishes_calls.c | 2 + test/core/end2end/tests/shutdown_finishes_tags.c | 2 + test/core/end2end/tests/simple_cacheable_request.c | 8 +- test/core/end2end/tests/simple_delayed_request.c | 8 +- test/core/end2end/tests/simple_metadata.c | 8 +- test/core/end2end/tests/simple_request.c | 8 +- test/core/end2end/tests/streaming_error_response.c | 8 +- test/core/end2end/tests/trailing_metadata.c | 8 +- test/core/end2end/tests/write_buffering.c | 8 +- test/core/end2end/tests/write_buffering_at_end.c | 8 +- test/core/fling/client.c | 2 +- test/core/fling/server.c | 23 ++- test/core/handshake/client_ssl.c | 4 +- test/core/handshake/server_ssl.c | 3 +- test/core/memory_usage/client.c | 7 +- test/core/memory_usage/server.c | 21 ++- test/core/surface/alarm_test.c | 2 +- test/core/surface/completion_queue_test.c | 192 ++++++++++++++------- test/core/surface/concurrent_connectivity_test.c | 5 +- test/core/surface/lame_client_test.c | 2 +- test/core/surface/sequential_connectivity_test.c | 6 +- test/core/surface/server_chttp2_test.c | 3 +- test/core/surface/server_test.c | 9 +- 101 files changed, 658 insertions(+), 334 deletions(-) diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index 5874710bd4..0e4711fa1f 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -127,14 +127,8 @@ typedef enum { NON_POLLING } grpc_cq_polling_type; -/** Create a completion queue. - - WARNING: This API is deprecated and will soon be deleted and replaced with - completion_queue_create_ex() */ -GRPCAPI grpc_completion_queue *grpc_completion_queue_create(void *reserved); - /** Create a completion queue */ -GRPCAPI grpc_completion_queue *grpc_completion_queue_create_ex( +GRPCAPI grpc_completion_queue *grpc_completion_queue_create( grpc_cq_completion_type completion_type, grpc_cq_polling_type polling_type, void *reserved); diff --git a/src/core/lib/surface/completion_queue.c b/src/core/lib/surface/completion_queue.c index 59148fa6a5..d45e265d5c 100644 --- a/src/core/lib/surface/completion_queue.c +++ b/src/core/lib/surface/completion_queue.c @@ -115,7 +115,7 @@ int grpc_cq_event_timeout_trace; static void on_pollset_shutdown_done(grpc_exec_ctx *exec_ctx, void *cc, grpc_error *error); -grpc_completion_queue *grpc_completion_queue_create_ex( +grpc_completion_queue *grpc_completion_queue_create( grpc_cq_completion_type completion_type, grpc_cq_polling_type polling_type, void *reserved) { grpc_completion_queue *cc; @@ -132,6 +132,9 @@ grpc_completion_queue *grpc_completion_queue_create_ex( cc->outstanding_tag_capacity = 0; #endif + cc->completion_type = completion_type; + cc->polling_type = polling_type; + /* Initial ref is dropped by grpc_completion_queue_shutdown */ gpr_ref_init(&cc->pending_events, 1); /* One for destroy(), one for pollset_shutdown */ @@ -155,8 +158,12 @@ grpc_completion_queue *grpc_completion_queue_create_ex( return cc; } -grpc_completion_queue *grpc_completion_queue_create(void *reserved) { - return grpc_completion_queue_create_ex(0, DEFAULT_POLLING, reserved); +grpc_cq_completion_type grpc_get_cq_completion_type(grpc_completion_queue *cc) { + return cc->completion_type; +} + +grpc_cq_polling_type grpc_get_cq_polling_type(grpc_completion_queue *cc) { + return cc->polling_type; } #ifdef GRPC_CQ_REF_COUNT_DEBUG @@ -359,6 +366,13 @@ grpc_event grpc_completion_queue_next(grpc_completion_queue *cc, grpc_pollset_worker *worker = NULL; gpr_timespec now; + if (cc->completion_type != GRPC_CQ_NEXT) { + gpr_log(GPR_ERROR, + "grpc_completion_queue_next() cannot be called on this completion " + "queue since its completion type is not GRPC_CQ_NEXT"); + abort(); + } + GPR_TIMER_BEGIN("grpc_completion_queue_next", 0); GRPC_API_TRACE( @@ -529,6 +543,13 @@ grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cc, void *tag, GPR_TIMER_BEGIN("grpc_completion_queue_pluck", 0); + if (cc->completion_type != GRPC_CQ_PLUCK) { + gpr_log(GPR_ERROR, + "grpc_completion_queue_pluck() cannot be called on this completion " + "queue since its completion type is not GRPC_CQ_PLUCK"); + abort(); + } + if (grpc_cq_pluck_trace) { GRPC_API_TRACE( "grpc_completion_queue_pluck(" diff --git a/src/core/lib/surface/completion_queue.h b/src/core/lib/surface/completion_queue.h index 5d73dd7216..21f28e9424 100644 --- a/src/core/lib/surface/completion_queue.h +++ b/src/core/lib/surface/completion_queue.h @@ -99,4 +99,7 @@ bool grpc_cq_is_non_listening_server_cq(grpc_completion_queue *cc); void grpc_cq_mark_server_cq(grpc_completion_queue *cc); int grpc_cq_is_server_cq(grpc_completion_queue *cc); +grpc_cq_completion_type grpc_get_cq_completion_type(grpc_completion_queue *cc); +grpc_cq_polling_type grpc_get_cq_polling_type(grpc_completion_queue *cc); + #endif /* GRPC_CORE_LIB_SURFACE_COMPLETION_QUEUE_H */ diff --git a/src/core/lib/surface/server.c b/src/core/lib/surface/server.c index b360579553..13f7321fac 100644 --- a/src/core/lib/surface/server.c +++ b/src/core/lib/surface/server.c @@ -1001,6 +1001,14 @@ void grpc_server_register_completion_queue(grpc_server *server, GRPC_API_TRACE( "grpc_server_register_completion_queue(server=%p, cq=%p, reserved=%p)", 3, (server, cq, reserved)); + + if (grpc_get_cq_completion_type(cq) != GRPC_CQ_NEXT) { + gpr_log( + GPR_ERROR, + "Server completion queues must have a completion type of GRPC_CQ_NEXT"); + abort(); + } + register_completion_queue(server, cq, false, reserved); } @@ -1423,8 +1431,9 @@ grpc_call_error grpc_server_request_call( "grpc_server_request_call(" "server=%p, call=%p, details=%p, initial_metadata=%p, " "cq_bound_to_call=%p, cq_for_notification=%p, tag=%p)", - 7, (server, call, details, initial_metadata, cq_bound_to_call, - cq_for_notification, tag)); + 7, + (server, call, details, initial_metadata, cq_bound_to_call, + cq_for_notification, tag)); size_t cq_idx; for (cq_idx = 0; cq_idx < server->cq_count; cq_idx++) { if (server->cqs[cq_idx] == cq_for_notification) { @@ -1466,8 +1475,9 @@ grpc_call_error grpc_server_request_registered_call( "server=%p, rmp=%p, call=%p, deadline=%p, initial_metadata=%p, " "optional_payload=%p, cq_bound_to_call=%p, cq_for_notification=%p, " "tag=%p)", - 9, (server, rmp, call, deadline, initial_metadata, optional_payload, - cq_bound_to_call, cq_for_notification, tag)); + 9, + (server, rmp, call, deadline, initial_metadata, optional_payload, + cq_bound_to_call, cq_for_notification, tag)); size_t cq_idx; for (cq_idx = 0; cq_idx < server->cq_count; cq_idx++) { diff --git a/test/core/bad_client/bad_client.c b/test/core/bad_client/bad_client.c index fdedfe284e..a6e859d06e 100644 --- a/test/core/bad_client/bad_client.c +++ b/test/core/bad_client/bad_client.c @@ -104,6 +104,7 @@ void grpc_run_bad_client_test( grpc_slice_buffer outgoing; grpc_closure done_write_closure; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_completion_queue *shutdown_cq; hex = gpr_dump(client_payload, client_payload_length, GPR_DUMP_HEX | GPR_DUMP_ASCII); @@ -124,7 +125,7 @@ void grpc_run_bad_client_test( /* Create server, completion events */ a.server = grpc_server_create(NULL, NULL); - a.cq = grpc_completion_queue_create(NULL); + a.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); gpr_event_init(&a.done_thd); gpr_event_init(&a.done_write); a.validator = server_validator; @@ -195,10 +196,13 @@ void grpc_run_bad_client_test( grpc_endpoint_destroy(&exec_ctx, sfd.client); grpc_exec_ctx_finish(&exec_ctx); } - grpc_server_shutdown_and_notify(a.server, a.cq, NULL); + + shutdown_cq = grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + grpc_server_shutdown_and_notify(a.server, shutdown_cq, NULL); GPR_ASSERT(grpc_completion_queue_pluck( - a.cq, NULL, grpc_timeout_seconds_to_deadline(1), NULL) + shutdown_cq, NULL, grpc_timeout_seconds_to_deadline(1), NULL) .type == GRPC_OP_COMPLETE); + grpc_completion_queue_destroy(shutdown_cq); grpc_server_destroy(a.server); grpc_completion_queue_destroy(a.cq); grpc_slice_buffer_destroy_internal(&exec_ctx, &outgoing); diff --git a/test/core/bad_ssl/bad_ssl_test.c b/test/core/bad_ssl/bad_ssl_test.c index bd85585706..4d34f8a9ea 100644 --- a/test/core/bad_ssl/bad_ssl_test.c +++ b/test/core/bad_ssl/bad_ssl_test.c @@ -61,7 +61,8 @@ static void run_test(const char *target, size_t nops) { grpc_status_code status; grpc_call_error error; gpr_timespec deadline = grpc_timeout_seconds_to_deadline(5); - grpc_completion_queue *cq = grpc_completion_queue_create(NULL); + grpc_completion_queue *cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); cq_verifier *cqv = cq_verifier_create(cq); grpc_op ops[6]; diff --git a/test/core/bad_ssl/server_common.c b/test/core/bad_ssl/server_common.c index 6a4313eafd..383899d94a 100644 --- a/test/core/bad_ssl/server_common.c +++ b/test/core/bad_ssl/server_common.c @@ -66,7 +66,10 @@ void bad_ssl_run(grpc_server *server) { grpc_call *s = NULL; grpc_call_details call_details; grpc_metadata_array request_metadata_recv; - grpc_completion_queue *cq = grpc_completion_queue_create(NULL); + + grpc_completion_queue *cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + grpc_completion_queue *shutdown_cq; grpc_call_details_init(&call_details); grpc_metadata_array_init(&request_metadata_recv); @@ -82,16 +85,21 @@ void bad_ssl_run(grpc_server *server) { while (!shutdown_finished) { if (got_sigint && !shutdown_started) { gpr_log(GPR_INFO, "Shutting down due to SIGINT"); - grpc_server_shutdown_and_notify(server, cq, NULL); - GPR_ASSERT(grpc_completion_queue_pluck( - cq, NULL, grpc_timeout_seconds_to_deadline(5), NULL) - .type == GRPC_OP_COMPLETE); + shutdown_cq = + grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + grpc_server_shutdown_and_notify(server, shutdown_cq, NULL); + GPR_ASSERT( + grpc_completion_queue_pluck(shutdown_cq, NULL, + grpc_timeout_seconds_to_deadline(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_completion_queue_destroy(shutdown_cq); grpc_completion_queue_shutdown(cq); shutdown_started = 1; } ev = grpc_completion_queue_next( - cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_micros(1000000, GPR_TIMESPAN)), + cq, + gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_micros(1000000, GPR_TIMESPAN)), NULL); switch (ev.type) { case GRPC_OP_COMPLETE: diff --git a/test/core/client_channel/lb_policies_test.c b/test/core/client_channel/lb_policies_test.c index 057b90ec84..9dcbdb979d 100644 --- a/test/core/client_channel/lb_policies_test.c +++ b/test/core/client_channel/lb_policies_test.c @@ -59,14 +59,15 @@ typedef struct servers_fixture { grpc_server **servers; grpc_call **server_calls; grpc_completion_queue *cq; + grpc_completion_queue *shutdown_cq; char **servers_hostports; grpc_metadata_array *request_metadata_recv; } servers_fixture; typedef struct request_sequences { - size_t n; /* number of iterations */ - int *connections; /* indexed by the interation number, value is the index of - the server it connected to or -1 if none */ + size_t n; /* number of iterations */ + int *connections; /* indexed by the interation number, value is the index of + the server it connected to or -1 if none */ int *connectivity_states; /* indexed by the interation number, value is the client connectivity state */ } request_sequences; @@ -146,10 +147,10 @@ static void drain_cq(grpc_completion_queue *cq) { static void kill_server(const servers_fixture *f, size_t i) { gpr_log(GPR_INFO, "KILLING SERVER %" PRIuPTR, i); GPR_ASSERT(f->servers[i] != NULL); - grpc_server_shutdown_and_notify(f->servers[i], f->cq, tag(10000)); - GPR_ASSERT( - grpc_completion_queue_pluck(f->cq, tag(10000), n_millis_time(5000), NULL) - .type == GRPC_OP_COMPLETE); + grpc_server_shutdown_and_notify(f->servers[i], f->shutdown_cq, tag(10000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(10000), + n_millis_time(5000), NULL) + .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->servers[i]); f->servers[i] = NULL; } @@ -196,7 +197,9 @@ static servers_fixture *setup_servers(const char *server_host, /* Create servers. */ f->servers = gpr_malloc(sizeof(grpc_server *) * num_servers); f->servers_hostports = gpr_malloc(sizeof(char *) * num_servers); - f->cq = grpc_completion_queue_create(NULL); + f->cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f->shutdown_cq = + grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); for (i = 0; i < num_servers; i++) { grpc_metadata_array_init(&f->request_metadata_recv[i]); gpr_join_host_port(&f->servers_hostports[i], server_host, @@ -212,8 +215,8 @@ static void teardown_servers(servers_fixture *f) { /* Destroy server. */ for (i = 0; i < f->num_servers; i++) { if (f->servers[i] == NULL) continue; - grpc_server_shutdown_and_notify(f->servers[i], f->cq, tag(10000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(10000), + grpc_server_shutdown_and_notify(f->servers[i], f->shutdown_cq, tag(10000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(10000), n_millis_time(5000), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->servers[i]); @@ -221,6 +224,7 @@ static void teardown_servers(servers_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); gpr_free(f->servers); diff --git a/test/core/client_channel/set_initial_connect_string_test.c b/test/core/client_channel/set_initial_connect_string_test.c index a0a33667cc..38f2fbac62 100644 --- a/test/core/client_channel/set_initial_connect_string_test.c +++ b/test/core/client_channel/set_initial_connect_string_test.c @@ -130,7 +130,7 @@ static gpr_timespec n_sec_deadline(int seconds) { } static void start_rpc(int use_creds, int target_port) { - state.cq = grpc_completion_queue_create(NULL); + state.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); if (use_creds) { state.creds = grpc_fake_transport_security_credentials_create(); } else { diff --git a/test/core/end2end/bad_server_response_test.c b/test/core/end2end/bad_server_response_test.c index 39a98e84ca..67f5bdbac8 100644 --- a/test/core/end2end/bad_server_response_test.c +++ b/test/core/end2end/bad_server_response_test.c @@ -178,7 +178,7 @@ static void start_rpc(int target_port, grpc_status_code expected_status, cq_verifier *cqv; grpc_slice details; - state.cq = grpc_completion_queue_create(NULL); + state.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); cqv = cq_verifier_create(state.cq); gpr_join_host_port(&state.target, "127.0.0.1", target_port); state.channel = grpc_insecure_channel_create(state.target, NULL, NULL); diff --git a/test/core/end2end/connection_refused_test.c b/test/core/end2end/connection_refused_test.c index 16a3005539..617828f954 100644 --- a/test/core/end2end/connection_refused_test.c +++ b/test/core/end2end/connection_refused_test.c @@ -69,7 +69,7 @@ static void run_test(bool wait_for_ready, bool use_service_config) { grpc_metadata_array_init(&trailing_metadata_recv); - cq = grpc_completion_queue_create(NULL); + cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); cqv = cq_verifier_create(cq); /* if using service config, create channel args */ diff --git a/test/core/end2end/dualstack_socket_test.c b/test/core/end2end/dualstack_socket_test.c index 3623bd7be8..5125be9b94 100644 --- a/test/core/end2end/dualstack_socket_test.c +++ b/test/core/end2end/dualstack_socket_test.c @@ -76,6 +76,7 @@ void test_connect(const char *server_host, const char *client_host, int port, grpc_channel *client; grpc_server *server; grpc_completion_queue *cq; + grpc_completion_queue *shutdown_cq; grpc_call *c; grpc_call *s; cq_verifier *cqv; @@ -107,7 +108,7 @@ void test_connect(const char *server_host, const char *client_host, int port, grpc_call_details_init(&call_details); /* Create server. */ - cq = grpc_completion_queue_create(NULL); + cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); server = grpc_server_create(NULL, NULL); grpc_server_register_completion_queue(server, cq, NULL); GPR_ASSERT((got_port = grpc_server_add_insecure_http2_port( @@ -259,11 +260,14 @@ void test_connect(const char *server_host, const char *client_host, int port, grpc_channel_destroy(client); /* Destroy server. */ - grpc_server_shutdown_and_notify(server, cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + shutdown_cq = grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + grpc_server_shutdown_and_notify(server, shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(server); + grpc_completion_queue_destroy(shutdown_cq); grpc_completion_queue_shutdown(cq); drain_cq(cq); grpc_completion_queue_destroy(cq); diff --git a/test/core/end2end/end2end_tests.h b/test/core/end2end/end2end_tests.h index cb0afd9cd9..ac87c55dc4 100644 --- a/test/core/end2end/end2end_tests.h +++ b/test/core/end2end/end2end_tests.h @@ -50,6 +50,7 @@ typedef struct grpc_end2end_test_config grpc_end2end_test_config; struct grpc_end2end_test_fixture { grpc_completion_queue *cq; + grpc_completion_queue *shutdown_cq; grpc_server *server; grpc_channel *client; void *fixture_data; diff --git a/test/core/end2end/fixtures/h2_census.c b/test/core/end2end/fixtures/h2_census.c index 8e60123ed6..a1fae013c2 100644 --- a/test/core/end2end/fixtures/h2_census.c +++ b/test/core/end2end/fixtures/h2_census.c @@ -65,7 +65,9 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(NULL); + f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.shutdown_cq = + grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); return f; } @@ -119,9 +121,10 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack+census", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack+census", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_compress.c b/test/core/end2end/fixtures/h2_compress.c index c01e45664b..7a2aa7ff7f 100644 --- a/test/core/end2end/fixtures/h2_compress.c +++ b/test/core/end2end/fixtures/h2_compress.c @@ -69,7 +69,9 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_compression( memset(&f, 0, sizeof(f)); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(NULL); + f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.shutdown_cq = + grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); return f; } @@ -119,9 +121,10 @@ void chttp2_tear_down_fullstack_compression(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack_compression", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack_compression", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack_compression, chttp2_init_client_fullstack_compression, chttp2_init_server_fullstack_compression, diff --git a/test/core/end2end/fixtures/h2_fakesec.c b/test/core/end2end/fixtures/h2_fakesec.c index c9747913c2..0ccdef9767 100644 --- a/test/core/end2end/fixtures/h2_fakesec.c +++ b/test/core/end2end/fixtures/h2_fakesec.c @@ -60,7 +60,9 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(NULL); + f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.shutdown_cq = + grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); return f; } diff --git a/test/core/end2end/fixtures/h2_fd.c b/test/core/end2end/fixtures/h2_fd.c index 223fadc386..d97b693e33 100644 --- a/test/core/end2end/fixtures/h2_fd.c +++ b/test/core/end2end/fixtures/h2_fd.c @@ -70,7 +70,9 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( grpc_end2end_test_fixture f; memset(&f, 0, sizeof(f)); f.fixture_data = fixture_data; - f.cq = grpc_completion_queue_create(NULL); + f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.shutdown_cq = + grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); create_sockets(fixture_data->fd_pair); diff --git a/test/core/end2end/fixtures/h2_full+pipe.c b/test/core/end2end/fixtures/h2_full+pipe.c index c6013f3040..812922ff5b 100644 --- a/test/core/end2end/fixtures/h2_full+pipe.c +++ b/test/core/end2end/fixtures/h2_full+pipe.c @@ -70,7 +70,9 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(NULL); + f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.shutdown_cq = + grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); return f; } @@ -102,9 +104,10 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_full+trace.c b/test/core/end2end/fixtures/h2_full+trace.c index 01316376e0..02d794d08d 100644 --- a/test/core/end2end/fixtures/h2_full+trace.c +++ b/test/core/end2end/fixtures/h2_full+trace.c @@ -70,7 +70,9 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(NULL); + f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.shutdown_cq = + grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); return f; } @@ -102,9 +104,10 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_full.c b/test/core/end2end/fixtures/h2_full.c index 3399f1981e..bfb300e42f 100644 --- a/test/core/end2end/fixtures/h2_full.c +++ b/test/core/end2end/fixtures/h2_full.c @@ -64,7 +64,9 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(NULL); + f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.shutdown_cq = + grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); return f; } @@ -96,9 +98,10 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_http_proxy.c b/test/core/end2end/fixtures/h2_http_proxy.c index 44b223664a..0f8e002e56 100644 --- a/test/core/end2end/fixtures/h2_http_proxy.c +++ b/test/core/end2end/fixtures/h2_http_proxy.c @@ -69,7 +69,9 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( ffd->proxy = grpc_end2end_http_proxy_create(); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(NULL); + f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.shutdown_cq = + grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); return f; } @@ -107,9 +109,10 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_load_reporting.c b/test/core/end2end/fixtures/h2_load_reporting.c index 38321f34db..664c7ba9d4 100644 --- a/test/core/end2end/fixtures/h2_load_reporting.c +++ b/test/core/end2end/fixtures/h2_load_reporting.c @@ -67,7 +67,9 @@ static grpc_end2end_test_fixture chttp2_create_fixture_load_reporting( gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(NULL); + f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.shutdown_cq = + grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); return f; } diff --git a/test/core/end2end/fixtures/h2_oauth2.c b/test/core/end2end/fixtures/h2_oauth2.c index 3351652858..73928759fe 100644 --- a/test/core/end2end/fixtures/h2_oauth2.c +++ b/test/core/end2end/fixtures/h2_oauth2.c @@ -113,7 +113,9 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(NULL); + f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.shutdown_cq = + grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); return f; } diff --git a/test/core/end2end/fixtures/h2_proxy.c b/test/core/end2end/fixtures/h2_proxy.c index 9e37ed4db3..016ba41fbd 100644 --- a/test/core/end2end/fixtures/h2_proxy.c +++ b/test/core/end2end/fixtures/h2_proxy.c @@ -79,7 +79,9 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( ffd->proxy = grpc_end2end_proxy_create(&proxy_def, client_args, server_args); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(NULL); + f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.shutdown_cq = + grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); return f; } @@ -113,10 +115,11 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack+proxy", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_REQUEST_PROXYING | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack+proxy", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_REQUEST_PROXYING | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_sockpair+trace.c b/test/core/end2end/fixtures/h2_sockpair+trace.c index edf42a4070..445f8a2dd1 100644 --- a/test/core/end2end/fixtures/h2_sockpair+trace.c +++ b/test/core/end2end/fixtures/h2_sockpair+trace.c @@ -94,7 +94,9 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( grpc_end2end_test_fixture f; memset(&f, 0, sizeof(f)); f.fixture_data = sfd; - f.cq = grpc_completion_queue_create(NULL); + f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.shutdown_cq = + grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); grpc_resource_quota *resource_quota = grpc_resource_quota_create("fixture"); *sfd = grpc_iomgr_create_endpoint_pair("fixture", resource_quota, 65536); diff --git a/test/core/end2end/fixtures/h2_sockpair.c b/test/core/end2end/fixtures/h2_sockpair.c index 94b2623b3e..66c05c5562 100644 --- a/test/core/end2end/fixtures/h2_sockpair.c +++ b/test/core/end2end/fixtures/h2_sockpair.c @@ -88,7 +88,9 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( grpc_end2end_test_fixture f; memset(&f, 0, sizeof(f)); f.fixture_data = sfd; - f.cq = grpc_completion_queue_create(NULL); + f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.shutdown_cq = + grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); grpc_resource_quota *resource_quota = grpc_resource_quota_create("fixture"); *sfd = grpc_iomgr_create_endpoint_pair("fixture", resource_quota, 65536); diff --git a/test/core/end2end/fixtures/h2_sockpair_1byte.c b/test/core/end2end/fixtures/h2_sockpair_1byte.c index 6f9cf8fe26..2d845f369b 100644 --- a/test/core/end2end/fixtures/h2_sockpair_1byte.c +++ b/test/core/end2end/fixtures/h2_sockpair_1byte.c @@ -88,7 +88,9 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( grpc_end2end_test_fixture f; memset(&f, 0, sizeof(f)); f.fixture_data = sfd; - f.cq = grpc_completion_queue_create(NULL); + f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.shutdown_cq = + grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); grpc_resource_quota *resource_quota = grpc_resource_quota_create("fixture"); *sfd = grpc_iomgr_create_endpoint_pair("fixture", resource_quota, 1); diff --git a/test/core/end2end/fixtures/h2_ssl.c b/test/core/end2end/fixtures/h2_ssl.c index cf44cd093c..d73944fe6c 100644 --- a/test/core/end2end/fixtures/h2_ssl.c +++ b/test/core/end2end/fixtures/h2_ssl.c @@ -64,7 +64,9 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(NULL); + f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.shutdown_cq = + grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); return f; } diff --git a/test/core/end2end/fixtures/h2_ssl_cert.c b/test/core/end2end/fixtures/h2_ssl_cert.c index f62331eea3..c8bd7153c2 100644 --- a/test/core/end2end/fixtures/h2_ssl_cert.c +++ b/test/core/end2end/fixtures/h2_ssl_cert.c @@ -67,7 +67,9 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(NULL); + f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.shutdown_cq = + grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); return f; } @@ -203,15 +205,17 @@ CLIENT_INIT(BAD_CERT_PAIR) typedef enum { SUCCESS, FAIL } test_result; -#define SSL_TEST(request_type, cert_type, result) \ - { \ - {TEST_NAME(request_type, cert_type, result), \ - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | \ - FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS | \ - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL, \ - chttp2_create_fixture_secure_fullstack, CLIENT_INIT_NAME(cert_type), \ - SERVER_INIT_NAME(request_type), chttp2_tear_down_secure_fullstack}, \ - result \ +#define SSL_TEST(request_type, cert_type, result) \ + { \ + {TEST_NAME(request_type, cert_type, result), \ + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | \ + FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS | \ + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL, \ + chttp2_create_fixture_secure_fullstack, \ + CLIENT_INIT_NAME(cert_type), \ + SERVER_INIT_NAME(request_type), \ + chttp2_tear_down_secure_fullstack}, \ + result \ } /* All test configurations */ @@ -289,9 +293,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -310,6 +315,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } static void simple_request_body(grpc_end2end_test_fixture f, diff --git a/test/core/end2end/fixtures/h2_ssl_proxy.c b/test/core/end2end/fixtures/h2_ssl_proxy.c index 740b075bf6..22fbeb1a83 100644 --- a/test/core/end2end/fixtures/h2_ssl_proxy.c +++ b/test/core/end2end/fixtures/h2_ssl_proxy.c @@ -100,7 +100,9 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( ffd->proxy = grpc_end2end_proxy_create(&proxy_def, client_args, server_args); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(NULL); + f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.shutdown_cq = + grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); return f; } diff --git a/test/core/end2end/fixtures/h2_uds.c b/test/core/end2end/fixtures/h2_uds.c index bc973ea8e3..1c7799d5d9 100644 --- a/test/core/end2end/fixtures/h2_uds.c +++ b/test/core/end2end/fixtures/h2_uds.c @@ -70,7 +70,9 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( unique++); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(NULL); + f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.shutdown_cq = + grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); return f; } @@ -101,9 +103,10 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack_uds", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack_uds", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/proxy.c b/test/core/end2end/fixtures/proxy.c index cee053e8c5..7f23eef66a 100644 --- a/test/core/end2end/fixtures/proxy.c +++ b/test/core/end2end/fixtures/proxy.c @@ -104,7 +104,7 @@ grpc_end2end_proxy *grpc_end2end_proxy_create(const grpc_end2end_proxy_def *def, gpr_log(GPR_DEBUG, "PROXY ADDR:%s BACKEND:%s", proxy->proxy_port, proxy->server_port); - proxy->cq = grpc_completion_queue_create(NULL); + proxy->cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); proxy->server = def->create_server(proxy->proxy_port, server_args); proxy->client = def->create_client(proxy->server_port, client_args); diff --git a/test/core/end2end/fuzzers/api_fuzzer.c b/test/core/end2end/fuzzers/api_fuzzer.c index 0de8b9459a..61f972e65e 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.c +++ b/test/core/end2end/fuzzers/api_fuzzer.c @@ -314,8 +314,9 @@ static grpc_call_credentials *read_call_creds(input_stream *inp) { cred_artifact_ctx ctx = CRED_ARTIFACT_CTX_INIT; const char *access_token = read_cred_artifact(&ctx, inp, NULL, 0); grpc_call_credentials *out = - access_token == NULL ? NULL : grpc_access_token_credentials_create( - access_token, NULL); + access_token == NULL + ? NULL + : grpc_access_token_credentials_create(access_token, NULL); cred_artifact_ctx_finish(&ctx); return out; } @@ -409,8 +410,9 @@ void my_resolve_address(grpc_exec_ctx *exec_ctx, const char *addr, r->on_done = on_done; r->addrs = addresses; grpc_timer_init( - exec_ctx, &r->timer, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), - gpr_time_from_seconds(1, GPR_TIMESPAN)), + exec_ctx, &r->timer, + gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), + gpr_time_from_seconds(1, GPR_TIMESPAN)), grpc_closure_create(finish_resolve, r, grpc_schedule_on_exec_ctx), gpr_now(GPR_CLOCK_MONOTONIC)); } @@ -471,8 +473,9 @@ static void sched_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure, fc->ep = ep; fc->deadline = deadline; grpc_timer_init( - exec_ctx, &fc->timer, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), - gpr_time_from_millis(1, GPR_TIMESPAN)), + exec_ctx, &fc->timer, + gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), + gpr_time_from_millis(1, GPR_TIMESPAN)), grpc_closure_create(do_connect, fc, grpc_schedule_on_exec_ctx), gpr_now(GPR_CLOCK_MONOTONIC)); } @@ -735,7 +738,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { g_active_call = new_call(NULL, ROOT); g_resource_quota = grpc_resource_quota_create("api_fuzzer"); - grpc_completion_queue *cq = grpc_completion_queue_create(NULL); + grpc_completion_queue *cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); while (!is_eof(&inp) || g_channel != NULL || g_server != NULL || pending_channel_watches > 0 || pending_pings > 0 || @@ -748,8 +752,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { if (g_server != NULL) { if (!server_shutdown) { grpc_server_shutdown_and_notify( - g_server, cq, create_validator(assert_success_and_decrement, - &pending_server_shutdowns)); + g_server, cq, + create_validator(assert_success_and_decrement, + &pending_server_shutdowns)); server_shutdown = true; pending_server_shutdowns++; } else if (pending_server_shutdowns == 0) { @@ -854,8 +859,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { case 5: { if (g_server != NULL) { grpc_server_shutdown_and_notify( - g_server, cq, create_validator(assert_success_and_decrement, - &pending_server_shutdowns)); + g_server, cq, + create_validator(assert_success_and_decrement, + &pending_server_shutdowns)); pending_server_shutdowns++; server_shutdown = true; } else { diff --git a/test/core/end2end/fuzzers/client_fuzzer.c b/test/core/end2end/fuzzers/client_fuzzer.c index e7e7dbefd0..6b8c09cdf4 100644 --- a/test/core/end2end/fuzzers/client_fuzzer.c +++ b/test/core/end2end/fuzzers/client_fuzzer.c @@ -65,7 +65,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { grpc_mock_endpoint_create(discard_write, resource_quota); grpc_resource_quota_unref_internal(&exec_ctx, resource_quota); - grpc_completion_queue *cq = grpc_completion_queue_create(NULL); + grpc_completion_queue *cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); grpc_transport *transport = grpc_create_chttp2_transport(&exec_ctx, NULL, mock_endpoint, 1); grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL); diff --git a/test/core/end2end/fuzzers/server_fuzzer.c b/test/core/end2end/fuzzers/server_fuzzer.c index 186542d4b2..76fe97ec0f 100644 --- a/test/core/end2end/fuzzers/server_fuzzer.c +++ b/test/core/end2end/fuzzers/server_fuzzer.c @@ -67,7 +67,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { grpc_slice_from_copied_buffer((const char *)data, size)); grpc_server *server = grpc_server_create(NULL, NULL); - grpc_completion_queue *cq = grpc_completion_queue_create(NULL); + grpc_completion_queue *cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); grpc_server_register_completion_queue(server, cq, NULL); // TODO(ctiller): add registered methods (one for POST, one for PUT) // void *registered_method = diff --git a/test/core/end2end/goaway_server_test.c b/test/core/end2end/goaway_server_test.c index a9634bfbae..85d54c16e5 100644 --- a/test/core/end2end/goaway_server_test.c +++ b/test/core/end2end/goaway_server_test.c @@ -121,7 +121,7 @@ int main(int argc, char **argv) { grpc_metadata_array_init(&request_metadata2); grpc_call_details_init(&request_details2); - cq = grpc_completion_queue_create(NULL); + cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); cqv = cq_verifier_create(cq); /* reserve two ports */ diff --git a/test/core/end2end/invalid_call_argument_test.c b/test/core/end2end/invalid_call_argument_test.c index 2a9072570d..0563127af8 100644 --- a/test/core/end2end/invalid_call_argument_test.c +++ b/test/core/end2end/invalid_call_argument_test.c @@ -73,7 +73,8 @@ static void prepare_test(int is_client) { grpc_metadata_array_init(&g_state.initial_metadata_recv); grpc_metadata_array_init(&g_state.trailing_metadata_recv); g_state.deadline = grpc_timeout_seconds_to_deadline(2); - g_state.cq = grpc_completion_queue_create(NULL); + g_state.cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); g_state.cqv = cq_verifier_create(g_state.cq); g_state.details = grpc_empty_slice(); memset(g_state.ops, 0, sizeof(g_state.ops)); @@ -123,6 +124,7 @@ static void prepare_test(int is_client) { } static void cleanup_test() { + grpc_completion_queue *shutdown_cq; grpc_call_destroy(g_state.call); cq_verifier_destroy(g_state.cqv); grpc_channel_destroy(g_state.chan); @@ -131,12 +133,15 @@ static void cleanup_test() { grpc_metadata_array_destroy(&g_state.trailing_metadata_recv); if (!g_state.is_client) { + shutdown_cq = + grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); grpc_call_destroy(g_state.server_call); - grpc_server_shutdown_and_notify(g_state.server, g_state.cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(g_state.cq, tag(1000), + grpc_server_shutdown_and_notify(g_state.server, shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(shutdown_cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); + grpc_completion_queue_destroy(shutdown_cq); grpc_server_destroy(g_state.server); grpc_call_details_destroy(&g_state.call_details); grpc_metadata_array_destroy(&g_state.server_initial_metadata_recv); diff --git a/test/core/end2end/multiple_server_queues_test.c b/test/core/end2end/multiple_server_queues_test.c index 5e2eaf4ae9..94e615f1aa 100644 --- a/test/core/end2end/multiple_server_queues_test.c +++ b/test/core/end2end/multiple_server_queues_test.c @@ -37,27 +37,37 @@ int main(int argc, char **argv) { grpc_completion_queue *cq1; grpc_completion_queue *cq2; + grpc_completion_queue *cq3; grpc_server *server; grpc_test_init(argc, argv); grpc_init(); - cq1 = grpc_completion_queue_create(NULL); - cq2 = grpc_completion_queue_create(NULL); + cq1 = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + cq2 = grpc_completion_queue_create(GRPC_CQ_NEXT, NON_LISTENING, NULL); + cq3 = grpc_completion_queue_create(GRPC_CQ_NEXT, NON_POLLING, NULL); + server = grpc_server_create(NULL, NULL); grpc_server_register_completion_queue(server, cq1, NULL); grpc_server_add_insecure_http2_port(server, "[::]:0"); grpc_server_register_completion_queue(server, cq2, NULL); + grpc_server_register_completion_queue(server, cq3, NULL); + grpc_server_start(server); grpc_server_shutdown_and_notify(server, cq2, NULL); grpc_completion_queue_next(cq2, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); /* cue queue hang */ grpc_completion_queue_shutdown(cq1); grpc_completion_queue_shutdown(cq2); + grpc_completion_queue_shutdown(cq3); + grpc_completion_queue_next(cq1, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); grpc_completion_queue_next(cq2, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + grpc_completion_queue_next(cq3, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + grpc_server_destroy(server); grpc_completion_queue_destroy(cq1); grpc_completion_queue_destroy(cq2); + grpc_completion_queue_destroy(cq3); grpc_shutdown(); return 0; } diff --git a/test/core/end2end/no_server_test.c b/test/core/end2end/no_server_test.c index 26d26d8f7a..e16c129d67 100644 --- a/test/core/end2end/no_server_test.c +++ b/test/core/end2end/no_server_test.c @@ -59,7 +59,7 @@ int main(int argc, char **argv) { grpc_metadata_array_init(&trailing_metadata_recv); - cq = grpc_completion_queue_create(NULL); + cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); cqv = cq_verifier_create(cq); /* create a call, channel to a non existant server */ diff --git a/test/core/end2end/tests/authority_not_supported.c b/test/core/end2end/tests/authority_not_supported.c index 7db2fd6b27..4b6878794d 100644 --- a/test/core/end2end/tests/authority_not_supported.c +++ b/test/core/end2end/tests/authority_not_supported.c @@ -72,9 +72,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -93,6 +94,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } /* Request/response with metadata and payload.*/ diff --git a/test/core/end2end/tests/bad_hostname.c b/test/core/end2end/tests/bad_hostname.c index f50a5805a2..c7bdd34a0b 100644 --- a/test/core/end2end/tests/bad_hostname.c +++ b/test/core/end2end/tests/bad_hostname.c @@ -74,9 +74,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -95,6 +96,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } static void simple_request_body(grpc_end2end_test_fixture f) { diff --git a/test/core/end2end/tests/binary_metadata.c b/test/core/end2end/tests/binary_metadata.c index 7fb60f4495..90258185ba 100644 --- a/test/core/end2end/tests/binary_metadata.c +++ b/test/core/end2end/tests/binary_metadata.c @@ -72,9 +72,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -93,6 +94,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } /* Request/response with metadata and payload.*/ diff --git a/test/core/end2end/tests/call_creds.c b/test/core/end2end/tests/call_creds.c index 38cba50e12..2a9269345e 100644 --- a/test/core/end2end/tests/call_creds.c +++ b/test/core/end2end/tests/call_creds.c @@ -90,9 +90,9 @@ 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->cq, tag(1000)); + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + f->shutdown_cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -111,6 +111,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } static void print_auth_context(int is_client, const grpc_auth_context *ctx) { diff --git a/test/core/end2end/tests/cancel_after_accept.c b/test/core/end2end/tests/cancel_after_accept.c index 1a92aa4837..3c59511ebe 100644 --- a/test/core/end2end/tests/cancel_after_accept.c +++ b/test/core/end2end/tests/cancel_after_accept.c @@ -79,9 +79,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -100,6 +101,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } /* Cancel after accept, no payload */ diff --git a/test/core/end2end/tests/cancel_after_client_done.c b/test/core/end2end/tests/cancel_after_client_done.c index 0afeecb037..2edadeff42 100644 --- a/test/core/end2end/tests/cancel_after_client_done.c +++ b/test/core/end2end/tests/cancel_after_client_done.c @@ -73,9 +73,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -94,6 +95,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } /* Cancel after accept with a writes closed, no payload */ diff --git a/test/core/end2end/tests/cancel_after_invoke.c b/test/core/end2end/tests/cancel_after_invoke.c index 8a96ef2f89..6a7fae8614 100644 --- a/test/core/end2end/tests/cancel_after_invoke.c +++ b/test/core/end2end/tests/cancel_after_invoke.c @@ -75,9 +75,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -96,6 +97,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } /* Cancel after invoke, no payload */ diff --git a/test/core/end2end/tests/cancel_before_invoke.c b/test/core/end2end/tests/cancel_before_invoke.c index 586aa7ead3..e96ee5a0e1 100644 --- a/test/core/end2end/tests/cancel_before_invoke.c +++ b/test/core/end2end/tests/cancel_before_invoke.c @@ -72,9 +72,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -93,6 +94,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } /* Cancel before invoke */ diff --git a/test/core/end2end/tests/cancel_in_a_vacuum.c b/test/core/end2end/tests/cancel_in_a_vacuum.c index bc462ddcf5..630527a658 100644 --- a/test/core/end2end/tests/cancel_in_a_vacuum.c +++ b/test/core/end2end/tests/cancel_in_a_vacuum.c @@ -73,9 +73,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -94,6 +95,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } /* Cancel and do nothing */ diff --git a/test/core/end2end/tests/cancel_with_status.c b/test/core/end2end/tests/cancel_with_status.c index 7d03fe5580..2a81feaf0b 100644 --- a/test/core/end2end/tests/cancel_with_status.c +++ b/test/core/end2end/tests/cancel_with_status.c @@ -74,9 +74,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -95,6 +96,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } static void simple_request_body(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/compressed_payload.c b/test/core/end2end/tests/compressed_payload.c index 7dd8c112d1..1ad4d118e0 100644 --- a/test/core/end2end/tests/compressed_payload.c +++ b/test/core/end2end/tests/compressed_payload.c @@ -80,9 +80,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -101,6 +102,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } static void request_for_disabled_algorithm( diff --git a/test/core/end2end/tests/connectivity.c b/test/core/end2end/tests/connectivity.c index 979419a100..eb84aaed16 100644 --- a/test/core/end2end/tests/connectivity.c +++ b/test/core/end2end/tests/connectivity.c @@ -171,6 +171,9 @@ static void test_connectivity(grpc_end2end_test_config config) { grpc_channel_destroy(f.client); grpc_completion_queue_shutdown(f.cq); grpc_completion_queue_destroy(f.cq); + + /* shutdown_cq is not used in this test */ + grpc_completion_queue_destroy(f.shutdown_cq); config.tear_down_data(&f); cq_verifier_destroy(cqv); diff --git a/test/core/end2end/tests/default_host.c b/test/core/end2end/tests/default_host.c index bc1829b24b..b765de3cea 100644 --- a/test/core/end2end/tests/default_host.c +++ b/test/core/end2end/tests/default_host.c @@ -74,9 +74,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -95,6 +96,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } static void simple_request_body(grpc_end2end_test_fixture f) { diff --git a/test/core/end2end/tests/disappearing_server.c b/test/core/end2end/tests/disappearing_server.c index 05440a6f56..d7265a7780 100644 --- a/test/core/end2end/tests/disappearing_server.c +++ b/test/core/end2end/tests/disappearing_server.c @@ -77,6 +77,9 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + + /* Note: shutdown_cq was unused in this test */ + grpc_completion_queue_destroy(f->shutdown_cq); } static void do_request_and_shutdown_server(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/empty_batch.c b/test/core/end2end/tests/empty_batch.c index 50bb6b849e..9aa9294258 100644 --- a/test/core/end2end/tests/empty_batch.c +++ b/test/core/end2end/tests/empty_batch.c @@ -74,9 +74,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -95,6 +96,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } static void empty_batch_body(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/filter_call_init_fails.c b/test/core/end2end/tests/filter_call_init_fails.c index d2d6e82d57..dee3531f80 100644 --- a/test/core/end2end/tests/filter_call_init_fails.c +++ b/test/core/end2end/tests/filter_call_init_fails.c @@ -80,9 +80,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -101,6 +102,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } // Simple request via a server filter that always fails to initialize diff --git a/test/core/end2end/tests/filter_causes_close.c b/test/core/end2end/tests/filter_causes_close.c index 25e606556d..d41eb48101 100644 --- a/test/core/end2end/tests/filter_causes_close.c +++ b/test/core/end2end/tests/filter_causes_close.c @@ -77,9 +77,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -98,6 +99,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } /* Simple request via a server filter that always closes the stream.*/ diff --git a/test/core/end2end/tests/filter_latency.c b/test/core/end2end/tests/filter_latency.c index d05e9e79a1..ffe9880d81 100644 --- a/test/core/end2end/tests/filter_latency.c +++ b/test/core/end2end/tests/filter_latency.c @@ -84,9 +84,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -105,6 +106,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } // Simple request via a server filter that saves the reported latency value. diff --git a/test/core/end2end/tests/graceful_server_shutdown.c b/test/core/end2end/tests/graceful_server_shutdown.c index a3ad260cc2..8e35d27af9 100644 --- a/test/core/end2end/tests/graceful_server_shutdown.c +++ b/test/core/end2end/tests/graceful_server_shutdown.c @@ -89,6 +89,8 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + /* Note: shutdown_cq is not used in this test */ + grpc_completion_queue_destroy(f->shutdown_cq); } static void test_early_server_shutdown_finishes_inflight_calls( diff --git a/test/core/end2end/tests/high_initial_seqno.c b/test/core/end2end/tests/high_initial_seqno.c index cca8532b0e..1707c8192c 100644 --- a/test/core/end2end/tests/high_initial_seqno.c +++ b/test/core/end2end/tests/high_initial_seqno.c @@ -76,9 +76,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -97,6 +98,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } static void simple_request_body(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/hpack_size.c b/test/core/end2end/tests/hpack_size.c index 7601722dee..68a33f3008 100644 --- a/test/core/end2end/tests/hpack_size.c +++ b/test/core/end2end/tests/hpack_size.c @@ -216,9 +216,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -237,6 +238,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } static void simple_request_body(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/idempotent_request.c b/test/core/end2end/tests/idempotent_request.c index cef2e100be..3455c6eb41 100644 --- a/test/core/end2end/tests/idempotent_request.c +++ b/test/core/end2end/tests/idempotent_request.c @@ -74,9 +74,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -95,6 +96,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } static void simple_request_body(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/invoke_large_request.c b/test/core/end2end/tests/invoke_large_request.c index d799bd8ccf..3bce8dffe4 100644 --- a/test/core/end2end/tests/invoke_large_request.c +++ b/test/core/end2end/tests/invoke_large_request.c @@ -71,9 +71,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -92,6 +93,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } static grpc_slice large_slice(void) { diff --git a/test/core/end2end/tests/large_metadata.c b/test/core/end2end/tests/large_metadata.c index ac4c0e7f3b..227db3293f 100644 --- a/test/core/end2end/tests/large_metadata.c +++ b/test/core/end2end/tests/large_metadata.c @@ -72,9 +72,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -93,6 +94,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } // Request with a large amount of metadata. diff --git a/test/core/end2end/tests/load_reporting_hook.c b/test/core/end2end/tests/load_reporting_hook.c index d1ee26fe50..d8e9eaafa9 100644 --- a/test/core/end2end/tests/load_reporting_hook.c +++ b/test/core/end2end/tests/load_reporting_hook.c @@ -99,9 +99,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -120,6 +121,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } static void request_response_with_payload( diff --git a/test/core/end2end/tests/max_concurrent_streams.c b/test/core/end2end/tests/max_concurrent_streams.c index e81a628944..ebc92c6965 100644 --- a/test/core/end2end/tests/max_concurrent_streams.c +++ b/test/core/end2end/tests/max_concurrent_streams.c @@ -72,9 +72,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -93,6 +94,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } static void simple_request_body(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.c index b15d30f58c..c015b653b8 100644 --- a/test/core/end2end/tests/max_message_length.c +++ b/test/core/end2end/tests/max_message_length.c @@ -81,9 +81,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -102,6 +103,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } // Test with request larger than the limit. diff --git a/test/core/end2end/tests/negative_deadline.c b/test/core/end2end/tests/negative_deadline.c index 0b61efbac9..f0e81533c2 100644 --- a/test/core/end2end/tests/negative_deadline.c +++ b/test/core/end2end/tests/negative_deadline.c @@ -74,9 +74,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -95,6 +96,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } static void simple_request_body(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/network_status_change.c b/test/core/end2end/tests/network_status_change.c index 7540ce93a1..3a420cce23 100644 --- a/test/core/end2end/tests/network_status_change.c +++ b/test/core/end2end/tests/network_status_change.c @@ -75,9 +75,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -96,6 +97,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } /* Client sends a request with payload, server reads then returns status. */ diff --git a/test/core/end2end/tests/no_logging.c b/test/core/end2end/tests/no_logging.c index 56e48a88a8..4233f9ab5b 100644 --- a/test/core/end2end/tests/no_logging.c +++ b/test/core/end2end/tests/no_logging.c @@ -102,9 +102,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -123,6 +124,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } static void simple_request_body(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/no_op.c b/test/core/end2end/tests/no_op.c index 62fc728c3e..d5712cb1cc 100644 --- a/test/core/end2end/tests/no_op.c +++ b/test/core/end2end/tests/no_op.c @@ -72,9 +72,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -93,6 +94,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } static void test_no_op(grpc_end2end_test_config config) { diff --git a/test/core/end2end/tests/payload.c b/test/core/end2end/tests/payload.c index b04ee5705c..b0b639681f 100644 --- a/test/core/end2end/tests/payload.c +++ b/test/core/end2end/tests/payload.c @@ -72,9 +72,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -93,6 +94,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } /* Creates and returns a grpc_slice containing random alphanumeric characters. diff --git a/test/core/end2end/tests/ping.c b/test/core/end2end/tests/ping.c index f5bfac2255..966288239c 100644 --- a/test/core/end2end/tests/ping.c +++ b/test/core/end2end/tests/ping.c @@ -95,6 +95,9 @@ static void test_ping(grpc_end2end_test_config config) { grpc_channel_destroy(f.client); grpc_completion_queue_shutdown(f.cq); grpc_completion_queue_destroy(f.cq); + + /* f.shutdown_cq is not used in this test */ + grpc_completion_queue_destroy(f.shutdown_cq); config.tear_down_data(&f); cq_verifier_destroy(cqv); diff --git a/test/core/end2end/tests/ping_pong_streaming.c b/test/core/end2end/tests/ping_pong_streaming.c index 848f76018d..a4b48ea5c3 100644 --- a/test/core/end2end/tests/ping_pong_streaming.c +++ b/test/core/end2end/tests/ping_pong_streaming.c @@ -72,9 +72,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -93,6 +94,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } /* Client pings and server pongs. Repeat messages rounds before finishing. */ diff --git a/test/core/end2end/tests/registered_call.c b/test/core/end2end/tests/registered_call.c index 9c8ce89c83..4846cfe99e 100644 --- a/test/core/end2end/tests/registered_call.c +++ b/test/core/end2end/tests/registered_call.c @@ -74,9 +74,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -95,6 +96,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } static void simple_request_body(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/request_with_flags.c b/test/core/end2end/tests/request_with_flags.c index 329359e08b..fa943cf57d 100644 --- a/test/core/end2end/tests/request_with_flags.c +++ b/test/core/end2end/tests/request_with_flags.c @@ -73,9 +73,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -94,6 +95,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } static void test_invoke_request_with_flags( diff --git a/test/core/end2end/tests/request_with_payload.c b/test/core/end2end/tests/request_with_payload.c index f71f92bbb8..3cf6d828b5 100644 --- a/test/core/end2end/tests/request_with_payload.c +++ b/test/core/end2end/tests/request_with_payload.c @@ -72,9 +72,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -93,6 +94,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } /* Client sends a request with payload, server reads then returns status. */ diff --git a/test/core/end2end/tests/resource_quota_server.c b/test/core/end2end/tests/resource_quota_server.c index 4f9ed7a3a1..115fddc167 100644 --- a/test/core/end2end/tests/resource_quota_server.c +++ b/test/core/end2end/tests/resource_quota_server.c @@ -72,9 +72,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -93,6 +94,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } /* Creates and returns a grpc_slice containing random alphanumeric characters. diff --git a/test/core/end2end/tests/server_finishes_request.c b/test/core/end2end/tests/server_finishes_request.c index b42d17002e..b545f14454 100644 --- a/test/core/end2end/tests/server_finishes_request.c +++ b/test/core/end2end/tests/server_finishes_request.c @@ -74,9 +74,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -95,6 +96,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } static void simple_request_body(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/shutdown_finishes_calls.c b/test/core/end2end/tests/shutdown_finishes_calls.c index c019682ea6..d74b740a6c 100644 --- a/test/core/end2end/tests/shutdown_finishes_calls.c +++ b/test/core/end2end/tests/shutdown_finishes_calls.c @@ -82,6 +82,8 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + /* f->shutdown_cq is not used in this test */ + grpc_completion_queue_destroy(f->shutdown_cq); } static void test_early_server_shutdown_finishes_inflight_calls( diff --git a/test/core/end2end/tests/shutdown_finishes_tags.c b/test/core/end2end/tests/shutdown_finishes_tags.c index 5540d2aab9..e5d3c43e69 100644 --- a/test/core/end2end/tests/shutdown_finishes_tags.c +++ b/test/core/end2end/tests/shutdown_finishes_tags.c @@ -82,6 +82,8 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + /* f->shutdown_cq is not used in this test */ + grpc_completion_queue_destroy(f->shutdown_cq); } static void test_early_server_shutdown_finishes_tags( diff --git a/test/core/end2end/tests/simple_cacheable_request.c b/test/core/end2end/tests/simple_cacheable_request.c index 4eef02e9ee..bb594a9fbd 100644 --- a/test/core/end2end/tests/simple_cacheable_request.c +++ b/test/core/end2end/tests/simple_cacheable_request.c @@ -74,9 +74,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -95,6 +96,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } /* Request/response with metadata and payload.*/ diff --git a/test/core/end2end/tests/simple_delayed_request.c b/test/core/end2end/tests/simple_delayed_request.c index e3b6aee783..489ed5c073 100644 --- a/test/core/end2end/tests/simple_delayed_request.c +++ b/test/core/end2end/tests/simple_delayed_request.c @@ -60,9 +60,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -81,6 +82,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } static void simple_delayed_request_body(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/simple_metadata.c b/test/core/end2end/tests/simple_metadata.c index 7ab5563cfa..f8a5254fe8 100644 --- a/test/core/end2end/tests/simple_metadata.c +++ b/test/core/end2end/tests/simple_metadata.c @@ -72,9 +72,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -93,6 +94,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } /* Request/response with metadata and payload.*/ diff --git a/test/core/end2end/tests/simple_request.c b/test/core/end2end/tests/simple_request.c index af5d74959e..47fbff3375 100644 --- a/test/core/end2end/tests/simple_request.c +++ b/test/core/end2end/tests/simple_request.c @@ -74,9 +74,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -95,6 +96,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } static void simple_request_body(grpc_end2end_test_config config, diff --git a/test/core/end2end/tests/streaming_error_response.c b/test/core/end2end/tests/streaming_error_response.c index 42055907c8..354c5091fd 100644 --- a/test/core/end2end/tests/streaming_error_response.c +++ b/test/core/end2end/tests/streaming_error_response.c @@ -74,9 +74,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -95,6 +96,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } /* Client sends a request with payload, server reads then returns status. */ diff --git a/test/core/end2end/tests/trailing_metadata.c b/test/core/end2end/tests/trailing_metadata.c index dbbda505bc..0cb111976a 100644 --- a/test/core/end2end/tests/trailing_metadata.c +++ b/test/core/end2end/tests/trailing_metadata.c @@ -72,9 +72,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -93,6 +94,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } /* Request/response with metadata and payload.*/ diff --git a/test/core/end2end/tests/write_buffering.c b/test/core/end2end/tests/write_buffering.c index abf90ca6e0..7bb44f5c6f 100644 --- a/test/core/end2end/tests/write_buffering.c +++ b/test/core/end2end/tests/write_buffering.c @@ -72,9 +72,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -93,6 +94,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } /* Client sends a request with payload, server reads then returns status. */ diff --git a/test/core/end2end/tests/write_buffering_at_end.c b/test/core/end2end/tests/write_buffering_at_end.c index 8c02b425ba..2ff506a744 100644 --- a/test/core/end2end/tests/write_buffering_at_end.c +++ b/test/core/end2end/tests/write_buffering_at_end.c @@ -72,9 +72,10 @@ 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->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; @@ -93,6 +94,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } /* Client sends a request with payload, server reads then returns status. */ diff --git a/test/core/fling/client.c b/test/core/fling/client.c index 85bab6d431..188696c189 100644 --- a/test/core/fling/client.c +++ b/test/core/fling/client.c @@ -208,7 +208,7 @@ int main(int argc, char **argv) { } channel = grpc_insecure_channel_create(target, NULL, NULL); - cq = grpc_completion_queue_create(NULL); + cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); the_buffer = grpc_raw_byte_buffer_create(&slice, (size_t)payload_size); histogram = gpr_histogram_create(0.01, 60e9); diff --git a/test/core/fling/server.c b/test/core/fling/server.c index 7ea54b1167..f1b5f39a60 100644 --- a/test/core/fling/server.c +++ b/test/core/fling/server.c @@ -185,6 +185,7 @@ int main(int argc, char **argv) { call_state *s; char *addr_buf = NULL; gpr_cmdline *cl; + grpc_completion_queue *shutdown_cq; int shutdown_started = 0; int shutdown_finished = 0; @@ -214,7 +215,7 @@ int main(int argc, char **argv) { } gpr_log(GPR_INFO, "creating server on: %s", addr); - cq = grpc_completion_queue_create(NULL); + cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); if (secure) { grpc_ssl_pem_key_cert_pair pem_key_cert_pair = {test_server1_key, test_server1_cert}; @@ -242,16 +243,24 @@ int main(int argc, char **argv) { while (!shutdown_finished) { if (got_sigint && !shutdown_started) { gpr_log(GPR_INFO, "Shutting down due to SIGINT"); - grpc_server_shutdown_and_notify(server, cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) - .type == GRPC_OP_COMPLETE); + + shutdown_cq = + grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + grpc_server_shutdown_and_notify(server, shutdown_cq, tag(1000)); + + GPR_ASSERT( + grpc_completion_queue_pluck(shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_completion_queue_destroy(shutdown_cq); + grpc_completion_queue_shutdown(cq); shutdown_started = 1; } ev = grpc_completion_queue_next( - cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_micros(1000000, GPR_TIMESPAN)), + cq, + gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_micros(1000000, GPR_TIMESPAN)), NULL); s = ev.tag; switch (ev.type) { diff --git a/test/core/handshake/client_ssl.c b/test/core/handshake/client_ssl.c index 5cfe60de4b..72e8ffe02a 100644 --- a/test/core/handshake/client_ssl.c +++ b/test/core/handshake/client_ssl.c @@ -289,7 +289,9 @@ static bool client_ssl_test(char *server_alpn_preferred) { // completed and we know that the client's ALPN list satisfied the server. int retries = 10; grpc_connectivity_state state = GRPC_CHANNEL_IDLE; - grpc_completion_queue *cq = grpc_completion_queue_create(NULL); + grpc_completion_queue *cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + while (state != GRPC_CHANNEL_READY && retries-- > 0) { grpc_channel_watch_connectivity_state( channel, state, grpc_timeout_seconds_to_deadline(3), cq, NULL); diff --git a/test/core/handshake/server_ssl.c b/test/core/handshake/server_ssl.c index 0bd5a03cff..f61ad786bc 100644 --- a/test/core/handshake/server_ssl.c +++ b/test/core/handshake/server_ssl.c @@ -104,7 +104,8 @@ static void server_thread(void *arg) { GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, ssl_creds)); free(addr); - grpc_completion_queue *cq = grpc_completion_queue_create(NULL); + grpc_completion_queue *cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); grpc_server_register_completion_queue(server, cq, NULL); grpc_server_start(server); diff --git a/test/core/memory_usage/client.c b/test/core/memory_usage/client.c index 09f0e2d867..588f559d4c 100644 --- a/test/core/memory_usage/client.c +++ b/test/core/memory_usage/client.c @@ -222,7 +222,7 @@ int main(int argc, char **argv) { calls[k].details = grpc_empty_slice(); } - cq = grpc_completion_queue_create(NULL); + cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); struct grpc_memory_counters client_channel_start = grpc_memory_counters_snapshot(); @@ -260,8 +260,9 @@ int main(int argc, char **argv) { do { event = grpc_completion_queue_next( - cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_micros(10000, GPR_TIMESPAN)), + cq, + gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_micros(10000, GPR_TIMESPAN)), NULL); } while (event.type != GRPC_QUEUE_TIMEOUT); diff --git a/test/core/memory_usage/server.c b/test/core/memory_usage/server.c index ab059c25b8..eb9794b558 100644 --- a/test/core/memory_usage/server.c +++ b/test/core/memory_usage/server.c @@ -161,6 +161,7 @@ int main(int argc, char **argv) { grpc_event ev; char *addr_buf = NULL; gpr_cmdline *cl; + grpc_completion_queue *shutdown_cq; int shutdown_started = 0; int shutdown_finished = 0; @@ -188,7 +189,7 @@ int main(int argc, char **argv) { } gpr_log(GPR_INFO, "creating server on: %s", addr); - cq = grpc_completion_queue_create(NULL); + cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); struct grpc_memory_counters before_server_create = grpc_memory_counters_snapshot(); @@ -230,16 +231,22 @@ int main(int argc, char **argv) { while (!shutdown_finished) { if (got_sigint && !shutdown_started) { gpr_log(GPR_INFO, "Shutting down due to SIGINT"); - grpc_server_shutdown_and_notify(server, cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) - .type == GRPC_OP_COMPLETE); + + shutdown_cq = + grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + grpc_server_shutdown_and_notify(server, shutdown_cq, tag(1000)); + GPR_ASSERT( + grpc_completion_queue_pluck(shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_completion_queue_destroy(shutdown_cq); grpc_completion_queue_shutdown(cq); shutdown_started = 1; } ev = grpc_completion_queue_next( - cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_micros(1000000, GPR_TIMESPAN)), + cq, + gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_micros(1000000, GPR_TIMESPAN)), NULL); fling_call *s = ev.tag; switch (ev.type) { diff --git a/test/core/surface/alarm_test.c b/test/core/surface/alarm_test.c index 4afe357c27..7419d388a3 100644 --- a/test/core/surface/alarm_test.c +++ b/test/core/surface/alarm_test.c @@ -58,7 +58,7 @@ static void test_alarm(void) { grpc_completion_queue *cc; LOG_TEST("test_alarm"); - cc = grpc_completion_queue_create(NULL); + cc = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); { /* regular expiry */ grpc_event ev; diff --git a/test/core/surface/completion_queue_test.c b/test/core/surface/completion_queue_test.c index 07f6a9869b..6d913cc932 100644 --- a/test/core/surface/completion_queue_test.c +++ b/test/core/surface/completion_queue_test.c @@ -51,24 +51,62 @@ static void *create_test_tag(void) { static void shutdown_and_destroy(grpc_completion_queue *cc) { grpc_event ev; grpc_completion_queue_shutdown(cc); - ev = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME), NULL); + + switch (grpc_get_cq_completion_type(cc)) { + case GRPC_CQ_NEXT: { + ev = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME), + NULL); + break; + } + case GRPC_CQ_PLUCK: { + ev = grpc_completion_queue_pluck(cc, create_test_tag(), + gpr_inf_past(GPR_CLOCK_REALTIME), NULL); + break; + } + default: { + gpr_log(GPR_ERROR, "Unknown completion type"); + break; + } + } + GPR_ASSERT(ev.type == GRPC_QUEUE_SHUTDOWN); grpc_completion_queue_destroy(cc); } /* ensure we can create and destroy a completion channel */ static void test_no_op(void) { + grpc_cq_completion_type completion_types[] = {GRPC_CQ_NEXT, GRPC_CQ_PLUCK}; + grpc_cq_polling_type polling_types[] = {DEFAULT_POLLING, NON_LISTENING, + NON_POLLING}; LOG_TEST("test_no_op"); - shutdown_and_destroy(grpc_completion_queue_create(NULL)); + + for (size_t i = 0; i < GPR_ARRAY_SIZE(completion_types); i++) { + for (size_t j = 0; j < GPR_ARRAY_SIZE(polling_types); j++) { + shutdown_and_destroy(grpc_completion_queue_create( + completion_types[i], polling_types[j], NULL)); + } + } } static void test_pollset_conversion(void) { - grpc_completion_queue *cq = grpc_completion_queue_create(NULL); - GPR_ASSERT(grpc_cq_from_pollset(grpc_cq_pollset(cq)) == cq); - shutdown_and_destroy(cq); + grpc_cq_completion_type completion_types[] = {GRPC_CQ_NEXT, GRPC_CQ_PLUCK}; + grpc_cq_polling_type polling_types[] = {DEFAULT_POLLING, NON_LISTENING}; + grpc_completion_queue *cq; + + LOG_TEST("test_pollset_conversion"); + + for (size_t i = 0; i < GPR_ARRAY_SIZE(completion_types); i++) { + for (size_t j = 0; j < GPR_ARRAY_SIZE(polling_types); j++) { + cq = grpc_completion_queue_create(completion_types[i], polling_types[j], + NULL); + GPR_ASSERT(grpc_cq_from_pollset(grpc_cq_pollset(cq)) == cq); + shutdown_and_destroy(cq); + } + } } static void test_wait_empty(void) { + grpc_cq_polling_type polling_types[] = {DEFAULT_POLLING, NON_LISTENING}; grpc_completion_queue *cc; grpc_event event; @@ -87,50 +125,66 @@ static void test_cq_end_op(void) { grpc_event ev; grpc_completion_queue *cc; grpc_cq_completion completion; - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_cq_polling_type polling_types[] = {DEFAULT_POLLING, NON_LISTENING, + NON_POLLING}; + + grpc_exec_ctx init_exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_exec_ctx exec_ctx; void *tag = create_test_tag(); LOG_TEST("test_cq_end_op"); - cc = grpc_completion_queue_create(NULL); + for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) { + exec_ctx = init_exec_ctx; // Reset exec_ctx + cc = grpc_completion_queue_create(GRPC_CQ_NEXT, polling_types[i], NULL); - grpc_cq_begin_op(cc, tag); - grpc_cq_end_op(&exec_ctx, cc, tag, GRPC_ERROR_NONE, do_nothing_end_completion, - NULL, &completion); + grpc_cq_begin_op(cc, tag); + grpc_cq_end_op(&exec_ctx, cc, tag, GRPC_ERROR_NONE, + do_nothing_end_completion, NULL, &completion); - ev = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME), NULL); - GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); - GPR_ASSERT(ev.tag == tag); - GPR_ASSERT(ev.success); + ev = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME), NULL); + GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); + GPR_ASSERT(ev.tag == tag); + GPR_ASSERT(ev.success); - shutdown_and_destroy(cc); - grpc_exec_ctx_finish(&exec_ctx); + shutdown_and_destroy(cc); + grpc_exec_ctx_finish(&exec_ctx); + } } static void test_shutdown_then_next_polling(void) { + grpc_cq_polling_type polling_types[] = {DEFAULT_POLLING, NON_LISTENING, + NON_POLLING}; grpc_completion_queue *cc; grpc_event event; LOG_TEST("test_shutdown_then_next_polling"); - cc = grpc_completion_queue_create(NULL); - grpc_completion_queue_shutdown(cc); - event = - grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME), NULL); - GPR_ASSERT(event.type == GRPC_QUEUE_SHUTDOWN); - grpc_completion_queue_destroy(cc); + for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) { + cc = grpc_completion_queue_create(GRPC_CQ_NEXT, polling_types[i], NULL); + grpc_completion_queue_shutdown(cc); + event = + grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME), NULL); + GPR_ASSERT(event.type == GRPC_QUEUE_SHUTDOWN); + grpc_completion_queue_destroy(cc); + } } static void test_shutdown_then_next_with_timeout(void) { + grpc_cq_polling_type polling_types[] = {DEFAULT_POLLING, NON_LISTENING, + NON_POLLING}; grpc_completion_queue *cc; grpc_event event; LOG_TEST("test_shutdown_then_next_with_timeout"); - cc = grpc_completion_queue_create(NULL); - grpc_completion_queue_shutdown(cc); - event = - grpc_completion_queue_next(cc, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); - GPR_ASSERT(event.type == GRPC_QUEUE_SHUTDOWN); - grpc_completion_queue_destroy(cc); + for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) { + cc = grpc_completion_queue_create(GRPC_CQ_NEXT, polling_types[i], NULL); + + grpc_completion_queue_shutdown(cc); + event = grpc_completion_queue_next(cc, gpr_inf_future(GPR_CLOCK_REALTIME), + NULL); + GPR_ASSERT(event.type == GRPC_QUEUE_SHUTDOWN); + grpc_completion_queue_destroy(cc); + } } static void test_pluck(void) { @@ -138,7 +192,10 @@ static void test_pluck(void) { grpc_completion_queue *cc; void *tags[128]; grpc_cq_completion completions[GPR_ARRAY_SIZE(tags)]; - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_cq_polling_type polling_types[] = {DEFAULT_POLLING, NON_LISTENING, + NON_POLLING}; + grpc_exec_ctx init_exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_exec_ctx exec_ctx; unsigned i, j; LOG_TEST("test_pluck"); @@ -150,47 +207,66 @@ static void test_pluck(void) { } } - cc = grpc_completion_queue_create(NULL); + for (size_t pidx = 0; pidx < GPR_ARRAY_SIZE(polling_types); pidx++) { + exec_ctx = init_exec_ctx; // reset exec_ctx + cc = grpc_completion_queue_create(GRPC_CQ_PLUCK, polling_types[pidx], NULL); - for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { - grpc_cq_begin_op(cc, tags[i]); - grpc_cq_end_op(&exec_ctx, cc, tags[i], GRPC_ERROR_NONE, - do_nothing_end_completion, NULL, &completions[i]); - } + for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { + grpc_cq_begin_op(cc, tags[i]); + grpc_cq_end_op(&exec_ctx, cc, tags[i], GRPC_ERROR_NONE, + do_nothing_end_completion, NULL, &completions[i]); + } - for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { - ev = grpc_completion_queue_pluck(cc, tags[i], - gpr_inf_past(GPR_CLOCK_REALTIME), NULL); - GPR_ASSERT(ev.tag == tags[i]); - } + for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { + ev = grpc_completion_queue_pluck(cc, tags[i], + gpr_inf_past(GPR_CLOCK_REALTIME), NULL); + GPR_ASSERT(ev.tag == tags[i]); + } - for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { - grpc_cq_begin_op(cc, tags[i]); - grpc_cq_end_op(&exec_ctx, cc, tags[i], GRPC_ERROR_NONE, - do_nothing_end_completion, NULL, &completions[i]); - } + for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { + grpc_cq_begin_op(cc, tags[i]); + grpc_cq_end_op(&exec_ctx, cc, tags[i], GRPC_ERROR_NONE, + do_nothing_end_completion, NULL, &completions[i]); + } - for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { - ev = grpc_completion_queue_pluck(cc, tags[GPR_ARRAY_SIZE(tags) - i - 1], - gpr_inf_past(GPR_CLOCK_REALTIME), NULL); - GPR_ASSERT(ev.tag == tags[GPR_ARRAY_SIZE(tags) - i - 1]); - } + for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { + ev = grpc_completion_queue_pluck(cc, tags[GPR_ARRAY_SIZE(tags) - i - 1], + gpr_inf_past(GPR_CLOCK_REALTIME), NULL); + GPR_ASSERT(ev.tag == tags[GPR_ARRAY_SIZE(tags) - i - 1]); + } - shutdown_and_destroy(cc); - grpc_exec_ctx_finish(&exec_ctx); + shutdown_and_destroy(cc); + grpc_exec_ctx_finish(&exec_ctx); + } } static void test_pluck_after_shutdown(void) { + grpc_cq_polling_type polling_types[] = {DEFAULT_POLLING, NON_LISTENING, + NON_POLLING}; grpc_event ev; grpc_completion_queue *cc; LOG_TEST("test_pluck_after_shutdown"); - cc = grpc_completion_queue_create(NULL); - grpc_completion_queue_shutdown(cc); - ev = grpc_completion_queue_pluck(cc, NULL, gpr_inf_future(GPR_CLOCK_REALTIME), - NULL); - GPR_ASSERT(ev.type == GRPC_QUEUE_SHUTDOWN); - grpc_completion_queue_destroy(cc); + + for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) { + cc = grpc_completion_queue_create(GRPC_CQ_PLUCK, polling_types[i], NULL); + grpc_completion_queue_shutdown(cc); + ev = grpc_completion_queue_pluck(cc, NULL, + gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + GPR_ASSERT(ev.type == GRPC_QUEUE_SHUTDOWN); + grpc_completion_queue_destroy(cc); + } +} + +struct thread_state { + grpc_completion_queue *cc; + void *tag; +}; + +static void pluck_one(void *arg) { + struct thread_state *state = arg; + grpc_completion_queue_pluck(state->cc, state->tag, + gpr_inf_future(GPR_CLOCK_REALTIME), NULL); } int main(int argc, char **argv) { diff --git a/test/core/surface/concurrent_connectivity_test.c b/test/core/surface/concurrent_connectivity_test.c index ff927385d4..3758b86fab 100644 --- a/test/core/surface/concurrent_connectivity_test.c +++ b/test/core/surface/concurrent_connectivity_test.c @@ -66,7 +66,8 @@ static int detag(void *p) { return (int)(uintptr_t)p; } void create_loop_destroy(void *addr) { for (int i = 0; i < NUM_OUTER_LOOPS; ++i) { - grpc_completion_queue *cq = grpc_completion_queue_create(NULL); + grpc_completion_queue *cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); grpc_channel *chan = grpc_insecure_channel_create((char *)addr, NULL, NULL); for (int j = 0; j < NUM_INNER_LOOPS; ++j) { @@ -195,7 +196,7 @@ int main(int argc, char **argv) { gpr_asprintf(&args.addr, "localhost:%d", port); args.server = grpc_server_create(NULL, NULL); grpc_server_add_insecure_http2_port(args.server, args.addr); - args.cq = grpc_completion_queue_create(NULL); + args.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); grpc_server_register_completion_queue(args.server, args.cq, NULL); grpc_server_start(args.server); gpr_thd_new(&server, server_thread, &args, &options); diff --git a/test/core/surface/lame_client_test.c b/test/core/surface/lame_client_test.c index 9deb50bb04..0cb183a4f0 100644 --- a/test/core/surface/lame_client_test.c +++ b/test/core/surface/lame_client_test.c @@ -108,7 +108,7 @@ int main(int argc, char **argv) { GPR_ASSERT(GRPC_CHANNEL_SHUTDOWN == grpc_channel_check_connectivity_state(chan, 0)); - cq = grpc_completion_queue_create(NULL); + cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); grpc_slice host = grpc_slice_from_static_string("anywhere"); call = grpc_channel_create_call(chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq, diff --git a/test/core/surface/sequential_connectivity_test.c b/test/core/surface/sequential_connectivity_test.c index 5f66f90037..37678a40d9 100644 --- a/test/core/surface/sequential_connectivity_test.c +++ b/test/core/surface/sequential_connectivity_test.c @@ -76,7 +76,8 @@ static void run_test(const test_fixture *fixture) { grpc_server *server = grpc_server_create(NULL, NULL); fixture->add_server_port(server, addr); - grpc_completion_queue *server_cq = grpc_completion_queue_create(NULL); + grpc_completion_queue *server_cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); grpc_server_register_completion_queue(server, server_cq, NULL); grpc_server_start(server); @@ -86,7 +87,8 @@ static void run_test(const test_fixture *fixture) { gpr_thd_options_set_joinable(&thdopt); gpr_thd_new(&server_thread, server_thread_func, &sta, &thdopt); - grpc_completion_queue *cq = grpc_completion_queue_create(NULL); + grpc_completion_queue *cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); grpc_channel *channels[NUM_CONNECTIONS]; for (size_t i = 0; i < NUM_CONNECTIONS; i++) { channels[i] = fixture->create_channel(addr); diff --git a/test/core/surface/server_chttp2_test.c b/test/core/surface/server_chttp2_test.c index 6c178abdad..9fac63418f 100644 --- a/test/core/surface/server_chttp2_test.c +++ b/test/core/surface/server_chttp2_test.c @@ -60,7 +60,8 @@ void test_add_same_port_twice() { int port = grpc_pick_unused_port_or_die(); char *addr = NULL; - grpc_completion_queue *cq = grpc_completion_queue_create(NULL); + grpc_completion_queue *cq = + grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); grpc_server *server = grpc_server_create(&args, NULL); grpc_server_credentials *fake_creds = grpc_fake_transport_security_server_credentials_create(); diff --git a/test/core/surface/server_test.c b/test/core/surface/server_test.c index 3fd1c2c266..aa54794d14 100644 --- a/test/core/surface/server_test.c +++ b/test/core/surface/server_test.c @@ -70,7 +70,8 @@ void test_register_method_fail(void) { } void test_request_call_on_no_server_cq(void) { - grpc_completion_queue *cc = grpc_completion_queue_create(NULL); + grpc_completion_queue *cc = + grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); grpc_server *server = grpc_server_create(NULL, NULL); GPR_ASSERT(GRPC_CALL_ERROR_NOT_SERVER_COMPLETION_QUEUE == grpc_server_request_call(server, NULL, NULL, NULL, cc, cc, NULL)); @@ -91,7 +92,8 @@ void test_bind_server_twice(void) { char *addr; grpc_server *server1 = grpc_server_create(&args, NULL); grpc_server *server2 = grpc_server_create(&args, NULL); - grpc_completion_queue *cq = grpc_completion_queue_create(NULL); + grpc_completion_queue *cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); int port = grpc_pick_unused_port_or_die(); gpr_asprintf(&addr, "[::]:%d", port); grpc_server_register_completion_queue(server1, cq, NULL); @@ -128,7 +130,8 @@ void test_bind_server_to_addr(const char *host, bool secure) { } else { GPR_ASSERT(grpc_server_add_insecure_http2_port(server, addr)); } - grpc_completion_queue *cq = grpc_completion_queue_create(NULL); + grpc_completion_queue *cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); grpc_server_register_completion_queue(server, cq, NULL); grpc_server_start(server); grpc_server_shutdown_and_notify(server, cq, NULL); -- cgit v1.2.3 From 0393d5d0a6f3567fd9f38580ae2651ceade7dfcc Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Thu, 2 Mar 2017 10:44:46 -0800 Subject: generate_projects.sh --- src/ruby/ext/grpc/rb_grpc_imports.generated.h | 2 +- tools/run_tests/generated/tests.json | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h index b16e673878..8ec7f6fd95 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h @@ -224,7 +224,7 @@ extern grpc_version_string_type grpc_version_string_import; typedef const char *(*grpc_g_stands_for_type)(void); extern grpc_g_stands_for_type grpc_g_stands_for_import; #define grpc_g_stands_for grpc_g_stands_for_import -typedef grpc_completion_queue *(*grpc_completion_queue_create_type)(void *reserved); +typedef grpc_completion_queue *(*grpc_completion_queue_create_type)(grpc_cq_completion_type completion_type, grpc_cq_polling_type polling_type, void *reserved); extern grpc_completion_queue_create_type grpc_completion_queue_create_import; #define grpc_completion_queue_create grpc_completion_queue_create_import typedef grpc_event(*grpc_completion_queue_next_type)(grpc_completion_queue *cq, gpr_timespec deadline, void *reserved); diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index ab7938d0ca..7ac14ab2c9 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -2551,6 +2551,10 @@ "cpu_cost": 1.0, "exclude_configs": [], "exclude_iomgrs": [], + "excluded_poll_engines": [ + "poll", + "poll-cv" + ], "flaky": false, "gtest": false, "language": "c++", @@ -2661,10 +2665,6 @@ "cpu_cost": 1.0, "exclude_configs": [], "exclude_iomgrs": [], - "excluded_poll_engines": [ - "poll", - "poll-cv" - ], "flaky": false, "gtest": false, "language": "c++", -- cgit v1.2.3 From 4f31f44f344bdb1da1429db830989a3aced27b8a Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Thu, 2 Mar 2017 13:15:39 -0800 Subject: rebase with latest master --- test/core/surface/completion_queue_test.c | 19 ++++++++----------- test/core/surface/completion_queue_threading_test.c | 5 +++-- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/test/core/surface/completion_queue_test.c b/test/core/surface/completion_queue_test.c index 6d913cc932..f76074f207 100644 --- a/test/core/surface/completion_queue_test.c +++ b/test/core/surface/completion_queue_test.c @@ -106,16 +106,19 @@ static void test_pollset_conversion(void) { } static void test_wait_empty(void) { - grpc_cq_polling_type polling_types[] = {DEFAULT_POLLING, NON_LISTENING}; + grpc_cq_polling_type polling_types[] = {DEFAULT_POLLING, NON_LISTENING, + NON_POLLING}; grpc_completion_queue *cc; grpc_event event; LOG_TEST("test_wait_empty"); - cc = grpc_completion_queue_create(NULL); - event = grpc_completion_queue_next(cc, gpr_now(GPR_CLOCK_REALTIME), NULL); - GPR_ASSERT(event.type == GRPC_QUEUE_TIMEOUT); - shutdown_and_destroy(cc); + for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) { + cc = grpc_completion_queue_create(GRPC_CQ_NEXT, polling_types[i], NULL); + event = grpc_completion_queue_next(cc, gpr_now(GPR_CLOCK_REALTIME), NULL); + GPR_ASSERT(event.type == GRPC_QUEUE_TIMEOUT); + shutdown_and_destroy(cc); + } } static void do_nothing_end_completion(grpc_exec_ctx *exec_ctx, void *arg, @@ -263,12 +266,6 @@ struct thread_state { void *tag; }; -static void pluck_one(void *arg) { - struct thread_state *state = arg; - grpc_completion_queue_pluck(state->cc, state->tag, - gpr_inf_future(GPR_CLOCK_REALTIME), NULL); -} - int main(int argc, char **argv) { grpc_test_init(argc, argv); grpc_init(); diff --git a/test/core/surface/completion_queue_threading_test.c b/test/core/surface/completion_queue_threading_test.c index 2d55ead843..0945597284 100644 --- a/test/core/surface/completion_queue_threading_test.c +++ b/test/core/surface/completion_queue_threading_test.c @@ -84,7 +84,7 @@ static void test_too_many_plucks(void) { LOG_TEST("test_too_many_plucks"); - cc = grpc_completion_queue_create(NULL); + cc = grpc_completion_queue_create(GRPC_CQ_PLUCK, DEFAULT_POLLING, NULL); gpr_thd_options_set_joinable(&thread_options); for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { @@ -210,7 +210,8 @@ static void test_threading(size_t producers, size_t consumers) { gpr_malloc((producers + consumers) * sizeof(test_thread_options)); gpr_event phase1 = GPR_EVENT_INIT; gpr_event phase2 = GPR_EVENT_INIT; - grpc_completion_queue *cc = grpc_completion_queue_create(NULL); + grpc_completion_queue *cc = + grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); size_t i; size_t total_consumed = 0; static int optid = 101; -- cgit v1.2.3 From 6b45d012466025c227eead4cf2c9f5abe28ea0dc Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Thu, 2 Mar 2017 16:37:59 -0800 Subject: fix tests after rebase --- test/core/end2end/tests/keepalive_timeout.c | 9 +++++---- test/core/surface/completion_queue_threading_test.c | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/test/core/end2end/tests/keepalive_timeout.c b/test/core/end2end/tests/keepalive_timeout.c index 4296be3619..66dcc1cd10 100644 --- a/test/core/end2end/tests/keepalive_timeout.c +++ b/test/core/end2end/tests/keepalive_timeout.c @@ -75,10 +75,10 @@ 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->cq, tag(1000)); - GPR_ASSERT( - grpc_completion_queue_pluck(f->cq, tag(1000), five_seconds_time(), NULL) - .type == GRPC_OP_COMPLETE); + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + five_seconds_time(), NULL) + .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; } @@ -96,6 +96,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } /* Client sends a request, server replies with a payload, then waits for the diff --git a/test/core/surface/completion_queue_threading_test.c b/test/core/surface/completion_queue_threading_test.c index 0945597284..b101cd13f7 100644 --- a/test/core/surface/completion_queue_threading_test.c +++ b/test/core/surface/completion_queue_threading_test.c @@ -52,7 +52,24 @@ static void *create_test_tag(void) { static void shutdown_and_destroy(grpc_completion_queue *cc) { grpc_event ev; grpc_completion_queue_shutdown(cc); - ev = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME), NULL); + + switch (grpc_get_cq_completion_type(cc)) { + case GRPC_CQ_NEXT: { + ev = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME), + NULL); + break; + } + case GRPC_CQ_PLUCK: { + ev = grpc_completion_queue_pluck(cc, create_test_tag(), + gpr_inf_past(GPR_CLOCK_REALTIME), NULL); + break; + } + default: { + gpr_log(GPR_ERROR, "Unknown completion type"); + break; + } + } + GPR_ASSERT(ev.type == GRPC_QUEUE_SHUTDOWN); grpc_completion_queue_destroy(cc); } -- cgit v1.2.3 From 982a6f2b1c8ca5ec6d361776fc76472ef6728253 Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Fri, 3 Mar 2017 02:19:31 -0800 Subject: C++ code changes in response to grpc_completion_queue_create() API change --- include/grpc++/impl/codegen/client_unary_call.h | 2 +- include/grpc++/impl/codegen/completion_queue.h | 19 +++++++++++++------ include/grpc++/impl/codegen/core_codegen.h | 5 ++++- include/grpc++/impl/codegen/core_codegen_interface.h | 4 +++- include/grpc++/impl/codegen/sync_stream.h | 12 +++++++++--- include/grpc/impl/codegen/grpc_types.h | 7 +++++-- src/cpp/common/core_codegen.cc | 4 +++- src/cpp/server/server_cc.cc | 19 +++++++++++++++---- test/cpp/grpclb/grpclb_test.cc | 20 +++++++++++++------- test/cpp/microbenchmarks/bm_call_create.cc | 3 ++- test/cpp/microbenchmarks/bm_cq.cc | 20 ++++++++++++++++---- 11 files changed, 84 insertions(+), 31 deletions(-) diff --git a/include/grpc++/impl/codegen/client_unary_call.h b/include/grpc++/impl/codegen/client_unary_call.h index 201e52ae07..bf18a7d644 100644 --- a/include/grpc++/impl/codegen/client_unary_call.h +++ b/include/grpc++/impl/codegen/client_unary_call.h @@ -52,7 +52,7 @@ template Status BlockingUnaryCall(ChannelInterface* channel, const RpcMethod& method, ClientContext* context, const InputMessage& request, OutputMessage* result) { - CompletionQueue cq; + CompletionQueue cq(GRPC_CQ_PLUCK, DEFAULT_POLLING); Call call(channel->CreateCall(method, context, &cq)); CallOpSet, diff --git a/include/grpc++/impl/codegen/completion_queue.h b/include/grpc++/impl/codegen/completion_queue.h index 03cecdc21c..a123af2cf6 100644 --- a/include/grpc++/impl/codegen/completion_queue.h +++ b/include/grpc++/impl/codegen/completion_queue.h @@ -52,6 +52,7 @@ #include #include #include +#include #include struct grpc_completion_queue; @@ -102,10 +103,7 @@ class CompletionQueue : private GrpcLibraryCodegen { public: /// Default constructor. Implicitly creates a \a grpc_completion_queue /// instance. - CompletionQueue() { - cq_ = g_core_codegen_interface->grpc_completion_queue_create(nullptr); - InitialAvalanching(); // reserve this for the future shutdown - } + CompletionQueue() : CompletionQueue(GRPC_CQ_NEXT, DEFAULT_POLLING) {} /// Wrap \a take, taking ownership of the instance. /// @@ -149,8 +147,9 @@ class CompletionQueue : private GrpcLibraryCodegen { /// /// \return true if read a regular event, false if the queue is shutting down. bool Next(void** tag, bool* ok) { - return (AsyncNextInternal(tag, ok, g_core_codegen_interface->gpr_inf_future( - GPR_CLOCK_REALTIME)) != SHUTDOWN); + return (AsyncNextInternal(tag, ok, + g_core_codegen_interface->gpr_inf_future( + GPR_CLOCK_REALTIME)) != SHUTDOWN); } /// Request the shutdown of the queue. @@ -218,6 +217,14 @@ class CompletionQueue : private GrpcLibraryCodegen { const InputMessage& request, OutputMessage* result); + /// Private constructor of CompletionQueue only visible to friend classes + CompletionQueue(grpc_cq_completion_type completion_type, + grpc_cq_polling_type polling_type) { + cq_ = g_core_codegen_interface->grpc_completion_queue_create( + completion_type, polling_type, nullptr); + InitialAvalanching(); // reserve this for the future shutdown + } + NextStatus AsyncNextInternal(void** tag, bool* ok, gpr_timespec deadline); /// Wraps \a grpc_completion_queue_pluck. diff --git a/include/grpc++/impl/codegen/core_codegen.h b/include/grpc++/impl/codegen/core_codegen.h index 754bf14b25..4c8567f770 100644 --- a/include/grpc++/impl/codegen/core_codegen.h +++ b/include/grpc++/impl/codegen/core_codegen.h @@ -38,6 +38,7 @@ #include #include +#include #include namespace grpc { @@ -45,7 +46,9 @@ namespace grpc { /// Implementation of the core codegen interface. class CoreCodegen : public CoreCodegenInterface { private: - grpc_completion_queue* grpc_completion_queue_create(void* reserved) override; + grpc_completion_queue* grpc_completion_queue_create( + grpc_cq_completion_type completion_type, + grpc_cq_polling_type polling_type, void* reserved) override; void grpc_completion_queue_destroy(grpc_completion_queue* cq) override; grpc_event grpc_completion_queue_pluck(grpc_completion_queue* cq, void* tag, gpr_timespec deadline, diff --git a/include/grpc++/impl/codegen/core_codegen_interface.h b/include/grpc++/impl/codegen/core_codegen_interface.h index 45ea040303..8f2b4a3b76 100644 --- a/include/grpc++/impl/codegen/core_codegen_interface.h +++ b/include/grpc++/impl/codegen/core_codegen_interface.h @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -60,7 +61,8 @@ class CoreCodegenInterface { int line) = 0; virtual grpc_completion_queue* grpc_completion_queue_create( - void* reserved) = 0; + grpc_cq_completion_type completion_type, + grpc_cq_polling_type polling_type, void* reserved) = 0; virtual void grpc_completion_queue_destroy(grpc_completion_queue* cq) = 0; virtual grpc_event grpc_completion_queue_pluck(grpc_completion_queue* cq, void* tag, diff --git a/include/grpc++/impl/codegen/sync_stream.h b/include/grpc++/impl/codegen/sync_stream.h index 4d9b074e95..d3a6c7ff89 100644 --- a/include/grpc++/impl/codegen/sync_stream.h +++ b/include/grpc++/impl/codegen/sync_stream.h @@ -137,7 +137,9 @@ class ClientReader final : public ClientReaderInterface { template ClientReader(ChannelInterface* channel, const RpcMethod& method, ClientContext* context, const W& request) - : context_(context), call_(channel->CreateCall(method, context, &cq_)) { + : context_(context), + cq_(GRPC_CQ_PLUCK, DEFAULT_POLLING), + call_(channel->CreateCall(method, context, &cq_)) { CallOpSet ops; @@ -209,7 +211,9 @@ class ClientWriter : public ClientWriterInterface { template ClientWriter(ChannelInterface* channel, const RpcMethod& method, ClientContext* context, R* response) - : context_(context), call_(channel->CreateCall(method, context, &cq_)) { + : context_(context), + cq_(GRPC_CQ_PLUCK, DEFAULT_POLLING), + call_(channel->CreateCall(method, context, &cq_)) { finish_ops_.RecvMessage(response); finish_ops_.AllowNoMessage(); @@ -292,7 +296,9 @@ class ClientReaderWriter final : public ClientReaderWriterInterface { /// Blocking create a stream. ClientReaderWriter(ChannelInterface* channel, const RpcMethod& method, ClientContext* context) - : context_(context), call_(channel->CreateCall(method, context, &cq_)) { + : context_(context), + cq_(GRPC_CQ_PLUCK, DEFAULT_POLLING), + call_(channel->CreateCall(method, context, &cq_)) { CallOpSet ops; ops.SendInitialMetadata(context->send_initial_metadata_, context->initial_metadata_flags()); diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index e5c731304c..061f59213c 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -352,8 +352,11 @@ typedef enum grpc_completion_type { typedef struct grpc_event { /** The type of the completion. */ grpc_completion_type type; - /** non-zero if the operation was successful, 0 upon failure. - Only GRPC_OP_COMPLETE can succeed or fail. */ + /** If the grpc_completion_type is GRPC_OP_COMPLETE, this field indicates + whether the operation was successful or not; 0 in case of failure and + non-zero in case of success. + If grpc_completion_type is GRPC_QUEUE_SHUTDOWN or GRPC_QUEUE_TIMEOUT, this + field is guaranteed to be 0 */ int success; /** The tag passed to grpc_call_start_batch etc to start this operation. Only GRPC_OP_COMPLETE has a tag. */ diff --git a/src/cpp/common/core_codegen.cc b/src/cpp/common/core_codegen.cc index 36e4c89354..81b32938b8 100644 --- a/src/cpp/common/core_codegen.cc +++ b/src/cpp/common/core_codegen.cc @@ -55,8 +55,10 @@ struct grpc_byte_buffer; namespace grpc { grpc_completion_queue* CoreCodegen::grpc_completion_queue_create( + grpc_cq_completion_type completion_type, grpc_cq_polling_type polling_type, void* reserved) { - return ::grpc_completion_queue_create(reserved); + return ::grpc_completion_queue_create(completion_type, polling_type, + reserved); } void CoreCodegen::grpc_completion_queue_destroy(grpc_completion_queue* cq) { diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc index 9e11a8a9e0..1b7ca82be0 100644 --- a/src/cpp/server/server_cc.cc +++ b/src/cpp/server/server_cc.cc @@ -124,6 +124,14 @@ class ShutdownTag : public CompletionQueueTag { bool FinalizeResult(void** tag, bool* status) { return false; } }; +class DummyTag : public CompletionQueueTag { + public: + bool FinalizeResult(void** tag, bool* status) { + *status = true; + return true; + } +}; + class Server::SyncRequest final : public CompletionQueueTag { public: SyncRequest(RpcServiceMethod* method, void* tag) @@ -145,7 +153,10 @@ class Server::SyncRequest final : public CompletionQueueTag { grpc_metadata_array_destroy(&request_metadata_); } - void SetupRequest() { cq_ = grpc_completion_queue_create(nullptr); } + void SetupRequest() { + // TODO: sreek - Double check if this should be GRPC_CQ_PLUCK + cq_ = grpc_completion_queue_create(GRPC_CQ_PLUCK, DEFAULT_POLLING, nullptr); + } void TeardownRequest() { grpc_completion_queue_destroy(cq_); @@ -213,10 +224,10 @@ class Server::SyncRequest final : public CompletionQueueTag { MethodHandler::HandlerParameter(&call_, &ctx_, request_payload_)); global_callbacks->PostSynchronousRequest(&ctx_); request_payload_ = nullptr; - void* ignored_tag; - bool ignored_ok; + DummyTag ignored_tag; cq_.Shutdown(); - GPR_ASSERT(cq_.Next(&ignored_tag, &ignored_ok) == false); + /* Ensure the cq_ is shutdown (else this will hang indefinitely) */ + GPR_ASSERT(cq_.Pluck(&ignored_tag) == false); } private: diff --git a/test/cpp/grpclb/grpclb_test.cc b/test/cpp/grpclb/grpclb_test.cc index 89ed9249ad..542f396d10 100644 --- a/test/cpp/grpclb/grpclb_test.cc +++ b/test/cpp/grpclb/grpclb_test.cc @@ -354,8 +354,9 @@ static void start_backend_server(server_fixture *sf) { } GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); const string expected_token = - strlen(sf->lb_token_prefix) == 0 ? "" : sf->lb_token_prefix + - std::to_string(sf->port); + strlen(sf->lb_token_prefix) == 0 + ? "" + : sf->lb_token_prefix + std::to_string(sf->port); GPR_ASSERT(contains_metadata(&request_metadata_recv, "lb-token", expected_token.c_str())); @@ -593,7 +594,7 @@ static void setup_client(const server_fixture *lb_server, grpc_channel_args_copy_and_add(NULL, &expected_target_arg, 1); gpr_free(expected_target_names); - cf->cq = grpc_completion_queue_create(NULL); + cf->cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); cf->server_uri = lb_uri; grpc_channel_credentials *fake_creds = grpc_fake_transport_security_credentials_create(); @@ -616,7 +617,7 @@ static void teardown_client(client_fixture *cf) { static void setup_server(const char *host, server_fixture *sf) { int assigned_port; - sf->cq = grpc_completion_queue_create(NULL); + sf->cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); const char *colon_idx = strchr(host, ':'); if (colon_idx) { const char *port_str = colon_idx + 1; @@ -643,10 +644,15 @@ static void teardown_server(server_fixture *sf) { if (!sf->server) return; gpr_log(GPR_INFO, "Server[%s] shutting down", sf->servers_hostport); - grpc_server_shutdown_and_notify(sf->server, sf->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - sf->cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + + grpc_completion_queue *shutdown_cq = + grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + grpc_server_shutdown_and_notify(sf->server, shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); + grpc_completion_queue_destroy(shutdown_cq); grpc_server_destroy(sf->server); gpr_thd_join(sf->tid); diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc index 76d5030276..ecfa20aa90 100644 --- a/test/cpp/microbenchmarks/bm_call_create.cc +++ b/test/cpp/microbenchmarks/bm_call_create.cc @@ -65,7 +65,8 @@ static struct Init { static void BM_InsecureChannelWithDefaults(benchmark::State &state) { grpc_channel *channel = grpc_insecure_channel_create("localhost:12345", NULL, NULL); - grpc_completion_queue *cq = grpc_completion_queue_create(NULL); + grpc_completion_queue *cq = + grpc_completion_queue_create(GRPC_CQ_PLUCK, DEFAULT_POLLING, NULL); grpc_slice method = grpc_slice_from_static_string("/foo/bar"); gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); while (state.KeepRunning()) { diff --git a/test/cpp/microbenchmarks/bm_cq.cc b/test/cpp/microbenchmarks/bm_cq.cc index c017474bf4..c7bd8743a5 100644 --- a/test/cpp/microbenchmarks/bm_cq.cc +++ b/test/cpp/microbenchmarks/bm_cq.cc @@ -66,7 +66,10 @@ BENCHMARK(BM_CreateDestroyCpp); static void BM_CreateDestroyCore(benchmark::State& state) { while (state.KeepRunning()) { - grpc_completion_queue_destroy(grpc_completion_queue_create(NULL)); + // TODO: sreek Make this a templatized benchmark and pass completion type + // and polling type as parameters + grpc_completion_queue_destroy( + grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL)); } } BENCHMARK(BM_CreateDestroyCore); @@ -98,7 +101,10 @@ static void BM_Pass1Cpp(benchmark::State& state) { BENCHMARK(BM_Pass1Cpp); static void BM_Pass1Core(benchmark::State& state) { - grpc_completion_queue* cq = grpc_completion_queue_create(NULL); + // TODO: sreek Make this templatized benchmark and pass polling_type as a + // param + grpc_completion_queue* cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); while (state.KeepRunning()) { grpc_cq_completion completion; @@ -114,7 +120,10 @@ static void BM_Pass1Core(benchmark::State& state) { BENCHMARK(BM_Pass1Core); static void BM_Pluck1Core(benchmark::State& state) { - grpc_completion_queue* cq = grpc_completion_queue_create(NULL); + // TODO: sreek Make this templatized benchmark and pass polling_type as a + // param + grpc_completion_queue* cq = + grpc_completion_queue_create(GRPC_CQ_PLUCK, DEFAULT_POLLING, NULL); gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); while (state.KeepRunning()) { grpc_cq_completion completion; @@ -130,7 +139,10 @@ static void BM_Pluck1Core(benchmark::State& state) { BENCHMARK(BM_Pluck1Core); static void BM_EmptyCore(benchmark::State& state) { - grpc_completion_queue* cq = grpc_completion_queue_create(NULL); + // TODO: sreek Make this a templatized benchmark and pass polling_type as a + // param + grpc_completion_queue* cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); gpr_timespec deadline = gpr_inf_past(GPR_CLOCK_MONOTONIC); while (state.KeepRunning()) { grpc_completion_queue_next(cq, deadline, NULL); -- cgit v1.2.3 From 39b6f27a3570d850076ae65fc4b1f32a621ce96c Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Fri, 3 Mar 2017 02:22:09 -0800 Subject: generate_projects.sh change --- tools/run_tests/generated/tests.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 7ac14ab2c9..ab7938d0ca 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -2551,10 +2551,6 @@ "cpu_cost": 1.0, "exclude_configs": [], "exclude_iomgrs": [], - "excluded_poll_engines": [ - "poll", - "poll-cv" - ], "flaky": false, "gtest": false, "language": "c++", @@ -2665,6 +2661,10 @@ "cpu_cost": 1.0, "exclude_configs": [], "exclude_iomgrs": [], + "excluded_poll_engines": [ + "poll", + "poll-cv" + ], "flaky": false, "gtest": false, "language": "c++", -- cgit v1.2.3 From 9f71b177074ceb2607f331241dcceafa03431eaa Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Fri, 3 Mar 2017 12:54:58 -0800 Subject: Fix clang formatting issues --- include/grpc++/impl/codegen/completion_queue.h | 5 ++--- test/core/bad_ssl/server_common.c | 5 ++--- test/core/client_channel/lb_policies_test.c | 4 ++-- test/core/end2end/fixtures/h2_full+pipe.c | 7 +++---- test/core/end2end/fixtures/h2_full+trace.c | 7 +++---- test/core/end2end/fixtures/h2_http_proxy.c | 7 +++---- test/core/end2end/fixtures/h2_uds.c | 7 +++---- test/core/fling/server.c | 5 ++--- test/core/memory_usage/client.c | 5 ++--- test/core/memory_usage/server.c | 5 ++--- test/cpp/grpclb/grpclb_test.cc | 5 ++--- 11 files changed, 26 insertions(+), 36 deletions(-) diff --git a/include/grpc++/impl/codegen/completion_queue.h b/include/grpc++/impl/codegen/completion_queue.h index a123af2cf6..a7125e6af3 100644 --- a/include/grpc++/impl/codegen/completion_queue.h +++ b/include/grpc++/impl/codegen/completion_queue.h @@ -147,9 +147,8 @@ class CompletionQueue : private GrpcLibraryCodegen { /// /// \return true if read a regular event, false if the queue is shutting down. bool Next(void** tag, bool* ok) { - return (AsyncNextInternal(tag, ok, - g_core_codegen_interface->gpr_inf_future( - GPR_CLOCK_REALTIME)) != SHUTDOWN); + return (AsyncNextInternal(tag, ok, g_core_codegen_interface->gpr_inf_future( + GPR_CLOCK_REALTIME)) != SHUTDOWN); } /// Request the shutdown of the queue. diff --git a/test/core/bad_ssl/server_common.c b/test/core/bad_ssl/server_common.c index 383899d94a..42a8d4ede8 100644 --- a/test/core/bad_ssl/server_common.c +++ b/test/core/bad_ssl/server_common.c @@ -97,9 +97,8 @@ void bad_ssl_run(grpc_server *server) { shutdown_started = 1; } ev = grpc_completion_queue_next( - cq, - gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_micros(1000000, GPR_TIMESPAN)), + cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_micros(1000000, GPR_TIMESPAN)), NULL); switch (ev.type) { case GRPC_OP_COMPLETE: diff --git a/test/core/client_channel/lb_policies_test.c b/test/core/client_channel/lb_policies_test.c index 9dcbdb979d..8bbcfe987e 100644 --- a/test/core/client_channel/lb_policies_test.c +++ b/test/core/client_channel/lb_policies_test.c @@ -65,8 +65,8 @@ typedef struct servers_fixture { } servers_fixture; typedef struct request_sequences { - size_t n; /* number of iterations */ - int *connections; /* indexed by the interation number, value is the index of + size_t n; /* number of iterations */ + int *connections; /* indexed by the interation number, value is the index of the server it connected to or -1 if none */ int *connectivity_states; /* indexed by the interation number, value is the client connectivity state */ diff --git a/test/core/end2end/fixtures/h2_full+pipe.c b/test/core/end2end/fixtures/h2_full+pipe.c index 812922ff5b..833b8278cc 100644 --- a/test/core/end2end/fixtures/h2_full+pipe.c +++ b/test/core/end2end/fixtures/h2_full+pipe.c @@ -104,10 +104,9 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_full+trace.c b/test/core/end2end/fixtures/h2_full+trace.c index 02d794d08d..a44587cd15 100644 --- a/test/core/end2end/fixtures/h2_full+trace.c +++ b/test/core/end2end/fixtures/h2_full+trace.c @@ -104,10 +104,9 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_http_proxy.c b/test/core/end2end/fixtures/h2_http_proxy.c index 0f8e002e56..2c0dc84d40 100644 --- a/test/core/end2end/fixtures/h2_http_proxy.c +++ b/test/core/end2end/fixtures/h2_http_proxy.c @@ -109,10 +109,9 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_uds.c b/test/core/end2end/fixtures/h2_uds.c index 1c7799d5d9..4e2b5f0ba5 100644 --- a/test/core/end2end/fixtures/h2_uds.c +++ b/test/core/end2end/fixtures/h2_uds.c @@ -103,10 +103,9 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack_uds", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack_uds", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/fling/server.c b/test/core/fling/server.c index f1b5f39a60..3d20d22aaa 100644 --- a/test/core/fling/server.c +++ b/test/core/fling/server.c @@ -258,9 +258,8 @@ int main(int argc, char **argv) { shutdown_started = 1; } ev = grpc_completion_queue_next( - cq, - gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_micros(1000000, GPR_TIMESPAN)), + cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_micros(1000000, GPR_TIMESPAN)), NULL); s = ev.tag; switch (ev.type) { diff --git a/test/core/memory_usage/client.c b/test/core/memory_usage/client.c index 588f559d4c..ef18ac03e8 100644 --- a/test/core/memory_usage/client.c +++ b/test/core/memory_usage/client.c @@ -260,9 +260,8 @@ int main(int argc, char **argv) { do { event = grpc_completion_queue_next( - cq, - gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_micros(10000, GPR_TIMESPAN)), + cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_micros(10000, GPR_TIMESPAN)), NULL); } while (event.type != GRPC_QUEUE_TIMEOUT); diff --git a/test/core/memory_usage/server.c b/test/core/memory_usage/server.c index eb9794b558..6b61ecabba 100644 --- a/test/core/memory_usage/server.c +++ b/test/core/memory_usage/server.c @@ -244,9 +244,8 @@ int main(int argc, char **argv) { shutdown_started = 1; } ev = grpc_completion_queue_next( - cq, - gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_micros(1000000, GPR_TIMESPAN)), + cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_micros(1000000, GPR_TIMESPAN)), NULL); fling_call *s = ev.tag; switch (ev.type) { diff --git a/test/cpp/grpclb/grpclb_test.cc b/test/cpp/grpclb/grpclb_test.cc index 542f396d10..7fd31a2dbf 100644 --- a/test/cpp/grpclb/grpclb_test.cc +++ b/test/cpp/grpclb/grpclb_test.cc @@ -354,9 +354,8 @@ static void start_backend_server(server_fixture *sf) { } GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); const string expected_token = - strlen(sf->lb_token_prefix) == 0 - ? "" - : sf->lb_token_prefix + std::to_string(sf->port); + strlen(sf->lb_token_prefix) == 0 ? "" : sf->lb_token_prefix + + std::to_string(sf->port); GPR_ASSERT(contains_metadata(&request_metadata_recv, "lb-token", expected_token.c_str())); -- cgit v1.2.3 From 1dbd981cf8be17db0268e96c2e2a0647b7d53385 Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Fri, 3 Mar 2017 14:27:44 -0800 Subject: Prefix grpc_cq_polling_type enums with GRPC_CQ_ --- include/grpc++/impl/codegen/client_unary_call.h | 2 +- include/grpc++/impl/codegen/completion_queue.h | 2 +- include/grpc++/impl/codegen/sync_stream.h | 6 ++--- include/grpc/grpc.h | 14 +++++----- src/core/lib/surface/completion_queue.c | 4 +-- src/cpp/server/server_cc.cc | 4 +-- test/core/bad_client/bad_client.c | 6 +++-- test/core/bad_ssl/bad_ssl_test.c | 2 +- test/core/bad_ssl/server_common.c | 11 ++++---- test/core/client_channel/lb_policies_test.c | 7 ++--- .../set_initial_connect_string_test.c | 3 ++- test/core/end2end/bad_server_response_test.c | 3 ++- test/core/end2end/connection_refused_test.c | 3 ++- test/core/end2end/dualstack_socket_test.c | 6 +++-- test/core/end2end/fixtures/h2_census.c | 5 ++-- test/core/end2end/fixtures/h2_compress.c | 5 ++-- test/core/end2end/fixtures/h2_fakesec.c | 5 ++-- test/core/end2end/fixtures/h2_fd.c | 5 ++-- test/core/end2end/fixtures/h2_full+pipe.c | 5 ++-- test/core/end2end/fixtures/h2_full+trace.c | 12 +++++---- test/core/end2end/fixtures/h2_full.c | 5 ++-- test/core/end2end/fixtures/h2_http_proxy.c | 5 ++-- test/core/end2end/fixtures/h2_load_reporting.c | 5 ++-- test/core/end2end/fixtures/h2_oauth2.c | 5 ++-- test/core/end2end/fixtures/h2_proxy.c | 5 ++-- test/core/end2end/fixtures/h2_sockpair+trace.c | 5 ++-- test/core/end2end/fixtures/h2_sockpair.c | 5 ++-- test/core/end2end/fixtures/h2_sockpair_1byte.c | 5 ++-- test/core/end2end/fixtures/h2_ssl.c | 5 ++-- test/core/end2end/fixtures/h2_ssl_cert.c | 5 ++-- test/core/end2end/fixtures/h2_ssl_proxy.c | 5 ++-- test/core/end2end/fixtures/h2_uds.c | 12 +++++---- test/core/end2end/fixtures/proxy.c | 3 ++- test/core/end2end/fuzzers/api_fuzzer.c | 2 +- test/core/end2end/fuzzers/client_fuzzer.c | 2 +- test/core/end2end/fuzzers/server_fuzzer.c | 2 +- test/core/end2end/goaway_server_test.c | 3 ++- test/core/end2end/invalid_call_argument_test.c | 4 +-- test/core/end2end/multiple_server_queues_test.c | 7 ++--- test/core/end2end/no_server_test.c | 3 ++- test/core/fling/client.c | 3 ++- test/core/fling/server.c | 12 +++++---- test/core/handshake/client_ssl.c | 2 +- test/core/handshake/server_ssl.c | 2 +- test/core/memory_usage/client.c | 8 +++--- test/core/memory_usage/server.c | 12 +++++---- test/core/surface/alarm_test.c | 3 ++- test/core/surface/completion_queue_test.c | 31 +++++++++++----------- .../core/surface/completion_queue_threading_test.c | 5 ++-- test/core/surface/concurrent_connectivity_test.c | 7 ++--- test/core/surface/lame_client_test.c | 3 ++- test/core/surface/sequential_connectivity_test.c | 4 +-- test/core/surface/server_chttp2_test.c | 2 +- test/core/surface/server_test.c | 6 ++--- test/cpp/grpclb/grpclb_test.cc | 13 +++++---- test/cpp/microbenchmarks/bm_call_create.cc | 2 +- test/cpp/microbenchmarks/bm_cq.cc | 12 ++++----- 57 files changed, 189 insertions(+), 141 deletions(-) diff --git a/include/grpc++/impl/codegen/client_unary_call.h b/include/grpc++/impl/codegen/client_unary_call.h index bf18a7d644..d8085a0a7f 100644 --- a/include/grpc++/impl/codegen/client_unary_call.h +++ b/include/grpc++/impl/codegen/client_unary_call.h @@ -52,7 +52,7 @@ template Status BlockingUnaryCall(ChannelInterface* channel, const RpcMethod& method, ClientContext* context, const InputMessage& request, OutputMessage* result) { - CompletionQueue cq(GRPC_CQ_PLUCK, DEFAULT_POLLING); + CompletionQueue cq(GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING); Call call(channel->CreateCall(method, context, &cq)); CallOpSet, diff --git a/include/grpc++/impl/codegen/completion_queue.h b/include/grpc++/impl/codegen/completion_queue.h index a7125e6af3..f34b82dad2 100644 --- a/include/grpc++/impl/codegen/completion_queue.h +++ b/include/grpc++/impl/codegen/completion_queue.h @@ -103,7 +103,7 @@ class CompletionQueue : private GrpcLibraryCodegen { public: /// Default constructor. Implicitly creates a \a grpc_completion_queue /// instance. - CompletionQueue() : CompletionQueue(GRPC_CQ_NEXT, DEFAULT_POLLING) {} + CompletionQueue() : CompletionQueue(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING) {} /// Wrap \a take, taking ownership of the instance. /// diff --git a/include/grpc++/impl/codegen/sync_stream.h b/include/grpc++/impl/codegen/sync_stream.h index d3a6c7ff89..c09ab5e647 100644 --- a/include/grpc++/impl/codegen/sync_stream.h +++ b/include/grpc++/impl/codegen/sync_stream.h @@ -138,7 +138,7 @@ class ClientReader final : public ClientReaderInterface { ClientReader(ChannelInterface* channel, const RpcMethod& method, ClientContext* context, const W& request) : context_(context), - cq_(GRPC_CQ_PLUCK, DEFAULT_POLLING), + cq_(GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING), call_(channel->CreateCall(method, context, &cq_)) { CallOpSet @@ -212,7 +212,7 @@ class ClientWriter : public ClientWriterInterface { ClientWriter(ChannelInterface* channel, const RpcMethod& method, ClientContext* context, R* response) : context_(context), - cq_(GRPC_CQ_PLUCK, DEFAULT_POLLING), + cq_(GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING), call_(channel->CreateCall(method, context, &cq_)) { finish_ops_.RecvMessage(response); finish_ops_.AllowNoMessage(); @@ -297,7 +297,7 @@ class ClientReaderWriter final : public ClientReaderWriterInterface { ClientReaderWriter(ChannelInterface* channel, const RpcMethod& method, ClientContext* context) : context_(context), - cq_(GRPC_CQ_PLUCK, DEFAULT_POLLING), + cq_(GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING), call_(channel->CreateCall(method, context, &cq_)) { CallOpSet ops; ops.SendInitialMetadata(context->send_initial_metadata_, diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index 0e4711fa1f..29fd3048fc 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -108,23 +108,23 @@ typedef enum { I/O progress can only be made when grpc_completion_queue_next() or grpc_completion_queue_pluck() are called on the completion queue (unless the - grpc_cq_polling_type is NON_POLLING) and hence it is very important to - actively call these APIs */ + grpc_cq_polling_type is GRPC_CQ_NON_POLLING) and hence it is very important + to actively call these APIs */ typedef enum { /** The completion queue will have an associated pollset and there is no restriction on the type of file descriptors the pollset may contain */ - DEFAULT_POLLING, + GRPC_CQ_DEFAULT_POLLING, - /** Similar to DEFAULT_POLLING except that the completion queues will not - contain any 'listening file descriptors' (i.e file descriptors used to + /** Similar to GRPC_CQ_DEFAULT_POLLING except that the completion queues will + not contain any 'listening file descriptors' (i.e file descriptors used to listen to incoming channels */ - NON_LISTENING, + GRPC_CQ_NON_LISTENING, /** The completion queue will not have an associated pollset. Note that grpc_completion_queue_next() or grpc_completion_queue_pluck() MUST still be called to pop events from the completion queue; it is not required to call them actively to make I/O progress */ - NON_POLLING + GRPC_CQ_NON_POLLING } grpc_cq_polling_type; /** Create a completion queue */ diff --git a/src/core/lib/surface/completion_queue.c b/src/core/lib/surface/completion_queue.c index d45e265d5c..ad9d7b20b0 100644 --- a/src/core/lib/surface/completion_queue.c +++ b/src/core/lib/surface/completion_queue.c @@ -717,12 +717,12 @@ grpc_completion_queue *grpc_cq_from_pollset(grpc_pollset *ps) { void grpc_cq_mark_non_listening_server_cq(grpc_completion_queue *cc) { /* TODO: sreek - use cc->polling_type field here and add a validation check (i.e grpc_cq_mark_non_listening_server_cq can only be called on a cc whose - polling_type is set to NON_LISTENING */ + polling_type is set to GRPC_CQ_NON_LISTENING */ cc->is_non_listening_server_cq = 1; } bool grpc_cq_is_non_listening_server_cq(grpc_completion_queue *cc) { - /* TODO (sreek) - return (cc->polling_type == NON_LISTENING) */ + /* TODO (sreek) - return (cc->polling_type == GRPC_CQ_NON_LISTENING) */ return (cc->is_non_listening_server_cq == 1); } diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc index 1b7ca82be0..50c4cafa7a 100644 --- a/src/cpp/server/server_cc.cc +++ b/src/cpp/server/server_cc.cc @@ -154,8 +154,8 @@ class Server::SyncRequest final : public CompletionQueueTag { } void SetupRequest() { - // TODO: sreek - Double check if this should be GRPC_CQ_PLUCK - cq_ = grpc_completion_queue_create(GRPC_CQ_PLUCK, DEFAULT_POLLING, nullptr); + cq_ = grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, + nullptr); } void TeardownRequest() { diff --git a/test/core/bad_client/bad_client.c b/test/core/bad_client/bad_client.c index a6e859d06e..2ecb75883b 100644 --- a/test/core/bad_client/bad_client.c +++ b/test/core/bad_client/bad_client.c @@ -125,7 +125,8 @@ void grpc_run_bad_client_test( /* Create server, completion events */ a.server = grpc_server_create(NULL, NULL); - a.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + a.cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); gpr_event_init(&a.done_thd); gpr_event_init(&a.done_write); a.validator = server_validator; @@ -197,7 +198,8 @@ void grpc_run_bad_client_test( grpc_exec_ctx_finish(&exec_ctx); } - shutdown_cq = grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + shutdown_cq = + grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); grpc_server_shutdown_and_notify(a.server, shutdown_cq, NULL); GPR_ASSERT(grpc_completion_queue_pluck( shutdown_cq, NULL, grpc_timeout_seconds_to_deadline(1), NULL) diff --git a/test/core/bad_ssl/bad_ssl_test.c b/test/core/bad_ssl/bad_ssl_test.c index 4d34f8a9ea..e0f1d2789f 100644 --- a/test/core/bad_ssl/bad_ssl_test.c +++ b/test/core/bad_ssl/bad_ssl_test.c @@ -62,7 +62,7 @@ static void run_test(const char *target, size_t nops) { grpc_call_error error; gpr_timespec deadline = grpc_timeout_seconds_to_deadline(5); grpc_completion_queue *cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); cq_verifier *cqv = cq_verifier_create(cq); grpc_op ops[6]; diff --git a/test/core/bad_ssl/server_common.c b/test/core/bad_ssl/server_common.c index 42a8d4ede8..b112ae4e78 100644 --- a/test/core/bad_ssl/server_common.c +++ b/test/core/bad_ssl/server_common.c @@ -68,7 +68,7 @@ void bad_ssl_run(grpc_server *server) { grpc_metadata_array request_metadata_recv; grpc_completion_queue *cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); grpc_completion_queue *shutdown_cq; grpc_call_details_init(&call_details); @@ -85,8 +85,8 @@ void bad_ssl_run(grpc_server *server) { while (!shutdown_finished) { if (got_sigint && !shutdown_started) { gpr_log(GPR_INFO, "Shutting down due to SIGINT"); - shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + shutdown_cq = grpc_completion_queue_create(GRPC_CQ_PLUCK, + GRPC_CQ_NON_POLLING, NULL); grpc_server_shutdown_and_notify(server, shutdown_cq, NULL); GPR_ASSERT( grpc_completion_queue_pluck(shutdown_cq, NULL, @@ -97,8 +97,9 @@ void bad_ssl_run(grpc_server *server) { shutdown_started = 1; } ev = grpc_completion_queue_next( - cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_micros(1000000, GPR_TIMESPAN)), + cq, + gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_micros(1000000, GPR_TIMESPAN)), NULL); switch (ev.type) { case GRPC_OP_COMPLETE: diff --git a/test/core/client_channel/lb_policies_test.c b/test/core/client_channel/lb_policies_test.c index 8bbcfe987e..f440e3348c 100644 --- a/test/core/client_channel/lb_policies_test.c +++ b/test/core/client_channel/lb_policies_test.c @@ -67,7 +67,7 @@ typedef struct servers_fixture { typedef struct request_sequences { size_t n; /* number of iterations */ int *connections; /* indexed by the interation number, value is the index of - the server it connected to or -1 if none */ + the server it connected to or -1 if none */ int *connectivity_states; /* indexed by the interation number, value is the client connectivity state */ } request_sequences; @@ -197,9 +197,10 @@ static servers_fixture *setup_servers(const char *server_host, /* Create servers. */ f->servers = gpr_malloc(sizeof(grpc_server *) * num_servers); f->servers_hostports = gpr_malloc(sizeof(char *) * num_servers); - f->cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f->cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); f->shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); for (i = 0; i < num_servers; i++) { grpc_metadata_array_init(&f->request_metadata_recv[i]); gpr_join_host_port(&f->servers_hostports[i], server_host, diff --git a/test/core/client_channel/set_initial_connect_string_test.c b/test/core/client_channel/set_initial_connect_string_test.c index 38f2fbac62..999c89bdbd 100644 --- a/test/core/client_channel/set_initial_connect_string_test.c +++ b/test/core/client_channel/set_initial_connect_string_test.c @@ -130,7 +130,8 @@ static gpr_timespec n_sec_deadline(int seconds) { } static void start_rpc(int use_creds, int target_port) { - state.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + state.cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); if (use_creds) { state.creds = grpc_fake_transport_security_credentials_create(); } else { diff --git a/test/core/end2end/bad_server_response_test.c b/test/core/end2end/bad_server_response_test.c index 67f5bdbac8..e4dc3831dc 100644 --- a/test/core/end2end/bad_server_response_test.c +++ b/test/core/end2end/bad_server_response_test.c @@ -178,7 +178,8 @@ static void start_rpc(int target_port, grpc_status_code expected_status, cq_verifier *cqv; grpc_slice details; - state.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + state.cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); cqv = cq_verifier_create(state.cq); gpr_join_host_port(&state.target, "127.0.0.1", target_port); state.channel = grpc_insecure_channel_create(state.target, NULL, NULL); diff --git a/test/core/end2end/connection_refused_test.c b/test/core/end2end/connection_refused_test.c index 617828f954..fe203ddf4d 100644 --- a/test/core/end2end/connection_refused_test.c +++ b/test/core/end2end/connection_refused_test.c @@ -69,7 +69,8 @@ static void run_test(bool wait_for_ready, bool use_service_config) { grpc_metadata_array_init(&trailing_metadata_recv); - cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); cqv = cq_verifier_create(cq); /* if using service config, create channel args */ diff --git a/test/core/end2end/dualstack_socket_test.c b/test/core/end2end/dualstack_socket_test.c index 5125be9b94..19f947865a 100644 --- a/test/core/end2end/dualstack_socket_test.c +++ b/test/core/end2end/dualstack_socket_test.c @@ -108,7 +108,8 @@ void test_connect(const char *server_host, const char *client_host, int port, grpc_call_details_init(&call_details); /* Create server. */ - cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); server = grpc_server_create(NULL, NULL); grpc_server_register_completion_queue(server, cq, NULL); GPR_ASSERT((got_port = grpc_server_add_insecure_http2_port( @@ -260,7 +261,8 @@ void test_connect(const char *server_host, const char *client_host, int port, grpc_channel_destroy(client); /* Destroy server. */ - shutdown_cq = grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + shutdown_cq = + grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); grpc_server_shutdown_and_notify(server, shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(shutdown_cq, tag(1000), grpc_timeout_seconds_to_deadline(5), diff --git a/test/core/end2end/fixtures/h2_census.c b/test/core/end2end/fixtures/h2_census.c index a1fae013c2..1077e063b8 100644 --- a/test/core/end2end/fixtures/h2_census.c +++ b/test/core/end2end/fixtures/h2_census.c @@ -65,9 +65,10 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); return f; } diff --git a/test/core/end2end/fixtures/h2_compress.c b/test/core/end2end/fixtures/h2_compress.c index 7a2aa7ff7f..a985faeb5a 100644 --- a/test/core/end2end/fixtures/h2_compress.c +++ b/test/core/end2end/fixtures/h2_compress.c @@ -69,9 +69,10 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_compression( memset(&f, 0, sizeof(f)); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); return f; } diff --git a/test/core/end2end/fixtures/h2_fakesec.c b/test/core/end2end/fixtures/h2_fakesec.c index 0ccdef9767..59ae3f0cb3 100644 --- a/test/core/end2end/fixtures/h2_fakesec.c +++ b/test/core/end2end/fixtures/h2_fakesec.c @@ -60,9 +60,10 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); return f; } diff --git a/test/core/end2end/fixtures/h2_fd.c b/test/core/end2end/fixtures/h2_fd.c index d97b693e33..b01b52c996 100644 --- a/test/core/end2end/fixtures/h2_fd.c +++ b/test/core/end2end/fixtures/h2_fd.c @@ -70,9 +70,10 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( grpc_end2end_test_fixture f; memset(&f, 0, sizeof(f)); f.fixture_data = fixture_data; - f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); create_sockets(fixture_data->fd_pair); diff --git a/test/core/end2end/fixtures/h2_full+pipe.c b/test/core/end2end/fixtures/h2_full+pipe.c index 833b8278cc..6add99707f 100644 --- a/test/core/end2end/fixtures/h2_full+pipe.c +++ b/test/core/end2end/fixtures/h2_full+pipe.c @@ -70,9 +70,10 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); return f; } diff --git a/test/core/end2end/fixtures/h2_full+trace.c b/test/core/end2end/fixtures/h2_full+trace.c index a44587cd15..c24bacc42f 100644 --- a/test/core/end2end/fixtures/h2_full+trace.c +++ b/test/core/end2end/fixtures/h2_full+trace.c @@ -70,9 +70,10 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); return f; } @@ -104,9 +105,10 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_full.c b/test/core/end2end/fixtures/h2_full.c index bfb300e42f..901a419f25 100644 --- a/test/core/end2end/fixtures/h2_full.c +++ b/test/core/end2end/fixtures/h2_full.c @@ -64,9 +64,10 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); return f; } diff --git a/test/core/end2end/fixtures/h2_http_proxy.c b/test/core/end2end/fixtures/h2_http_proxy.c index 2c0dc84d40..5285068797 100644 --- a/test/core/end2end/fixtures/h2_http_proxy.c +++ b/test/core/end2end/fixtures/h2_http_proxy.c @@ -69,9 +69,10 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( ffd->proxy = grpc_end2end_http_proxy_create(); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); return f; } diff --git a/test/core/end2end/fixtures/h2_load_reporting.c b/test/core/end2end/fixtures/h2_load_reporting.c index 664c7ba9d4..5b8721adbd 100644 --- a/test/core/end2end/fixtures/h2_load_reporting.c +++ b/test/core/end2end/fixtures/h2_load_reporting.c @@ -67,9 +67,10 @@ static grpc_end2end_test_fixture chttp2_create_fixture_load_reporting( gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); return f; } diff --git a/test/core/end2end/fixtures/h2_oauth2.c b/test/core/end2end/fixtures/h2_oauth2.c index 73928759fe..19920473ff 100644 --- a/test/core/end2end/fixtures/h2_oauth2.c +++ b/test/core/end2end/fixtures/h2_oauth2.c @@ -113,9 +113,10 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); return f; } diff --git a/test/core/end2end/fixtures/h2_proxy.c b/test/core/end2end/fixtures/h2_proxy.c index 016ba41fbd..5a64a10918 100644 --- a/test/core/end2end/fixtures/h2_proxy.c +++ b/test/core/end2end/fixtures/h2_proxy.c @@ -79,9 +79,10 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( ffd->proxy = grpc_end2end_proxy_create(&proxy_def, client_args, server_args); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); return f; } diff --git a/test/core/end2end/fixtures/h2_sockpair+trace.c b/test/core/end2end/fixtures/h2_sockpair+trace.c index 445f8a2dd1..069b880238 100644 --- a/test/core/end2end/fixtures/h2_sockpair+trace.c +++ b/test/core/end2end/fixtures/h2_sockpair+trace.c @@ -94,9 +94,10 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( grpc_end2end_test_fixture f; memset(&f, 0, sizeof(f)); f.fixture_data = sfd; - f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); grpc_resource_quota *resource_quota = grpc_resource_quota_create("fixture"); *sfd = grpc_iomgr_create_endpoint_pair("fixture", resource_quota, 65536); diff --git a/test/core/end2end/fixtures/h2_sockpair.c b/test/core/end2end/fixtures/h2_sockpair.c index 66c05c5562..c19d485403 100644 --- a/test/core/end2end/fixtures/h2_sockpair.c +++ b/test/core/end2end/fixtures/h2_sockpair.c @@ -88,9 +88,10 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( grpc_end2end_test_fixture f; memset(&f, 0, sizeof(f)); f.fixture_data = sfd; - f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); grpc_resource_quota *resource_quota = grpc_resource_quota_create("fixture"); *sfd = grpc_iomgr_create_endpoint_pair("fixture", resource_quota, 65536); diff --git a/test/core/end2end/fixtures/h2_sockpair_1byte.c b/test/core/end2end/fixtures/h2_sockpair_1byte.c index 2d845f369b..05883b5ef4 100644 --- a/test/core/end2end/fixtures/h2_sockpair_1byte.c +++ b/test/core/end2end/fixtures/h2_sockpair_1byte.c @@ -88,9 +88,10 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( grpc_end2end_test_fixture f; memset(&f, 0, sizeof(f)); f.fixture_data = sfd; - f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); grpc_resource_quota *resource_quota = grpc_resource_quota_create("fixture"); *sfd = grpc_iomgr_create_endpoint_pair("fixture", resource_quota, 1); diff --git a/test/core/end2end/fixtures/h2_ssl.c b/test/core/end2end/fixtures/h2_ssl.c index d73944fe6c..d704b97e1c 100644 --- a/test/core/end2end/fixtures/h2_ssl.c +++ b/test/core/end2end/fixtures/h2_ssl.c @@ -64,9 +64,10 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); return f; } diff --git a/test/core/end2end/fixtures/h2_ssl_cert.c b/test/core/end2end/fixtures/h2_ssl_cert.c index c8bd7153c2..c3d25ac836 100644 --- a/test/core/end2end/fixtures/h2_ssl_cert.c +++ b/test/core/end2end/fixtures/h2_ssl_cert.c @@ -67,9 +67,10 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); return f; } diff --git a/test/core/end2end/fixtures/h2_ssl_proxy.c b/test/core/end2end/fixtures/h2_ssl_proxy.c index 22fbeb1a83..61bcfebbbe 100644 --- a/test/core/end2end/fixtures/h2_ssl_proxy.c +++ b/test/core/end2end/fixtures/h2_ssl_proxy.c @@ -100,9 +100,10 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( ffd->proxy = grpc_end2end_proxy_create(&proxy_def, client_args, server_args); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); return f; } diff --git a/test/core/end2end/fixtures/h2_uds.c b/test/core/end2end/fixtures/h2_uds.c index 4e2b5f0ba5..820c587bee 100644 --- a/test/core/end2end/fixtures/h2_uds.c +++ b/test/core/end2end/fixtures/h2_uds.c @@ -70,9 +70,10 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( unique++); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + f.cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); return f; } @@ -103,9 +104,10 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack_uds", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack_uds", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/proxy.c b/test/core/end2end/fixtures/proxy.c index 7f23eef66a..7d306c6032 100644 --- a/test/core/end2end/fixtures/proxy.c +++ b/test/core/end2end/fixtures/proxy.c @@ -104,7 +104,8 @@ grpc_end2end_proxy *grpc_end2end_proxy_create(const grpc_end2end_proxy_def *def, gpr_log(GPR_DEBUG, "PROXY ADDR:%s BACKEND:%s", proxy->proxy_port, proxy->server_port); - proxy->cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + proxy->cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); proxy->server = def->create_server(proxy->proxy_port, server_args); proxy->client = def->create_client(proxy->server_port, client_args); diff --git a/test/core/end2end/fuzzers/api_fuzzer.c b/test/core/end2end/fuzzers/api_fuzzer.c index 61f972e65e..278b6dbae0 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.c +++ b/test/core/end2end/fuzzers/api_fuzzer.c @@ -739,7 +739,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { g_resource_quota = grpc_resource_quota_create("api_fuzzer"); grpc_completion_queue *cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); while (!is_eof(&inp) || g_channel != NULL || g_server != NULL || pending_channel_watches > 0 || pending_pings > 0 || diff --git a/test/core/end2end/fuzzers/client_fuzzer.c b/test/core/end2end/fuzzers/client_fuzzer.c index 6b8c09cdf4..46acf7d70a 100644 --- a/test/core/end2end/fuzzers/client_fuzzer.c +++ b/test/core/end2end/fuzzers/client_fuzzer.c @@ -66,7 +66,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { grpc_resource_quota_unref_internal(&exec_ctx, resource_quota); grpc_completion_queue *cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); grpc_transport *transport = grpc_create_chttp2_transport(&exec_ctx, NULL, mock_endpoint, 1); grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL); diff --git a/test/core/end2end/fuzzers/server_fuzzer.c b/test/core/end2end/fuzzers/server_fuzzer.c index 76fe97ec0f..33c8ed4e72 100644 --- a/test/core/end2end/fuzzers/server_fuzzer.c +++ b/test/core/end2end/fuzzers/server_fuzzer.c @@ -68,7 +68,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { grpc_server *server = grpc_server_create(NULL, NULL); grpc_completion_queue *cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); grpc_server_register_completion_queue(server, cq, NULL); // TODO(ctiller): add registered methods (one for POST, one for PUT) // void *registered_method = diff --git a/test/core/end2end/goaway_server_test.c b/test/core/end2end/goaway_server_test.c index 85d54c16e5..92ea7a72ef 100644 --- a/test/core/end2end/goaway_server_test.c +++ b/test/core/end2end/goaway_server_test.c @@ -121,7 +121,8 @@ int main(int argc, char **argv) { grpc_metadata_array_init(&request_metadata2); grpc_call_details_init(&request_details2); - cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); cqv = cq_verifier_create(cq); /* reserve two ports */ diff --git a/test/core/end2end/invalid_call_argument_test.c b/test/core/end2end/invalid_call_argument_test.c index 0563127af8..7aa8d98933 100644 --- a/test/core/end2end/invalid_call_argument_test.c +++ b/test/core/end2end/invalid_call_argument_test.c @@ -74,7 +74,7 @@ static void prepare_test(int is_client) { grpc_metadata_array_init(&g_state.trailing_metadata_recv); g_state.deadline = grpc_timeout_seconds_to_deadline(2); g_state.cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); g_state.cqv = cq_verifier_create(g_state.cq); g_state.details = grpc_empty_slice(); memset(g_state.ops, 0, sizeof(g_state.ops)); @@ -134,7 +134,7 @@ static void cleanup_test() { if (!g_state.is_client) { shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); grpc_call_destroy(g_state.server_call); grpc_server_shutdown_and_notify(g_state.server, shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(shutdown_cq, tag(1000), diff --git a/test/core/end2end/multiple_server_queues_test.c b/test/core/end2end/multiple_server_queues_test.c index 94e615f1aa..7da5ee55ae 100644 --- a/test/core/end2end/multiple_server_queues_test.c +++ b/test/core/end2end/multiple_server_queues_test.c @@ -42,9 +42,10 @@ int main(int argc, char **argv) { grpc_test_init(argc, argv); grpc_init(); - cq1 = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); - cq2 = grpc_completion_queue_create(GRPC_CQ_NEXT, NON_LISTENING, NULL); - cq3 = grpc_completion_queue_create(GRPC_CQ_NEXT, NON_POLLING, NULL); + cq1 = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + cq2 = grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_NON_LISTENING, NULL); + cq3 = grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_NON_POLLING, NULL); server = grpc_server_create(NULL, NULL); grpc_server_register_completion_queue(server, cq1, NULL); diff --git a/test/core/end2end/no_server_test.c b/test/core/end2end/no_server_test.c index e16c129d67..fd8a2f8a39 100644 --- a/test/core/end2end/no_server_test.c +++ b/test/core/end2end/no_server_test.c @@ -59,7 +59,8 @@ int main(int argc, char **argv) { grpc_metadata_array_init(&trailing_metadata_recv); - cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); cqv = cq_verifier_create(cq); /* create a call, channel to a non existant server */ diff --git a/test/core/fling/client.c b/test/core/fling/client.c index 188696c189..a9f6a3d516 100644 --- a/test/core/fling/client.c +++ b/test/core/fling/client.c @@ -208,7 +208,8 @@ int main(int argc, char **argv) { } channel = grpc_insecure_channel_create(target, NULL, NULL); - cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); the_buffer = grpc_raw_byte_buffer_create(&slice, (size_t)payload_size); histogram = gpr_histogram_create(0.01, 60e9); diff --git a/test/core/fling/server.c b/test/core/fling/server.c index 3d20d22aaa..02168c4ea9 100644 --- a/test/core/fling/server.c +++ b/test/core/fling/server.c @@ -215,7 +215,8 @@ int main(int argc, char **argv) { } gpr_log(GPR_INFO, "creating server on: %s", addr); - cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); if (secure) { grpc_ssl_pem_key_cert_pair pem_key_cert_pair = {test_server1_key, test_server1_cert}; @@ -244,8 +245,8 @@ int main(int argc, char **argv) { if (got_sigint && !shutdown_started) { gpr_log(GPR_INFO, "Shutting down due to SIGINT"); - shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + shutdown_cq = grpc_completion_queue_create(GRPC_CQ_PLUCK, + GRPC_CQ_NON_POLLING, NULL); grpc_server_shutdown_and_notify(server, shutdown_cq, tag(1000)); GPR_ASSERT( @@ -258,8 +259,9 @@ int main(int argc, char **argv) { shutdown_started = 1; } ev = grpc_completion_queue_next( - cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_micros(1000000, GPR_TIMESPAN)), + cq, + gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_micros(1000000, GPR_TIMESPAN)), NULL); s = ev.tag; switch (ev.type) { diff --git a/test/core/handshake/client_ssl.c b/test/core/handshake/client_ssl.c index 72e8ffe02a..5ebbc42609 100644 --- a/test/core/handshake/client_ssl.c +++ b/test/core/handshake/client_ssl.c @@ -290,7 +290,7 @@ static bool client_ssl_test(char *server_alpn_preferred) { int retries = 10; grpc_connectivity_state state = GRPC_CHANNEL_IDLE; grpc_completion_queue *cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); while (state != GRPC_CHANNEL_READY && retries-- > 0) { grpc_channel_watch_connectivity_state( diff --git a/test/core/handshake/server_ssl.c b/test/core/handshake/server_ssl.c index f61ad786bc..6ac22eaae5 100644 --- a/test/core/handshake/server_ssl.c +++ b/test/core/handshake/server_ssl.c @@ -105,7 +105,7 @@ static void server_thread(void *arg) { free(addr); grpc_completion_queue *cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); grpc_server_register_completion_queue(server, cq, NULL); grpc_server_start(server); diff --git a/test/core/memory_usage/client.c b/test/core/memory_usage/client.c index ef18ac03e8..b2bc269136 100644 --- a/test/core/memory_usage/client.c +++ b/test/core/memory_usage/client.c @@ -222,7 +222,8 @@ int main(int argc, char **argv) { calls[k].details = grpc_empty_slice(); } - cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); struct grpc_memory_counters client_channel_start = grpc_memory_counters_snapshot(); @@ -260,8 +261,9 @@ int main(int argc, char **argv) { do { event = grpc_completion_queue_next( - cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_micros(10000, GPR_TIMESPAN)), + cq, + gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_micros(10000, GPR_TIMESPAN)), NULL); } while (event.type != GRPC_QUEUE_TIMEOUT); diff --git a/test/core/memory_usage/server.c b/test/core/memory_usage/server.c index 6b61ecabba..9f4c7fd22c 100644 --- a/test/core/memory_usage/server.c +++ b/test/core/memory_usage/server.c @@ -189,7 +189,8 @@ int main(int argc, char **argv) { } gpr_log(GPR_INFO, "creating server on: %s", addr); - cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); struct grpc_memory_counters before_server_create = grpc_memory_counters_snapshot(); @@ -232,8 +233,8 @@ int main(int argc, char **argv) { if (got_sigint && !shutdown_started) { gpr_log(GPR_INFO, "Shutting down due to SIGINT"); - shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + shutdown_cq = grpc_completion_queue_create(GRPC_CQ_PLUCK, + GRPC_CQ_NON_POLLING, NULL); grpc_server_shutdown_and_notify(server, shutdown_cq, tag(1000)); GPR_ASSERT( grpc_completion_queue_pluck(shutdown_cq, tag(1000), @@ -244,8 +245,9 @@ int main(int argc, char **argv) { shutdown_started = 1; } ev = grpc_completion_queue_next( - cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_micros(1000000, GPR_TIMESPAN)), + cq, + gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_micros(1000000, GPR_TIMESPAN)), NULL); fling_call *s = ev.tag; switch (ev.type) { diff --git a/test/core/surface/alarm_test.c b/test/core/surface/alarm_test.c index 7419d388a3..2c555db5dd 100644 --- a/test/core/surface/alarm_test.c +++ b/test/core/surface/alarm_test.c @@ -58,7 +58,8 @@ static void test_alarm(void) { grpc_completion_queue *cc; LOG_TEST("test_alarm"); - cc = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + cc = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); { /* regular expiry */ grpc_event ev; diff --git a/test/core/surface/completion_queue_test.c b/test/core/surface/completion_queue_test.c index f76074f207..c90e72cde6 100644 --- a/test/core/surface/completion_queue_test.c +++ b/test/core/surface/completion_queue_test.c @@ -76,8 +76,8 @@ static void shutdown_and_destroy(grpc_completion_queue *cc) { /* ensure we can create and destroy a completion channel */ static void test_no_op(void) { grpc_cq_completion_type completion_types[] = {GRPC_CQ_NEXT, GRPC_CQ_PLUCK}; - grpc_cq_polling_type polling_types[] = {DEFAULT_POLLING, NON_LISTENING, - NON_POLLING}; + grpc_cq_polling_type polling_types[] = { + GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING}; LOG_TEST("test_no_op"); for (size_t i = 0; i < GPR_ARRAY_SIZE(completion_types); i++) { @@ -90,7 +90,8 @@ static void test_no_op(void) { static void test_pollset_conversion(void) { grpc_cq_completion_type completion_types[] = {GRPC_CQ_NEXT, GRPC_CQ_PLUCK}; - grpc_cq_polling_type polling_types[] = {DEFAULT_POLLING, NON_LISTENING}; + grpc_cq_polling_type polling_types[] = {GRPC_CQ_DEFAULT_POLLING, + GRPC_CQ_NON_LISTENING}; grpc_completion_queue *cq; LOG_TEST("test_pollset_conversion"); @@ -106,8 +107,8 @@ static void test_pollset_conversion(void) { } static void test_wait_empty(void) { - grpc_cq_polling_type polling_types[] = {DEFAULT_POLLING, NON_LISTENING, - NON_POLLING}; + grpc_cq_polling_type polling_types[] = { + GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING}; grpc_completion_queue *cc; grpc_event event; @@ -128,8 +129,8 @@ static void test_cq_end_op(void) { grpc_event ev; grpc_completion_queue *cc; grpc_cq_completion completion; - grpc_cq_polling_type polling_types[] = {DEFAULT_POLLING, NON_LISTENING, - NON_POLLING}; + grpc_cq_polling_type polling_types[] = { + GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING}; grpc_exec_ctx init_exec_ctx = GRPC_EXEC_CTX_INIT; grpc_exec_ctx exec_ctx; @@ -156,8 +157,8 @@ static void test_cq_end_op(void) { } static void test_shutdown_then_next_polling(void) { - grpc_cq_polling_type polling_types[] = {DEFAULT_POLLING, NON_LISTENING, - NON_POLLING}; + grpc_cq_polling_type polling_types[] = { + GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING}; grpc_completion_queue *cc; grpc_event event; LOG_TEST("test_shutdown_then_next_polling"); @@ -173,8 +174,8 @@ static void test_shutdown_then_next_polling(void) { } static void test_shutdown_then_next_with_timeout(void) { - grpc_cq_polling_type polling_types[] = {DEFAULT_POLLING, NON_LISTENING, - NON_POLLING}; + grpc_cq_polling_type polling_types[] = { + GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING}; grpc_completion_queue *cc; grpc_event event; LOG_TEST("test_shutdown_then_next_with_timeout"); @@ -195,8 +196,8 @@ static void test_pluck(void) { grpc_completion_queue *cc; void *tags[128]; grpc_cq_completion completions[GPR_ARRAY_SIZE(tags)]; - grpc_cq_polling_type polling_types[] = {DEFAULT_POLLING, NON_LISTENING, - NON_POLLING}; + grpc_cq_polling_type polling_types[] = { + GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING}; grpc_exec_ctx init_exec_ctx = GRPC_EXEC_CTX_INIT; grpc_exec_ctx exec_ctx; unsigned i, j; @@ -244,8 +245,8 @@ static void test_pluck(void) { } static void test_pluck_after_shutdown(void) { - grpc_cq_polling_type polling_types[] = {DEFAULT_POLLING, NON_LISTENING, - NON_POLLING}; + grpc_cq_polling_type polling_types[] = { + GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING}; grpc_event ev; grpc_completion_queue *cc; diff --git a/test/core/surface/completion_queue_threading_test.c b/test/core/surface/completion_queue_threading_test.c index b101cd13f7..6a23aee537 100644 --- a/test/core/surface/completion_queue_threading_test.c +++ b/test/core/surface/completion_queue_threading_test.c @@ -101,7 +101,8 @@ static void test_too_many_plucks(void) { LOG_TEST("test_too_many_plucks"); - cc = grpc_completion_queue_create(GRPC_CQ_PLUCK, DEFAULT_POLLING, NULL); + cc = grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, + NULL); gpr_thd_options_set_joinable(&thread_options); for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { @@ -228,7 +229,7 @@ static void test_threading(size_t producers, size_t consumers) { gpr_event phase1 = GPR_EVENT_INIT; gpr_event phase2 = GPR_EVENT_INIT; grpc_completion_queue *cc = - grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); size_t i; size_t total_consumed = 0; static int optid = 101; diff --git a/test/core/surface/concurrent_connectivity_test.c b/test/core/surface/concurrent_connectivity_test.c index 3758b86fab..69f00f4d48 100644 --- a/test/core/surface/concurrent_connectivity_test.c +++ b/test/core/surface/concurrent_connectivity_test.c @@ -66,8 +66,8 @@ static int detag(void *p) { return (int)(uintptr_t)p; } void create_loop_destroy(void *addr) { for (int i = 0; i < NUM_OUTER_LOOPS; ++i) { - grpc_completion_queue *cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + grpc_completion_queue *cq = grpc_completion_queue_create( + GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); grpc_channel *chan = grpc_insecure_channel_create((char *)addr, NULL, NULL); for (int j = 0; j < NUM_INNER_LOOPS; ++j) { @@ -196,7 +196,8 @@ int main(int argc, char **argv) { gpr_asprintf(&args.addr, "localhost:%d", port); args.server = grpc_server_create(NULL, NULL); grpc_server_add_insecure_http2_port(args.server, args.addr); - args.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + args.cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); grpc_server_register_completion_queue(args.server, args.cq, NULL); grpc_server_start(args.server); gpr_thd_new(&server, server_thread, &args, &options); diff --git a/test/core/surface/lame_client_test.c b/test/core/surface/lame_client_test.c index 0cb183a4f0..6531e5eb18 100644 --- a/test/core/surface/lame_client_test.c +++ b/test/core/surface/lame_client_test.c @@ -108,7 +108,8 @@ int main(int argc, char **argv) { GPR_ASSERT(GRPC_CHANNEL_SHUTDOWN == grpc_channel_check_connectivity_state(chan, 0)); - cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); grpc_slice host = grpc_slice_from_static_string("anywhere"); call = grpc_channel_create_call(chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq, diff --git a/test/core/surface/sequential_connectivity_test.c b/test/core/surface/sequential_connectivity_test.c index 37678a40d9..1880c0b859 100644 --- a/test/core/surface/sequential_connectivity_test.c +++ b/test/core/surface/sequential_connectivity_test.c @@ -77,7 +77,7 @@ static void run_test(const test_fixture *fixture) { grpc_server *server = grpc_server_create(NULL, NULL); fixture->add_server_port(server, addr); grpc_completion_queue *server_cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); grpc_server_register_completion_queue(server, server_cq, NULL); grpc_server_start(server); @@ -88,7 +88,7 @@ static void run_test(const test_fixture *fixture) { gpr_thd_new(&server_thread, server_thread_func, &sta, &thdopt); grpc_completion_queue *cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); grpc_channel *channels[NUM_CONNECTIONS]; for (size_t i = 0; i < NUM_CONNECTIONS; i++) { channels[i] = fixture->create_channel(addr); diff --git a/test/core/surface/server_chttp2_test.c b/test/core/surface/server_chttp2_test.c index 9fac63418f..47e8eeab1e 100644 --- a/test/core/surface/server_chttp2_test.c +++ b/test/core/surface/server_chttp2_test.c @@ -61,7 +61,7 @@ void test_add_same_port_twice() { int port = grpc_pick_unused_port_or_die(); char *addr = NULL; grpc_completion_queue *cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); grpc_server *server = grpc_server_create(&args, NULL); grpc_server_credentials *fake_creds = grpc_fake_transport_security_server_credentials_create(); diff --git a/test/core/surface/server_test.c b/test/core/surface/server_test.c index aa54794d14..e488966b93 100644 --- a/test/core/surface/server_test.c +++ b/test/core/surface/server_test.c @@ -71,7 +71,7 @@ void test_register_method_fail(void) { void test_request_call_on_no_server_cq(void) { grpc_completion_queue *cc = - grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); grpc_server *server = grpc_server_create(NULL, NULL); GPR_ASSERT(GRPC_CALL_ERROR_NOT_SERVER_COMPLETION_QUEUE == grpc_server_request_call(server, NULL, NULL, NULL, cc, cc, NULL)); @@ -93,7 +93,7 @@ void test_bind_server_twice(void) { grpc_server *server1 = grpc_server_create(&args, NULL); grpc_server *server2 = grpc_server_create(&args, NULL); grpc_completion_queue *cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); int port = grpc_pick_unused_port_or_die(); gpr_asprintf(&addr, "[::]:%d", port); grpc_server_register_completion_queue(server1, cq, NULL); @@ -131,7 +131,7 @@ void test_bind_server_to_addr(const char *host, bool secure) { GPR_ASSERT(grpc_server_add_insecure_http2_port(server, addr)); } grpc_completion_queue *cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); grpc_server_register_completion_queue(server, cq, NULL); grpc_server_start(server); grpc_server_shutdown_and_notify(server, cq, NULL); diff --git a/test/cpp/grpclb/grpclb_test.cc b/test/cpp/grpclb/grpclb_test.cc index 7fd31a2dbf..71370ad3b4 100644 --- a/test/cpp/grpclb/grpclb_test.cc +++ b/test/cpp/grpclb/grpclb_test.cc @@ -354,8 +354,9 @@ static void start_backend_server(server_fixture *sf) { } GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); const string expected_token = - strlen(sf->lb_token_prefix) == 0 ? "" : sf->lb_token_prefix + - std::to_string(sf->port); + strlen(sf->lb_token_prefix) == 0 + ? "" + : sf->lb_token_prefix + std::to_string(sf->port); GPR_ASSERT(contains_metadata(&request_metadata_recv, "lb-token", expected_token.c_str())); @@ -593,7 +594,8 @@ static void setup_client(const server_fixture *lb_server, grpc_channel_args_copy_and_add(NULL, &expected_target_arg, 1); gpr_free(expected_target_names); - cf->cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + cf->cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); cf->server_uri = lb_uri; grpc_channel_credentials *fake_creds = grpc_fake_transport_security_credentials_create(); @@ -616,7 +618,8 @@ static void teardown_client(client_fixture *cf) { static void setup_server(const char *host, server_fixture *sf) { int assigned_port; - sf->cq = grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + sf->cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); const char *colon_idx = strchr(host, ':'); if (colon_idx) { const char *port_str = colon_idx + 1; @@ -645,7 +648,7 @@ static void teardown_server(server_fixture *sf) { gpr_log(GPR_INFO, "Server[%s] shutting down", sf->servers_hostport); grpc_completion_queue *shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, NON_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); grpc_server_shutdown_and_notify(sf->server, shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(shutdown_cq, tag(1000), grpc_timeout_seconds_to_deadline(5), diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc index 21e3374f91..b8aa87dfb3 100644 --- a/test/cpp/microbenchmarks/bm_call_create.cc +++ b/test/cpp/microbenchmarks/bm_call_create.cc @@ -91,7 +91,7 @@ template static void BM_CallCreateDestroy(benchmark::State &state) { Fixture fixture; grpc_completion_queue *cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); void *method_hdl = grpc_channel_register_call(fixture.channel(), "/foo/bar", NULL, NULL); diff --git a/test/cpp/microbenchmarks/bm_cq.cc b/test/cpp/microbenchmarks/bm_cq.cc index c7bd8743a5..6fda0081ae 100644 --- a/test/cpp/microbenchmarks/bm_cq.cc +++ b/test/cpp/microbenchmarks/bm_cq.cc @@ -68,8 +68,8 @@ static void BM_CreateDestroyCore(benchmark::State& state) { while (state.KeepRunning()) { // TODO: sreek Make this a templatized benchmark and pass completion type // and polling type as parameters - grpc_completion_queue_destroy( - grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL)); + grpc_completion_queue_destroy(grpc_completion_queue_create( + GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL)); } } BENCHMARK(BM_CreateDestroyCore); @@ -104,7 +104,7 @@ static void BM_Pass1Core(benchmark::State& state) { // TODO: sreek Make this templatized benchmark and pass polling_type as a // param grpc_completion_queue* cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); while (state.KeepRunning()) { grpc_cq_completion completion; @@ -122,8 +122,8 @@ BENCHMARK(BM_Pass1Core); static void BM_Pluck1Core(benchmark::State& state) { // TODO: sreek Make this templatized benchmark and pass polling_type as a // param - grpc_completion_queue* cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, DEFAULT_POLLING, NULL); + grpc_completion_queue* cq = grpc_completion_queue_create( + GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, NULL); gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); while (state.KeepRunning()) { grpc_cq_completion completion; @@ -142,7 +142,7 @@ static void BM_EmptyCore(benchmark::State& state) { // TODO: sreek Make this a templatized benchmark and pass polling_type as a // param grpc_completion_queue* cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, DEFAULT_POLLING, NULL); + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); gpr_timespec deadline = gpr_inf_past(GPR_CLOCK_MONOTONIC); while (state.KeepRunning()) { grpc_completion_queue_next(cq, deadline, NULL); -- cgit v1.2.3 From 752be9ceeba1e3958229b2ab0a9d59c072eebb7c Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Fri, 3 Mar 2017 14:36:02 -0800 Subject: clang format code --- src/core/lib/surface/completion_queue.c | 10 ++++------ src/core/lib/surface/server.c | 10 ++++------ test/core/bad_ssl/server_common.c | 5 ++--- test/core/end2end/fixtures/h2_census.c | 7 +++---- test/core/end2end/fixtures/h2_compress.c | 7 +++---- test/core/end2end/fixtures/h2_full+trace.c | 7 +++---- test/core/end2end/fixtures/h2_full.c | 7 +++---- test/core/end2end/fixtures/h2_proxy.c | 9 ++++----- test/core/end2end/fixtures/h2_ssl_cert.c | 20 +++++++++----------- test/core/end2end/fixtures/h2_uds.c | 7 +++---- test/core/end2end/fuzzers/api_fuzzer.c | 25 ++++++++++--------------- test/core/end2end/tests/call_creds.c | 5 +++-- test/core/fling/server.c | 5 ++--- test/core/memory_usage/client.c | 5 ++--- test/core/memory_usage/server.c | 5 ++--- test/cpp/grpclb/grpclb_test.cc | 5 ++--- 16 files changed, 59 insertions(+), 80 deletions(-) diff --git a/src/core/lib/surface/completion_queue.c b/src/core/lib/surface/completion_queue.c index ad9d7b20b0..e571733a20 100644 --- a/src/core/lib/surface/completion_queue.c +++ b/src/core/lib/surface/completion_queue.c @@ -381,9 +381,8 @@ grpc_event grpc_completion_queue_next(grpc_completion_queue *cc, "deadline=gpr_timespec { tv_sec: %" PRId64 ", tv_nsec: %d, clock_type: %d }, " "reserved=%p)", - 5, - (cc, deadline.tv_sec, deadline.tv_nsec, (int)deadline.clock_type, - reserved)); + 5, (cc, deadline.tv_sec, deadline.tv_nsec, (int)deadline.clock_type, + reserved)); GPR_ASSERT(!reserved); dump_pending_tags(cc); @@ -557,9 +556,8 @@ grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cc, void *tag, "deadline=gpr_timespec { tv_sec: %" PRId64 ", tv_nsec: %d, clock_type: %d }, " "reserved=%p)", - 6, - (cc, tag, deadline.tv_sec, deadline.tv_nsec, (int)deadline.clock_type, - reserved)); + 6, (cc, tag, deadline.tv_sec, deadline.tv_nsec, + (int)deadline.clock_type, reserved)); } GPR_ASSERT(!reserved); diff --git a/src/core/lib/surface/server.c b/src/core/lib/surface/server.c index 13f7321fac..7dd320a75b 100644 --- a/src/core/lib/surface/server.c +++ b/src/core/lib/surface/server.c @@ -1431,9 +1431,8 @@ grpc_call_error grpc_server_request_call( "grpc_server_request_call(" "server=%p, call=%p, details=%p, initial_metadata=%p, " "cq_bound_to_call=%p, cq_for_notification=%p, tag=%p)", - 7, - (server, call, details, initial_metadata, cq_bound_to_call, - cq_for_notification, tag)); + 7, (server, call, details, initial_metadata, cq_bound_to_call, + cq_for_notification, tag)); size_t cq_idx; for (cq_idx = 0; cq_idx < server->cq_count; cq_idx++) { if (server->cqs[cq_idx] == cq_for_notification) { @@ -1475,9 +1474,8 @@ grpc_call_error grpc_server_request_registered_call( "server=%p, rmp=%p, call=%p, deadline=%p, initial_metadata=%p, " "optional_payload=%p, cq_bound_to_call=%p, cq_for_notification=%p, " "tag=%p)", - 9, - (server, rmp, call, deadline, initial_metadata, optional_payload, - cq_bound_to_call, cq_for_notification, tag)); + 9, (server, rmp, call, deadline, initial_metadata, optional_payload, + cq_bound_to_call, cq_for_notification, tag)); size_t cq_idx; for (cq_idx = 0; cq_idx < server->cq_count; cq_idx++) { diff --git a/test/core/bad_ssl/server_common.c b/test/core/bad_ssl/server_common.c index b112ae4e78..1176c079b2 100644 --- a/test/core/bad_ssl/server_common.c +++ b/test/core/bad_ssl/server_common.c @@ -97,9 +97,8 @@ void bad_ssl_run(grpc_server *server) { shutdown_started = 1; } ev = grpc_completion_queue_next( - cq, - gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_micros(1000000, GPR_TIMESPAN)), + cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_micros(1000000, GPR_TIMESPAN)), NULL); switch (ev.type) { case GRPC_OP_COMPLETE: diff --git a/test/core/end2end/fixtures/h2_census.c b/test/core/end2end/fixtures/h2_census.c index 1077e063b8..35a52fa9a9 100644 --- a/test/core/end2end/fixtures/h2_census.c +++ b/test/core/end2end/fixtures/h2_census.c @@ -122,10 +122,9 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack+census", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack+census", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_compress.c b/test/core/end2end/fixtures/h2_compress.c index a985faeb5a..e627007151 100644 --- a/test/core/end2end/fixtures/h2_compress.c +++ b/test/core/end2end/fixtures/h2_compress.c @@ -122,10 +122,9 @@ void chttp2_tear_down_fullstack_compression(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack_compression", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack_compression", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack_compression, chttp2_init_client_fullstack_compression, chttp2_init_server_fullstack_compression, diff --git a/test/core/end2end/fixtures/h2_full+trace.c b/test/core/end2end/fixtures/h2_full+trace.c index c24bacc42f..25a76ca266 100644 --- a/test/core/end2end/fixtures/h2_full+trace.c +++ b/test/core/end2end/fixtures/h2_full+trace.c @@ -105,10 +105,9 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_full.c b/test/core/end2end/fixtures/h2_full.c index 901a419f25..435d9dfd45 100644 --- a/test/core/end2end/fixtures/h2_full.c +++ b/test/core/end2end/fixtures/h2_full.c @@ -99,10 +99,9 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_proxy.c b/test/core/end2end/fixtures/h2_proxy.c index 5a64a10918..55eec11b81 100644 --- a/test/core/end2end/fixtures/h2_proxy.c +++ b/test/core/end2end/fixtures/h2_proxy.c @@ -116,11 +116,10 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack+proxy", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_REQUEST_PROXYING | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack+proxy", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_REQUEST_PROXYING | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_ssl_cert.c b/test/core/end2end/fixtures/h2_ssl_cert.c index c3d25ac836..cf3bc45741 100644 --- a/test/core/end2end/fixtures/h2_ssl_cert.c +++ b/test/core/end2end/fixtures/h2_ssl_cert.c @@ -206,17 +206,15 @@ CLIENT_INIT(BAD_CERT_PAIR) typedef enum { SUCCESS, FAIL } test_result; -#define SSL_TEST(request_type, cert_type, result) \ - { \ - {TEST_NAME(request_type, cert_type, result), \ - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | \ - FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS | \ - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL, \ - chttp2_create_fixture_secure_fullstack, \ - CLIENT_INIT_NAME(cert_type), \ - SERVER_INIT_NAME(request_type), \ - chttp2_tear_down_secure_fullstack}, \ - result \ +#define SSL_TEST(request_type, cert_type, result) \ + { \ + {TEST_NAME(request_type, cert_type, result), \ + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | \ + FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS | \ + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL, \ + chttp2_create_fixture_secure_fullstack, CLIENT_INIT_NAME(cert_type), \ + SERVER_INIT_NAME(request_type), chttp2_tear_down_secure_fullstack}, \ + result \ } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_uds.c b/test/core/end2end/fixtures/h2_uds.c index 820c587bee..8f043566b1 100644 --- a/test/core/end2end/fixtures/h2_uds.c +++ b/test/core/end2end/fixtures/h2_uds.c @@ -104,10 +104,9 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack_uds", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack_uds", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fuzzers/api_fuzzer.c b/test/core/end2end/fuzzers/api_fuzzer.c index 278b6dbae0..88026d9815 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.c +++ b/test/core/end2end/fuzzers/api_fuzzer.c @@ -314,9 +314,8 @@ static grpc_call_credentials *read_call_creds(input_stream *inp) { cred_artifact_ctx ctx = CRED_ARTIFACT_CTX_INIT; const char *access_token = read_cred_artifact(&ctx, inp, NULL, 0); grpc_call_credentials *out = - access_token == NULL - ? NULL - : grpc_access_token_credentials_create(access_token, NULL); + access_token == NULL ? NULL : grpc_access_token_credentials_create( + access_token, NULL); cred_artifact_ctx_finish(&ctx); return out; } @@ -410,9 +409,8 @@ void my_resolve_address(grpc_exec_ctx *exec_ctx, const char *addr, r->on_done = on_done; r->addrs = addresses; grpc_timer_init( - exec_ctx, &r->timer, - gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), - gpr_time_from_seconds(1, GPR_TIMESPAN)), + exec_ctx, &r->timer, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), + gpr_time_from_seconds(1, GPR_TIMESPAN)), grpc_closure_create(finish_resolve, r, grpc_schedule_on_exec_ctx), gpr_now(GPR_CLOCK_MONOTONIC)); } @@ -473,9 +471,8 @@ static void sched_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure, fc->ep = ep; fc->deadline = deadline; grpc_timer_init( - exec_ctx, &fc->timer, - gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), - gpr_time_from_millis(1, GPR_TIMESPAN)), + exec_ctx, &fc->timer, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), + gpr_time_from_millis(1, GPR_TIMESPAN)), grpc_closure_create(do_connect, fc, grpc_schedule_on_exec_ctx), gpr_now(GPR_CLOCK_MONOTONIC)); } @@ -752,9 +749,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { if (g_server != NULL) { if (!server_shutdown) { grpc_server_shutdown_and_notify( - g_server, cq, - create_validator(assert_success_and_decrement, - &pending_server_shutdowns)); + g_server, cq, create_validator(assert_success_and_decrement, + &pending_server_shutdowns)); server_shutdown = true; pending_server_shutdowns++; } else if (pending_server_shutdowns == 0) { @@ -859,9 +855,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { case 5: { if (g_server != NULL) { grpc_server_shutdown_and_notify( - g_server, cq, - create_validator(assert_success_and_decrement, - &pending_server_shutdowns)); + g_server, cq, create_validator(assert_success_and_decrement, + &pending_server_shutdowns)); pending_server_shutdowns++; server_shutdown = true; } else { diff --git a/test/core/end2end/tests/call_creds.c b/test/core/end2end/tests/call_creds.c index 2a9269345e..52e7a2a7e4 100644 --- a/test/core/end2end/tests/call_creds.c +++ b/test/core/end2end/tests/call_creds.c @@ -91,8 +91,9 @@ 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->shutdown_cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->shutdown_cq, tag(1000), grpc_timeout_seconds_to_deadline(5), NULL) + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) .type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; diff --git a/test/core/fling/server.c b/test/core/fling/server.c index 02168c4ea9..4a47fe4cf5 100644 --- a/test/core/fling/server.c +++ b/test/core/fling/server.c @@ -259,9 +259,8 @@ int main(int argc, char **argv) { shutdown_started = 1; } ev = grpc_completion_queue_next( - cq, - gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_micros(1000000, GPR_TIMESPAN)), + cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_micros(1000000, GPR_TIMESPAN)), NULL); s = ev.tag; switch (ev.type) { diff --git a/test/core/memory_usage/client.c b/test/core/memory_usage/client.c index b2bc269136..d3eb5ac7c2 100644 --- a/test/core/memory_usage/client.c +++ b/test/core/memory_usage/client.c @@ -261,9 +261,8 @@ int main(int argc, char **argv) { do { event = grpc_completion_queue_next( - cq, - gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_micros(10000, GPR_TIMESPAN)), + cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_micros(10000, GPR_TIMESPAN)), NULL); } while (event.type != GRPC_QUEUE_TIMEOUT); diff --git a/test/core/memory_usage/server.c b/test/core/memory_usage/server.c index 9f4c7fd22c..437b5473df 100644 --- a/test/core/memory_usage/server.c +++ b/test/core/memory_usage/server.c @@ -245,9 +245,8 @@ int main(int argc, char **argv) { shutdown_started = 1; } ev = grpc_completion_queue_next( - cq, - gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_micros(1000000, GPR_TIMESPAN)), + cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_micros(1000000, GPR_TIMESPAN)), NULL); fling_call *s = ev.tag; switch (ev.type) { diff --git a/test/cpp/grpclb/grpclb_test.cc b/test/cpp/grpclb/grpclb_test.cc index 71370ad3b4..c9c569cfbe 100644 --- a/test/cpp/grpclb/grpclb_test.cc +++ b/test/cpp/grpclb/grpclb_test.cc @@ -354,9 +354,8 @@ static void start_backend_server(server_fixture *sf) { } GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); const string expected_token = - strlen(sf->lb_token_prefix) == 0 - ? "" - : sf->lb_token_prefix + std::to_string(sf->port); + strlen(sf->lb_token_prefix) == 0 ? "" : sf->lb_token_prefix + + std::to_string(sf->port); GPR_ASSERT(contains_metadata(&request_metadata_recv, "lb-token", expected_token.c_str())); -- cgit v1.2.3 From 39bc495a1631a332a551e217de2bb6d69e8bbced Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Fri, 3 Mar 2017 17:48:29 -0800 Subject: Node: Completion queue API changes --- src/node/ext/completion_queue_threadpool.cc | 19 +++++++++---------- src/node/ext/completion_queue_uv.cc | 21 ++++++++++----------- src/node/ext/server_generic.cc | 5 +++-- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/node/ext/completion_queue_threadpool.cc b/src/node/ext/completion_queue_threadpool.cc index 1917074dc2..b5227bad65 100644 --- a/src/node/ext/completion_queue_threadpool.cc +++ b/src/node/ext/completion_queue_threadpool.cc @@ -34,14 +34,14 @@ /* I don't like using #ifndef, but I don't see a better way to do this */ #ifndef GRPC_UV -#include #include +#include +#include "call.h" +#include "completion_queue.h" #include "grpc/grpc.h" #include "grpc/support/log.h" #include "grpc/support/time.h" -#include "completion_queue.h" -#include "call.h" namespace grpc { namespace node { @@ -111,8 +111,8 @@ CompletionQueueAsyncWorker::CompletionQueueAsyncWorker() CompletionQueueAsyncWorker::~CompletionQueueAsyncWorker() {} void CompletionQueueAsyncWorker::Execute() { - result = - grpc_completion_queue_next(queue, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + result = grpc_completion_queue_next(queue, gpr_inf_future(GPR_CLOCK_REALTIME), + NULL); if (!result.success) { SetErrorMessage("The async function encountered an error"); } @@ -141,7 +141,8 @@ void CompletionQueueAsyncWorker::Init(Local exports) { Nan::HandleScope scope; current_threads = 0; waiting_next_calls = 0; - queue = grpc_completion_queue_create(NULL); + queue = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); } void CompletionQueueAsyncWorker::HandleOKCallback() { @@ -173,9 +174,7 @@ grpc_completion_queue *GetCompletionQueue() { return CompletionQueueAsyncWorker::GetQueue(); } -void CompletionQueueNext() { - CompletionQueueAsyncWorker::Next(); -} +void CompletionQueueNext() { CompletionQueueAsyncWorker::Next(); } void CompletionQueueInit(Local exports) { CompletionQueueAsyncWorker::Init(exports); @@ -184,4 +183,4 @@ void CompletionQueueInit(Local exports) { } // namespace node } // namespace grpc -#endif /* GRPC_UV */ +#endif /* GRPC_UV */ diff --git a/src/node/ext/completion_queue_uv.cc b/src/node/ext/completion_queue_uv.cc index 615973a6c9..9c1f093a40 100644 --- a/src/node/ext/completion_queue_uv.cc +++ b/src/node/ext/completion_queue_uv.cc @@ -33,10 +33,10 @@ #ifdef GRPC_UV -#include +#include #include +#include #include -#include #include "call.h" #include "completion_queue.h" @@ -57,18 +57,18 @@ void drain_completion_queue(uv_prepare_t *handle) { grpc_event event; (void)handle; do { - event = grpc_completion_queue_next( - queue, gpr_inf_past(GPR_CLOCK_MONOTONIC), NULL); + event = grpc_completion_queue_next(queue, gpr_inf_past(GPR_CLOCK_MONOTONIC), + NULL); if (event.type == GRPC_OP_COMPLETE) { Nan::Callback *callback = grpc::node::GetTagCallback(event.tag); if (event.success) { Local argv[] = {Nan::Null(), - grpc::node::GetTagNodeValue(event.tag)}; + grpc::node::GetTagNodeValue(event.tag)}; callback->Call(2, argv); } else { - Local argv[] = {Nan::Error( - "The async function encountered an error")}; + Local argv[] = { + Nan::Error("The async function encountered an error")}; callback->Call(1, argv); } grpc::node::CompleteTag(event.tag); @@ -81,9 +81,7 @@ void drain_completion_queue(uv_prepare_t *handle) { } while (event.type != GRPC_QUEUE_TIMEOUT); } -grpc_completion_queue *GetCompletionQueue() { - return queue; -} +grpc_completion_queue *GetCompletionQueue() { return queue; } void CompletionQueueNext() { if (pending_batches == 0) { @@ -94,7 +92,8 @@ void CompletionQueueNext() { } void CompletionQueueInit(Local exports) { - queue = grpc_completion_queue_create(NULL); + queue = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); uv_prepare_init(uv_default_loop(), &prepare); pending_batches = 0; } diff --git a/src/node/ext/server_generic.cc b/src/node/ext/server_generic.cc index 0cf20f754a..787605aebf 100644 --- a/src/node/ext/server_generic.cc +++ b/src/node/ext/server_generic.cc @@ -35,8 +35,8 @@ #include "server.h" -#include #include +#include #include "grpc/grpc.h" #include "grpc/support/time.h" @@ -44,7 +44,8 @@ namespace grpc { namespace node { Server::Server(grpc_server *server) : wrapped_server(server) { - shutdown_queue = grpc_completion_queue_create(NULL); + shutdown_queue = grpc_completion_queue_create(GRPC_CQ_PLUCK, + GRPC_CQ_DEFAULT_POLLING, NULL); grpc_server_register_non_listening_completion_queue(server, shutdown_queue, NULL); } -- cgit v1.2.3 From 98ab52003a7afbf1dc193d80ebecbb9d503078a9 Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Fri, 3 Mar 2017 18:28:47 -0800 Subject: Ruby: Completion queue creation API changes --- src/ruby/ext/grpc/rb_channel.c | 80 +++++++++++++++++++++--------------------- src/ruby/ext/grpc/rb_server.c | 57 ++++++++++++++---------------- 2 files changed, 67 insertions(+), 70 deletions(-) diff --git a/src/ruby/ext/grpc/rb_channel.c b/src/ruby/ext/grpc/rb_channel.c index 84e43d3f7b..2b9f03abd4 100644 --- a/src/ruby/ext/grpc/rb_channel.c +++ b/src/ruby/ext/grpc/rb_channel.c @@ -33,20 +33,20 @@ #include -#include "rb_grpc_imports.generated.h" -#include "rb_channel.h" #include "rb_byte_buffer.h" +#include "rb_channel.h" +#include "rb_grpc_imports.generated.h" #include #include #include #include #include -#include "rb_grpc.h" #include "rb_call.h" #include "rb_channel_args.h" #include "rb_channel_credentials.h" #include "rb_completion_queue.h" +#include "rb_grpc.h" #include "rb_server.h" /* id_channel is the name of the hidden ivar that preserves a reference to the @@ -104,13 +104,15 @@ static void grpc_rb_channel_mark(void *p) { } } -static rb_data_type_t grpc_channel_data_type = { - "grpc_channel", - {grpc_rb_channel_mark, grpc_rb_channel_free, GRPC_RB_MEMSIZE_UNAVAILABLE, - {NULL, NULL}}, - NULL, NULL, +static rb_data_type_t grpc_channel_data_type = {"grpc_channel", + {grpc_rb_channel_mark, + grpc_rb_channel_free, + GRPC_RB_MEMSIZE_UNAVAILABLE, + {NULL, NULL}}, + NULL, + NULL, #ifdef RUBY_TYPED_FREE_IMMEDIATELY - RUBY_TYPED_FREE_IMMEDIATELY + RUBY_TYPED_FREE_IMMEDIATELY #endif }; @@ -169,7 +171,8 @@ static VALUE grpc_rb_channel_init(int argc, VALUE *argv, VALUE self) { } rb_ivar_set(self, id_target, target); wrapper->wrapped = ch; - wrapper->queue = grpc_completion_queue_create(NULL); + wrapper->queue = grpc_completion_queue_create(GRPC_CQ_PLUCK, + GRPC_CQ_DEFAULT_POLLING, NULL); return self; } @@ -225,14 +228,11 @@ static VALUE grpc_rb_channel_watch_connectivity_state(VALUE self, return Qnil; } grpc_channel_watch_connectivity_state( - ch, - (grpc_connectivity_state)NUM2LONG(last_state), - grpc_rb_time_timeval(deadline, /* absolute time */ 0), - cq, - tag); + ch, (grpc_connectivity_state)NUM2LONG(last_state), + grpc_rb_time_timeval(deadline, /* absolute time */ 0), cq, tag); - event = rb_completion_queue_pluck(cq, tag, - gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + event = rb_completion_queue_pluck(cq, tag, gpr_inf_future(GPR_CLOCK_REALTIME), + NULL); if (event.success) { return Qtrue; @@ -243,9 +243,9 @@ static VALUE grpc_rb_channel_watch_connectivity_state(VALUE self, /* Create a call given a grpc_channel, in order to call method. The request is not sent until grpc_call_invoke is called. */ -static VALUE grpc_rb_channel_create_call(VALUE self, VALUE parent, - VALUE mask, VALUE method, - VALUE host, VALUE deadline) { +static VALUE grpc_rb_channel_create_call(VALUE self, VALUE parent, VALUE mask, + VALUE method, VALUE host, + VALUE deadline) { VALUE res = Qnil; grpc_rb_channel *wrapper = NULL; grpc_call *call = NULL; @@ -256,10 +256,11 @@ static VALUE grpc_rb_channel_create_call(VALUE self, VALUE parent, grpc_slice method_slice; grpc_slice host_slice; grpc_slice *host_slice_ptr = NULL; - char* tmp_str = NULL; + char *tmp_str = NULL; if (host != Qnil) { - host_slice = grpc_slice_from_copied_buffer(RSTRING_PTR(host), RSTRING_LEN(host)); + host_slice = + grpc_slice_from_copied_buffer(RSTRING_PTR(host), RSTRING_LEN(host)); host_slice_ptr = &host_slice; } if (mask != Qnil) { @@ -269,7 +270,8 @@ static VALUE grpc_rb_channel_create_call(VALUE self, VALUE parent, parent_call = grpc_rb_get_wrapped_call(parent); } - cq = grpc_completion_queue_create(NULL); + cq = grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, + NULL); TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper); ch = wrapper->wrapped; if (ch == NULL) { @@ -277,17 +279,18 @@ static VALUE grpc_rb_channel_create_call(VALUE self, VALUE parent, return Qnil; } - method_slice = grpc_slice_from_copied_buffer(RSTRING_PTR(method), RSTRING_LEN(method)); + method_slice = + grpc_slice_from_copied_buffer(RSTRING_PTR(method), RSTRING_LEN(method)); call = grpc_channel_create_call(ch, parent_call, flags, cq, method_slice, - host_slice_ptr, grpc_rb_time_timeval( - deadline, - /* absolute time */ 0), NULL); + host_slice_ptr, + grpc_rb_time_timeval(deadline, + /* absolute time */ 0), + NULL); if (call == NULL) { tmp_str = grpc_slice_to_c_string(method_slice); - rb_raise(rb_eRuntimeError, "cannot create call with method %s", - tmp_str); + rb_raise(rb_eRuntimeError, "cannot create call with method %s", tmp_str); return Qnil; } @@ -304,7 +307,6 @@ static VALUE grpc_rb_channel_create_call(VALUE self, VALUE parent, return res; } - /* Closes the channel, calling it's destroy method */ static VALUE grpc_rb_channel_destroy(VALUE self) { grpc_rb_channel *wrapper = NULL; @@ -320,12 +322,11 @@ static VALUE grpc_rb_channel_destroy(VALUE self) { return Qnil; } - /* Called to obtain the target that this channel accesses. */ static VALUE grpc_rb_channel_get_target(VALUE self) { grpc_rb_channel *wrapper = NULL; VALUE res = Qnil; - char* target = NULL; + char *target = NULL; TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper); target = grpc_channel_get_target(wrapper->wrapped); @@ -337,8 +338,8 @@ static VALUE grpc_rb_channel_get_target(VALUE self) { static void Init_grpc_propagate_masks() { /* Constants representing call propagation masks in grpc.h */ - VALUE grpc_rb_mPropagateMasks = rb_define_module_under( - grpc_rb_mGrpcCore, "PropagateMasks"); + VALUE grpc_rb_mPropagateMasks = + rb_define_module_under(grpc_rb_mGrpcCore, "PropagateMasks"); rb_define_const(grpc_rb_mPropagateMasks, "DEADLINE", UINT2NUM(GRPC_PROPAGATE_DEADLINE)); rb_define_const(grpc_rb_mPropagateMasks, "CENSUS_STATS_CONTEXT", @@ -353,8 +354,8 @@ static void Init_grpc_propagate_masks() { static void Init_grpc_connectivity_states() { /* Constants representing call propagation masks in grpc.h */ - VALUE grpc_rb_mConnectivityStates = rb_define_module_under( - grpc_rb_mGrpcCore, "ConnectivityStates"); + VALUE grpc_rb_mConnectivityStates = + rb_define_module_under(grpc_rb_mGrpcCore, "ConnectivityStates"); rb_define_const(grpc_rb_mConnectivityStates, "IDLE", LONG2NUM(GRPC_CHANNEL_IDLE)); rb_define_const(grpc_rb_mConnectivityStates, "CONNECTING", @@ -382,12 +383,11 @@ void Init_grpc_channel() { /* Add ruby analogues of the Channel methods. */ rb_define_method(grpc_rb_cChannel, "connectivity_state", - grpc_rb_channel_get_connectivity_state, - -1); + grpc_rb_channel_get_connectivity_state, -1); rb_define_method(grpc_rb_cChannel, "watch_connectivity_state", grpc_rb_channel_watch_connectivity_state, 4); - rb_define_method(grpc_rb_cChannel, "create_call", - grpc_rb_channel_create_call, 5); + rb_define_method(grpc_rb_cChannel, "create_call", grpc_rb_channel_create_call, + 5); rb_define_method(grpc_rb_cChannel, "target", grpc_rb_channel_get_target, 0); rb_define_method(grpc_rb_cChannel, "destroy", grpc_rb_channel_destroy, 0); rb_define_alias(grpc_rb_cChannel, "close", "destroy"); diff --git a/src/ruby/ext/grpc/rb_server.c b/src/ruby/ext/grpc/rb_server.c index 7b2f5774aa..a0e8f15294 100644 --- a/src/ruby/ext/grpc/rb_server.c +++ b/src/ruby/ext/grpc/rb_server.c @@ -37,15 +37,15 @@ #include "rb_server.h" #include -#include #include +#include #include +#include "rb_byte_buffer.h" #include "rb_call.h" #include "rb_channel_args.h" #include "rb_completion_queue.h" -#include "rb_server_credentials.h" -#include "rb_byte_buffer.h" #include "rb_grpc.h" +#include "rb_server_credentials.h" /* grpc_rb_cServer is the ruby class that proxies grpc_server. */ static VALUE grpc_rb_cServer = Qnil; @@ -93,9 +93,8 @@ static void grpc_rb_server_free(void *p) { }; svr = (grpc_rb_server *)p; - deadline = gpr_time_add( - gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_seconds(2, GPR_TIMESPAN)); + deadline = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_seconds(2, GPR_TIMESPAN)); destroy_server(svr, deadline); @@ -104,13 +103,15 @@ static void grpc_rb_server_free(void *p) { static const rb_data_type_t grpc_rb_server_data_type = { "grpc_server", - {GRPC_RB_GC_NOT_MARKED, grpc_rb_server_free, GRPC_RB_MEMSIZE_UNAVAILABLE, + {GRPC_RB_GC_NOT_MARKED, + grpc_rb_server_free, + GRPC_RB_MEMSIZE_UNAVAILABLE, {NULL, NULL}}, NULL, NULL, #ifdef RUBY_TYPED_FREE_IMMEDIATELY - /* It is unsafe to specify RUBY_TYPED_FREE_IMMEDIATELY because the free function would block - * and we might want to unlock GVL + /* It is unsafe to specify RUBY_TYPED_FREE_IMMEDIATELY because the free + * function would block and we might want to unlock GVL * TODO(yugui) Unlock GVL? */ 0, @@ -131,7 +132,8 @@ static VALUE grpc_rb_server_alloc(VALUE cls) { Initializes server instances. */ static VALUE grpc_rb_server_init(VALUE self, VALUE channel_args) { - grpc_completion_queue *cq = grpc_completion_queue_create(NULL); + grpc_completion_queue *cq = grpc_completion_queue_create( + GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, NULL); grpc_rb_server *wrapper = NULL; grpc_server *srv = NULL; grpc_channel_args args; @@ -163,7 +165,7 @@ typedef struct request_call_stack { /* grpc_request_call_stack_init ensures the request_call_stack is properly * initialized */ -static void grpc_request_call_stack_init(request_call_stack* st) { +static void grpc_request_call_stack_init(request_call_stack *st) { MEMZERO(st, request_call_stack, 1); grpc_metadata_array_init(&st->md_ary); grpc_call_details_init(&st->details); @@ -171,7 +173,7 @@ static void grpc_request_call_stack_init(request_call_stack* st) { /* grpc_request_call_stack_cleanup ensures the request_call_stack is properly * cleaned up */ -static void grpc_request_call_stack_cleanup(request_call_stack* st) { +static void grpc_request_call_stack_cleanup(request_call_stack *st) { grpc_metadata_array_destroy(&st->md_ary); grpc_call_details_destroy(&st->details); } @@ -187,8 +189,9 @@ static VALUE grpc_rb_server_request_call(VALUE self) { grpc_call_error err; request_call_stack st; VALUE result; - void *tag = (void*)&st; - grpc_completion_queue *call_queue = grpc_completion_queue_create(NULL); + void *tag = (void *)&st; + grpc_completion_queue *call_queue = grpc_completion_queue_create( + GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, NULL); gpr_timespec deadline; TypedData_Get_Struct(self, grpc_rb_server, &grpc_rb_server_data_type, s); @@ -199,9 +202,8 @@ static VALUE grpc_rb_server_request_call(VALUE self) { grpc_request_call_stack_init(&st); /* call grpc_server_request_call, then wait for it to complete using * pluck_event */ - err = grpc_server_request_call( - s->wrapped, &call, &st.details, &st.md_ary, - call_queue, s->queue, tag); + err = grpc_server_request_call(s->wrapped, &call, &st.details, &st.md_ary, + call_queue, s->queue, tag); if (err != GRPC_CALL_OK) { grpc_request_call_stack_cleanup(&st); rb_raise(grpc_rb_eCallError, @@ -218,8 +220,6 @@ static VALUE grpc_rb_server_request_call(VALUE self) { return Qnil; } - - /* build the NewServerRpc struct result */ deadline = gpr_convert_clock_type(st.details.deadline, GPR_CLOCK_REALTIME); result = rb_struct_new( @@ -299,8 +299,7 @@ static VALUE grpc_rb_server_add_http2_port(VALUE self, VALUE port, return Qnil; } else if (TYPE(rb_creds) == T_SYMBOL) { if (id_insecure_server != SYM2ID(rb_creds)) { - rb_raise(rb_eTypeError, - "bad creds symbol, want :this_port_is_insecure"); + rb_raise(rb_eTypeError, "bad creds symbol, want :this_port_is_insecure"); return Qnil; } recvd_port = @@ -312,9 +311,8 @@ static VALUE grpc_rb_server_add_http2_port(VALUE self, VALUE port, } } else { creds = grpc_rb_get_wrapped_server_credentials(rb_creds); - recvd_port = - grpc_server_add_secure_http2_port(s->wrapped, StringValueCStr(port), - creds); + recvd_port = grpc_server_add_secure_http2_port( + s->wrapped, StringValueCStr(port), creds); if (recvd_port == 0) { rb_raise(rb_eRuntimeError, "could not add secure port %s to server, not sure why", @@ -333,18 +331,17 @@ void Init_grpc_server() { /* Provides a ruby constructor and support for dup/clone. */ rb_define_method(grpc_rb_cServer, "initialize", grpc_rb_server_init, 1); - rb_define_method(grpc_rb_cServer, "initialize_copy", - grpc_rb_cannot_init_copy, 1); + rb_define_method(grpc_rb_cServer, "initialize_copy", grpc_rb_cannot_init_copy, + 1); /* Add the server methods. */ - rb_define_method(grpc_rb_cServer, "request_call", - grpc_rb_server_request_call, 0); + rb_define_method(grpc_rb_cServer, "request_call", grpc_rb_server_request_call, + 0); rb_define_method(grpc_rb_cServer, "start", grpc_rb_server_start, 0); rb_define_method(grpc_rb_cServer, "destroy", grpc_rb_server_destroy, -1); rb_define_alias(grpc_rb_cServer, "close", "destroy"); rb_define_method(grpc_rb_cServer, "add_http2_port", - grpc_rb_server_add_http2_port, - 2); + grpc_rb_server_add_http2_port, 2); id_at = rb_intern("at"); id_insecure_server = rb_intern("this_port_is_insecure"); } -- cgit v1.2.3 From e7e38da2373d369a325a247582732771a196b745 Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Fri, 3 Mar 2017 18:38:06 -0800 Subject: Remove the check that ensures server completion queues are of type GRPC_CQ_NEXT (because ruby uses GRPC_CQ_PLUCK only) --- src/core/lib/surface/server.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/core/lib/surface/server.c b/src/core/lib/surface/server.c index 7dd320a75b..7ebe130751 100644 --- a/src/core/lib/surface/server.c +++ b/src/core/lib/surface/server.c @@ -1003,10 +1003,11 @@ void grpc_server_register_completion_queue(grpc_server *server, (server, cq, reserved)); if (grpc_get_cq_completion_type(cq) != GRPC_CQ_NEXT) { - gpr_log( - GPR_ERROR, - "Server completion queues must have a completion type of GRPC_CQ_NEXT"); - abort(); + gpr_log(GPR_INFO, + "Completion queue which is not of type GRPC_CQ_NEXT is being " + "registered as a server-completion-queue"); + /* Ideally we should log an error and abort but ruby-wrapped-language API + calls grpc_completion_queue_pluck() on server completion queues */ } register_completion_queue(server, cq, false, reserved); -- cgit v1.2.3 From 013a8b9a55f899e23429e74a49b5341079095a8f Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Fri, 3 Mar 2017 18:55:48 -0800 Subject: Objective-C: Completion queue creation API changes --- src/objective-c/GRPCClient/private/GRPCCompletionQueue.m | 4 +++- .../tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m | 3 ++- src/objective-c/tests/CronetUnitTests/CronetUnitTests.m | 8 ++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/objective-c/GRPCClient/private/GRPCCompletionQueue.m b/src/objective-c/GRPCClient/private/GRPCCompletionQueue.m index 539b5ab83c..8edb4ef048 100644 --- a/src/objective-c/GRPCClient/private/GRPCCompletionQueue.m +++ b/src/objective-c/GRPCClient/private/GRPCCompletionQueue.m @@ -48,7 +48,9 @@ - (instancetype)init { if ((self = [super init])) { - _unmanagedQueue = grpc_completion_queue_create(NULL); + _unmanagedQueue = grpc_completion_queue_create(GRPC_CQ_NEXT, + GRPC_CQ_DEFAULT_POLLING, + NULL); // This is for the following block to capture the pointer by value (instead // of retaining self and doing self->_unmanagedQueue). This is essential diff --git a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m index 1e0c8024ca..7656fb8d51 100644 --- a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m +++ b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m @@ -79,7 +79,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( gpr_join_host_port(&ffd->localaddr, "127.0.0.1", port); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(NULL); + f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, + NULL); return f; } diff --git a/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m b/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m index e97f3d2d1a..1840894d81 100644 --- a/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m +++ b/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m @@ -160,7 +160,9 @@ unsigned int parse_h2_length(const char *field) { int port = grpc_pick_unused_port_or_die(); char *addr; gpr_join_host_port(&addr, "127.0.0.1", port); - grpc_completion_queue *cq = grpc_completion_queue_create(NULL); + grpc_completion_queue *cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, + NULL); stream_engine *cronetEngine = [Cronet getGlobalEngine]; grpc_channel *client = grpc_cronet_secure_channel_create(cronetEngine, addr, NULL, NULL); @@ -294,7 +296,9 @@ unsigned int parse_h2_length(const char *field) { int port = grpc_pick_unused_port_or_die(); char *addr; gpr_join_host_port(&addr, "127.0.0.1", port); - grpc_completion_queue *cq = grpc_completion_queue_create(NULL); + grpc_completion_queue *cq = + grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, + NULL); stream_engine *cronetEngine = [Cronet getGlobalEngine]; grpc_channel *client = grpc_cronet_secure_channel_create(cronetEngine, addr, args, NULL); -- cgit v1.2.3 From b4a6f908caf27996e0474c3f482e8929dfb3126c Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Mon, 6 Mar 2017 10:53:47 -0800 Subject: Python: Completion queue creation API changes --- .../grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi | 2 +- src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi index d8df6c2ef4..368919b62f 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi @@ -40,7 +40,7 @@ cdef class CompletionQueue: def __cinit__(self): grpc_init() with nogil: - self.c_completion_queue = grpc_completion_queue_create(NULL) + self.c_completion_queue = grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL) self.is_shutting_down = False self.is_shutdown = False diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi index bbd72424b9..b26b240b4e 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi @@ -309,7 +309,20 @@ cdef extern from "grpc/grpc.h": void grpc_init() nogil void grpc_shutdown() nogil - grpc_completion_queue *grpc_completion_queue_create(void *reserved) nogil + ctypedef enum grpc_cq_completion_type: + GRPC_CQ_NEXT = 1 + GRPC_CQ_PLUCK = 2 + + ctypedef enum grpc_cq_polling_type: + GRPC_CQ_DEFAULT_POLLING + GRPC_CQ_NON_LISTENING + GRPC_CQ_NON_POLLING + + grpc_completion_queue *grpc_completion_queue_create( + grpc_cq_completion_type completion_type, + grpc_cq_polling_type polling_type, + void *reserved) nogil + grpc_event grpc_completion_queue_next(grpc_completion_queue *cq, gpr_timespec deadline, void *reserved) nogil -- cgit v1.2.3 From 5fcb8cc271a66868328d72f6e8e8f20d8316acc5 Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Tue, 7 Mar 2017 14:57:35 -0800 Subject: Php: Completion queue create API changes (and also remove the redundant completion_queue_next() loop in grpc_php_shutdown_completion_queue function as it is no longer needed. This was most likely an artifact of a previous version of grpc-core where completion queues did not have a "one tag in, one tag out" rule --- src/php/ext/grpc/completion_queue.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/php/ext/grpc/completion_queue.c b/src/php/ext/grpc/completion_queue.c index 741204b0b1..441088bf68 100644 --- a/src/php/ext/grpc/completion_queue.c +++ b/src/php/ext/grpc/completion_queue.c @@ -38,13 +38,12 @@ grpc_completion_queue *completion_queue; void grpc_php_init_completion_queue(TSRMLS_D) { - completion_queue = grpc_completion_queue_create(NULL); + completion_queue = grpc_completion_queue_create(GRPC_CQ_PLUCK, + GRPC_CQ_DEFAULT_POLLING, + NULL); } void grpc_php_shutdown_completion_queue(TSRMLS_D) { grpc_completion_queue_shutdown(completion_queue); - while (grpc_completion_queue_next(completion_queue, - gpr_inf_future(GPR_CLOCK_REALTIME), - NULL).type != GRPC_QUEUE_SHUTDOWN); grpc_completion_queue_destroy(completion_queue); } -- cgit v1.2.3 From b7462944ba184c24f545470a5bf631b59584ec4b Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 8 Mar 2017 19:30:21 +0100 Subject: adapt C# to new cq_create API --- .../Internal/CompletionQueueSafeHandleTest.cs | 10 +++++----- src/csharp/Grpc.Core.Tests/PInvokeTest.cs | 4 ++-- src/csharp/Grpc.Core/Internal/AsyncCall.cs | 2 +- src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs | 14 ++++++++++---- src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs | 2 +- src/csharp/Grpc.Core/Internal/NativeMethods.cs | 9 ++++++--- src/csharp/ext/grpc_csharp_ext.c | 9 +++++++-- 7 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/csharp/Grpc.Core.Tests/Internal/CompletionQueueSafeHandleTest.cs b/src/csharp/Grpc.Core.Tests/Internal/CompletionQueueSafeHandleTest.cs index e9ec59eb3d..8649906bec 100644 --- a/src/csharp/Grpc.Core.Tests/Internal/CompletionQueueSafeHandleTest.cs +++ b/src/csharp/Grpc.Core.Tests/Internal/CompletionQueueSafeHandleTest.cs @@ -43,19 +43,19 @@ namespace Grpc.Core.Internal.Tests public class CompletionQueueSafeHandleTest { [Test] - public void CreateAndDestroy() + public void CreateSyncAndDestroy() { GrpcEnvironment.AddRef(); - var cq = CompletionQueueSafeHandle.Create(); + var cq = CompletionQueueSafeHandle.CreateSync(); cq.Dispose(); GrpcEnvironment.ReleaseAsync().Wait(); } [Test] - public void CreateAndShutdown() + public void CreateAsyncAndShutdown() { - GrpcEnvironment.AddRef(); - var cq = CompletionQueueSafeHandle.Create(); + var env = GrpcEnvironment.AddRef(); + var cq = CompletionQueueSafeHandle.CreateAsync(new CompletionRegistry(env)); cq.Shutdown(); var ev = cq.Next(); cq.Dispose(); diff --git a/src/csharp/Grpc.Core.Tests/PInvokeTest.cs b/src/csharp/Grpc.Core.Tests/PInvokeTest.cs index d3735c7880..d760717ba6 100644 --- a/src/csharp/Grpc.Core.Tests/PInvokeTest.cs +++ b/src/csharp/Grpc.Core.Tests/PInvokeTest.cs @@ -53,7 +53,7 @@ namespace Grpc.Core.Tests /// (~1.26us .NET Windows) /// [Test] - public void CompletionQueueCreateDestroyBenchmark() + public void CompletionQueueCreateSyncDestroyBenchmark() { GrpcEnvironment.AddRef(); // completion queue requires gRPC environment being initialized. @@ -61,7 +61,7 @@ namespace Grpc.Core.Tests 10, 10, () => { - CompletionQueueSafeHandle cq = CompletionQueueSafeHandle.Create(); + CompletionQueueSafeHandle cq = CompletionQueueSafeHandle.CreateSync(); cq.Dispose(); }); diff --git a/src/csharp/Grpc.Core/Internal/AsyncCall.cs b/src/csharp/Grpc.Core/Internal/AsyncCall.cs index 1f738a3b6f..f037b2351a 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCall.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCall.cs @@ -87,7 +87,7 @@ namespace Grpc.Core.Internal var profiler = Profilers.ForCurrentThread(); using (profiler.NewScope("AsyncCall.UnaryCall")) - using (CompletionQueueSafeHandle cq = CompletionQueueSafeHandle.Create()) + using (CompletionQueueSafeHandle cq = CompletionQueueSafeHandle.CreateSync()) { byte[] payload = UnsafeSerialize(msg); diff --git a/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs b/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs index 6c9a31921e..577d7044a5 100644 --- a/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/CompletionQueueSafeHandle.cs @@ -51,14 +51,20 @@ namespace Grpc.Core.Internal { } - public static CompletionQueueSafeHandle Create() + /// + /// Create a completion queue that can only be used for Pluck operations. + /// + public static CompletionQueueSafeHandle CreateSync() { - return Native.grpcsharp_completion_queue_create(); + return Native.grpcsharp_completion_queue_create_sync(); } - public static CompletionQueueSafeHandle Create(CompletionRegistry completionRegistry) + /// + /// Create a completion queue that can only be used for Next operations. + /// + public static CompletionQueueSafeHandle CreateAsync(CompletionRegistry completionRegistry) { - var cq = Native.grpcsharp_completion_queue_create(); + var cq = Native.grpcsharp_completion_queue_create_async(); cq.completionRegistry = completionRegistry; return cq; } diff --git a/src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs b/src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs index 25a6589f11..07fea812b2 100644 --- a/src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs +++ b/src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs @@ -197,7 +197,7 @@ namespace Grpc.Core.Internal for (int i = 0; i < completionQueueCount; i++) { var completionRegistry = new CompletionRegistry(environment); - list.Add(CompletionQueueSafeHandle.Create(completionRegistry)); + list.Add(CompletionQueueSafeHandle.CreateAsync(completionRegistry)); } return list.AsReadOnly(); } diff --git a/src/csharp/Grpc.Core/Internal/NativeMethods.cs b/src/csharp/Grpc.Core/Internal/NativeMethods.cs index dd65f05217..a98861af61 100644 --- a/src/csharp/Grpc.Core/Internal/NativeMethods.cs +++ b/src/csharp/Grpc.Core/Internal/NativeMethods.cs @@ -115,7 +115,8 @@ namespace Grpc.Core.Internal public readonly Delegates.grpcsharp_sizeof_grpc_event_delegate grpcsharp_sizeof_grpc_event; - public readonly Delegates.grpcsharp_completion_queue_create_delegate grpcsharp_completion_queue_create; + public readonly Delegates.grpcsharp_completion_queue_create_async_delegate grpcsharp_completion_queue_create_async; + public readonly Delegates.grpcsharp_completion_queue_create_sync_delegate grpcsharp_completion_queue_create_sync; public readonly Delegates.grpcsharp_completion_queue_shutdown_delegate grpcsharp_completion_queue_shutdown; public readonly Delegates.grpcsharp_completion_queue_next_delegate grpcsharp_completion_queue_next; public readonly Delegates.grpcsharp_completion_queue_pluck_delegate grpcsharp_completion_queue_pluck; @@ -229,7 +230,8 @@ namespace Grpc.Core.Internal this.grpcsharp_sizeof_grpc_event = GetMethodDelegate(library); - this.grpcsharp_completion_queue_create = GetMethodDelegate(library); + this.grpcsharp_completion_queue_create_async = GetMethodDelegate(library); + this.grpcsharp_completion_queue_create_sync = GetMethodDelegate(library); this.grpcsharp_completion_queue_shutdown = GetMethodDelegate(library); this.grpcsharp_completion_queue_next = GetMethodDelegate(library); this.grpcsharp_completion_queue_pluck = GetMethodDelegate(library); @@ -383,7 +385,8 @@ namespace Grpc.Core.Internal public delegate int grpcsharp_sizeof_grpc_event_delegate(); - public delegate CompletionQueueSafeHandle grpcsharp_completion_queue_create_delegate(); + public delegate CompletionQueueSafeHandle grpcsharp_completion_queue_create_async_delegate(); + public delegate CompletionQueueSafeHandle grpcsharp_completion_queue_create_sync_delegate(); public delegate void grpcsharp_completion_queue_shutdown_delegate(CompletionQueueSafeHandle cq); public delegate CompletionQueueEvent grpcsharp_completion_queue_next_delegate(CompletionQueueSafeHandle cq); public delegate CompletionQueueEvent grpcsharp_completion_queue_pluck_delegate(CompletionQueueSafeHandle cq, IntPtr tag); diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index 491df4de6a..ceb2671faf 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -354,8 +354,13 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_shutdown(void) { grpc_shutdown(); } /* Completion queue */ GPR_EXPORT grpc_completion_queue *GPR_CALLTYPE -grpcsharp_completion_queue_create(void) { - return grpc_completion_queue_create(NULL); +grpcsharp_completion_queue_create_async(void) { + return grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); +} + +GPR_EXPORT grpc_completion_queue *GPR_CALLTYPE +grpcsharp_completion_queue_create_sync(void) { + return grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, NULL); } GPR_EXPORT void GPR_CALLTYPE -- cgit v1.2.3 From 2abbf8a319781ddeb614187c90f3be016fafd036 Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Tue, 21 Mar 2017 17:31:03 -0700 Subject: Changes to use the new API --- include/grpc/grpc.h | 5 ++-- src/core/lib/surface/completion_queue.c | 26 ++++++++++--------- src/core/lib/surface/completion_queue.h | 3 +++ src/core/lib/surface/completion_queue_factory.c | 33 ++++++++++++++++++------- 4 files changed, 44 insertions(+), 23 deletions(-) diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index 2f7e4ed426..bddb0c77ec 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -128,7 +128,6 @@ typedef enum { GRPC_CQ_NON_POLLING } grpc_cq_polling_type; - #define GRPC_CQ_CURRENT_VERSION 1 typedef struct grpc_completion_queue_attributes { /* The version number of this structure. More fields might be added to this @@ -161,8 +160,8 @@ GRPCAPI grpc_completion_queue *grpc_completion_queue_create_for_pluck( /** Create a completion queue */ GRPCAPI grpc_completion_queue *grpc_completion_queue_create( - grpc_cq_completion_type completion_type, grpc_cq_polling_type polling_type, - void *reserved); + const grpc_completion_queue_factory *factory, + const grpc_completion_queue_attributes *attributes, void *reserved); /** Blocks until an event is available, the completion queue is being shut down, or deadline is reached. diff --git a/src/core/lib/surface/completion_queue.c b/src/core/lib/surface/completion_queue.c index e571733a20..1e88e83449 100644 --- a/src/core/lib/surface/completion_queue.c +++ b/src/core/lib/surface/completion_queue.c @@ -115,15 +115,17 @@ int grpc_cq_event_timeout_trace; static void on_pollset_shutdown_done(grpc_exec_ctx *exec_ctx, void *cc, grpc_error *error); -grpc_completion_queue *grpc_completion_queue_create( - grpc_cq_completion_type completion_type, grpc_cq_polling_type polling_type, - void *reserved) { +grpc_completion_queue *grpc_completion_queue_create_internal( + grpc_cq_completion_type completion_type, + grpc_cq_polling_type polling_type) { grpc_completion_queue *cc; - GPR_ASSERT(!reserved); - GPR_TIMER_BEGIN("grpc_completion_queue_create", 0); + GPR_TIMER_BEGIN("grpc_completion_queue_create_internal", 0); - GRPC_API_TRACE("grpc_completion_queue_create(reserved=%p)", 1, (reserved)); + GRPC_API_TRACE( + "grpc_completion_queue_create_internal(completion_type=%d, " + "polling_type=%d)", + 2, (completion_type, polling_type)); cc = gpr_zalloc(sizeof(grpc_completion_queue) + grpc_pollset_size()); grpc_pollset_init(POLLSET_FROM_CQ(cc), &cc->mu); @@ -153,7 +155,7 @@ grpc_completion_queue *grpc_completion_queue_create( grpc_closure_init(&cc->pollset_shutdown_done, on_pollset_shutdown_done, cc, grpc_schedule_on_exec_ctx); - GPR_TIMER_END("grpc_completion_queue_create", 0); + GPR_TIMER_END("grpc_completion_queue_create_internal", 0); return cc; } @@ -381,8 +383,9 @@ grpc_event grpc_completion_queue_next(grpc_completion_queue *cc, "deadline=gpr_timespec { tv_sec: %" PRId64 ", tv_nsec: %d, clock_type: %d }, " "reserved=%p)", - 5, (cc, deadline.tv_sec, deadline.tv_nsec, (int)deadline.clock_type, - reserved)); + 5, + (cc, deadline.tv_sec, deadline.tv_nsec, (int)deadline.clock_type, + reserved)); GPR_ASSERT(!reserved); dump_pending_tags(cc); @@ -556,8 +559,9 @@ grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cc, void *tag, "deadline=gpr_timespec { tv_sec: %" PRId64 ", tv_nsec: %d, clock_type: %d }, " "reserved=%p)", - 6, (cc, tag, deadline.tv_sec, deadline.tv_nsec, - (int)deadline.clock_type, reserved)); + 6, + (cc, tag, deadline.tv_sec, deadline.tv_nsec, (int)deadline.clock_type, + reserved)); } GPR_ASSERT(!reserved); diff --git a/src/core/lib/surface/completion_queue.h b/src/core/lib/surface/completion_queue.h index 21f28e9424..1ff3d64293 100644 --- a/src/core/lib/surface/completion_queue.h +++ b/src/core/lib/surface/completion_queue.h @@ -102,4 +102,7 @@ int grpc_cq_is_server_cq(grpc_completion_queue *cc); grpc_cq_completion_type grpc_get_cq_completion_type(grpc_completion_queue *cc); grpc_cq_polling_type grpc_get_cq_polling_type(grpc_completion_queue *cc); +grpc_completion_queue *grpc_completion_queue_create_internal( + grpc_cq_completion_type completion_type, grpc_cq_polling_type polling_type); + #endif /* GRPC_CORE_LIB_SURFACE_COMPLETION_QUEUE_H */ diff --git a/src/core/lib/surface/completion_queue_factory.c b/src/core/lib/surface/completion_queue_factory.c index 138dfeff48..0d789e0f2f 100644 --- a/src/core/lib/surface/completion_queue_factory.c +++ b/src/core/lib/surface/completion_queue_factory.c @@ -36,12 +36,15 @@ #include -/* TODO (sreek) - Currently this does not use the attributes arg. This will be - added in a future PR */ +/* + * == Default completion queue factory implementation == + */ + static grpc_completion_queue* default_create( const grpc_completion_queue_factory* factory, - const grpc_completion_queue_attributes* attributes) { - return grpc_completion_queue_create(NULL); + const grpc_completion_queue_attributes* attr) { + return grpc_completion_queue_create_internal(attr->cq_type, + attr->cq_polling_type); } static grpc_completion_queue_factory_vtable default_vtable = {default_create}; @@ -49,19 +52,24 @@ static grpc_completion_queue_factory_vtable default_vtable = {default_create}; static const grpc_completion_queue_factory g_default_cq_factory = { "Default Factory", NULL, &default_vtable}; +/* + * == Completion queue factory APIs + */ + const grpc_completion_queue_factory* grpc_completion_queue_factory_lookup( const grpc_completion_queue_attributes* attributes) { - /* As we add more fields to grpc_completion_queue_attributes, we may have to - change this assert to: - GPR_ASSERT (attributes->version >= 1 && - attributes->version <= GRPC_CQ_CURRENT_VERSION) */ - GPR_ASSERT(attributes->version == 1); + GPR_ASSERT(attributes->version >= 1 && + attributes->version <= GRPC_CQ_CURRENT_VERSION); /* The default factory can handle version 1 of the attributes structure. We may have to change this as more fields are added to the structure */ return &g_default_cq_factory; } +/* + * == Completion queue creation APIs == + */ + grpc_completion_queue* grpc_completion_queue_create_for_next(void* reserved) { GPR_ASSERT(!reserved); grpc_completion_queue_attributes attr = {1, GRPC_CQ_NEXT, @@ -75,3 +83,10 @@ grpc_completion_queue* grpc_completion_queue_create_for_pluck(void* reserved) { GRPC_CQ_DEFAULT_POLLING}; return g_default_cq_factory.vtable->create(&g_default_cq_factory, &attr); } + +grpc_completion_queue* grpc_completion_queue_create( + const grpc_completion_queue_factory* factory, + const grpc_completion_queue_attributes* attr, void* reserved) { + GPR_ASSERT(!reserved); + return factory->vtable->create(factory, attr); +} -- cgit v1.2.3 From b5b6bfd89b642c6a3de305b985d736fd2bd93bab Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Wed, 22 Mar 2017 02:32:01 -0700 Subject: Updates C Core --- include/grpc/grpc.h | 2 +- src/core/lib/surface/completion_queue_factory.c | 4 +- test/core/bad_client/bad_client.c | 6 +-- test/core/bad_ssl/bad_ssl_test.c | 3 +- test/core/bad_ssl/server_common.c | 11 ++--- test/core/client_channel/lb_policies_test.c | 12 ++--- .../set_initial_connect_string_test.c | 3 +- test/core/end2end/bad_server_response_test.c | 3 +- test/core/end2end/connection_refused_test.c | 3 +- test/core/end2end/dualstack_socket_test.c | 6 +-- test/core/end2end/fixtures/h2_census.c | 13 +++-- test/core/end2end/fixtures/h2_compress.c | 13 +++-- test/core/end2end/fixtures/h2_fakesec.c | 6 +-- test/core/end2end/fixtures/h2_fd.c | 6 +-- test/core/end2end/fixtures/h2_full+pipe.c | 13 +++-- test/core/end2end/fixtures/h2_full+trace.c | 13 +++-- test/core/end2end/fixtures/h2_full.c | 13 +++-- test/core/end2end/fixtures/h2_http_proxy.c | 13 +++-- test/core/end2end/fixtures/h2_load_reporting.c | 6 +-- test/core/end2end/fixtures/h2_oauth2.c | 6 +-- test/core/end2end/fixtures/h2_proxy.c | 15 +++--- test/core/end2end/fixtures/h2_sockpair+trace.c | 6 +-- test/core/end2end/fixtures/h2_sockpair.c | 6 +-- test/core/end2end/fixtures/h2_sockpair_1byte.c | 6 +-- test/core/end2end/fixtures/h2_ssl.c | 6 +-- test/core/end2end/fixtures/h2_ssl_cert.c | 26 +++++----- test/core/end2end/fixtures/h2_ssl_proxy.c | 6 +-- test/core/end2end/fixtures/h2_uds.c | 13 +++-- test/core/end2end/fixtures/proxy.c | 3 +- test/core/end2end/fuzzers/api_fuzzer.c | 28 ++++++----- test/core/end2end/fuzzers/client_fuzzer.c | 3 +- test/core/end2end/fuzzers/server_fuzzer.c | 3 +- test/core/end2end/goaway_server_test.c | 3 +- test/core/end2end/invalid_call_argument_test.c | 6 +-- test/core/end2end/multiple_server_queues_test.c | 20 ++++++-- test/core/end2end/no_server_test.c | 3 +- test/core/fling/client.c | 3 +- test/core/fling/server.c | 11 ++--- test/core/handshake/client_ssl.c | 3 +- test/core/handshake/server_ssl.c | 3 +- test/core/memory_usage/client.c | 8 ++-- test/core/memory_usage/server.c | 11 ++--- test/core/surface/alarm_test.c | 3 +- test/core/surface/completion_queue_test.c | 55 ++++++++++++++++++---- .../core/surface/completion_queue_threading_test.c | 6 +-- test/core/surface/concurrent_connectivity_test.c | 6 +-- test/core/surface/lame_client_test.c | 3 +- test/core/surface/sequential_connectivity_test.c | 5 +- test/core/surface/server_chttp2_test.c | 3 +- test/core/surface/server_test.c | 9 ++-- 50 files changed, 214 insertions(+), 223 deletions(-) diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index bddb0c77ec..d2c18795ea 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -134,7 +134,7 @@ typedef struct grpc_completion_queue_attributes { structure in future. */ int version; /* Set to GRPC_CQ_CURRENT_VERSION */ - grpc_cq_completion_type cq_type; + grpc_cq_completion_type cq_completion_type; grpc_cq_polling_type cq_polling_type; } grpc_completion_queue_attributes; diff --git a/src/core/lib/surface/completion_queue_factory.c b/src/core/lib/surface/completion_queue_factory.c index 0d789e0f2f..d68b84eddd 100644 --- a/src/core/lib/surface/completion_queue_factory.c +++ b/src/core/lib/surface/completion_queue_factory.c @@ -43,7 +43,7 @@ static grpc_completion_queue* default_create( const grpc_completion_queue_factory* factory, const grpc_completion_queue_attributes* attr) { - return grpc_completion_queue_create_internal(attr->cq_type, + return grpc_completion_queue_create_internal(attr->cq_completion_type, attr->cq_polling_type); } @@ -79,7 +79,7 @@ grpc_completion_queue* grpc_completion_queue_create_for_next(void* reserved) { grpc_completion_queue* grpc_completion_queue_create_for_pluck(void* reserved) { GPR_ASSERT(!reserved); - grpc_completion_queue_attributes attr = {1, GRPC_CQ_NEXT, + grpc_completion_queue_attributes attr = {1, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING}; return g_default_cq_factory.vtable->create(&g_default_cq_factory, &attr); } diff --git a/test/core/bad_client/bad_client.c b/test/core/bad_client/bad_client.c index 2ecb75883b..cf3d9f6c6a 100644 --- a/test/core/bad_client/bad_client.c +++ b/test/core/bad_client/bad_client.c @@ -125,8 +125,7 @@ void grpc_run_bad_client_test( /* Create server, completion events */ a.server = grpc_server_create(NULL, NULL); - a.cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + a.cq = grpc_completion_queue_create_for_next(NULL); gpr_event_init(&a.done_thd); gpr_event_init(&a.done_write); a.validator = server_validator; @@ -198,8 +197,7 @@ void grpc_run_bad_client_test( grpc_exec_ctx_finish(&exec_ctx); } - shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); + shutdown_cq = grpc_completion_queue_create_for_pluck(NULL); grpc_server_shutdown_and_notify(a.server, shutdown_cq, NULL); GPR_ASSERT(grpc_completion_queue_pluck( shutdown_cq, NULL, grpc_timeout_seconds_to_deadline(1), NULL) diff --git a/test/core/bad_ssl/bad_ssl_test.c b/test/core/bad_ssl/bad_ssl_test.c index e0f1d2789f..b961ffacd7 100644 --- a/test/core/bad_ssl/bad_ssl_test.c +++ b/test/core/bad_ssl/bad_ssl_test.c @@ -61,8 +61,7 @@ static void run_test(const char *target, size_t nops) { grpc_status_code status; grpc_call_error error; gpr_timespec deadline = grpc_timeout_seconds_to_deadline(5); - grpc_completion_queue *cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); cq_verifier *cqv = cq_verifier_create(cq); grpc_op ops[6]; diff --git a/test/core/bad_ssl/server_common.c b/test/core/bad_ssl/server_common.c index 1176c079b2..67404711cd 100644 --- a/test/core/bad_ssl/server_common.c +++ b/test/core/bad_ssl/server_common.c @@ -67,8 +67,7 @@ void bad_ssl_run(grpc_server *server) { grpc_call_details call_details; grpc_metadata_array request_metadata_recv; - grpc_completion_queue *cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); grpc_completion_queue *shutdown_cq; grpc_call_details_init(&call_details); @@ -85,8 +84,7 @@ void bad_ssl_run(grpc_server *server) { while (!shutdown_finished) { if (got_sigint && !shutdown_started) { gpr_log(GPR_INFO, "Shutting down due to SIGINT"); - shutdown_cq = grpc_completion_queue_create(GRPC_CQ_PLUCK, - GRPC_CQ_NON_POLLING, NULL); + shutdown_cq = grpc_completion_queue_create_for_pluck(NULL); grpc_server_shutdown_and_notify(server, shutdown_cq, NULL); GPR_ASSERT( grpc_completion_queue_pluck(shutdown_cq, NULL, @@ -97,8 +95,9 @@ void bad_ssl_run(grpc_server *server) { shutdown_started = 1; } ev = grpc_completion_queue_next( - cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_micros(1000000, GPR_TIMESPAN)), + cq, + gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_micros(1000000, GPR_TIMESPAN)), NULL); switch (ev.type) { case GRPC_OP_COMPLETE: diff --git a/test/core/client_channel/lb_policies_test.c b/test/core/client_channel/lb_policies_test.c index f440e3348c..433f77db82 100644 --- a/test/core/client_channel/lb_policies_test.c +++ b/test/core/client_channel/lb_policies_test.c @@ -65,9 +65,9 @@ typedef struct servers_fixture { } servers_fixture; typedef struct request_sequences { - size_t n; /* number of iterations */ - int *connections; /* indexed by the interation number, value is the index of - the server it connected to or -1 if none */ + size_t n; /* number of iterations */ + int *connections; /* indexed by the interation number, value is the index of + the server it connected to or -1 if none */ int *connectivity_states; /* indexed by the interation number, value is the client connectivity state */ } request_sequences; @@ -197,10 +197,8 @@ static servers_fixture *setup_servers(const char *server_host, /* Create servers. */ f->servers = gpr_malloc(sizeof(grpc_server *) * num_servers); f->servers_hostports = gpr_malloc(sizeof(char *) * num_servers); - f->cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); - f->shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); + f->cq = grpc_completion_queue_create_for_next(NULL); + f->shutdown_cq = grpc_completion_queue_create_for_pluck(NULL); for (i = 0; i < num_servers; i++) { grpc_metadata_array_init(&f->request_metadata_recv[i]); gpr_join_host_port(&f->servers_hostports[i], server_host, diff --git a/test/core/client_channel/set_initial_connect_string_test.c b/test/core/client_channel/set_initial_connect_string_test.c index 999c89bdbd..7f38418ea7 100644 --- a/test/core/client_channel/set_initial_connect_string_test.c +++ b/test/core/client_channel/set_initial_connect_string_test.c @@ -130,8 +130,7 @@ static gpr_timespec n_sec_deadline(int seconds) { } static void start_rpc(int use_creds, int target_port) { - state.cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + state.cq = grpc_completion_queue_create_for_next(NULL); if (use_creds) { state.creds = grpc_fake_transport_security_credentials_create(); } else { diff --git a/test/core/end2end/bad_server_response_test.c b/test/core/end2end/bad_server_response_test.c index e4dc3831dc..96052ed7fd 100644 --- a/test/core/end2end/bad_server_response_test.c +++ b/test/core/end2end/bad_server_response_test.c @@ -178,8 +178,7 @@ static void start_rpc(int target_port, grpc_status_code expected_status, cq_verifier *cqv; grpc_slice details; - state.cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + state.cq = grpc_completion_queue_create_for_next(NULL); cqv = cq_verifier_create(state.cq); gpr_join_host_port(&state.target, "127.0.0.1", target_port); state.channel = grpc_insecure_channel_create(state.target, NULL, NULL); diff --git a/test/core/end2end/connection_refused_test.c b/test/core/end2end/connection_refused_test.c index fe203ddf4d..4d9908fba6 100644 --- a/test/core/end2end/connection_refused_test.c +++ b/test/core/end2end/connection_refused_test.c @@ -69,8 +69,7 @@ static void run_test(bool wait_for_ready, bool use_service_config) { grpc_metadata_array_init(&trailing_metadata_recv); - cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + cq = grpc_completion_queue_create_for_next(NULL); cqv = cq_verifier_create(cq); /* if using service config, create channel args */ diff --git a/test/core/end2end/dualstack_socket_test.c b/test/core/end2end/dualstack_socket_test.c index 19f947865a..c61ea6d260 100644 --- a/test/core/end2end/dualstack_socket_test.c +++ b/test/core/end2end/dualstack_socket_test.c @@ -108,8 +108,7 @@ void test_connect(const char *server_host, const char *client_host, int port, grpc_call_details_init(&call_details); /* Create server. */ - cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + cq = grpc_completion_queue_create_for_next(NULL); server = grpc_server_create(NULL, NULL); grpc_server_register_completion_queue(server, cq, NULL); GPR_ASSERT((got_port = grpc_server_add_insecure_http2_port( @@ -261,8 +260,7 @@ void test_connect(const char *server_host, const char *client_host, int port, grpc_channel_destroy(client); /* Destroy server. */ - shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); + shutdown_cq = grpc_completion_queue_create_for_pluck(NULL); grpc_server_shutdown_and_notify(server, shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(shutdown_cq, tag(1000), grpc_timeout_seconds_to_deadline(5), diff --git a/test/core/end2end/fixtures/h2_census.c b/test/core/end2end/fixtures/h2_census.c index 35a52fa9a9..1a754835f0 100644 --- a/test/core/end2end/fixtures/h2_census.c +++ b/test/core/end2end/fixtures/h2_census.c @@ -65,10 +65,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); - f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); + f.cq = grpc_completion_queue_create_for_next(NULL); + f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL); return f; } @@ -122,9 +120,10 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack+census", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack+census", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_compress.c b/test/core/end2end/fixtures/h2_compress.c index e627007151..b73d6d787a 100644 --- a/test/core/end2end/fixtures/h2_compress.c +++ b/test/core/end2end/fixtures/h2_compress.c @@ -69,10 +69,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_compression( memset(&f, 0, sizeof(f)); f.fixture_data = ffd; - f.cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); - f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); + f.cq = grpc_completion_queue_create_for_next(NULL); + f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL); return f; } @@ -122,9 +120,10 @@ void chttp2_tear_down_fullstack_compression(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack_compression", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack_compression", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack_compression, chttp2_init_client_fullstack_compression, chttp2_init_server_fullstack_compression, diff --git a/test/core/end2end/fixtures/h2_fakesec.c b/test/core/end2end/fixtures/h2_fakesec.c index 59ae3f0cb3..5969b110e6 100644 --- a/test/core/end2end/fixtures/h2_fakesec.c +++ b/test/core/end2end/fixtures/h2_fakesec.c @@ -60,10 +60,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); - f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); + f.cq = grpc_completion_queue_create_for_next(NULL); + f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL); return f; } diff --git a/test/core/end2end/fixtures/h2_fd.c b/test/core/end2end/fixtures/h2_fd.c index b01b52c996..53888dbc5b 100644 --- a/test/core/end2end/fixtures/h2_fd.c +++ b/test/core/end2end/fixtures/h2_fd.c @@ -70,10 +70,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( grpc_end2end_test_fixture f; memset(&f, 0, sizeof(f)); f.fixture_data = fixture_data; - f.cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); - f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); + f.cq = grpc_completion_queue_create_for_next(NULL); + f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL); create_sockets(fixture_data->fd_pair); diff --git a/test/core/end2end/fixtures/h2_full+pipe.c b/test/core/end2end/fixtures/h2_full+pipe.c index 6add99707f..927ca8ae01 100644 --- a/test/core/end2end/fixtures/h2_full+pipe.c +++ b/test/core/end2end/fixtures/h2_full+pipe.c @@ -70,10 +70,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); - f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); + f.cq = grpc_completion_queue_create_for_next(NULL); + f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL); return f; } @@ -105,9 +103,10 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_full+trace.c b/test/core/end2end/fixtures/h2_full+trace.c index 25a76ca266..bb24f966c1 100644 --- a/test/core/end2end/fixtures/h2_full+trace.c +++ b/test/core/end2end/fixtures/h2_full+trace.c @@ -70,10 +70,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); - f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); + f.cq = grpc_completion_queue_create_for_next(NULL); + f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL); return f; } @@ -105,9 +103,10 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_full.c b/test/core/end2end/fixtures/h2_full.c index 435d9dfd45..d8d4d95177 100644 --- a/test/core/end2end/fixtures/h2_full.c +++ b/test/core/end2end/fixtures/h2_full.c @@ -64,10 +64,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); - f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); + f.cq = grpc_completion_queue_create_for_next(NULL); + f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL); return f; } @@ -99,9 +97,10 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_http_proxy.c b/test/core/end2end/fixtures/h2_http_proxy.c index 7f8f55f71f..451c55677f 100644 --- a/test/core/end2end/fixtures/h2_http_proxy.c +++ b/test/core/end2end/fixtures/h2_http_proxy.c @@ -69,10 +69,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( ffd->proxy = grpc_end2end_http_proxy_create(); f.fixture_data = ffd; - f.cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); - f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); + f.cq = grpc_completion_queue_create_for_next(NULL); + f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL); return f; } @@ -110,9 +108,10 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_load_reporting.c b/test/core/end2end/fixtures/h2_load_reporting.c index 5b8721adbd..31f9a46562 100644 --- a/test/core/end2end/fixtures/h2_load_reporting.c +++ b/test/core/end2end/fixtures/h2_load_reporting.c @@ -67,10 +67,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_load_reporting( gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); - f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); + f.cq = grpc_completion_queue_create_for_next(NULL); + f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL); return f; } diff --git a/test/core/end2end/fixtures/h2_oauth2.c b/test/core/end2end/fixtures/h2_oauth2.c index 19920473ff..c94f1f6239 100644 --- a/test/core/end2end/fixtures/h2_oauth2.c +++ b/test/core/end2end/fixtures/h2_oauth2.c @@ -113,10 +113,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); - f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); + f.cq = grpc_completion_queue_create_for_next(NULL); + f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL); return f; } diff --git a/test/core/end2end/fixtures/h2_proxy.c b/test/core/end2end/fixtures/h2_proxy.c index 55eec11b81..af7d277689 100644 --- a/test/core/end2end/fixtures/h2_proxy.c +++ b/test/core/end2end/fixtures/h2_proxy.c @@ -79,10 +79,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( ffd->proxy = grpc_end2end_proxy_create(&proxy_def, client_args, server_args); f.fixture_data = ffd; - f.cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); - f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); + f.cq = grpc_completion_queue_create_for_next(NULL); + f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL); return f; } @@ -116,10 +114,11 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack+proxy", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_REQUEST_PROXYING | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack+proxy", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_REQUEST_PROXYING | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_sockpair+trace.c b/test/core/end2end/fixtures/h2_sockpair+trace.c index 069b880238..0528b5d308 100644 --- a/test/core/end2end/fixtures/h2_sockpair+trace.c +++ b/test/core/end2end/fixtures/h2_sockpair+trace.c @@ -94,10 +94,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( grpc_end2end_test_fixture f; memset(&f, 0, sizeof(f)); f.fixture_data = sfd; - f.cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); - f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); + f.cq = grpc_completion_queue_create_for_next(NULL); + f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL); grpc_resource_quota *resource_quota = grpc_resource_quota_create("fixture"); *sfd = grpc_iomgr_create_endpoint_pair("fixture", resource_quota, 65536); diff --git a/test/core/end2end/fixtures/h2_sockpair.c b/test/core/end2end/fixtures/h2_sockpair.c index c19d485403..ca16de075b 100644 --- a/test/core/end2end/fixtures/h2_sockpair.c +++ b/test/core/end2end/fixtures/h2_sockpair.c @@ -88,10 +88,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( grpc_end2end_test_fixture f; memset(&f, 0, sizeof(f)); f.fixture_data = sfd; - f.cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); - f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); + f.cq = grpc_completion_queue_create_for_next(NULL); + f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL); grpc_resource_quota *resource_quota = grpc_resource_quota_create("fixture"); *sfd = grpc_iomgr_create_endpoint_pair("fixture", resource_quota, 65536); diff --git a/test/core/end2end/fixtures/h2_sockpair_1byte.c b/test/core/end2end/fixtures/h2_sockpair_1byte.c index 05883b5ef4..79b39aa915 100644 --- a/test/core/end2end/fixtures/h2_sockpair_1byte.c +++ b/test/core/end2end/fixtures/h2_sockpair_1byte.c @@ -88,10 +88,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( grpc_end2end_test_fixture f; memset(&f, 0, sizeof(f)); f.fixture_data = sfd; - f.cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); - f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); + f.cq = grpc_completion_queue_create_for_next(NULL); + f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL); grpc_resource_quota *resource_quota = grpc_resource_quota_create("fixture"); *sfd = grpc_iomgr_create_endpoint_pair("fixture", resource_quota, 1); diff --git a/test/core/end2end/fixtures/h2_ssl.c b/test/core/end2end/fixtures/h2_ssl.c index d704b97e1c..c6a1ca09f8 100644 --- a/test/core/end2end/fixtures/h2_ssl.c +++ b/test/core/end2end/fixtures/h2_ssl.c @@ -64,10 +64,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); - f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); + f.cq = grpc_completion_queue_create_for_next(NULL); + f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL); return f; } diff --git a/test/core/end2end/fixtures/h2_ssl_cert.c b/test/core/end2end/fixtures/h2_ssl_cert.c index cf3bc45741..59a728307b 100644 --- a/test/core/end2end/fixtures/h2_ssl_cert.c +++ b/test/core/end2end/fixtures/h2_ssl_cert.c @@ -67,10 +67,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); - f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); + f.cq = grpc_completion_queue_create_for_next(NULL); + f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL); return f; } @@ -206,15 +204,17 @@ CLIENT_INIT(BAD_CERT_PAIR) typedef enum { SUCCESS, FAIL } test_result; -#define SSL_TEST(request_type, cert_type, result) \ - { \ - {TEST_NAME(request_type, cert_type, result), \ - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | \ - FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS | \ - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL, \ - chttp2_create_fixture_secure_fullstack, CLIENT_INIT_NAME(cert_type), \ - SERVER_INIT_NAME(request_type), chttp2_tear_down_secure_fullstack}, \ - result \ +#define SSL_TEST(request_type, cert_type, result) \ + { \ + {TEST_NAME(request_type, cert_type, result), \ + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | \ + FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS | \ + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL, \ + chttp2_create_fixture_secure_fullstack, \ + CLIENT_INIT_NAME(cert_type), \ + SERVER_INIT_NAME(request_type), \ + chttp2_tear_down_secure_fullstack}, \ + result \ } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_ssl_proxy.c b/test/core/end2end/fixtures/h2_ssl_proxy.c index 61bcfebbbe..9a6c9f558f 100644 --- a/test/core/end2end/fixtures/h2_ssl_proxy.c +++ b/test/core/end2end/fixtures/h2_ssl_proxy.c @@ -100,10 +100,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( ffd->proxy = grpc_end2end_proxy_create(&proxy_def, client_args, server_args); f.fixture_data = ffd; - f.cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); - f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); + f.cq = grpc_completion_queue_create_for_next(NULL); + f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL); return f; } diff --git a/test/core/end2end/fixtures/h2_uds.c b/test/core/end2end/fixtures/h2_uds.c index 8f043566b1..89b4b5e64b 100644 --- a/test/core/end2end/fixtures/h2_uds.c +++ b/test/core/end2end/fixtures/h2_uds.c @@ -70,10 +70,8 @@ static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( unique++); f.fixture_data = ffd; - f.cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); - f.shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); + f.cq = grpc_completion_queue_create_for_next(NULL); + f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL); return f; } @@ -104,9 +102,10 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack_uds", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack_uds", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/proxy.c b/test/core/end2end/fixtures/proxy.c index 7d306c6032..b8b1e5c6c9 100644 --- a/test/core/end2end/fixtures/proxy.c +++ b/test/core/end2end/fixtures/proxy.c @@ -104,8 +104,7 @@ grpc_end2end_proxy *grpc_end2end_proxy_create(const grpc_end2end_proxy_def *def, gpr_log(GPR_DEBUG, "PROXY ADDR:%s BACKEND:%s", proxy->proxy_port, proxy->server_port); - proxy->cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + proxy->cq = grpc_completion_queue_create_for_next(NULL); proxy->server = def->create_server(proxy->proxy_port, server_args); proxy->client = def->create_client(proxy->server_port, client_args); diff --git a/test/core/end2end/fuzzers/api_fuzzer.c b/test/core/end2end/fuzzers/api_fuzzer.c index 88026d9815..afeaf73898 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.c +++ b/test/core/end2end/fuzzers/api_fuzzer.c @@ -314,8 +314,9 @@ static grpc_call_credentials *read_call_creds(input_stream *inp) { cred_artifact_ctx ctx = CRED_ARTIFACT_CTX_INIT; const char *access_token = read_cred_artifact(&ctx, inp, NULL, 0); grpc_call_credentials *out = - access_token == NULL ? NULL : grpc_access_token_credentials_create( - access_token, NULL); + access_token == NULL + ? NULL + : grpc_access_token_credentials_create(access_token, NULL); cred_artifact_ctx_finish(&ctx); return out; } @@ -409,8 +410,9 @@ void my_resolve_address(grpc_exec_ctx *exec_ctx, const char *addr, r->on_done = on_done; r->addrs = addresses; grpc_timer_init( - exec_ctx, &r->timer, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), - gpr_time_from_seconds(1, GPR_TIMESPAN)), + exec_ctx, &r->timer, + gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), + gpr_time_from_seconds(1, GPR_TIMESPAN)), grpc_closure_create(finish_resolve, r, grpc_schedule_on_exec_ctx), gpr_now(GPR_CLOCK_MONOTONIC)); } @@ -471,8 +473,9 @@ static void sched_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure, fc->ep = ep; fc->deadline = deadline; grpc_timer_init( - exec_ctx, &fc->timer, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), - gpr_time_from_millis(1, GPR_TIMESPAN)), + exec_ctx, &fc->timer, + gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), + gpr_time_from_millis(1, GPR_TIMESPAN)), grpc_closure_create(do_connect, fc, grpc_schedule_on_exec_ctx), gpr_now(GPR_CLOCK_MONOTONIC)); } @@ -735,8 +738,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { g_active_call = new_call(NULL, ROOT); g_resource_quota = grpc_resource_quota_create("api_fuzzer"); - grpc_completion_queue *cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); while (!is_eof(&inp) || g_channel != NULL || g_server != NULL || pending_channel_watches > 0 || pending_pings > 0 || @@ -749,8 +751,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { if (g_server != NULL) { if (!server_shutdown) { grpc_server_shutdown_and_notify( - g_server, cq, create_validator(assert_success_and_decrement, - &pending_server_shutdowns)); + g_server, cq, + create_validator(assert_success_and_decrement, + &pending_server_shutdowns)); server_shutdown = true; pending_server_shutdowns++; } else if (pending_server_shutdowns == 0) { @@ -855,8 +858,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { case 5: { if (g_server != NULL) { grpc_server_shutdown_and_notify( - g_server, cq, create_validator(assert_success_and_decrement, - &pending_server_shutdowns)); + g_server, cq, + create_validator(assert_success_and_decrement, + &pending_server_shutdowns)); pending_server_shutdowns++; server_shutdown = true; } else { diff --git a/test/core/end2end/fuzzers/client_fuzzer.c b/test/core/end2end/fuzzers/client_fuzzer.c index 46acf7d70a..bc322e45a3 100644 --- a/test/core/end2end/fuzzers/client_fuzzer.c +++ b/test/core/end2end/fuzzers/client_fuzzer.c @@ -65,8 +65,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { grpc_mock_endpoint_create(discard_write, resource_quota); grpc_resource_quota_unref_internal(&exec_ctx, resource_quota); - grpc_completion_queue *cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); grpc_transport *transport = grpc_create_chttp2_transport(&exec_ctx, NULL, mock_endpoint, 1); grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL); diff --git a/test/core/end2end/fuzzers/server_fuzzer.c b/test/core/end2end/fuzzers/server_fuzzer.c index 33c8ed4e72..97b436cdf9 100644 --- a/test/core/end2end/fuzzers/server_fuzzer.c +++ b/test/core/end2end/fuzzers/server_fuzzer.c @@ -67,8 +67,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { grpc_slice_from_copied_buffer((const char *)data, size)); grpc_server *server = grpc_server_create(NULL, NULL); - grpc_completion_queue *cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); grpc_server_register_completion_queue(server, cq, NULL); // TODO(ctiller): add registered methods (one for POST, one for PUT) // void *registered_method = diff --git a/test/core/end2end/goaway_server_test.c b/test/core/end2end/goaway_server_test.c index 92ea7a72ef..c394a032c0 100644 --- a/test/core/end2end/goaway_server_test.c +++ b/test/core/end2end/goaway_server_test.c @@ -121,8 +121,7 @@ int main(int argc, char **argv) { grpc_metadata_array_init(&request_metadata2); grpc_call_details_init(&request_details2); - cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + cq = grpc_completion_queue_create_for_next(NULL); cqv = cq_verifier_create(cq); /* reserve two ports */ diff --git a/test/core/end2end/invalid_call_argument_test.c b/test/core/end2end/invalid_call_argument_test.c index 7aa8d98933..6890cfd0a8 100644 --- a/test/core/end2end/invalid_call_argument_test.c +++ b/test/core/end2end/invalid_call_argument_test.c @@ -73,8 +73,7 @@ static void prepare_test(int is_client) { grpc_metadata_array_init(&g_state.initial_metadata_recv); grpc_metadata_array_init(&g_state.trailing_metadata_recv); g_state.deadline = grpc_timeout_seconds_to_deadline(2); - g_state.cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + g_state.cq = grpc_completion_queue_create_for_next(NULL); g_state.cqv = cq_verifier_create(g_state.cq); g_state.details = grpc_empty_slice(); memset(g_state.ops, 0, sizeof(g_state.ops)); @@ -133,8 +132,7 @@ static void cleanup_test() { grpc_metadata_array_destroy(&g_state.trailing_metadata_recv); if (!g_state.is_client) { - shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); + shutdown_cq = grpc_completion_queue_create_for_pluck(NULL); grpc_call_destroy(g_state.server_call); grpc_server_shutdown_and_notify(g_state.server, shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(shutdown_cq, tag(1000), diff --git a/test/core/end2end/multiple_server_queues_test.c b/test/core/end2end/multiple_server_queues_test.c index 7da5ee55ae..4696ecd813 100644 --- a/test/core/end2end/multiple_server_queues_test.c +++ b/test/core/end2end/multiple_server_queues_test.c @@ -38,14 +38,26 @@ int main(int argc, char **argv) { grpc_completion_queue *cq1; grpc_completion_queue *cq2; grpc_completion_queue *cq3; + grpc_completion_queue_attributes attr; + grpc_server *server; grpc_test_init(argc, argv); grpc_init(); - cq1 = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); - cq2 = grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_NON_LISTENING, NULL); - cq3 = grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_NON_POLLING, NULL); + + attr.version = 1; + attr.cq_completion_type = GRPC_CQ_NEXT; + attr.cq_polling_type = GRPC_CQ_DEFAULT_POLLING; + cq1 = grpc_completion_queue_create( + grpc_completion_queue_factory_lookup(&attr), &attr, NULL); + + attr.cq_polling_type = GRPC_CQ_NON_LISTENING; + cq2 = grpc_completion_queue_create( + grpc_completion_queue_factory_lookup(&attr), &attr, NULL); + + attr.cq_polling_type = GRPC_CQ_NON_POLLING; + cq3 = grpc_completion_queue_create( + grpc_completion_queue_factory_lookup(&attr), &attr, NULL); server = grpc_server_create(NULL, NULL); grpc_server_register_completion_queue(server, cq1, NULL); diff --git a/test/core/end2end/no_server_test.c b/test/core/end2end/no_server_test.c index fd8a2f8a39..dd18b0c692 100644 --- a/test/core/end2end/no_server_test.c +++ b/test/core/end2end/no_server_test.c @@ -59,8 +59,7 @@ int main(int argc, char **argv) { grpc_metadata_array_init(&trailing_metadata_recv); - cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + cq = grpc_completion_queue_create_for_next(NULL); cqv = cq_verifier_create(cq); /* create a call, channel to a non existant server */ diff --git a/test/core/fling/client.c b/test/core/fling/client.c index a9f6a3d516..ecb73cfbdb 100644 --- a/test/core/fling/client.c +++ b/test/core/fling/client.c @@ -208,8 +208,7 @@ int main(int argc, char **argv) { } channel = grpc_insecure_channel_create(target, NULL, NULL); - cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + cq = grpc_completion_queue_create_for_next(NULL); the_buffer = grpc_raw_byte_buffer_create(&slice, (size_t)payload_size); histogram = gpr_histogram_create(0.01, 60e9); diff --git a/test/core/fling/server.c b/test/core/fling/server.c index 4a47fe4cf5..ebcb8f05f0 100644 --- a/test/core/fling/server.c +++ b/test/core/fling/server.c @@ -215,8 +215,7 @@ int main(int argc, char **argv) { } gpr_log(GPR_INFO, "creating server on: %s", addr); - cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + cq = grpc_completion_queue_create_for_next(NULL); if (secure) { grpc_ssl_pem_key_cert_pair pem_key_cert_pair = {test_server1_key, test_server1_cert}; @@ -245,8 +244,7 @@ int main(int argc, char **argv) { if (got_sigint && !shutdown_started) { gpr_log(GPR_INFO, "Shutting down due to SIGINT"); - shutdown_cq = grpc_completion_queue_create(GRPC_CQ_PLUCK, - GRPC_CQ_NON_POLLING, NULL); + shutdown_cq = grpc_completion_queue_create_for_pluck(NULL); grpc_server_shutdown_and_notify(server, shutdown_cq, tag(1000)); GPR_ASSERT( @@ -259,8 +257,9 @@ int main(int argc, char **argv) { shutdown_started = 1; } ev = grpc_completion_queue_next( - cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_micros(1000000, GPR_TIMESPAN)), + cq, + gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_micros(1000000, GPR_TIMESPAN)), NULL); s = ev.tag; switch (ev.type) { diff --git a/test/core/handshake/client_ssl.c b/test/core/handshake/client_ssl.c index 5ebbc42609..16a1f47e8e 100644 --- a/test/core/handshake/client_ssl.c +++ b/test/core/handshake/client_ssl.c @@ -289,8 +289,7 @@ static bool client_ssl_test(char *server_alpn_preferred) { // completed and we know that the client's ALPN list satisfied the server. int retries = 10; grpc_connectivity_state state = GRPC_CHANNEL_IDLE; - grpc_completion_queue *cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); while (state != GRPC_CHANNEL_READY && retries-- > 0) { grpc_channel_watch_connectivity_state( diff --git a/test/core/handshake/server_ssl.c b/test/core/handshake/server_ssl.c index 6ac22eaae5..2f93277417 100644 --- a/test/core/handshake/server_ssl.c +++ b/test/core/handshake/server_ssl.c @@ -104,8 +104,7 @@ static void server_thread(void *arg) { GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, ssl_creds)); free(addr); - grpc_completion_queue *cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); grpc_server_register_completion_queue(server, cq, NULL); grpc_server_start(server); diff --git a/test/core/memory_usage/client.c b/test/core/memory_usage/client.c index 582ede48a8..4fb99217b6 100644 --- a/test/core/memory_usage/client.c +++ b/test/core/memory_usage/client.c @@ -223,8 +223,7 @@ int main(int argc, char **argv) { calls[k].details = grpc_empty_slice(); } - cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + cq = grpc_completion_queue_create_for_next(NULL); struct grpc_memory_counters client_channel_start = grpc_memory_counters_snapshot(); @@ -262,8 +261,9 @@ int main(int argc, char **argv) { do { event = grpc_completion_queue_next( - cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_micros(10000, GPR_TIMESPAN)), + cq, + gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_micros(10000, GPR_TIMESPAN)), NULL); } while (event.type != GRPC_QUEUE_TIMEOUT); diff --git a/test/core/memory_usage/server.c b/test/core/memory_usage/server.c index 437b5473df..94d90a58a6 100644 --- a/test/core/memory_usage/server.c +++ b/test/core/memory_usage/server.c @@ -189,8 +189,7 @@ int main(int argc, char **argv) { } gpr_log(GPR_INFO, "creating server on: %s", addr); - cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + cq = grpc_completion_queue_create_for_next(NULL); struct grpc_memory_counters before_server_create = grpc_memory_counters_snapshot(); @@ -233,8 +232,7 @@ int main(int argc, char **argv) { if (got_sigint && !shutdown_started) { gpr_log(GPR_INFO, "Shutting down due to SIGINT"); - shutdown_cq = grpc_completion_queue_create(GRPC_CQ_PLUCK, - GRPC_CQ_NON_POLLING, NULL); + shutdown_cq = grpc_completion_queue_create_for_pluck(NULL); grpc_server_shutdown_and_notify(server, shutdown_cq, tag(1000)); GPR_ASSERT( grpc_completion_queue_pluck(shutdown_cq, tag(1000), @@ -245,8 +243,9 @@ int main(int argc, char **argv) { shutdown_started = 1; } ev = grpc_completion_queue_next( - cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_micros(1000000, GPR_TIMESPAN)), + cq, + gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_micros(1000000, GPR_TIMESPAN)), NULL); fling_call *s = ev.tag; switch (ev.type) { diff --git a/test/core/surface/alarm_test.c b/test/core/surface/alarm_test.c index 2c555db5dd..6ea3444fe2 100644 --- a/test/core/surface/alarm_test.c +++ b/test/core/surface/alarm_test.c @@ -58,8 +58,7 @@ static void test_alarm(void) { grpc_completion_queue *cc; LOG_TEST("test_alarm"); - cc = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + cc = grpc_completion_queue_create_for_next(NULL); { /* regular expiry */ grpc_event ev; diff --git a/test/core/surface/completion_queue_test.c b/test/core/surface/completion_queue_test.c index c90e72cde6..4489057b2f 100644 --- a/test/core/surface/completion_queue_test.c +++ b/test/core/surface/completion_queue_test.c @@ -78,12 +78,15 @@ static void test_no_op(void) { grpc_cq_completion_type completion_types[] = {GRPC_CQ_NEXT, GRPC_CQ_PLUCK}; grpc_cq_polling_type polling_types[] = { GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING}; + grpc_completion_queue_attributes attr; LOG_TEST("test_no_op"); for (size_t i = 0; i < GPR_ARRAY_SIZE(completion_types); i++) { for (size_t j = 0; j < GPR_ARRAY_SIZE(polling_types); j++) { + attr.cq_completion_type = completion_types[i]; + attr.cq_polling_type = polling_types[j]; shutdown_and_destroy(grpc_completion_queue_create( - completion_types[i], polling_types[j], NULL)); + grpc_completion_queue_factory_lookup(&attr), &attr, NULL)); } } } @@ -93,13 +96,16 @@ static void test_pollset_conversion(void) { grpc_cq_polling_type polling_types[] = {GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING}; grpc_completion_queue *cq; + grpc_completion_queue_attributes attr; LOG_TEST("test_pollset_conversion"); for (size_t i = 0; i < GPR_ARRAY_SIZE(completion_types); i++) { for (size_t j = 0; j < GPR_ARRAY_SIZE(polling_types); j++) { - cq = grpc_completion_queue_create(completion_types[i], polling_types[j], - NULL); + attr.cq_completion_type = completion_types[i]; + attr.cq_polling_type = polling_types[j]; + cq = grpc_completion_queue_create( + grpc_completion_queue_factory_lookup(&attr), &attr, NULL); GPR_ASSERT(grpc_cq_from_pollset(grpc_cq_pollset(cq)) == cq); shutdown_and_destroy(cq); } @@ -110,12 +116,17 @@ static void test_wait_empty(void) { grpc_cq_polling_type polling_types[] = { GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING}; grpc_completion_queue *cc; + grpc_completion_queue_attributes attr; grpc_event event; LOG_TEST("test_wait_empty"); + attr.cq_completion_type = GRPC_CQ_NEXT; + for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) { - cc = grpc_completion_queue_create(GRPC_CQ_NEXT, polling_types[i], NULL); + attr.cq_polling_type = polling_types[i]; + cc = grpc_completion_queue_create( + grpc_completion_queue_factory_lookup(&attr), &attr, NULL); event = grpc_completion_queue_next(cc, gpr_now(GPR_CLOCK_REALTIME), NULL); GPR_ASSERT(event.type == GRPC_QUEUE_TIMEOUT); shutdown_and_destroy(cc); @@ -131,16 +142,20 @@ static void test_cq_end_op(void) { grpc_cq_completion completion; grpc_cq_polling_type polling_types[] = { GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING}; - + grpc_completion_queue_attributes attr; grpc_exec_ctx init_exec_ctx = GRPC_EXEC_CTX_INIT; grpc_exec_ctx exec_ctx; void *tag = create_test_tag(); LOG_TEST("test_cq_end_op"); + attr.cq_completion_type = GRPC_CQ_NEXT; + for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) { exec_ctx = init_exec_ctx; // Reset exec_ctx - cc = grpc_completion_queue_create(GRPC_CQ_NEXT, polling_types[i], NULL); + attr.cq_polling_type = polling_types[i]; + cc = grpc_completion_queue_create( + grpc_completion_queue_factory_lookup(&attr), &attr, NULL); grpc_cq_begin_op(cc, tag); grpc_cq_end_op(&exec_ctx, cc, tag, GRPC_ERROR_NONE, @@ -160,11 +175,16 @@ static void test_shutdown_then_next_polling(void) { grpc_cq_polling_type polling_types[] = { GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING}; grpc_completion_queue *cc; + grpc_completion_queue_attributes attr; grpc_event event; LOG_TEST("test_shutdown_then_next_polling"); + attr.cq_completion_type = GRPC_CQ_NEXT; + for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) { - cc = grpc_completion_queue_create(GRPC_CQ_NEXT, polling_types[i], NULL); + attr.cq_polling_type = polling_types[i]; + cc = grpc_completion_queue_create( + grpc_completion_queue_factory_lookup(&attr), &attr, NULL); grpc_completion_queue_shutdown(cc); event = grpc_completion_queue_next(cc, gpr_inf_past(GPR_CLOCK_REALTIME), NULL); @@ -177,11 +197,16 @@ static void test_shutdown_then_next_with_timeout(void) { grpc_cq_polling_type polling_types[] = { GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING}; grpc_completion_queue *cc; + grpc_completion_queue_attributes attr; grpc_event event; LOG_TEST("test_shutdown_then_next_with_timeout"); + attr.cq_completion_type = GRPC_CQ_NEXT; + for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) { - cc = grpc_completion_queue_create(GRPC_CQ_NEXT, polling_types[i], NULL); + attr.cq_polling_type = polling_types[i]; + cc = grpc_completion_queue_create( + grpc_completion_queue_factory_lookup(&attr), &attr, NULL); grpc_completion_queue_shutdown(cc); event = grpc_completion_queue_next(cc, gpr_inf_future(GPR_CLOCK_REALTIME), @@ -198,6 +223,7 @@ static void test_pluck(void) { grpc_cq_completion completions[GPR_ARRAY_SIZE(tags)]; grpc_cq_polling_type polling_types[] = { GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING}; + grpc_completion_queue_attributes attr; grpc_exec_ctx init_exec_ctx = GRPC_EXEC_CTX_INIT; grpc_exec_ctx exec_ctx; unsigned i, j; @@ -211,9 +237,13 @@ static void test_pluck(void) { } } + attr.cq_completion_type = GRPC_CQ_PLUCK; + for (size_t pidx = 0; pidx < GPR_ARRAY_SIZE(polling_types); pidx++) { exec_ctx = init_exec_ctx; // reset exec_ctx - cc = grpc_completion_queue_create(GRPC_CQ_PLUCK, polling_types[pidx], NULL); + attr.cq_polling_type = polling_types[pidx]; + cc = grpc_completion_queue_create( + grpc_completion_queue_factory_lookup(&attr), &attr, NULL); for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { grpc_cq_begin_op(cc, tags[i]); @@ -249,11 +279,16 @@ static void test_pluck_after_shutdown(void) { GRPC_CQ_DEFAULT_POLLING, GRPC_CQ_NON_LISTENING, GRPC_CQ_NON_POLLING}; grpc_event ev; grpc_completion_queue *cc; + grpc_completion_queue_attributes attr; LOG_TEST("test_pluck_after_shutdown"); + attr.cq_completion_type = GRPC_CQ_PLUCK; + for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) { - cc = grpc_completion_queue_create(GRPC_CQ_PLUCK, polling_types[i], NULL); + attr.cq_polling_type = polling_types[i]; + cc = grpc_completion_queue_create( + grpc_completion_queue_factory_lookup(&attr), &attr, NULL); grpc_completion_queue_shutdown(cc); ev = grpc_completion_queue_pluck(cc, NULL, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); diff --git a/test/core/surface/completion_queue_threading_test.c b/test/core/surface/completion_queue_threading_test.c index 6a23aee537..bff69ec74f 100644 --- a/test/core/surface/completion_queue_threading_test.c +++ b/test/core/surface/completion_queue_threading_test.c @@ -101,8 +101,7 @@ static void test_too_many_plucks(void) { LOG_TEST("test_too_many_plucks"); - cc = grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, - NULL); + cc = grpc_completion_queue_create_for_pluck(NULL); gpr_thd_options_set_joinable(&thread_options); for (i = 0; i < GPR_ARRAY_SIZE(tags); i++) { @@ -228,8 +227,7 @@ static void test_threading(size_t producers, size_t consumers) { gpr_malloc((producers + consumers) * sizeof(test_thread_options)); gpr_event phase1 = GPR_EVENT_INIT; gpr_event phase2 = GPR_EVENT_INIT; - grpc_completion_queue *cc = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + grpc_completion_queue *cc = grpc_completion_queue_create_for_next(NULL); size_t i; size_t total_consumed = 0; static int optid = 101; diff --git a/test/core/surface/concurrent_connectivity_test.c b/test/core/surface/concurrent_connectivity_test.c index 69f00f4d48..f9197fb8fc 100644 --- a/test/core/surface/concurrent_connectivity_test.c +++ b/test/core/surface/concurrent_connectivity_test.c @@ -66,8 +66,7 @@ static int detag(void *p) { return (int)(uintptr_t)p; } void create_loop_destroy(void *addr) { for (int i = 0; i < NUM_OUTER_LOOPS; ++i) { - grpc_completion_queue *cq = grpc_completion_queue_create( - GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); grpc_channel *chan = grpc_insecure_channel_create((char *)addr, NULL, NULL); for (int j = 0; j < NUM_INNER_LOOPS; ++j) { @@ -196,8 +195,7 @@ int main(int argc, char **argv) { gpr_asprintf(&args.addr, "localhost:%d", port); args.server = grpc_server_create(NULL, NULL); grpc_server_add_insecure_http2_port(args.server, args.addr); - args.cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + args.cq = grpc_completion_queue_create_for_next(NULL); grpc_server_register_completion_queue(args.server, args.cq, NULL); grpc_server_start(args.server); gpr_thd_new(&server, server_thread, &args, &options); diff --git a/test/core/surface/lame_client_test.c b/test/core/surface/lame_client_test.c index 6531e5eb18..6c14a5dcdf 100644 --- a/test/core/surface/lame_client_test.c +++ b/test/core/surface/lame_client_test.c @@ -108,8 +108,7 @@ int main(int argc, char **argv) { GPR_ASSERT(GRPC_CHANNEL_SHUTDOWN == grpc_channel_check_connectivity_state(chan, 0)); - cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + cq = grpc_completion_queue_create_for_next(NULL); grpc_slice host = grpc_slice_from_static_string("anywhere"); call = grpc_channel_create_call(chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq, diff --git a/test/core/surface/sequential_connectivity_test.c b/test/core/surface/sequential_connectivity_test.c index 1880c0b859..fbecdd7e38 100644 --- a/test/core/surface/sequential_connectivity_test.c +++ b/test/core/surface/sequential_connectivity_test.c @@ -77,7 +77,7 @@ static void run_test(const test_fixture *fixture) { grpc_server *server = grpc_server_create(NULL, NULL); fixture->add_server_port(server, addr); grpc_completion_queue *server_cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + grpc_completion_queue_create_for_next(NULL); grpc_server_register_completion_queue(server, server_cq, NULL); grpc_server_start(server); @@ -87,8 +87,7 @@ static void run_test(const test_fixture *fixture) { gpr_thd_options_set_joinable(&thdopt); gpr_thd_new(&server_thread, server_thread_func, &sta, &thdopt); - grpc_completion_queue *cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); grpc_channel *channels[NUM_CONNECTIONS]; for (size_t i = 0; i < NUM_CONNECTIONS; i++) { channels[i] = fixture->create_channel(addr); diff --git a/test/core/surface/server_chttp2_test.c b/test/core/surface/server_chttp2_test.c index 47e8eeab1e..0d4de0e28b 100644 --- a/test/core/surface/server_chttp2_test.c +++ b/test/core/surface/server_chttp2_test.c @@ -60,8 +60,7 @@ void test_add_same_port_twice() { int port = grpc_pick_unused_port_or_die(); char *addr = NULL; - grpc_completion_queue *cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); + grpc_completion_queue *cq = grpc_completion_queue_create_for_pluck(NULL); grpc_server *server = grpc_server_create(&args, NULL); grpc_server_credentials *fake_creds = grpc_fake_transport_security_server_credentials_create(); diff --git a/test/core/surface/server_test.c b/test/core/surface/server_test.c index e488966b93..81a39de216 100644 --- a/test/core/surface/server_test.c +++ b/test/core/surface/server_test.c @@ -70,8 +70,7 @@ void test_register_method_fail(void) { } void test_request_call_on_no_server_cq(void) { - grpc_completion_queue *cc = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + grpc_completion_queue *cc = grpc_completion_queue_create_for_next(NULL); grpc_server *server = grpc_server_create(NULL, NULL); GPR_ASSERT(GRPC_CALL_ERROR_NOT_SERVER_COMPLETION_QUEUE == grpc_server_request_call(server, NULL, NULL, NULL, cc, cc, NULL)); @@ -92,8 +91,7 @@ void test_bind_server_twice(void) { char *addr; grpc_server *server1 = grpc_server_create(&args, NULL); grpc_server *server2 = grpc_server_create(&args, NULL); - grpc_completion_queue *cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); int port = grpc_pick_unused_port_or_die(); gpr_asprintf(&addr, "[::]:%d", port); grpc_server_register_completion_queue(server1, cq, NULL); @@ -130,8 +128,7 @@ void test_bind_server_to_addr(const char *host, bool secure) { } else { GPR_ASSERT(grpc_server_add_insecure_http2_port(server, addr)); } - grpc_completion_queue *cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); grpc_server_register_completion_queue(server, cq, NULL); grpc_server_start(server); grpc_server_shutdown_and_notify(server, cq, NULL); -- cgit v1.2.3 From f2c32150efe7d980882f1fb2c89c7d0db551cf6c Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Wed, 22 Mar 2017 03:01:24 -0700 Subject: Update C++ code --- include/grpc++/impl/codegen/client_unary_call.h | 2 +- include/grpc++/impl/codegen/completion_queue.h | 19 ++++++++++++------- include/grpc++/impl/codegen/core_codegen.h | 7 ++++--- include/grpc++/impl/codegen/core_codegen_interface.h | 7 ++++--- include/grpc++/impl/codegen/sync_stream.h | 8 ++++---- src/cpp/common/core_codegen.cc | 11 +++++++---- src/cpp/server/server_cc.cc | 5 +---- test/cpp/grpclb/grpclb_test.cc | 13 ++++++------- test/cpp/microbenchmarks/bm_call_create.cc | 3 +-- test/cpp/microbenchmarks/bm_cq.cc | 12 ++++-------- 10 files changed, 44 insertions(+), 43 deletions(-) diff --git a/include/grpc++/impl/codegen/client_unary_call.h b/include/grpc++/impl/codegen/client_unary_call.h index d8085a0a7f..6218e3ed1b 100644 --- a/include/grpc++/impl/codegen/client_unary_call.h +++ b/include/grpc++/impl/codegen/client_unary_call.h @@ -52,7 +52,7 @@ template Status BlockingUnaryCall(ChannelInterface* channel, const RpcMethod& method, ClientContext* context, const InputMessage& request, OutputMessage* result) { - CompletionQueue cq(GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING); + CompletionQueue cq(true); // Pluckable completion queue Call call(channel->CreateCall(method, context, &cq)); CallOpSet, diff --git a/include/grpc++/impl/codegen/completion_queue.h b/include/grpc++/impl/codegen/completion_queue.h index f34b82dad2..0130e9ca0f 100644 --- a/include/grpc++/impl/codegen/completion_queue.h +++ b/include/grpc++/impl/codegen/completion_queue.h @@ -103,7 +103,7 @@ class CompletionQueue : private GrpcLibraryCodegen { public: /// Default constructor. Implicitly creates a \a grpc_completion_queue /// instance. - CompletionQueue() : CompletionQueue(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING) {} + CompletionQueue() : CompletionQueue(false) {} /// Wrap \a take, taking ownership of the instance. /// @@ -147,8 +147,9 @@ class CompletionQueue : private GrpcLibraryCodegen { /// /// \return true if read a regular event, false if the queue is shutting down. bool Next(void** tag, bool* ok) { - return (AsyncNextInternal(tag, ok, g_core_codegen_interface->gpr_inf_future( - GPR_CLOCK_REALTIME)) != SHUTDOWN); + return (AsyncNextInternal(tag, ok, + g_core_codegen_interface->gpr_inf_future( + GPR_CLOCK_REALTIME)) != SHUTDOWN); } /// Request the shutdown of the queue. @@ -217,10 +218,14 @@ class CompletionQueue : private GrpcLibraryCodegen { OutputMessage* result); /// Private constructor of CompletionQueue only visible to friend classes - CompletionQueue(grpc_cq_completion_type completion_type, - grpc_cq_polling_type polling_type) { - cq_ = g_core_codegen_interface->grpc_completion_queue_create( - completion_type, polling_type, nullptr); + CompletionQueue(bool is_pluck) { + if (is_pluck) { + cq_ = g_core_codegen_interface->grpc_completion_queue_create_for_pluck( + nullptr); + } else { + cq_ = g_core_codegen_interface->grpc_completion_queue_create_for_next( + nullptr); + } InitialAvalanching(); // reserve this for the future shutdown } diff --git a/include/grpc++/impl/codegen/core_codegen.h b/include/grpc++/impl/codegen/core_codegen.h index 4c8567f770..af7abdf898 100644 --- a/include/grpc++/impl/codegen/core_codegen.h +++ b/include/grpc++/impl/codegen/core_codegen.h @@ -46,9 +46,10 @@ namespace grpc { /// Implementation of the core codegen interface. class CoreCodegen : public CoreCodegenInterface { private: - grpc_completion_queue* grpc_completion_queue_create( - grpc_cq_completion_type completion_type, - grpc_cq_polling_type polling_type, void* reserved) override; + grpc_completion_queue* grpc_completion_queue_create_for_next( + void* reserved) override; + grpc_completion_queue* grpc_completion_queue_create_for_pluck( + void* reserved) override; void grpc_completion_queue_destroy(grpc_completion_queue* cq) override; grpc_event grpc_completion_queue_pluck(grpc_completion_queue* cq, void* tag, gpr_timespec deadline, diff --git a/include/grpc++/impl/codegen/core_codegen_interface.h b/include/grpc++/impl/codegen/core_codegen_interface.h index 8f2b4a3b76..fd4767a80a 100644 --- a/include/grpc++/impl/codegen/core_codegen_interface.h +++ b/include/grpc++/impl/codegen/core_codegen_interface.h @@ -60,9 +60,10 @@ class CoreCodegenInterface { virtual void assert_fail(const char* failed_assertion, const char* file, int line) = 0; - virtual grpc_completion_queue* grpc_completion_queue_create( - grpc_cq_completion_type completion_type, - grpc_cq_polling_type polling_type, void* reserved) = 0; + virtual grpc_completion_queue* grpc_completion_queue_create_for_next( + void* reserved) = 0; + virtual grpc_completion_queue* grpc_completion_queue_create_for_pluck( + void* reserved) = 0; virtual void grpc_completion_queue_destroy(grpc_completion_queue* cq) = 0; virtual grpc_event grpc_completion_queue_pluck(grpc_completion_queue* cq, void* tag, diff --git a/include/grpc++/impl/codegen/sync_stream.h b/include/grpc++/impl/codegen/sync_stream.h index c09ab5e647..4e12f3261e 100644 --- a/include/grpc++/impl/codegen/sync_stream.h +++ b/include/grpc++/impl/codegen/sync_stream.h @@ -138,7 +138,7 @@ class ClientReader final : public ClientReaderInterface { ClientReader(ChannelInterface* channel, const RpcMethod& method, ClientContext* context, const W& request) : context_(context), - cq_(GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING), + cq_(true), // Pluckable cq call_(channel->CreateCall(method, context, &cq_)) { CallOpSet @@ -212,7 +212,7 @@ class ClientWriter : public ClientWriterInterface { ClientWriter(ChannelInterface* channel, const RpcMethod& method, ClientContext* context, R* response) : context_(context), - cq_(GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING), + cq_(true), // Pluckable cq call_(channel->CreateCall(method, context, &cq_)) { finish_ops_.RecvMessage(response); finish_ops_.AllowNoMessage(); @@ -297,7 +297,7 @@ class ClientReaderWriter final : public ClientReaderWriterInterface { ClientReaderWriter(ChannelInterface* channel, const RpcMethod& method, ClientContext* context) : context_(context), - cq_(GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING), + cq_(true), // Pluckable cq call_(channel->CreateCall(method, context, &cq_)) { CallOpSet ops; ops.SendInitialMetadata(context->send_initial_metadata_, @@ -512,7 +512,7 @@ class ServerReaderWriterBody final { Call* const call_; ServerContext* const ctx_; }; -} +} // namespace internal // class to represent the user API for a bidirectional streaming call template diff --git a/src/cpp/common/core_codegen.cc b/src/cpp/common/core_codegen.cc index 81b32938b8..7d8a733912 100644 --- a/src/cpp/common/core_codegen.cc +++ b/src/cpp/common/core_codegen.cc @@ -54,11 +54,14 @@ struct grpc_byte_buffer; namespace grpc { -grpc_completion_queue* CoreCodegen::grpc_completion_queue_create( - grpc_cq_completion_type completion_type, grpc_cq_polling_type polling_type, +grpc_completion_queue* CoreCodegen::grpc_completion_queue_create_for_next( void* reserved) { - return ::grpc_completion_queue_create(completion_type, polling_type, - reserved); + return ::grpc_completion_queue_create_for_next(reserved); +} + +grpc_completion_queue* CoreCodegen::grpc_completion_queue_create_for_pluck( + void* reserved) { + return ::grpc_completion_queue_create_for_pluck(reserved); } void CoreCodegen::grpc_completion_queue_destroy(grpc_completion_queue* cq) { diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc index b11ea725e1..6adabef763 100644 --- a/src/cpp/server/server_cc.cc +++ b/src/cpp/server/server_cc.cc @@ -153,10 +153,7 @@ class Server::SyncRequest final : public CompletionQueueTag { grpc_metadata_array_destroy(&request_metadata_); } - void SetupRequest() { - cq_ = grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, - nullptr); - } + void SetupRequest() { cq_ = grpc_completion_queue_create_for_pluck(nullptr); } void TeardownRequest() { grpc_completion_queue_destroy(cq_); diff --git a/test/cpp/grpclb/grpclb_test.cc b/test/cpp/grpclb/grpclb_test.cc index c9c569cfbe..b85ad949a5 100644 --- a/test/cpp/grpclb/grpclb_test.cc +++ b/test/cpp/grpclb/grpclb_test.cc @@ -354,8 +354,9 @@ static void start_backend_server(server_fixture *sf) { } GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); const string expected_token = - strlen(sf->lb_token_prefix) == 0 ? "" : sf->lb_token_prefix + - std::to_string(sf->port); + strlen(sf->lb_token_prefix) == 0 + ? "" + : sf->lb_token_prefix + std::to_string(sf->port); GPR_ASSERT(contains_metadata(&request_metadata_recv, "lb-token", expected_token.c_str())); @@ -593,8 +594,7 @@ static void setup_client(const server_fixture *lb_server, grpc_channel_args_copy_and_add(NULL, &expected_target_arg, 1); gpr_free(expected_target_names); - cf->cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + cf->cq = grpc_completion_queue_create_for_next(NULL); cf->server_uri = lb_uri; grpc_channel_credentials *fake_creds = grpc_fake_transport_security_credentials_create(); @@ -617,8 +617,7 @@ static void teardown_client(client_fixture *cf) { static void setup_server(const char *host, server_fixture *sf) { int assigned_port; - sf->cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + sf->cq = grpc_completion_queue_create_for_next(NULL); const char *colon_idx = strchr(host, ':'); if (colon_idx) { const char *port_str = colon_idx + 1; @@ -647,7 +646,7 @@ static void teardown_server(server_fixture *sf) { gpr_log(GPR_INFO, "Server[%s] shutting down", sf->servers_hostport); grpc_completion_queue *shutdown_cq = - grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_NON_POLLING, NULL); + grpc_completion_queue_create_for_pluck(NULL); grpc_server_shutdown_and_notify(sf->server, shutdown_cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(shutdown_cq, tag(1000), grpc_timeout_seconds_to_deadline(5), diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc index ec6073e786..24d2a1b85f 100644 --- a/test/cpp/microbenchmarks/bm_call_create.cc +++ b/test/cpp/microbenchmarks/bm_call_create.cc @@ -114,8 +114,7 @@ template static void BM_CallCreateDestroy(benchmark::State &state) { TrackCounters track_counters; Fixture fixture; - grpc_completion_queue *cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); void *method_hdl = grpc_channel_register_call(fixture.channel(), "/foo/bar", NULL, NULL); diff --git a/test/cpp/microbenchmarks/bm_cq.cc b/test/cpp/microbenchmarks/bm_cq.cc index 14eae82717..eaba7d858c 100644 --- a/test/cpp/microbenchmarks/bm_cq.cc +++ b/test/cpp/microbenchmarks/bm_cq.cc @@ -64,8 +64,7 @@ static void BM_CreateDestroyCore(benchmark::State& state) { while (state.KeepRunning()) { // TODO: sreek Templatize this benchmark and pass completion type and // polling type as parameters - grpc_completion_queue_destroy(grpc_completion_queue_create( - GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL)); + grpc_completion_queue_destroy(grpc_completion_queue_create_for_next(NULL)); } track_counters.Finish(state); } @@ -102,8 +101,7 @@ BENCHMARK(BM_Pass1Cpp); static void BM_Pass1Core(benchmark::State& state) { TrackCounters track_counters; // TODO: sreek Templatize this benchmark and pass polling_type as a param - grpc_completion_queue* cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + grpc_completion_queue* cq = grpc_completion_queue_create_for_next(NULL); gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); while (state.KeepRunning()) { grpc_cq_completion completion; @@ -122,8 +120,7 @@ BENCHMARK(BM_Pass1Core); static void BM_Pluck1Core(benchmark::State& state) { TrackCounters track_counters; // TODO: sreek Templatize this benchmark and pass polling_type as a param - grpc_completion_queue* cq = grpc_completion_queue_create( - GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, NULL); + grpc_completion_queue* cq = grpc_completion_queue_create_for_pluck(NULL); gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); while (state.KeepRunning()) { grpc_cq_completion completion; @@ -142,8 +139,7 @@ BENCHMARK(BM_Pluck1Core); static void BM_EmptyCore(benchmark::State& state) { TrackCounters track_counters; // TODO: sreek Templatize this benchmark and pass polling_type as a param - grpc_completion_queue* cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + grpc_completion_queue* cq = grpc_completion_queue_create_for_next(NULL); gpr_timespec deadline = gpr_inf_past(GPR_CLOCK_MONOTONIC); while (state.KeepRunning()) { grpc_completion_queue_next(cq, deadline, NULL); -- cgit v1.2.3 From def3354c9ac0a71e1868ae2733657c00b8f990e7 Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Wed, 22 Mar 2017 03:07:01 -0700 Subject: Fix test bug and generate_projects.sh --- src/ruby/ext/grpc/rb_grpc_imports.generated.h | 2 +- test/core/surface/completion_queue_test.c | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h index 6f1f1bd4db..e036ff7bd6 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h @@ -233,7 +233,7 @@ extern grpc_completion_queue_create_for_next_type grpc_completion_queue_create_f typedef grpc_completion_queue *(*grpc_completion_queue_create_for_pluck_type)(void *reserved); extern grpc_completion_queue_create_for_pluck_type grpc_completion_queue_create_for_pluck_import; #define grpc_completion_queue_create_for_pluck grpc_completion_queue_create_for_pluck_import -typedef grpc_completion_queue *(*grpc_completion_queue_create_type)(grpc_cq_completion_type completion_type, grpc_cq_polling_type polling_type, void *reserved); +typedef grpc_completion_queue *(*grpc_completion_queue_create_type)(const grpc_completion_queue_factory *factory, const grpc_completion_queue_attributes *attributes, void *reserved); extern grpc_completion_queue_create_type grpc_completion_queue_create_import; #define grpc_completion_queue_create grpc_completion_queue_create_import typedef grpc_event(*grpc_completion_queue_next_type)(grpc_completion_queue *cq, gpr_timespec deadline, void *reserved); diff --git a/test/core/surface/completion_queue_test.c b/test/core/surface/completion_queue_test.c index 4489057b2f..35bda5b641 100644 --- a/test/core/surface/completion_queue_test.c +++ b/test/core/surface/completion_queue_test.c @@ -81,6 +81,7 @@ static void test_no_op(void) { grpc_completion_queue_attributes attr; LOG_TEST("test_no_op"); + attr.version = 1; for (size_t i = 0; i < GPR_ARRAY_SIZE(completion_types); i++) { for (size_t j = 0; j < GPR_ARRAY_SIZE(polling_types); j++) { attr.cq_completion_type = completion_types[i]; @@ -100,6 +101,7 @@ static void test_pollset_conversion(void) { LOG_TEST("test_pollset_conversion"); + attr.version = 1; for (size_t i = 0; i < GPR_ARRAY_SIZE(completion_types); i++) { for (size_t j = 0; j < GPR_ARRAY_SIZE(polling_types); j++) { attr.cq_completion_type = completion_types[i]; @@ -121,8 +123,8 @@ static void test_wait_empty(void) { LOG_TEST("test_wait_empty"); + attr.version = 1; attr.cq_completion_type = GRPC_CQ_NEXT; - for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) { attr.cq_polling_type = polling_types[i]; cc = grpc_completion_queue_create( @@ -149,8 +151,8 @@ static void test_cq_end_op(void) { LOG_TEST("test_cq_end_op"); + attr.version = 1; attr.cq_completion_type = GRPC_CQ_NEXT; - for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) { exec_ctx = init_exec_ctx; // Reset exec_ctx attr.cq_polling_type = polling_types[i]; @@ -179,8 +181,8 @@ static void test_shutdown_then_next_polling(void) { grpc_event event; LOG_TEST("test_shutdown_then_next_polling"); + attr.version = 1; attr.cq_completion_type = GRPC_CQ_NEXT; - for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) { attr.cq_polling_type = polling_types[i]; cc = grpc_completion_queue_create( @@ -201,8 +203,8 @@ static void test_shutdown_then_next_with_timeout(void) { grpc_event event; LOG_TEST("test_shutdown_then_next_with_timeout"); + attr.version = 1; attr.cq_completion_type = GRPC_CQ_NEXT; - for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) { attr.cq_polling_type = polling_types[i]; cc = grpc_completion_queue_create( @@ -237,8 +239,8 @@ static void test_pluck(void) { } } + attr.version = 1; attr.cq_completion_type = GRPC_CQ_PLUCK; - for (size_t pidx = 0; pidx < GPR_ARRAY_SIZE(polling_types); pidx++) { exec_ctx = init_exec_ctx; // reset exec_ctx attr.cq_polling_type = polling_types[pidx]; @@ -283,8 +285,8 @@ static void test_pluck_after_shutdown(void) { LOG_TEST("test_pluck_after_shutdown"); + attr.version = 1; attr.cq_completion_type = GRPC_CQ_PLUCK; - for (size_t i = 0; i < GPR_ARRAY_SIZE(polling_types); i++) { attr.cq_polling_type = polling_types[i]; cc = grpc_completion_queue_create( -- cgit v1.2.3 From 615e468b08362237d5fedc788b3b3e524a3b1914 Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Wed, 22 Mar 2017 12:34:17 -0700 Subject: C# changes --- src/csharp/ext/grpc_csharp_ext.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index ceb2671faf..27de7bc11f 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -355,12 +355,12 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_shutdown(void) { grpc_shutdown(); } GPR_EXPORT grpc_completion_queue *GPR_CALLTYPE grpcsharp_completion_queue_create_async(void) { - return grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + return grpc_completion_queue_create_for_next(NULL); } GPR_EXPORT grpc_completion_queue *GPR_CALLTYPE grpcsharp_completion_queue_create_sync(void) { - return grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, NULL); + return grpc_completion_queue_create_for_pluck(NULL); } GPR_EXPORT void GPR_CALLTYPE -- cgit v1.2.3 From ef8857e4af2062f20c9e3e4cfad0c1576c31d9e6 Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Wed, 22 Mar 2017 12:35:09 -0700 Subject: Node changes --- src/node/ext/completion_queue_threadpool.cc | 3 +-- src/node/ext/completion_queue_uv.cc | 3 +-- src/node/ext/server_generic.cc | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/node/ext/completion_queue_threadpool.cc b/src/node/ext/completion_queue_threadpool.cc index b5227bad65..0b8bc019e0 100644 --- a/src/node/ext/completion_queue_threadpool.cc +++ b/src/node/ext/completion_queue_threadpool.cc @@ -141,8 +141,7 @@ void CompletionQueueAsyncWorker::Init(Local exports) { Nan::HandleScope scope; current_threads = 0; waiting_next_calls = 0; - queue = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + queue = grpc_completion_queue_create_for_next(NULL); } void CompletionQueueAsyncWorker::HandleOKCallback() { diff --git a/src/node/ext/completion_queue_uv.cc b/src/node/ext/completion_queue_uv.cc index 9c1f093a40..72900501e0 100644 --- a/src/node/ext/completion_queue_uv.cc +++ b/src/node/ext/completion_queue_uv.cc @@ -92,8 +92,7 @@ void CompletionQueueNext() { } void CompletionQueueInit(Local exports) { - queue = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL); + queue = grpc_completion_queue_create_for_next(NULL); uv_prepare_init(uv_default_loop(), &prepare); pending_batches = 0; } diff --git a/src/node/ext/server_generic.cc b/src/node/ext/server_generic.cc index 787605aebf..24573bd52f 100644 --- a/src/node/ext/server_generic.cc +++ b/src/node/ext/server_generic.cc @@ -44,8 +44,7 @@ namespace grpc { namespace node { Server::Server(grpc_server *server) : wrapped_server(server) { - shutdown_queue = grpc_completion_queue_create(GRPC_CQ_PLUCK, - GRPC_CQ_DEFAULT_POLLING, NULL); + shutdown_queue = grpc_completion_queue_create_for_pluck(NULL); grpc_server_register_non_listening_completion_queue(server, shutdown_queue, NULL); } -- cgit v1.2.3 From ffc69a7644fc96e63b255776749312c650b51127 Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Wed, 22 Mar 2017 12:35:19 -0700 Subject: Objective-C changes --- src/objective-c/GRPCClient/private/GRPCCompletionQueue.m | 4 +--- .../tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m | 3 +-- src/objective-c/tests/CronetUnitTests/CronetUnitTests.m | 8 ++------ 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/objective-c/GRPCClient/private/GRPCCompletionQueue.m b/src/objective-c/GRPCClient/private/GRPCCompletionQueue.m index 8edb4ef048..5ff77eac4c 100644 --- a/src/objective-c/GRPCClient/private/GRPCCompletionQueue.m +++ b/src/objective-c/GRPCClient/private/GRPCCompletionQueue.m @@ -48,9 +48,7 @@ - (instancetype)init { if ((self = [super init])) { - _unmanagedQueue = grpc_completion_queue_create(GRPC_CQ_NEXT, - GRPC_CQ_DEFAULT_POLLING, - NULL); + _unmanagedQueue = grpc_completion_queue_create_for_next(NULL); // This is for the following block to capture the pointer by value (instead // of retaining self and doing self->_unmanagedQueue). This is essential diff --git a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m index 7656fb8d51..54c3ed0e94 100644 --- a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m +++ b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m @@ -79,8 +79,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( gpr_join_host_port(&ffd->localaddr, "127.0.0.1", port); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, - NULL); + f.cq = grpc_completion_queue_create_for_next(NULL); return f; } diff --git a/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m b/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m index 1840894d81..6fe4706af6 100644 --- a/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m +++ b/src/objective-c/tests/CronetUnitTests/CronetUnitTests.m @@ -160,9 +160,7 @@ unsigned int parse_h2_length(const char *field) { int port = grpc_pick_unused_port_or_die(); char *addr; gpr_join_host_port(&addr, "127.0.0.1", port); - grpc_completion_queue *cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, - NULL); + grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); stream_engine *cronetEngine = [Cronet getGlobalEngine]; grpc_channel *client = grpc_cronet_secure_channel_create(cronetEngine, addr, NULL, NULL); @@ -296,9 +294,7 @@ unsigned int parse_h2_length(const char *field) { int port = grpc_pick_unused_port_or_die(); char *addr; gpr_join_host_port(&addr, "127.0.0.1", port); - grpc_completion_queue *cq = - grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, - NULL); + grpc_completion_queue *cq = grpc_completion_queue_create_for_next(NULL); stream_engine *cronetEngine = [Cronet getGlobalEngine]; grpc_channel *client = grpc_cronet_secure_channel_create(cronetEngine, addr, args, NULL); -- cgit v1.2.3 From 3a55efaed727ae472baf3b824918e4561baca36d Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Wed, 22 Mar 2017 12:37:07 -0700 Subject: PHP changes --- src/php/ext/grpc/completion_queue.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/php/ext/grpc/completion_queue.c b/src/php/ext/grpc/completion_queue.c index 441088bf68..c75a524530 100644 --- a/src/php/ext/grpc/completion_queue.c +++ b/src/php/ext/grpc/completion_queue.c @@ -38,9 +38,7 @@ grpc_completion_queue *completion_queue; void grpc_php_init_completion_queue(TSRMLS_D) { - completion_queue = grpc_completion_queue_create(GRPC_CQ_PLUCK, - GRPC_CQ_DEFAULT_POLLING, - NULL); + completion_queue = grpc_completion_queue_create_for_pluck(NULL); } void grpc_php_shutdown_completion_queue(TSRMLS_D) { -- cgit v1.2.3 From 56b1032feb1bc1bdd6f622906fd737ad1bc12e56 Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Wed, 22 Mar 2017 12:37:17 -0700 Subject: Python changes --- .../grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi | 2 +- src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi | 14 +------------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi index 368919b62f..34b2623d34 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/completion_queue.pyx.pxi @@ -40,7 +40,7 @@ cdef class CompletionQueue: def __cinit__(self): grpc_init() with nogil: - self.c_completion_queue = grpc_completion_queue_create(GRPC_CQ_NEXT, GRPC_CQ_DEFAULT_POLLING, NULL) + self.c_completion_queue = grpc_completion_queue_create_for_next(NULL) self.is_shutting_down = False self.is_shutdown = False diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi index b26b240b4e..0b2bdef48b 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi @@ -309,19 +309,7 @@ cdef extern from "grpc/grpc.h": void grpc_init() nogil void grpc_shutdown() nogil - ctypedef enum grpc_cq_completion_type: - GRPC_CQ_NEXT = 1 - GRPC_CQ_PLUCK = 2 - - ctypedef enum grpc_cq_polling_type: - GRPC_CQ_DEFAULT_POLLING - GRPC_CQ_NON_LISTENING - GRPC_CQ_NON_POLLING - - grpc_completion_queue *grpc_completion_queue_create( - grpc_cq_completion_type completion_type, - grpc_cq_polling_type polling_type, - void *reserved) nogil + grpc_completion_queue *grpc_completion_queue_create_for_next(void *reserved) nogil grpc_event grpc_completion_queue_next(grpc_completion_queue *cq, gpr_timespec deadline, -- cgit v1.2.3 From 8d8bb7a51557b0ce61ad79324bc5cb538918f6ac Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Wed, 22 Mar 2017 12:37:29 -0700 Subject: Ruby changes --- src/ruby/ext/grpc/rb_channel.c | 6 ++---- src/ruby/ext/grpc/rb_server.c | 7 +++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/ruby/ext/grpc/rb_channel.c b/src/ruby/ext/grpc/rb_channel.c index 2b9f03abd4..54b178ad87 100644 --- a/src/ruby/ext/grpc/rb_channel.c +++ b/src/ruby/ext/grpc/rb_channel.c @@ -171,8 +171,7 @@ static VALUE grpc_rb_channel_init(int argc, VALUE *argv, VALUE self) { } rb_ivar_set(self, id_target, target); wrapper->wrapped = ch; - wrapper->queue = grpc_completion_queue_create(GRPC_CQ_PLUCK, - GRPC_CQ_DEFAULT_POLLING, NULL); + wrapper->queue = grpc_completion_queue_create_for_pluck(NULL); return self; } @@ -270,8 +269,7 @@ static VALUE grpc_rb_channel_create_call(VALUE self, VALUE parent, VALUE mask, parent_call = grpc_rb_get_wrapped_call(parent); } - cq = grpc_completion_queue_create(GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, - NULL); + cq = grpc_completion_queue_create_for_pluck(NULL); TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper); ch = wrapper->wrapped; if (ch == NULL) { diff --git a/src/ruby/ext/grpc/rb_server.c b/src/ruby/ext/grpc/rb_server.c index a0e8f15294..ef57d5b07e 100644 --- a/src/ruby/ext/grpc/rb_server.c +++ b/src/ruby/ext/grpc/rb_server.c @@ -132,8 +132,7 @@ static VALUE grpc_rb_server_alloc(VALUE cls) { Initializes server instances. */ static VALUE grpc_rb_server_init(VALUE self, VALUE channel_args) { - grpc_completion_queue *cq = grpc_completion_queue_create( - GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, NULL); + grpc_completion_queue *cq = grpc_completion_queue_create_for_pluck(NULL); grpc_rb_server *wrapper = NULL; grpc_server *srv = NULL; grpc_channel_args args; @@ -190,8 +189,8 @@ static VALUE grpc_rb_server_request_call(VALUE self) { request_call_stack st; VALUE result; void *tag = (void *)&st; - grpc_completion_queue *call_queue = grpc_completion_queue_create( - GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, NULL); + grpc_completion_queue *call_queue = + grpc_completion_queue_create_for_pluck(NULL); gpr_timespec deadline; TypedData_Get_Struct(self, grpc_rb_server, &grpc_rb_server_data_type, s); -- cgit v1.2.3 From 2ae4fc2601c23f026e8abff2f1c1f817b72ef0b3 Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Wed, 22 Mar 2017 13:11:27 -0700 Subject: Minor formatting --- include/grpc/grpc.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index d2c18795ea..42cf201da4 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -117,14 +117,14 @@ typedef enum { GRPC_CQ_DEFAULT_POLLING, /** Similar to GRPC_CQ_DEFAULT_POLLING except that the completion queues will - not contain any 'listening file descriptors' (i.e file descriptors used to - listen to incoming channels) */ + not contain any 'listening file descriptors' (i.e file descriptors used to + listen to incoming channels) */ GRPC_CQ_NON_LISTENING, /** The completion queue will not have an associated pollset. Note that - grpc_completion_queue_next() or grpc_completion_queue_pluck() MUST still be - called to pop events from the completion queue; it is not required to call - them actively to make I/O progress */ + grpc_completion_queue_next() or grpc_completion_queue_pluck() MUST still + be called to pop events from the completion queue; it is not required to + call them actively to make I/O progress */ GRPC_CQ_NON_POLLING } grpc_cq_polling_type; -- cgit v1.2.3 From 6ac703d1fd943d219ef2b747b8d46466b663b2d9 Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Fri, 24 Mar 2017 09:53:01 -0700 Subject: Fix after merge with master --- test/cpp/microbenchmarks/bm_call_create.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc index 3ed4c05e21..bb52a08a54 100644 --- a/test/cpp/microbenchmarks/bm_call_create.cc +++ b/test/cpp/microbenchmarks/bm_call_create.cc @@ -567,7 +567,7 @@ class IsolatedCallFixture : public TrackCounters { GRPC_CLIENT_CHANNEL); grpc_exec_ctx_finish(&exec_ctx); } - cq_ = grpc_completion_queue_create(NULL); + cq_ = grpc_completion_queue_create_for_next(NULL); } void Finish(benchmark::State &state) { -- cgit v1.2.3 From a69599141c5ebdfbccd544ff8dcd75149c96ba16 Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Fri, 24 Mar 2017 09:56:50 -0700 Subject: Remove a file that wasn't properly deleted after the merge --- .../set_initial_connect_string_test.c | 268 --------------------- 1 file changed, 268 deletions(-) delete mode 100644 test/core/client_channel/set_initial_connect_string_test.c diff --git a/test/core/client_channel/set_initial_connect_string_test.c b/test/core/client_channel/set_initial_connect_string_test.c deleted file mode 100644 index 7f38418ea7..0000000000 --- a/test/core/client_channel/set_initial_connect_string_test.c +++ /dev/null @@ -1,268 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -/* With the addition of a libuv endpoint, sockaddr.h now includes uv.h when - using that endpoint. Because of various transitive includes in uv.h, - including windows.h on Windows, uv.h must be included before other system - headers. Therefore, sockaddr.h must always be included first */ -#include "src/core/lib/iomgr/sockaddr.h" - -#include - -#include -#include -#include -#include -#include -#include - -#include "src/core/ext/client_channel/initial_connect_string.h" -#include "src/core/lib/iomgr/sockaddr.h" -#include "src/core/lib/security/credentials/fake/fake_credentials.h" -#include "src/core/lib/slice/slice_string_helpers.h" -#include "src/core/lib/support/string.h" -#include "test/core/util/port.h" -#include "test/core/util/test_config.h" -#include "test/core/util/test_tcp_server.h" - -struct rpc_state { - char *target; - grpc_channel_credentials *creds; - grpc_completion_queue *cq; - grpc_channel *channel; - grpc_call *call; - grpc_op op; - grpc_slice_buffer incoming_buffer; - grpc_slice_buffer temp_incoming_buffer; - grpc_endpoint *tcp; - gpr_atm done_atm; -}; - -static const char *magic_connect_string = "magic initial string"; -static int server_port; -static struct rpc_state state; -static grpc_closure on_read; - -static void handle_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { - GPR_ASSERT(error == GRPC_ERROR_NONE); - grpc_slice_buffer_move_into(&state.temp_incoming_buffer, - &state.incoming_buffer); - gpr_log(GPR_DEBUG, "got %" PRIuPTR " bytes, magic is %" PRIuPTR " bytes", - state.incoming_buffer.length, strlen(magic_connect_string)); - if (state.incoming_buffer.length > strlen(magic_connect_string)) { - gpr_atm_rel_store(&state.done_atm, 1); - grpc_endpoint_shutdown( - exec_ctx, state.tcp, - GRPC_ERROR_CREATE("Incoming buffer longer than magic_connect_string")); - grpc_endpoint_destroy(exec_ctx, state.tcp); - } else { - grpc_endpoint_read(exec_ctx, state.tcp, &state.temp_incoming_buffer, - &on_read); - } -} - -static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp, - grpc_pollset *accepting_pollset, - grpc_tcp_server_acceptor *acceptor) { - gpr_free(acceptor); - test_tcp_server *server = arg; - grpc_closure_init(&on_read, handle_read, NULL, grpc_schedule_on_exec_ctx); - grpc_slice_buffer_init(&state.incoming_buffer); - grpc_slice_buffer_init(&state.temp_incoming_buffer); - state.tcp = tcp; - grpc_endpoint_add_to_pollset(exec_ctx, tcp, server->pollset); - grpc_endpoint_read(exec_ctx, tcp, &state.temp_incoming_buffer, &on_read); -} - -static void set_magic_initial_string(grpc_resolved_address **addr, - grpc_slice *connect_string) { - GPR_ASSERT(addr); - GPR_ASSERT((*addr)->len); - *connect_string = grpc_slice_from_copied_string(magic_connect_string); -} - -static void reset_addr_and_set_magic_string(grpc_resolved_address **addr, - grpc_slice *connect_string) { - struct sockaddr_in target; - *connect_string = grpc_slice_from_copied_string(magic_connect_string); - gpr_free(*addr); - target.sin_family = AF_INET; - target.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - target.sin_port = htons((uint16_t)server_port); - *addr = (grpc_resolved_address *)gpr_malloc(sizeof(grpc_resolved_address)); - (*addr)->len = sizeof(target); - memcpy((*addr)->addr, &target, sizeof(target)); -} - -static gpr_timespec n_sec_deadline(int seconds) { - return gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_seconds(seconds, GPR_TIMESPAN)); -} - -static void start_rpc(int use_creds, int target_port) { - state.cq = grpc_completion_queue_create_for_next(NULL); - if (use_creds) { - state.creds = grpc_fake_transport_security_credentials_create(); - } else { - state.creds = NULL; - } - gpr_join_host_port(&state.target, "127.0.0.1", target_port); - if (use_creds) { - state.channel = - grpc_secure_channel_create(state.creds, state.target, NULL, NULL); - } else { - state.channel = grpc_insecure_channel_create(state.target, NULL, NULL); - } - grpc_slice host = grpc_slice_from_static_string("localhost"); - state.call = grpc_channel_create_call( - state.channel, NULL, GRPC_PROPAGATE_DEFAULTS, state.cq, - grpc_slice_from_static_string("/Service/Method"), &host, - 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; - state.op.reserved = NULL; - GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(state.call, &state.op, - (size_t)(1), NULL, NULL)); - grpc_completion_queue_next(state.cq, n_sec_deadline(5), NULL); -} - -static void cleanup_rpc(void) { - grpc_event ev; - grpc_slice_buffer_destroy(&state.incoming_buffer); - grpc_slice_buffer_destroy(&state.temp_incoming_buffer); - grpc_channel_credentials_release(state.creds); - grpc_call_destroy(state.call); - grpc_completion_queue_shutdown(state.cq); - do { - ev = grpc_completion_queue_next(state.cq, n_sec_deadline(1), NULL); - } while (ev.type != GRPC_QUEUE_SHUTDOWN); - grpc_completion_queue_destroy(state.cq); - grpc_channel_destroy(state.channel); - gpr_free(state.target); -} - -typedef struct { - test_tcp_server *server; - gpr_event *signal_when_done; -} poll_args; - -static void actually_poll_server(void *arg) { - poll_args *pa = arg; - gpr_timespec deadline = n_sec_deadline(10); - while (true) { - bool done = gpr_atm_acq_load(&state.done_atm) != 0; - gpr_timespec time_left = - gpr_time_sub(deadline, gpr_now(GPR_CLOCK_REALTIME)); - gpr_log(GPR_DEBUG, "done=%d, time_left=%" PRId64 ".%09" PRId32, done, - time_left.tv_sec, time_left.tv_nsec); - if (done || gpr_time_cmp(time_left, gpr_time_0(GPR_TIMESPAN)) < 0) { - break; - } - test_tcp_server_poll(pa->server, 1); - } - gpr_event_set(pa->signal_when_done, (void *)1); - gpr_free(pa); -} - -static void poll_server_until_read_done(test_tcp_server *server, - gpr_event *signal_when_done) { - gpr_atm_rel_store(&state.done_atm, 0); - gpr_thd_id id; - poll_args *pa = gpr_malloc(sizeof(*pa)); - pa->server = server; - pa->signal_when_done = signal_when_done; - gpr_thd_new(&id, actually_poll_server, pa, NULL); -} - -static void match_initial_magic_string(grpc_slice_buffer *buffer) { - size_t i, j, cmp_length; - size_t magic_length = strlen(magic_connect_string); - GPR_ASSERT(buffer->length >= magic_length); - for (i = 0, j = 0; i < state.incoming_buffer.count && j < magic_length; i++) { - char *dump = grpc_slice_to_c_string(state.incoming_buffer.slices[i]); - cmp_length = GPR_MIN(strlen(dump), magic_length - j); - GPR_ASSERT(strncmp(dump, magic_connect_string + j, cmp_length) == 0); - j += cmp_length; - gpr_free(dump); - } -} - -static void test_initial_string(test_tcp_server *server, int secure) { - gpr_event ev; - gpr_event_init(&ev); - grpc_test_set_initial_connect_string_function(set_magic_initial_string); - poll_server_until_read_done(server, &ev); - start_rpc(secure, server_port); - gpr_event_wait(&ev, gpr_inf_future(GPR_CLOCK_REALTIME)); - match_initial_magic_string(&state.incoming_buffer); - cleanup_rpc(); -} - -static void test_initial_string_with_redirect(test_tcp_server *server, - int secure) { - gpr_event ev; - gpr_event_init(&ev); - int another_port = grpc_pick_unused_port_or_die(); - grpc_test_set_initial_connect_string_function( - reset_addr_and_set_magic_string); - poll_server_until_read_done(server, &ev); - start_rpc(secure, another_port); - gpr_event_wait(&ev, gpr_inf_future(GPR_CLOCK_REALTIME)); - match_initial_magic_string(&state.incoming_buffer); - cleanup_rpc(); -} - -static void run_test(void (*test)(test_tcp_server *server, int secure), - int secure) { - test_tcp_server test_server; - server_port = grpc_pick_unused_port_or_die(); - test_tcp_server_init(&test_server, on_connect, &test_server); - test_tcp_server_start(&test_server, server_port); - test(&test_server, secure); - test_tcp_server_destroy(&test_server); -} - -int main(int argc, char **argv) { - grpc_test_init(argc, argv); - grpc_init(); - - run_test(test_initial_string, 0); - run_test(test_initial_string, 1); - run_test(test_initial_string_with_redirect, 0); - run_test(test_initial_string_with_redirect, 1); - - grpc_shutdown(); - return 0; -} -- cgit v1.2.3 From 5bec133ba03f8cdffc7e2ace03a06aa5b48aed5c Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Fri, 24 Mar 2017 10:03:22 -0700 Subject: clang format --- include/grpc++/impl/codegen/client_unary_call.h | 2 +- include/grpc++/impl/codegen/completion_queue.h | 5 ++--- include/grpc++/impl/codegen/sync_stream.h | 6 +++--- src/core/lib/surface/completion_queue.c | 10 ++++------ test/core/bad_ssl/server_common.c | 5 ++--- test/core/client_channel/lb_policies_test.c | 6 +++--- test/core/end2end/fixtures/h2_census.c | 7 +++---- test/core/end2end/fixtures/h2_compress.c | 7 +++---- test/core/end2end/fixtures/h2_full+pipe.c | 7 +++---- test/core/end2end/fixtures/h2_full+trace.c | 7 +++---- test/core/end2end/fixtures/h2_full.c | 7 +++---- test/core/end2end/fixtures/h2_http_proxy.c | 7 +++---- test/core/end2end/fixtures/h2_proxy.c | 9 ++++----- test/core/end2end/fixtures/h2_ssl_cert.c | 20 +++++++++----------- test/core/end2end/fixtures/h2_uds.c | 7 +++---- test/core/end2end/fuzzers/api_fuzzer.c | 25 ++++++++++--------------- test/core/fling/server.c | 5 ++--- test/core/memory_usage/client.c | 5 ++--- test/core/memory_usage/server.c | 5 ++--- test/cpp/grpclb/grpclb_test.cc | 5 ++--- 20 files changed, 67 insertions(+), 90 deletions(-) diff --git a/include/grpc++/impl/codegen/client_unary_call.h b/include/grpc++/impl/codegen/client_unary_call.h index 6218e3ed1b..a5a4f3d739 100644 --- a/include/grpc++/impl/codegen/client_unary_call.h +++ b/include/grpc++/impl/codegen/client_unary_call.h @@ -52,7 +52,7 @@ template Status BlockingUnaryCall(ChannelInterface* channel, const RpcMethod& method, ClientContext* context, const InputMessage& request, OutputMessage* result) { - CompletionQueue cq(true); // Pluckable completion queue + CompletionQueue cq(true); // Pluckable completion queue Call call(channel->CreateCall(method, context, &cq)); CallOpSet, diff --git a/include/grpc++/impl/codegen/completion_queue.h b/include/grpc++/impl/codegen/completion_queue.h index 0130e9ca0f..025eea3ef5 100644 --- a/include/grpc++/impl/codegen/completion_queue.h +++ b/include/grpc++/impl/codegen/completion_queue.h @@ -147,9 +147,8 @@ class CompletionQueue : private GrpcLibraryCodegen { /// /// \return true if read a regular event, false if the queue is shutting down. bool Next(void** tag, bool* ok) { - return (AsyncNextInternal(tag, ok, - g_core_codegen_interface->gpr_inf_future( - GPR_CLOCK_REALTIME)) != SHUTDOWN); + return (AsyncNextInternal(tag, ok, g_core_codegen_interface->gpr_inf_future( + GPR_CLOCK_REALTIME)) != SHUTDOWN); } /// Request the shutdown of the queue. diff --git a/include/grpc++/impl/codegen/sync_stream.h b/include/grpc++/impl/codegen/sync_stream.h index 4e12f3261e..1ed290966c 100644 --- a/include/grpc++/impl/codegen/sync_stream.h +++ b/include/grpc++/impl/codegen/sync_stream.h @@ -138,7 +138,7 @@ class ClientReader final : public ClientReaderInterface { ClientReader(ChannelInterface* channel, const RpcMethod& method, ClientContext* context, const W& request) : context_(context), - cq_(true), // Pluckable cq + cq_(true), // Pluckable cq call_(channel->CreateCall(method, context, &cq_)) { CallOpSet @@ -212,7 +212,7 @@ class ClientWriter : public ClientWriterInterface { ClientWriter(ChannelInterface* channel, const RpcMethod& method, ClientContext* context, R* response) : context_(context), - cq_(true), // Pluckable cq + cq_(true), // Pluckable cq call_(channel->CreateCall(method, context, &cq_)) { finish_ops_.RecvMessage(response); finish_ops_.AllowNoMessage(); @@ -297,7 +297,7 @@ class ClientReaderWriter final : public ClientReaderWriterInterface { ClientReaderWriter(ChannelInterface* channel, const RpcMethod& method, ClientContext* context) : context_(context), - cq_(true), // Pluckable cq + cq_(true), // Pluckable cq call_(channel->CreateCall(method, context, &cq_)) { CallOpSet ops; ops.SendInitialMetadata(context->send_initial_metadata_, diff --git a/src/core/lib/surface/completion_queue.c b/src/core/lib/surface/completion_queue.c index 1e88e83449..aecc393edf 100644 --- a/src/core/lib/surface/completion_queue.c +++ b/src/core/lib/surface/completion_queue.c @@ -383,9 +383,8 @@ grpc_event grpc_completion_queue_next(grpc_completion_queue *cc, "deadline=gpr_timespec { tv_sec: %" PRId64 ", tv_nsec: %d, clock_type: %d }, " "reserved=%p)", - 5, - (cc, deadline.tv_sec, deadline.tv_nsec, (int)deadline.clock_type, - reserved)); + 5, (cc, deadline.tv_sec, deadline.tv_nsec, (int)deadline.clock_type, + reserved)); GPR_ASSERT(!reserved); dump_pending_tags(cc); @@ -559,9 +558,8 @@ grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cc, void *tag, "deadline=gpr_timespec { tv_sec: %" PRId64 ", tv_nsec: %d, clock_type: %d }, " "reserved=%p)", - 6, - (cc, tag, deadline.tv_sec, deadline.tv_nsec, (int)deadline.clock_type, - reserved)); + 6, (cc, tag, deadline.tv_sec, deadline.tv_nsec, + (int)deadline.clock_type, reserved)); } GPR_ASSERT(!reserved); diff --git a/test/core/bad_ssl/server_common.c b/test/core/bad_ssl/server_common.c index 67404711cd..0ec14676c6 100644 --- a/test/core/bad_ssl/server_common.c +++ b/test/core/bad_ssl/server_common.c @@ -95,9 +95,8 @@ void bad_ssl_run(grpc_server *server) { shutdown_started = 1; } ev = grpc_completion_queue_next( - cq, - gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_micros(1000000, GPR_TIMESPAN)), + cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_micros(1000000, GPR_TIMESPAN)), NULL); switch (ev.type) { case GRPC_OP_COMPLETE: diff --git a/test/core/client_channel/lb_policies_test.c b/test/core/client_channel/lb_policies_test.c index 433f77db82..50ec08b1db 100644 --- a/test/core/client_channel/lb_policies_test.c +++ b/test/core/client_channel/lb_policies_test.c @@ -65,9 +65,9 @@ typedef struct servers_fixture { } servers_fixture; typedef struct request_sequences { - size_t n; /* number of iterations */ - int *connections; /* indexed by the interation number, value is the index of - the server it connected to or -1 if none */ + size_t n; /* number of iterations */ + int *connections; /* indexed by the interation number, value is the index of + the server it connected to or -1 if none */ int *connectivity_states; /* indexed by the interation number, value is the client connectivity state */ } request_sequences; diff --git a/test/core/end2end/fixtures/h2_census.c b/test/core/end2end/fixtures/h2_census.c index 1a754835f0..7fc965a718 100644 --- a/test/core/end2end/fixtures/h2_census.c +++ b/test/core/end2end/fixtures/h2_census.c @@ -120,10 +120,9 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack+census", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack+census", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_compress.c b/test/core/end2end/fixtures/h2_compress.c index b73d6d787a..8636324ca1 100644 --- a/test/core/end2end/fixtures/h2_compress.c +++ b/test/core/end2end/fixtures/h2_compress.c @@ -120,10 +120,9 @@ void chttp2_tear_down_fullstack_compression(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack_compression", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack_compression", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack_compression, chttp2_init_client_fullstack_compression, chttp2_init_server_fullstack_compression, diff --git a/test/core/end2end/fixtures/h2_full+pipe.c b/test/core/end2end/fixtures/h2_full+pipe.c index 927ca8ae01..bc99d26550 100644 --- a/test/core/end2end/fixtures/h2_full+pipe.c +++ b/test/core/end2end/fixtures/h2_full+pipe.c @@ -103,10 +103,9 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_full+trace.c b/test/core/end2end/fixtures/h2_full+trace.c index bb24f966c1..f849496d21 100644 --- a/test/core/end2end/fixtures/h2_full+trace.c +++ b/test/core/end2end/fixtures/h2_full+trace.c @@ -103,10 +103,9 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_full.c b/test/core/end2end/fixtures/h2_full.c index d8d4d95177..92bd28eea7 100644 --- a/test/core/end2end/fixtures/h2_full.c +++ b/test/core/end2end/fixtures/h2_full.c @@ -97,10 +97,9 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_http_proxy.c b/test/core/end2end/fixtures/h2_http_proxy.c index 451c55677f..ebab96943d 100644 --- a/test/core/end2end/fixtures/h2_http_proxy.c +++ b/test/core/end2end/fixtures/h2_http_proxy.c @@ -108,10 +108,9 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_proxy.c b/test/core/end2end/fixtures/h2_proxy.c index af7d277689..9078001e3b 100644 --- a/test/core/end2end/fixtures/h2_proxy.c +++ b/test/core/end2end/fixtures/h2_proxy.c @@ -114,11 +114,10 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack+proxy", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_REQUEST_PROXYING | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack+proxy", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_REQUEST_PROXYING | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_ssl_cert.c b/test/core/end2end/fixtures/h2_ssl_cert.c index 59a728307b..7aa0e16bf6 100644 --- a/test/core/end2end/fixtures/h2_ssl_cert.c +++ b/test/core/end2end/fixtures/h2_ssl_cert.c @@ -204,17 +204,15 @@ CLIENT_INIT(BAD_CERT_PAIR) typedef enum { SUCCESS, FAIL } test_result; -#define SSL_TEST(request_type, cert_type, result) \ - { \ - {TEST_NAME(request_type, cert_type, result), \ - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | \ - FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS | \ - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL, \ - chttp2_create_fixture_secure_fullstack, \ - CLIENT_INIT_NAME(cert_type), \ - SERVER_INIT_NAME(request_type), \ - chttp2_tear_down_secure_fullstack}, \ - result \ +#define SSL_TEST(request_type, cert_type, result) \ + { \ + {TEST_NAME(request_type, cert_type, result), \ + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | \ + FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS | \ + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL, \ + chttp2_create_fixture_secure_fullstack, CLIENT_INIT_NAME(cert_type), \ + SERVER_INIT_NAME(request_type), chttp2_tear_down_secure_fullstack}, \ + result \ } /* All test configurations */ diff --git a/test/core/end2end/fixtures/h2_uds.c b/test/core/end2end/fixtures/h2_uds.c index 89b4b5e64b..60c5c497c7 100644 --- a/test/core/end2end/fixtures/h2_uds.c +++ b/test/core/end2end/fixtures/h2_uds.c @@ -102,10 +102,9 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack_uds", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack_uds", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fuzzers/api_fuzzer.c b/test/core/end2end/fuzzers/api_fuzzer.c index c8384346f0..2eff2f103e 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.c +++ b/test/core/end2end/fuzzers/api_fuzzer.c @@ -314,9 +314,8 @@ static grpc_call_credentials *read_call_creds(input_stream *inp) { cred_artifact_ctx ctx = CRED_ARTIFACT_CTX_INIT; const char *access_token = read_cred_artifact(&ctx, inp, NULL, 0); grpc_call_credentials *out = - access_token == NULL - ? NULL - : grpc_access_token_credentials_create(access_token, NULL); + access_token == NULL ? NULL : grpc_access_token_credentials_create( + access_token, NULL); cred_artifact_ctx_finish(&ctx); return out; } @@ -410,9 +409,8 @@ void my_resolve_address(grpc_exec_ctx *exec_ctx, const char *addr, r->on_done = on_done; r->addrs = addresses; grpc_timer_init( - exec_ctx, &r->timer, - gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), - gpr_time_from_seconds(1, GPR_TIMESPAN)), + exec_ctx, &r->timer, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), + gpr_time_from_seconds(1, GPR_TIMESPAN)), grpc_closure_create(finish_resolve, r, grpc_schedule_on_exec_ctx), gpr_now(GPR_CLOCK_MONOTONIC)); } @@ -473,9 +471,8 @@ static void sched_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure, fc->ep = ep; fc->deadline = deadline; grpc_timer_init( - exec_ctx, &fc->timer, - gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), - gpr_time_from_millis(1, GPR_TIMESPAN)), + exec_ctx, &fc->timer, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), + gpr_time_from_millis(1, GPR_TIMESPAN)), grpc_closure_create(do_connect, fc, grpc_schedule_on_exec_ctx), gpr_now(GPR_CLOCK_MONOTONIC)); } @@ -751,9 +748,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { if (g_server != NULL) { if (!server_shutdown) { grpc_server_shutdown_and_notify( - g_server, cq, - create_validator(assert_success_and_decrement, - &pending_server_shutdowns)); + g_server, cq, create_validator(assert_success_and_decrement, + &pending_server_shutdowns)); server_shutdown = true; pending_server_shutdowns++; } else if (pending_server_shutdowns == 0) { @@ -858,9 +854,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { case 5: { if (g_server != NULL) { grpc_server_shutdown_and_notify( - g_server, cq, - create_validator(assert_success_and_decrement, - &pending_server_shutdowns)); + g_server, cq, create_validator(assert_success_and_decrement, + &pending_server_shutdowns)); pending_server_shutdowns++; server_shutdown = true; } else { diff --git a/test/core/fling/server.c b/test/core/fling/server.c index ebcb8f05f0..7edff3d132 100644 --- a/test/core/fling/server.c +++ b/test/core/fling/server.c @@ -257,9 +257,8 @@ int main(int argc, char **argv) { shutdown_started = 1; } ev = grpc_completion_queue_next( - cq, - gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_micros(1000000, GPR_TIMESPAN)), + cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_micros(1000000, GPR_TIMESPAN)), NULL); s = ev.tag; switch (ev.type) { diff --git a/test/core/memory_usage/client.c b/test/core/memory_usage/client.c index 4fb99217b6..d0ec060aca 100644 --- a/test/core/memory_usage/client.c +++ b/test/core/memory_usage/client.c @@ -261,9 +261,8 @@ int main(int argc, char **argv) { do { event = grpc_completion_queue_next( - cq, - gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_micros(10000, GPR_TIMESPAN)), + cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_micros(10000, GPR_TIMESPAN)), NULL); } while (event.type != GRPC_QUEUE_TIMEOUT); diff --git a/test/core/memory_usage/server.c b/test/core/memory_usage/server.c index 94d90a58a6..44c5488014 100644 --- a/test/core/memory_usage/server.c +++ b/test/core/memory_usage/server.c @@ -243,9 +243,8 @@ int main(int argc, char **argv) { shutdown_started = 1; } ev = grpc_completion_queue_next( - cq, - gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), - gpr_time_from_micros(1000000, GPR_TIMESPAN)), + cq, gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_micros(1000000, GPR_TIMESPAN)), NULL); fling_call *s = ev.tag; switch (ev.type) { diff --git a/test/cpp/grpclb/grpclb_test.cc b/test/cpp/grpclb/grpclb_test.cc index b85ad949a5..e0ae86955e 100644 --- a/test/cpp/grpclb/grpclb_test.cc +++ b/test/cpp/grpclb/grpclb_test.cc @@ -354,9 +354,8 @@ static void start_backend_server(server_fixture *sf) { } GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); const string expected_token = - strlen(sf->lb_token_prefix) == 0 - ? "" - : sf->lb_token_prefix + std::to_string(sf->port); + strlen(sf->lb_token_prefix) == 0 ? "" : sf->lb_token_prefix + + std::to_string(sf->port); GPR_ASSERT(contains_metadata(&request_metadata_recv, "lb-token", expected_token.c_str())); -- cgit v1.2.3 From d166e38e938db324e10a8d009e9c819a99ba11e6 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Fri, 24 Mar 2017 10:03:10 -0700 Subject: Fix soname version mismatch in Makefile --- Makefile | 14 +++++++------- templates/Makefile.template | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 4a32fed2c9..23886d1dc6 100644 --- a/Makefile +++ b/Makefile @@ -465,7 +465,7 @@ SHARED_VERSION_CORE = -3 SHARED_VERSION_CPP = -1 SHARED_VERSION_CSHARP = -1 else ifeq ($(SYSTEM),Darwin) -EXECUTABLE_SUFFIX = +EXECUTABLE_SUFFIX = SHARED_EXT_CORE = dylib SHARED_EXT_CPP = dylib SHARED_EXT_CSHARP = dylib @@ -474,7 +474,7 @@ SHARED_VERSION_CORE = SHARED_VERSION_CPP = SHARED_VERSION_CSHARP = else -EXECUTABLE_SUFFIX = +EXECUTABLE_SUFFIX = SHARED_EXT_CORE = so.$(CORE_VERSION) SHARED_EXT_CPP = so.$(CPP_VERSION) SHARED_EXT_CSHARP = so.$(CSHARP_VERSION) @@ -4100,7 +4100,7 @@ $(LIBDIR)/$(CONFIG)/libgrpc++$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP): $(LIBGRPC+ ifeq ($(SYSTEM),Darwin) $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc++$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc++$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBGRPC++_OBJS) $(ZLIB_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) -lgrpc else - $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc++.so.3 -o $(LIBDIR)/$(CONFIG)/libgrpc++$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBGRPC++_OBJS) $(ZLIB_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) -lgrpc + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc++.so.1 -o $(LIBDIR)/$(CONFIG)/libgrpc++$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBGRPC++_OBJS) $(ZLIB_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) -lgrpc $(Q) ln -sf $(SHARED_PREFIX)grpc++$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBDIR)/$(CONFIG)/libgrpc++$(SHARED_VERSION_CPP).so.1 $(Q) ln -sf $(SHARED_PREFIX)grpc++$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBDIR)/$(CONFIG)/libgrpc++$(SHARED_VERSION_CPP).so endif @@ -4491,7 +4491,7 @@ $(LIBDIR)/$(CONFIG)/libgrpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP): $(L ifeq ($(SYSTEM),Darwin) $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBGRPC++_CRONET_OBJS) $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) -lgpr -lgrpc_cronet else - $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc++_cronet.so.3 -o $(LIBDIR)/$(CONFIG)/libgrpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBGRPC++_CRONET_OBJS) $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) -lgpr -lgrpc_cronet + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc++_cronet.so.1 -o $(LIBDIR)/$(CONFIG)/libgrpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBGRPC++_CRONET_OBJS) $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) -lgpr -lgrpc_cronet $(Q) ln -sf $(SHARED_PREFIX)grpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBDIR)/$(CONFIG)/libgrpc++_cronet$(SHARED_VERSION_CPP).so.1 $(Q) ln -sf $(SHARED_PREFIX)grpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBDIR)/$(CONFIG)/libgrpc++_cronet$(SHARED_VERSION_CPP).so endif @@ -4614,7 +4614,7 @@ $(LIBDIR)/$(CONFIG)/libgrpc++_reflection$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP): ifeq ($(SYSTEM),Darwin) $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc++_reflection$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBGRPC++_REFLECTION_OBJS) $(ZLIB_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) -lgrpc++ else - $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc++_reflection.so.3 -o $(LIBDIR)/$(CONFIG)/libgrpc++_reflection$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBGRPC++_REFLECTION_OBJS) $(ZLIB_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) -lgrpc++ + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc++_reflection.so.1 -o $(LIBDIR)/$(CONFIG)/libgrpc++_reflection$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBGRPC++_REFLECTION_OBJS) $(ZLIB_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) -lgrpc++ $(Q) ln -sf $(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBDIR)/$(CONFIG)/libgrpc++_reflection$(SHARED_VERSION_CPP).so.1 $(Q) ln -sf $(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBDIR)/$(CONFIG)/libgrpc++_reflection$(SHARED_VERSION_CPP).so endif @@ -4970,7 +4970,7 @@ $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP): $ ifeq ($(SYSTEM),Darwin) $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBGRPC++_UNSECURE_OBJS) $(ZLIB_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) -lgpr -lgrpc_unsecure else - $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc++_unsecure.so.3 -o $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBGRPC++_UNSECURE_OBJS) $(ZLIB_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) -lgpr -lgrpc_unsecure + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc++_unsecure.so.1 -o $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBGRPC++_UNSECURE_OBJS) $(ZLIB_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) -lgpr -lgrpc_unsecure $(Q) ln -sf $(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure$(SHARED_VERSION_CPP).so.1 $(Q) ln -sf $(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure$(SHARED_VERSION_CPP).so endif @@ -5560,7 +5560,7 @@ $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHA ifeq ($(SYSTEM),Darwin) $(Q) $(LD) $(LDFLAGS) $(if $(subst Linux,,$(SYSTEM)),,-Wl$(comma)-wrap$(comma)memcpy) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBGRPC_CSHARP_EXT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LD) $(LDFLAGS) $(if $(subst Linux,,$(SYSTEM)),,-Wl$(comma)-wrap$(comma)memcpy) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_csharp_ext.so.3 -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBGRPC_CSHARP_EXT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(LDLIBS) + $(Q) $(LD) $(LDFLAGS) $(if $(subst Linux,,$(SYSTEM)),,-Wl$(comma)-wrap$(comma)memcpy) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_csharp_ext.so.1 -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBGRPC_CSHARP_EXT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(LDLIBS) $(Q) ln -sf $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).so.1 $(Q) ln -sf $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).so endif diff --git a/templates/Makefile.template b/templates/Makefile.template index f81d643991..9fc1fe898b 100644 --- a/templates/Makefile.template +++ b/templates/Makefile.template @@ -405,7 +405,7 @@ SHARED_VERSION_CPP = -${settings.cpp_version.major} SHARED_VERSION_CSHARP = -${settings.csharp_version.major} else ifeq ($(SYSTEM),Darwin) - EXECUTABLE_SUFFIX = + EXECUTABLE_SUFFIX = SHARED_EXT_CORE = dylib SHARED_EXT_CPP = dylib SHARED_EXT_CSHARP = dylib @@ -414,7 +414,7 @@ SHARED_VERSION_CPP = SHARED_VERSION_CSHARP = else - EXECUTABLE_SUFFIX = + EXECUTABLE_SUFFIX = SHARED_EXT_CORE = so.$(CORE_VERSION) SHARED_EXT_CPP = so.$(CPP_VERSION) SHARED_EXT_CSHARP = so.$(CSHARP_VERSION) @@ -1559,7 +1559,7 @@ ifeq ($(SYSTEM),Darwin) $(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_${lang_to_var[lib.language]}).$(SHARED_EXT_${lang_to_var[lib.language]}) -dynamiclib -o ${out_libbase}.$(SHARED_EXT_${lang_to_var[lib.language]}) ${common}${link_libs} else - $(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,lib${lib.name}.so.${settings.core_version.major} -o ${out_libbase}.$(SHARED_EXT_${lang_to_var[lib.language]}) ${common}${link_libs} + $(Q) ${ld} ${ldflags} -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,lib${lib.name}.so.${settings.get(lang_to_var[lib.language].lower() + '_version').major} -o ${out_libbase}.$(SHARED_EXT_${lang_to_var[lib.language]}) ${common}${link_libs} $(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_${lang_to_var[lib.language]}).$(SHARED_EXT_${lang_to_var[lib.language]}) ${out_libbase}.so.${settings.get(lang_to_var[lib.language].lower() + '_version').major} $(Q) ln -sf $(SHARED_PREFIX)${lib.name}$(SHARED_VERSION_${lang_to_var[lib.language]}).$(SHARED_EXT_${lang_to_var[lib.language]}) ${out_libbase}.so endif -- cgit v1.2.3 From 057230b0cd08ebb4ecacd079589deaecfdcbd415 Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Fri, 24 Mar 2017 15:03:55 -0700 Subject: Minor bug --- include/grpc++/impl/codegen/completion_queue.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/grpc++/impl/codegen/completion_queue.h b/include/grpc++/impl/codegen/completion_queue.h index 025eea3ef5..bd2b33d27b 100644 --- a/include/grpc++/impl/codegen/completion_queue.h +++ b/include/grpc++/impl/codegen/completion_queue.h @@ -103,7 +103,9 @@ class CompletionQueue : private GrpcLibraryCodegen { public: /// Default constructor. Implicitly creates a \a grpc_completion_queue /// instance. - CompletionQueue() : CompletionQueue(false) {} + CompletionQueue() : CompletionQueue(false) { + InitialAvalanching(); // reserve this for the future shutdown + } /// Wrap \a take, taking ownership of the instance. /// -- cgit v1.2.3 From 74f419fe743d998bd65014d4211d843569c3cfd3 Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Fri, 24 Mar 2017 15:11:06 -0700 Subject: undo prev change --- include/grpc++/impl/codegen/completion_queue.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/grpc++/impl/codegen/completion_queue.h b/include/grpc++/impl/codegen/completion_queue.h index bd2b33d27b..025eea3ef5 100644 --- a/include/grpc++/impl/codegen/completion_queue.h +++ b/include/grpc++/impl/codegen/completion_queue.h @@ -103,9 +103,7 @@ class CompletionQueue : private GrpcLibraryCodegen { public: /// Default constructor. Implicitly creates a \a grpc_completion_queue /// instance. - CompletionQueue() : CompletionQueue(false) { - InitialAvalanching(); // reserve this for the future shutdown - } + CompletionQueue() : CompletionQueue(false) {} /// Wrap \a take, taking ownership of the instance. /// -- cgit v1.2.3 From 2c614a7a7b19633c2f1d962d05e3282486895034 Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Tue, 28 Mar 2017 12:54:20 -0700 Subject: clang --- include/grpc++/impl/codegen/sync_stream.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/grpc++/impl/codegen/sync_stream.h b/include/grpc++/impl/codegen/sync_stream.h index 7657f337f8..328d5cb1e8 100644 --- a/include/grpc++/impl/codegen/sync_stream.h +++ b/include/grpc++/impl/codegen/sync_stream.h @@ -330,7 +330,7 @@ class ClientReaderWriter final : public ClientReaderWriterInterface { ClientReaderWriter(ChannelInterface* channel, const RpcMethod& method, ClientContext* context) : context_(context), - cq_(true), // Pluckable cq + cq_(true), // Pluckable cq call_(channel->CreateCall(method, context, &cq_)) { if (!context_->initial_metadata_corked_) { CallOpSet ops; -- cgit v1.2.3 From 9a7bab5b76413f49fdeb35a2d40021ca3a0bdf04 Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Wed, 29 Mar 2017 11:51:25 -0700 Subject: Core version bump to 4.0.0 --- Makefile | 48 ++++++++++++++++++------------------ build.yaml | 2 +- build_config.rb | 2 +- src/core/lib/surface/version.c | 2 +- tools/doxygen/Doxyfile.core | 2 +- tools/doxygen/Doxyfile.core.internal | 2 +- 6 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index bfc43aab28..94f5a8fd75 100644 --- a/Makefile +++ b/Makefile @@ -411,7 +411,7 @@ E = @echo Q = @ endif -CORE_VERSION = 3.0.0-dev +CORE_VERSION = 4.0.0-dev CPP_VERSION = 1.3.0-dev CSHARP_VERSION = 1.3.0-dev @@ -461,7 +461,7 @@ SHARED_EXT_CORE = dll SHARED_EXT_CPP = dll SHARED_EXT_CSHARP = dll SHARED_PREFIX = -SHARED_VERSION_CORE = -3 +SHARED_VERSION_CORE = -4 SHARED_VERSION_CPP = -1 SHARED_VERSION_CSHARP = -1 else ifeq ($(SYSTEM),Darwin) @@ -2510,7 +2510,7 @@ install-shared_c: shared_c strip-shared_c install-pkg-config_c ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE)-dll.a $(prefix)/lib/libgpr.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgpr.so.3 + $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgpr.so.4 $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgpr.so endif $(E) "[INSTALL] Installing $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE)" @@ -2519,7 +2519,7 @@ endif ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE)-dll.a $(prefix)/lib/libgrpc.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc.so.3 + $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc.so.4 $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc.so endif $(E) "[INSTALL] Installing $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE)" @@ -2528,7 +2528,7 @@ endif ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE)-dll.a $(prefix)/lib/libgrpc_cronet.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc_cronet.so.3 + $(Q) ln -sf $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc_cronet.so.4 $(Q) ln -sf $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc_cronet.so endif $(E) "[INSTALL] Installing $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE)" @@ -2537,7 +2537,7 @@ endif ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE)-dll.a $(prefix)/lib/libgrpc_unsecure.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc_unsecure.so.3 + $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc_unsecure.so.4 $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(prefix)/lib/libgrpc_unsecure.so endif ifneq ($(SYSTEM),MINGW32) @@ -2554,7 +2554,7 @@ install-shared_cxx: shared_cxx strip-shared_cxx install-shared_c install-pkg-con ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc++$(SHARED_VERSION_CPP)-dll.a $(prefix)/lib/libgrpc++.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)grpc++$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++.so.3 + $(Q) ln -sf $(SHARED_PREFIX)grpc++$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++.so.4 $(Q) ln -sf $(SHARED_PREFIX)grpc++$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++.so endif $(E) "[INSTALL] Installing $(SHARED_PREFIX)grpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP)" @@ -2563,7 +2563,7 @@ endif ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc++_cronet$(SHARED_VERSION_CPP)-dll.a $(prefix)/lib/libgrpc++_cronet.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)grpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++_cronet.so.3 + $(Q) ln -sf $(SHARED_PREFIX)grpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++_cronet.so.4 $(Q) ln -sf $(SHARED_PREFIX)grpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++_cronet.so endif $(E) "[INSTALL] Installing $(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP)" @@ -2572,7 +2572,7 @@ endif ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc++_reflection$(SHARED_VERSION_CPP)-dll.a $(prefix)/lib/libgrpc++_reflection.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++_reflection.so.3 + $(Q) ln -sf $(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++_reflection.so.4 $(Q) ln -sf $(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++_reflection.so endif $(E) "[INSTALL] Installing $(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP)" @@ -2581,7 +2581,7 @@ endif ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure$(SHARED_VERSION_CPP)-dll.a $(prefix)/lib/libgrpc++_unsecure.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++_unsecure.so.3 + $(Q) ln -sf $(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++_unsecure.so.4 $(Q) ln -sf $(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(prefix)/lib/libgrpc++_unsecure.so endif ifneq ($(SYSTEM),MINGW32) @@ -2598,7 +2598,7 @@ install-shared_csharp: shared_csharp strip-shared_csharp ifeq ($(SYSTEM),MINGW32) $(Q) $(INSTALL) $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP)-dll.a $(prefix)/lib/libgrpc_csharp_ext.a else ifneq ($(SYSTEM),Darwin) - $(Q) ln -sf $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(prefix)/lib/libgrpc_csharp_ext.so.3 + $(Q) ln -sf $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(prefix)/lib/libgrpc_csharp_ext.so.4 $(Q) ln -sf $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(prefix)/lib/libgrpc_csharp_ext.so endif ifneq ($(SYSTEM),MINGW32) @@ -2764,8 +2764,8 @@ $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGPR_OB ifeq ($(SYSTEM),Darwin) $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgpr.so.3 -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).so.3 + $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgpr.so.4 -o $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGPR_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).so.4 $(Q) ln -sf $(SHARED_PREFIX)gpr$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgpr$(SHARED_VERSION_CORE).so endif endif @@ -3104,8 +3104,8 @@ $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(LIBGRPC_ ifeq ($(SYSTEM),Darwin) $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc.so.3 -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so.3 + $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc.so.4 -o $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so.4 $(Q) ln -sf $(SHARED_PREFIX)grpc$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc$(SHARED_VERSION_CORE).so endif endif @@ -3392,8 +3392,8 @@ $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $(L ifeq ($(SYSTEM),Darwin) $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_CRONET_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_cronet.so.3 -o $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_CRONET_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).so.3 + $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_cronet.so.4 -o $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_CRONET_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).so.4 $(Q) ln -sf $(SHARED_PREFIX)grpc_cronet$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_cronet$(SHARED_VERSION_CORE).so endif endif @@ -3921,8 +3921,8 @@ $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE): $ ifeq ($(SYSTEM),Darwin) $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_unsecure.so.3 -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBS) - $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).so.3 + $(Q) $(LD) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_unsecure.so.4 -o $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBGRPC_UNSECURE_OBJS) $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBS) + $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).so.4 $(Q) ln -sf $(SHARED_PREFIX)grpc_unsecure$(SHARED_VERSION_CORE).$(SHARED_EXT_CORE) $(LIBDIR)/$(CONFIG)/libgrpc_unsecure$(SHARED_VERSION_CORE).so endif endif @@ -4198,7 +4198,7 @@ $(LIBDIR)/$(CONFIG)/libgrpc++$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP): $(LIBGRPC+ ifeq ($(SYSTEM),Darwin) $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc++$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc++$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBGRPC++_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) -lgrpc else - $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc++.so.3 -o $(LIBDIR)/$(CONFIG)/libgrpc++$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBGRPC++_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) -lgrpc + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc++.so.4 -o $(LIBDIR)/$(CONFIG)/libgrpc++$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBGRPC++_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) -lgrpc $(Q) ln -sf $(SHARED_PREFIX)grpc++$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBDIR)/$(CONFIG)/libgrpc++$(SHARED_VERSION_CPP).so.1 $(Q) ln -sf $(SHARED_PREFIX)grpc++$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBDIR)/$(CONFIG)/libgrpc++$(SHARED_VERSION_CPP).so endif @@ -4596,7 +4596,7 @@ $(LIBDIR)/$(CONFIG)/libgrpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP): $(L ifeq ($(SYSTEM),Darwin) $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBGRPC++_CRONET_OBJS) $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) -lgpr -lgrpc_cronet else - $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc++_cronet.so.3 -o $(LIBDIR)/$(CONFIG)/libgrpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBGRPC++_CRONET_OBJS) $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) -lgpr -lgrpc_cronet + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc++_cronet.so.4 -o $(LIBDIR)/$(CONFIG)/libgrpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBGRPC++_CRONET_OBJS) $(OPENSSL_MERGE_LIBS) $(LDLIBS_SECURE) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) -lgpr -lgrpc_cronet $(Q) ln -sf $(SHARED_PREFIX)grpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBDIR)/$(CONFIG)/libgrpc++_cronet$(SHARED_VERSION_CPP).so.1 $(Q) ln -sf $(SHARED_PREFIX)grpc++_cronet$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBDIR)/$(CONFIG)/libgrpc++_cronet$(SHARED_VERSION_CPP).so endif @@ -4719,7 +4719,7 @@ $(LIBDIR)/$(CONFIG)/libgrpc++_reflection$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP): ifeq ($(SYSTEM),Darwin) $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc++_reflection$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBGRPC++_REFLECTION_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) -lgrpc++ else - $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc++_reflection.so.3 -o $(LIBDIR)/$(CONFIG)/libgrpc++_reflection$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBGRPC++_REFLECTION_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) -lgrpc++ + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc++_reflection.so.4 -o $(LIBDIR)/$(CONFIG)/libgrpc++_reflection$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBGRPC++_REFLECTION_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) -lgrpc++ $(Q) ln -sf $(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBDIR)/$(CONFIG)/libgrpc++_reflection$(SHARED_VERSION_CPP).so.1 $(Q) ln -sf $(SHARED_PREFIX)grpc++_reflection$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBDIR)/$(CONFIG)/libgrpc++_reflection$(SHARED_VERSION_CPP).so endif @@ -5077,7 +5077,7 @@ $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP): $ ifeq ($(SYSTEM),Darwin) $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBGRPC++_UNSECURE_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) -lgpr -lgrpc_unsecure else - $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc++_unsecure.so.3 -o $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBGRPC++_UNSECURE_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) -lgpr -lgrpc_unsecure + $(Q) $(LDXX) $(LDFLAGS) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc++_unsecure.so.4 -o $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBGRPC++_UNSECURE_OBJS) $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) -lgpr -lgrpc_unsecure $(Q) ln -sf $(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure$(SHARED_VERSION_CPP).so.1 $(Q) ln -sf $(SHARED_PREFIX)grpc++_unsecure$(SHARED_VERSION_CPP).$(SHARED_EXT_CPP) $(LIBDIR)/$(CONFIG)/libgrpc++_unsecure$(SHARED_VERSION_CPP).so endif @@ -5667,7 +5667,7 @@ $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHA ifeq ($(SYSTEM),Darwin) $(Q) $(LD) $(LDFLAGS) $(if $(subst Linux,,$(SYSTEM)),,-Wl$(comma)-wrap$(comma)memcpy) -L$(LIBDIR)/$(CONFIG) -install_name $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) -dynamiclib -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBGRPC_CSHARP_EXT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBS) else - $(Q) $(LD) $(LDFLAGS) $(if $(subst Linux,,$(SYSTEM)),,-Wl$(comma)-wrap$(comma)memcpy) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_csharp_ext.so.3 -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBGRPC_CSHARP_EXT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBS) + $(Q) $(LD) $(LDFLAGS) $(if $(subst Linux,,$(SYSTEM)),,-Wl$(comma)-wrap$(comma)memcpy) -L$(LIBDIR)/$(CONFIG) -shared -Wl,-soname,libgrpc_csharp_ext.so.4 -o $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBGRPC_CSHARP_EXT_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr.a $(ZLIB_MERGE_LIBS) $(CARES_MERGE_LIBS) $(LDLIBS) $(Q) ln -sf $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).so.1 $(Q) ln -sf $(SHARED_PREFIX)grpc_csharp_ext$(SHARED_VERSION_CSHARP).$(SHARED_EXT_CSHARP) $(LIBDIR)/$(CONFIG)/libgrpc_csharp_ext$(SHARED_VERSION_CSHARP).so endif diff --git a/build.yaml b/build.yaml index 6e590f4ca6..5b701a8dd3 100644 --- a/build.yaml +++ b/build.yaml @@ -12,7 +12,7 @@ settings: '#08': Use "-preN" suffixes to identify pre-release versions '#09': Per-language overrides are possible with (eg) ruby_version tag here '#10': See the expand_version.py for all the quirks here - core_version: 3.0.0-dev + core_version: 4.0.0-dev g_stands_for: gentle version: 1.3.0-dev filegroups: diff --git a/build_config.rb b/build_config.rb index b5a8c2020b..9a69070dc7 100644 --- a/build_config.rb +++ b/build_config.rb @@ -28,5 +28,5 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. module GrpcBuildConfig - CORE_WINDOWS_DLL = '/tmp/libs/opt/grpc-3.dll' + CORE_WINDOWS_DLL = '/tmp/libs/opt/grpc-4.dll' end diff --git a/src/core/lib/surface/version.c b/src/core/lib/surface/version.c index ba80bd801e..3793845559 100644 --- a/src/core/lib/surface/version.c +++ b/src/core/lib/surface/version.c @@ -36,6 +36,6 @@ #include -const char *grpc_version_string(void) { return "3.0.0-dev"; } +const char *grpc_version_string(void) { return "4.0.0-dev"; } const char *grpc_g_stands_for(void) { return "gentle"; } diff --git a/tools/doxygen/Doxyfile.core b/tools/doxygen/Doxyfile.core index 272bb4cebf..c796f10fc6 100644 --- a/tools/doxygen/Doxyfile.core +++ b/tools/doxygen/Doxyfile.core @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC Core" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 3.0.0-dev +PROJECT_NUMBER = 4.0.0-dev # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index d09ddaa04d..8d9898ab66 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC Core" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 3.0.0-dev +PROJECT_NUMBER = 4.0.0-dev # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a -- cgit v1.2.3 From 08bbdb8801f212ef3930bd4e4e3c31106756acab Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Thu, 30 Mar 2017 13:25:06 -0700 Subject: Fix cq creation code after merge --- test/cpp/microbenchmarks/bm_cq.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/cpp/microbenchmarks/bm_cq.cc b/test/cpp/microbenchmarks/bm_cq.cc index 6f153f77f5..8b26bf977c 100644 --- a/test/cpp/microbenchmarks/bm_cq.cc +++ b/test/cpp/microbenchmarks/bm_cq.cc @@ -62,7 +62,8 @@ BENCHMARK(BM_CreateDestroyCpp); static void BM_CreateDestroyCpp2(benchmark::State& state) { TrackCounters track_counters; while (state.KeepRunning()) { - grpc_completion_queue* core_cq = grpc_completion_queue_create(NULL); + grpc_completion_queue* core_cq = + grpc_completion_queue_create_for_next(NULL); CompletionQueue cq(core_cq); } track_counters.Finish(state); -- cgit v1.2.3 From fa71f6f36923f0c8ceb978fb33e716fa9346a422 Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Sat, 1 Apr 2017 17:32:34 -0700 Subject: Fix ASAN failure --- include/grpc++/impl/codegen/completion_queue.h | 23 +++++++++++++++++++++++ include/grpc++/impl/codegen/server_context.h | 3 +++ src/cpp/server/server_cc.cc | 9 +++++++-- src/cpp/server/server_context.cc | 4 ++++ 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/include/grpc++/impl/codegen/completion_queue.h b/include/grpc++/impl/codegen/completion_queue.h index 025eea3ef5..90595de482 100644 --- a/include/grpc++/impl/codegen/completion_queue.h +++ b/include/grpc++/impl/codegen/completion_queue.h @@ -247,6 +247,12 @@ class CompletionQueue : private GrpcLibraryCodegen { /// Performs a single polling pluck on \a tag. /// \warning Must not be mixed with calls to \a Next. + /// + /// TODO: sreek - This calls tag->FinalizeResult() even if the cq_ is already + /// shutdown. This is most likely a bug and if it is a bug, then change this + /// implementation to simple call the other TryPluck function with a zero + /// timeout. i.e: + /// TryPluck(tag, gpr_time_0(GPR_CLOCK_REALTIME)) void TryPluck(CompletionQueueTag* tag) { auto deadline = g_core_codegen_interface->gpr_time_0(GPR_CLOCK_REALTIME); auto ev = g_core_codegen_interface->grpc_completion_queue_pluck( @@ -258,6 +264,23 @@ class CompletionQueue : private GrpcLibraryCodegen { GPR_CODEGEN_ASSERT(!tag->FinalizeResult(&ignored, &ok)); } + /// Performs a single polling pluck on \a tag. Calls tag->FinalizeResult if + /// the pluck() was successful and returned the tag. + /// + /// This exects tag->FinalizeResult (if called) to return 'false' i.e expects + /// that the tag is internal not something that is returned to the user. + void TryPluck(CompletionQueueTag* tag, gpr_timespec deadline) { + auto ev = g_core_codegen_interface->grpc_completion_queue_pluck( + cq_, tag, deadline, nullptr); + if (ev.type == GRPC_QUEUE_TIMEOUT || ev.type == GRPC_QUEUE_SHUTDOWN) { + return; + } + + bool ok = ev.success != 0; + void* ignored = tag; + GPR_CODEGEN_ASSERT(!tag->FinalizeResult(&ignored, &ok)); + } + grpc_completion_queue* cq_; // owned gpr_atm avalanches_in_flight_; diff --git a/include/grpc++/impl/codegen/server_context.h b/include/grpc++/impl/codegen/server_context.h index bf9a9b6f1a..f84ede9eb1 100644 --- a/include/grpc++/impl/codegen/server_context.h +++ b/include/grpc++/impl/codegen/server_context.h @@ -41,6 +41,7 @@ #include #include +#include #include #include #include @@ -212,6 +213,8 @@ class ServerContext { class CompletionOp; void BeginCompletionOp(Call* call); + // Return the tag queued by BeginCompletionOp() + CompletionQueueTag* GetCompletionOpTag(); ServerContext(gpr_timespec deadline, grpc_metadata_array* arr); diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc index 6adabef763..6bb88bcd94 100644 --- a/src/cpp/server/server_cc.cc +++ b/src/cpp/server/server_cc.cc @@ -221,9 +221,14 @@ class Server::SyncRequest final : public CompletionQueueTag { MethodHandler::HandlerParameter(&call_, &ctx_, request_payload_)); global_callbacks->PostSynchronousRequest(&ctx_); request_payload_ = nullptr; - DummyTag ignored_tag; + cq_.Shutdown(); - /* Ensure the cq_ is shutdown (else this will hang indefinitely) */ + + CompletionQueueTag* op_tag = ctx_.GetCompletionOpTag(); + cq_.TryPluck(op_tag, gpr_inf_future(GPR_CLOCK_REALTIME)); + + /* Ensure the cq_ is shutdown */ + DummyTag ignored_tag; GPR_ASSERT(cq_.Pluck(&ignored_tag) == false); } diff --git a/src/cpp/server/server_context.cc b/src/cpp/server/server_context.cc index 05c05c8695..01e9c00434 100644 --- a/src/cpp/server/server_context.cc +++ b/src/cpp/server/server_context.cc @@ -166,6 +166,10 @@ void ServerContext::BeginCompletionOp(Call* call) { call->PerformOps(completion_op_); } +CompletionQueueTag* ServerContext::GetCompletionOpTag() { + return static_cast(completion_op_); +} + void ServerContext::AddInitialMetadata(const grpc::string& key, const grpc::string& value) { initial_metadata_.insert(std::make_pair(key, value)); -- cgit v1.2.3 From 4426800e6c3b8e1c535918166a1e59fea521bfd7 Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Sat, 1 Apr 2017 17:33:50 -0700 Subject: clang format --- src/cpp/server/server_cc.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc index 6bb88bcd94..f121b481c5 100644 --- a/src/cpp/server/server_cc.cc +++ b/src/cpp/server/server_cc.cc @@ -227,7 +227,7 @@ class Server::SyncRequest final : public CompletionQueueTag { CompletionQueueTag* op_tag = ctx_.GetCompletionOpTag(); cq_.TryPluck(op_tag, gpr_inf_future(GPR_CLOCK_REALTIME)); - /* Ensure the cq_ is shutdown */ + /* Ensure the cq_ is shutdown */ DummyTag ignored_tag; GPR_ASSERT(cq_.Pluck(&ignored_tag) == false); } -- cgit v1.2.3 From 3f182df7de52374e600264af7d76f1f6f73da6b8 Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Sun, 2 Apr 2017 03:44:43 -0700 Subject: Fix C asan error and check_sources_and_headers.py --- include/grpc++/impl/codegen/completion_queue.h | 1 - include/grpc++/impl/codegen/core_codegen_interface.h | 1 - test/core/end2end/tests/max_connection_age.c | 1 + test/core/end2end/tests/max_connection_idle.c | 1 + 4 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/grpc++/impl/codegen/completion_queue.h b/include/grpc++/impl/codegen/completion_queue.h index 90595de482..61617f2bdc 100644 --- a/include/grpc++/impl/codegen/completion_queue.h +++ b/include/grpc++/impl/codegen/completion_queue.h @@ -52,7 +52,6 @@ #include #include #include -#include #include struct grpc_completion_queue; diff --git a/include/grpc++/impl/codegen/core_codegen_interface.h b/include/grpc++/impl/codegen/core_codegen_interface.h index fd4767a80a..c7e10b6496 100644 --- a/include/grpc++/impl/codegen/core_codegen_interface.h +++ b/include/grpc++/impl/codegen/core_codegen_interface.h @@ -36,7 +36,6 @@ #include #include -#include #include #include #include diff --git a/test/core/end2end/tests/max_connection_age.c b/test/core/end2end/tests/max_connection_age.c index 1de54e0825..28f6323236 100644 --- a/test/core/end2end/tests/max_connection_age.c +++ b/test/core/end2end/tests/max_connection_age.c @@ -88,6 +88,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } static void test_max_age_forcibly_close(grpc_end2end_test_config config) { diff --git a/test/core/end2end/tests/max_connection_idle.c b/test/core/end2end/tests/max_connection_idle.c index 9dc1ee4766..4e5aa15a5a 100644 --- a/test/core/end2end/tests/max_connection_idle.c +++ b/test/core/end2end/tests/max_connection_idle.c @@ -105,6 +105,7 @@ static void test_max_connection_idle(grpc_end2end_test_config config) { grpc_channel_destroy(f.client); grpc_completion_queue_shutdown(f.cq); grpc_completion_queue_destroy(f.cq); + grpc_completion_queue_destroy(f.shutdown_cq); config.tear_down_data(&f); cq_verifier_destroy(cqv); -- cgit v1.2.3 From 494e72d6b4ad057bcbcf67d808fc0639c2a8724b Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 3 Apr 2017 08:43:22 -0700 Subject: Add a minimal stack test --- CMakeLists.txt | 32 +++++++++++++++ Makefile | 36 +++++++++++++++++ build.yaml | 10 +++++ test/core/channel/minimal_stack_is_minimal_test.c | 45 ++++++++++++++++++++++ tools/run_tests/generated/sources_and_headers.json | 17 ++++++++ tools/run_tests/generated/tests.json | 22 +++++++++++ vsprojects/buildtests_c.sln | 27 +++++++++++++ 7 files changed, 189 insertions(+) create mode 100644 test/core/channel/minimal_stack_is_minimal_test.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 332f8a541c..872b782b44 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -472,6 +472,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX) add_dependencies(buildtests_c memory_profile_test) endif() add_dependencies(buildtests_c message_compress_test) +add_dependencies(buildtests_c minimal_stack_is_minimal_test) add_dependencies(buildtests_c mlog_test) add_dependencies(buildtests_c multiple_server_queues_test) add_dependencies(buildtests_c murmur_hash_test) @@ -7376,6 +7377,37 @@ target_link_libraries(message_compress_test endif (gRPC_BUILD_TESTS) if (gRPC_BUILD_TESTS) +add_executable(minimal_stack_is_minimal_test + test/core/channel/minimal_stack_is_minimal_test.c +) + + +target_include_directories(minimal_stack_is_minimal_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include + PRIVATE ${BORINGSSL_ROOT_DIR}/include + PRIVATE ${PROTOBUF_ROOT_DIR}/src + PRIVATE ${BENCHMARK_ROOT_DIR}/include + PRIVATE ${ZLIB_ROOT_DIR} + PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib + PRIVATE ${CARES_BUILD_INCLUDE_DIR} + PRIVATE ${CARES_INCLUDE_DIR} + PRIVATE ${CARES_PLATFORM_INCLUDE_DIR} + PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/cares/cares + PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include +) + +target_link_libraries(minimal_stack_is_minimal_test + ${_gRPC_ALLTARGETS_LIBRARIES} + grpc_test_util + grpc + gpr_test_util + gpr +) + +endif (gRPC_BUILD_TESTS) +if (gRPC_BUILD_TESTS) + add_executable(mlog_test test/core/census/mlog_test.c ) diff --git a/Makefile b/Makefile index 8bad909fe9..e8987c85e0 100644 --- a/Makefile +++ b/Makefile @@ -1050,6 +1050,7 @@ memory_profile_client: $(BINDIR)/$(CONFIG)/memory_profile_client memory_profile_server: $(BINDIR)/$(CONFIG)/memory_profile_server memory_profile_test: $(BINDIR)/$(CONFIG)/memory_profile_test message_compress_test: $(BINDIR)/$(CONFIG)/message_compress_test +minimal_stack_is_minimal_test: $(BINDIR)/$(CONFIG)/minimal_stack_is_minimal_test mlog_test: $(BINDIR)/$(CONFIG)/mlog_test multiple_server_queues_test: $(BINDIR)/$(CONFIG)/multiple_server_queues_test murmur_hash_test: $(BINDIR)/$(CONFIG)/murmur_hash_test @@ -1421,6 +1422,7 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/memory_profile_server \ $(BINDIR)/$(CONFIG)/memory_profile_test \ $(BINDIR)/$(CONFIG)/message_compress_test \ + $(BINDIR)/$(CONFIG)/minimal_stack_is_minimal_test \ $(BINDIR)/$(CONFIG)/mlog_test \ $(BINDIR)/$(CONFIG)/multiple_server_queues_test \ $(BINDIR)/$(CONFIG)/murmur_hash_test \ @@ -1871,6 +1873,8 @@ test_c: buildtests_c $(Q) $(BINDIR)/$(CONFIG)/memory_profile_test || ( echo test memory_profile_test failed ; exit 1 ) $(E) "[RUN] Testing message_compress_test" $(Q) $(BINDIR)/$(CONFIG)/message_compress_test || ( echo test message_compress_test failed ; exit 1 ) + $(E) "[RUN] Testing minimal_stack_is_minimal_test" + $(Q) $(BINDIR)/$(CONFIG)/minimal_stack_is_minimal_test || ( echo test minimal_stack_is_minimal_test failed ; exit 1 ) $(E) "[RUN] Testing multiple_server_queues_test" $(Q) $(BINDIR)/$(CONFIG)/multiple_server_queues_test || ( echo test multiple_server_queues_test failed ; exit 1 ) $(E) "[RUN] Testing murmur_hash_test" @@ -11493,6 +11497,38 @@ endif endif +MINIMAL_STACK_IS_MINIMAL_TEST_SRC = \ + test/core/channel/minimal_stack_is_minimal_test.c \ + +MINIMAL_STACK_IS_MINIMAL_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(MINIMAL_STACK_IS_MINIMAL_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/minimal_stack_is_minimal_test: openssl_dep_error + +else + + + +$(BINDIR)/$(CONFIG)/minimal_stack_is_minimal_test: $(MINIMAL_STACK_IS_MINIMAL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LD) $(LDFLAGS) $(MINIMAL_STACK_IS_MINIMAL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/minimal_stack_is_minimal_test + +endif + +$(OBJDIR)/$(CONFIG)/test/core/channel/minimal_stack_is_minimal_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_minimal_stack_is_minimal_test: $(MINIMAL_STACK_IS_MINIMAL_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(MINIMAL_STACK_IS_MINIMAL_TEST_OBJS:.o=.dep) +endif +endif + + MLOG_TEST_SRC = \ test/core/census/mlog_test.c \ diff --git a/build.yaml b/build.yaml index de72276f56..f14f4c2ec0 100644 --- a/build.yaml +++ b/build.yaml @@ -2500,6 +2500,16 @@ targets: - grpc - gpr_test_util - gpr +- name: minimal_stack_is_minimal_test + build: test + language: c + src: + - test/core/channel/minimal_stack_is_minimal_test.c + deps: + - grpc_test_util + - grpc + - gpr_test_util + - gpr - name: mlog_test flaky: true build: test diff --git a/test/core/channel/minimal_stack_is_minimal_test.c b/test/core/channel/minimal_stack_is_minimal_test.c new file mode 100644 index 0000000000..1c12c9ebde --- /dev/null +++ b/test/core/channel/minimal_stack_is_minimal_test.c @@ -0,0 +1,45 @@ +/* + * + * Copyright 2017, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "src/core/lib/surface/channel_stack_type.h" + +int main(int argc, char **argv) { + grpc_test_init(argc, argv); + grpc_init(); + check_stack(GRPC_CLIENT_CHANNEL, "client_channel", NULL); + check_stack(GRPC_CLIENT_DIRECT_CHANNEL, "connected_channel", NULL); + check_stack(GRPC_CLIENT_SUBCHANNEL, "connected_channel", NULL); + check_stack(GRPC_SERVER_CHANNEL, "server", "connected_channel", NULL); + grpc_shutdown(); + return 0; +} diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 5d2c3840cd..254df5568d 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -1589,6 +1589,23 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "gpr", + "gpr_test_util", + "grpc", + "grpc_test_util" + ], + "headers": [], + "is_filegroup": false, + "language": "c", + "name": "minimal_stack_is_minimal_test", + "src": [ + "test/core/channel/minimal_stack_is_minimal_test.c" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "gpr", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index f2228a9e92..ddcac57a6d 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -1675,6 +1675,28 @@ "windows" ] }, + { + "args": [], + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "gtest": false, + "language": "c", + "name": "minimal_stack_is_minimal_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ] + }, { "args": [], "ci_platforms": [ diff --git a/vsprojects/buildtests_c.sln b/vsprojects/buildtests_c.sln index c8fcacf75b..1e8336c54e 100644 --- a/vsprojects/buildtests_c.sln +++ b/vsprojects/buildtests_c.sln @@ -1242,6 +1242,17 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "message_compress_test", "vc {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "minimal_stack_is_minimal_test", "vcxproj\test\minimal_stack_is_minimal_test\minimal_stack_is_minimal_test.vcxproj", "{68A54124-DFA3-4FF3-081F-70356222C977}" + ProjectSection(myProperties) = preProject + lib = "False" + EndProjectSection + ProjectSection(ProjectDependencies) = postProject + {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} = {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} + {29D16885-7228-4C31-81ED-5F9187C7F2A9} = {29D16885-7228-4C31-81ED-5F9187C7F2A9} + {EAB0A629-17A9-44DB-B5FF-E91A721FE037} = {EAB0A629-17A9-44DB-B5FF-E91A721FE037} + {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} + EndProjectSection +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mlog_test", "vcxproj\test\mlog_test\mlog_test.vcxproj", "{9345E329-80F3-DED4-FDC3-BF63FCEA2C03}" ProjectSection(myProperties) = preProject lib = "False" @@ -3513,6 +3524,22 @@ Global {07170557-CCB0-D23C-8018-C2909D115DF9}.Release-DLL|Win32.Build.0 = Release|Win32 {07170557-CCB0-D23C-8018-C2909D115DF9}.Release-DLL|x64.ActiveCfg = Release|x64 {07170557-CCB0-D23C-8018-C2909D115DF9}.Release-DLL|x64.Build.0 = Release|x64 + {68A54124-DFA3-4FF3-081F-70356222C977}.Debug|Win32.ActiveCfg = Debug|Win32 + {68A54124-DFA3-4FF3-081F-70356222C977}.Debug|x64.ActiveCfg = Debug|x64 + {68A54124-DFA3-4FF3-081F-70356222C977}.Release|Win32.ActiveCfg = Release|Win32 + {68A54124-DFA3-4FF3-081F-70356222C977}.Release|x64.ActiveCfg = Release|x64 + {68A54124-DFA3-4FF3-081F-70356222C977}.Debug|Win32.Build.0 = Debug|Win32 + {68A54124-DFA3-4FF3-081F-70356222C977}.Debug|x64.Build.0 = Debug|x64 + {68A54124-DFA3-4FF3-081F-70356222C977}.Release|Win32.Build.0 = Release|Win32 + {68A54124-DFA3-4FF3-081F-70356222C977}.Release|x64.Build.0 = Release|x64 + {68A54124-DFA3-4FF3-081F-70356222C977}.Debug-DLL|Win32.ActiveCfg = Debug|Win32 + {68A54124-DFA3-4FF3-081F-70356222C977}.Debug-DLL|Win32.Build.0 = Debug|Win32 + {68A54124-DFA3-4FF3-081F-70356222C977}.Debug-DLL|x64.ActiveCfg = Debug|x64 + {68A54124-DFA3-4FF3-081F-70356222C977}.Debug-DLL|x64.Build.0 = Debug|x64 + {68A54124-DFA3-4FF3-081F-70356222C977}.Release-DLL|Win32.ActiveCfg = Release|Win32 + {68A54124-DFA3-4FF3-081F-70356222C977}.Release-DLL|Win32.Build.0 = Release|Win32 + {68A54124-DFA3-4FF3-081F-70356222C977}.Release-DLL|x64.ActiveCfg = Release|x64 + {68A54124-DFA3-4FF3-081F-70356222C977}.Release-DLL|x64.Build.0 = Release|x64 {9345E329-80F3-DED4-FDC3-BF63FCEA2C03}.Debug|Win32.ActiveCfg = Debug|Win32 {9345E329-80F3-DED4-FDC3-BF63FCEA2C03}.Debug|x64.ActiveCfg = Debug|x64 {9345E329-80F3-DED4-FDC3-BF63FCEA2C03}.Release|Win32.ActiveCfg = Release|Win32 -- cgit v1.2.3 From 988ef83446a5b2b3a8517d1648394f97796dda4f Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 3 Apr 2017 09:44:35 -0700 Subject: Minimal stack test --- src/core/lib/channel/channel_stack_builder.c | 11 +++ src/core/lib/channel/channel_stack_builder.h | 4 + test/core/channel/minimal_stack_is_minimal_test.c | 103 +++++++++++++++++++++- 3 files changed, 114 insertions(+), 4 deletions(-) diff --git a/src/core/lib/channel/channel_stack_builder.c b/src/core/lib/channel/channel_stack_builder.c index b515b7321a..88c02edb70 100644 --- a/src/core/lib/channel/channel_stack_builder.c +++ b/src/core/lib/channel/channel_stack_builder.c @@ -113,6 +113,17 @@ grpc_channel_stack_builder_create_iterator_at_last( return create_iterator_at_filter_node(builder, &builder->end); } +bool grpc_channel_stack_builder_iterator_is_end( + grpc_channel_stack_builder_iterator *iterator) { + return iterator->node == &iterator->builder->end; +} + +const char *grpc_channel_stack_builder_iterator_filter_name( + grpc_channel_stack_builder_iterator *iterator) { + if (iterator->node->filter == NULL) return NULL; + return iterator->node->filter->name; +} + bool grpc_channel_stack_builder_move_next( grpc_channel_stack_builder_iterator *iterator) { if (iterator->node == &iterator->builder->end) return false; diff --git a/src/core/lib/channel/channel_stack_builder.h b/src/core/lib/channel/channel_stack_builder.h index 8adf38e27b..c78111b00d 100644 --- a/src/core/lib/channel/channel_stack_builder.h +++ b/src/core/lib/channel/channel_stack_builder.h @@ -98,6 +98,10 @@ bool grpc_channel_stack_builder_iterator_is_first( bool grpc_channel_stack_builder_iterator_is_end( grpc_channel_stack_builder_iterator *iterator); +/// What is the name of the filter at this iterator position? +const char *grpc_channel_stack_builder_iterator_filter_name( + grpc_channel_stack_builder_iterator *iterator); + /// Move an iterator to the next item bool grpc_channel_stack_builder_move_next( grpc_channel_stack_builder_iterator *iterator); diff --git a/test/core/channel/minimal_stack_is_minimal_test.c b/test/core/channel/minimal_stack_is_minimal_test.c index 1c12c9ebde..622ca0ee03 100644 --- a/test/core/channel/minimal_stack_is_minimal_test.c +++ b/test/core/channel/minimal_stack_is_minimal_test.c @@ -31,15 +31,110 @@ * */ +#include +#include +#include +#include + +#include "src/core/lib/channel/channel_stack_builder.h" +#include "src/core/lib/support/string.h" +#include "src/core/lib/surface/channel_init.h" #include "src/core/lib/surface/channel_stack_type.h" +#include "src/core/lib/transport/transport_impl.h" +#include "test/core/util/test_config.h" + +static int check_stack(const char *transport_name, grpc_channel_args *init_args, + grpc_channel_stack_type channel_stack_type, ...) { + // create dummy channel stack + grpc_channel_stack_builder *builder = grpc_channel_stack_builder_create(); + grpc_transport_vtable fake_transport_vtable = {.name = transport_name}; + grpc_transport fake_transport = {.vtable = &fake_transport_vtable}; + grpc_arg arg = {.type = GRPC_ARG_INTEGER, + .key = GRPC_ARG_MINIMAL_STACK, + .value.integer = 1}; + grpc_channel_stack_builder_set_target(builder, "foo.test.google.fr"); + grpc_channel_args *channel_args = + grpc_channel_args_copy_and_add(init_args, &arg, 1); + if (transport_name != NULL) { + grpc_channel_stack_builder_set_transport(builder, &fake_transport); + } + { + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_channel_stack_builder_set_channel_arguments(&exec_ctx, builder, + channel_args); + GPR_ASSERT( + grpc_channel_init_create_stack(&exec_ctx, builder, channel_stack_type)); + grpc_exec_ctx_finish(&exec_ctx); + } + + // build up our expectation list + gpr_strvec v; + gpr_strvec_init(&v); + va_list args; + va_start(args, channel_stack_type); + for (;;) { + char *a = va_arg(args, char *); + if (a == NULL) break; + if (v.count != 0) gpr_strvec_add(&v, gpr_strdup(", ")); + gpr_strvec_add(&v, gpr_strdup(a)); + } + va_end(args); + char *expect = gpr_strvec_flatten(&v, NULL); + gpr_strvec_destroy(&v); + + // build up our "got" list + gpr_strvec_init(&v); + grpc_channel_stack_builder_iterator *it = + grpc_channel_stack_builder_create_iterator_at_first(builder); + while (grpc_channel_stack_builder_move_next(it)) { + const char *name = grpc_channel_stack_builder_iterator_filter_name(it); + if (name == NULL) continue; + if (v.count != 0) gpr_strvec_add(&v, gpr_strdup(", ")); + gpr_strvec_add(&v, gpr_strdup(name)); + } + char *got = gpr_strvec_flatten(&v, NULL); + gpr_strvec_destroy(&v); + + // figure out result, log if there's an error + int result = 0; + if (0 != strcmp(got, expect)) { + gpr_log(GPR_ERROR, + "FAILED transport=%s; stack_type=%d: expected '%s'; got '%s'", + transport_name, channel_stack_type, expect, got); + result = 1; + } + + gpr_free(got); + gpr_free(expect); + + { + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_channel_stack_builder_destroy(&exec_ctx, builder); + grpc_exec_ctx_finish(&exec_ctx); + } + + return result; +} int main(int argc, char **argv) { grpc_test_init(argc, argv); grpc_init(); - check_stack(GRPC_CLIENT_CHANNEL, "client_channel", NULL); - check_stack(GRPC_CLIENT_DIRECT_CHANNEL, "connected_channel", NULL); - check_stack(GRPC_CLIENT_SUBCHANNEL, "connected_channel", NULL); - check_stack(GRPC_SERVER_CHANNEL, "server", "connected_channel", NULL); + int errors = 0; + errors += check_stack("unknown", NULL, GRPC_CLIENT_DIRECT_CHANNEL, + "connected", NULL); + errors += + check_stack("unknown", NULL, GRPC_CLIENT_SUBCHANNEL, "connected", NULL); + errors += check_stack("unknown", NULL, GRPC_SERVER_CHANNEL, "server", + "connected", NULL); + errors += check_stack("chttp2", NULL, GRPC_CLIENT_DIRECT_CHANNEL, + "http-client", "connected", NULL); + errors += + check_stack("chttp2", NULL, GRPC_CLIENT_SUBCHANNEL, "connected", NULL); + errors += check_stack("chttp2", NULL, GRPC_SERVER_CHANNEL, "server", + "http-server", "connected", NULL); + errors += + check_stack(NULL, NULL, GRPC_CLIENT_CHANNEL, "client-channel", NULL); + GPR_ASSERT(errors == 0); grpc_shutdown(); return 0; } -- cgit v1.2.3 From 4f89b0b13958fac3d0caea76829bda9b36fb76fa Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 3 Apr 2017 10:00:17 -0700 Subject: Refine test to what we really expect --- src/core/lib/surface/channel_init.c | 21 +---- src/core/lib/surface/channel_stack_type.c | 18 +++++ src/core/lib/surface/channel_stack_type.h | 2 + test/core/channel/minimal_stack_is_minimal_test.c | 94 ++++++++++++++++++----- 4 files changed, 98 insertions(+), 37 deletions(-) diff --git a/src/core/lib/surface/channel_init.c b/src/core/lib/surface/channel_init.c index 7acb444d9b..20f5753004 100644 --- a/src/core/lib/surface/channel_init.c +++ b/src/core/lib/surface/channel_init.c @@ -104,30 +104,13 @@ void grpc_channel_init_shutdown(void) { } } -static const char *name_for_type(grpc_channel_stack_type type) { - switch (type) { - case GRPC_CLIENT_CHANNEL: - return "CLIENT_CHANNEL"; - case GRPC_CLIENT_SUBCHANNEL: - return "CLIENT_SUBCHANNEL"; - case GRPC_SERVER_CHANNEL: - return "SERVER_CHANNEL"; - case GRPC_CLIENT_LAME_CHANNEL: - return "CLIENT_LAME_CHANNEL"; - case GRPC_CLIENT_DIRECT_CHANNEL: - return "CLIENT_DIRECT_CHANNEL"; - case GRPC_NUM_CHANNEL_STACK_TYPES: - break; - } - GPR_UNREACHABLE_CODE(return "UNKNOWN"); -} - bool grpc_channel_init_create_stack(grpc_exec_ctx *exec_ctx, grpc_channel_stack_builder *builder, grpc_channel_stack_type type) { GPR_ASSERT(g_finalized); - grpc_channel_stack_builder_set_name(builder, name_for_type(type)); + grpc_channel_stack_builder_set_name(builder, + grpc_channel_stack_type_string(type)); for (size_t i = 0; i < g_slots[type].num_slots; i++) { const stage_slot *slot = &g_slots[type].slots[i]; diff --git a/src/core/lib/surface/channel_stack_type.c b/src/core/lib/surface/channel_stack_type.c index c35d603ca3..ed3b53fb36 100644 --- a/src/core/lib/surface/channel_stack_type.c +++ b/src/core/lib/surface/channel_stack_type.c @@ -52,3 +52,21 @@ bool grpc_channel_stack_type_is_client(grpc_channel_stack_type type) { } GPR_UNREACHABLE_CODE(return true;); } + +const char *grpc_channel_stack_type_string(grpc_channel_stack_type type) { + switch (type) { + case GRPC_CLIENT_CHANNEL: + return "CLIENT_CHANNEL"; + case GRPC_CLIENT_SUBCHANNEL: + return "CLIENT_SUBCHANNEL"; + case GRPC_SERVER_CHANNEL: + return "SERVER_CHANNEL"; + case GRPC_CLIENT_LAME_CHANNEL: + return "CLIENT_LAME_CHANNEL"; + case GRPC_CLIENT_DIRECT_CHANNEL: + return "CLIENT_DIRECT_CHANNEL"; + case GRPC_NUM_CHANNEL_STACK_TYPES: + break; + } + GPR_UNREACHABLE_CODE(return "UNKNOWN"); +} diff --git a/src/core/lib/surface/channel_stack_type.h b/src/core/lib/surface/channel_stack_type.h index 4eea4f1b01..ccf4e53d27 100644 --- a/src/core/lib/surface/channel_stack_type.h +++ b/src/core/lib/surface/channel_stack_type.h @@ -55,4 +55,6 @@ typedef enum { bool grpc_channel_stack_type_is_client(grpc_channel_stack_type type); +const char *grpc_channel_stack_type_string(grpc_channel_stack_type type); + #endif /* GRPC_CORE_LIB_SURFACE_CHANNEL_STACK_TYPE_H */ diff --git a/test/core/channel/minimal_stack_is_minimal_test.c b/test/core/channel/minimal_stack_is_minimal_test.c index 622ca0ee03..de8f78fb1a 100644 --- a/test/core/channel/minimal_stack_is_minimal_test.c +++ b/test/core/channel/minimal_stack_is_minimal_test.c @@ -43,18 +43,15 @@ #include "src/core/lib/transport/transport_impl.h" #include "test/core/util/test_config.h" -static int check_stack(const char *transport_name, grpc_channel_args *init_args, +static int check_stack(const char *file, int line, const char *transport_name, + grpc_channel_args *init_args, grpc_channel_stack_type channel_stack_type, ...) { // create dummy channel stack grpc_channel_stack_builder *builder = grpc_channel_stack_builder_create(); grpc_transport_vtable fake_transport_vtable = {.name = transport_name}; grpc_transport fake_transport = {.vtable = &fake_transport_vtable}; - grpc_arg arg = {.type = GRPC_ARG_INTEGER, - .key = GRPC_ARG_MINIMAL_STACK, - .value.integer = 1}; grpc_channel_stack_builder_set_target(builder, "foo.test.google.fr"); - grpc_channel_args *channel_args = - grpc_channel_args_copy_and_add(init_args, &arg, 1); + grpc_channel_args *channel_args = grpc_channel_args_copy(init_args); if (transport_name != NULL) { grpc_channel_stack_builder_set_transport(builder, &fake_transport); } @@ -98,10 +95,41 @@ static int check_stack(const char *transport_name, grpc_channel_args *init_args, // figure out result, log if there's an error int result = 0; if (0 != strcmp(got, expect)) { - gpr_log(GPR_ERROR, - "FAILED transport=%s; stack_type=%d: expected '%s'; got '%s'", - transport_name, channel_stack_type, expect, got); + gpr_strvec_init(&v); + gpr_strvec_add(&v, gpr_strdup("{")); + for (size_t i = 0; i < channel_args->num_args; i++) { + if (i > 0) gpr_strvec_add(&v, gpr_strdup(", ")); + gpr_strvec_add(&v, gpr_strdup(channel_args->args[i].key)); + gpr_strvec_add(&v, gpr_strdup("=")); + switch (channel_args->args[i].type) { + case GRPC_ARG_INTEGER: { + char *tmp; + gpr_asprintf(&tmp, "%d", channel_args->args[i].value.integer); + gpr_strvec_add(&v, tmp); + break; + } + case GRPC_ARG_STRING: + gpr_strvec_add(&v, gpr_strdup(channel_args->args[i].value.string)); + break; + case GRPC_ARG_POINTER: { + char *tmp; + gpr_asprintf(&tmp, "%p", channel_args->args[i].value.pointer.p); + gpr_strvec_add(&v, tmp); + break; + } + } + } + gpr_strvec_add(&v, gpr_strdup("}")); + char *args_str = gpr_strvec_flatten(&v, NULL); + gpr_strvec_destroy(&v); + + gpr_log(file, line, GPR_LOG_SEVERITY_ERROR, + "FAILED transport=%s; stack_type=%s; %s: expected '%s'; got '%s'", + transport_name, grpc_channel_stack_type_string(channel_stack_type), + args_str, expect, got); result = 1; + + gpr_free(args_str); } gpr_free(got); @@ -110,30 +138,60 @@ static int check_stack(const char *transport_name, grpc_channel_args *init_args, { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_channel_stack_builder_destroy(&exec_ctx, builder); + grpc_channel_args_destroy(&exec_ctx, channel_args); grpc_exec_ctx_finish(&exec_ctx); } return result; } +#define CHECK_STACK(...) check_stack(__FILE__, __LINE__, __VA_ARGS__) + int main(int argc, char **argv) { grpc_test_init(argc, argv); grpc_init(); int errors = 0; - errors += check_stack("unknown", NULL, GRPC_CLIENT_DIRECT_CHANNEL, + + // tests with a minimal stack + grpc_arg minimal_stack_arg = {.type = GRPC_ARG_INTEGER, + .key = GRPC_ARG_MINIMAL_STACK, + .value.integer = 1}; + grpc_channel_args minimal_stack_args = {.num_args = 1, + .args = &minimal_stack_arg}; + errors += CHECK_STACK("unknown", &minimal_stack_args, + GRPC_CLIENT_DIRECT_CHANNEL, "connected", NULL); + errors += CHECK_STACK("unknown", &minimal_stack_args, GRPC_CLIENT_SUBCHANNEL, "connected", NULL); + errors += CHECK_STACK("unknown", &minimal_stack_args, GRPC_SERVER_CHANNEL, + "server", "connected", NULL); errors += - check_stack("unknown", NULL, GRPC_CLIENT_SUBCHANNEL, "connected", NULL); - errors += check_stack("unknown", NULL, GRPC_SERVER_CHANNEL, "server", + CHECK_STACK("chttp2", &minimal_stack_args, GRPC_CLIENT_DIRECT_CHANNEL, + "http-client", "connected", NULL); + errors += CHECK_STACK("chttp2", &minimal_stack_args, GRPC_CLIENT_SUBCHANNEL, "connected", NULL); - errors += check_stack("chttp2", NULL, GRPC_CLIENT_DIRECT_CHANNEL, - "http-client", "connected", NULL); + errors += CHECK_STACK("chttp2", &minimal_stack_args, GRPC_SERVER_CHANNEL, + "server", "http-server", "connected", NULL); + errors += CHECK_STACK(NULL, &minimal_stack_args, GRPC_CLIENT_CHANNEL, + "client-channel", NULL); + + // tests with a default stack + errors += CHECK_STACK("unknown", NULL, GRPC_CLIENT_DIRECT_CHANNEL, "compress", + "deadline", "connected", NULL); + errors += + CHECK_STACK("unknown", NULL, GRPC_CLIENT_SUBCHANNEL, "connected", NULL); + errors += CHECK_STACK("unknown", NULL, GRPC_SERVER_CHANNEL, "server", + "compress", "deadline", "connected", NULL); errors += - check_stack("chttp2", NULL, GRPC_CLIENT_SUBCHANNEL, "connected", NULL); - errors += check_stack("chttp2", NULL, GRPC_SERVER_CHANNEL, "server", - "http-server", "connected", NULL); + CHECK_STACK("chttp2", NULL, GRPC_CLIENT_DIRECT_CHANNEL, "http-client", + "compress", "deadline", "connected", NULL); + errors += CHECK_STACK("chttp2", NULL, GRPC_CLIENT_SUBCHANNEL, "http-client", + "connected", NULL); errors += - check_stack(NULL, NULL, GRPC_CLIENT_CHANNEL, "client-channel", NULL); + CHECK_STACK("chttp2", NULL, GRPC_SERVER_CHANNEL, "server", "http-server", + "compress", "deadline", "connected", NULL); + errors += CHECK_STACK(NULL, NULL, GRPC_CLIENT_CHANNEL, "compress", + "client-channel", NULL); + GPR_ASSERT(errors == 0); grpc_shutdown(); return 0; -- cgit v1.2.3 From 9b3648a28e636398788737ce83982a4cb061031b Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 3 Apr 2017 12:25:19 -0700 Subject: Optionalize message_size_filter --- BUILD | 4 +- CMakeLists.txt | 9 +- Makefile | 9 +- binding.gyp | 2 +- build.yaml | 12 +- config.m4 | 3 +- gRPC-Core.podspec | 8 +- grpc.gemspec | 4 +- package.xml | 4 +- src/core/ext/filters/max_age/max_age_filter.c | 2 +- .../ext/filters/message_size/message_size_filter.c | 331 +++++++++++++++++++++ .../ext/filters/message_size/message_size_filter.h | 39 +++ src/core/lib/channel/message_size_filter.c | 267 ----------------- src/core/lib/channel/message_size_filter.h | 39 --- src/core/lib/surface/init.c | 10 - src/core/plugin_registry/grpc_plugin_registry.c | 4 + .../grpc_unsecure_plugin_registry.c | 4 + src/python/grpcio/grpc_core_dependencies.py | 2 +- test/cpp/microbenchmarks/bm_call_create.cc | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 - tools/doxygen/Doxyfile.core.internal | 4 +- tools/run_tests/generated/sources_and_headers.json | 23 +- vsprojects/vcxproj/grpc++/grpc++.vcxproj | 3 - vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters | 6 - .../grpc++_unsecure/grpc++_unsecure.vcxproj | 3 - .../grpc++_unsecure.vcxproj.filters | 6 - vsprojects/vcxproj/grpc/grpc.vcxproj | 6 +- vsprojects/vcxproj/grpc/grpc.vcxproj.filters | 15 +- .../vcxproj/grpc_test_util/grpc_test_util.vcxproj | 3 - .../grpc_test_util/grpc_test_util.vcxproj.filters | 6 - .../vcxproj/grpc_unsecure/grpc_unsecure.vcxproj | 6 +- .../grpc_unsecure/grpc_unsecure.vcxproj.filters | 15 +- .../minimal_stack_is_minimal_test.vcxproj | 199 +++++++++++++ .../minimal_stack_is_minimal_test.vcxproj.filters | 21 ++ 34 files changed, 674 insertions(+), 399 deletions(-) create mode 100644 src/core/ext/filters/message_size/message_size_filter.c create mode 100644 src/core/ext/filters/message_size/message_size_filter.h delete mode 100644 src/core/lib/channel/message_size_filter.c delete mode 100644 src/core/lib/channel/message_size_filter.h create mode 100644 vsprojects/vcxproj/test/minimal_stack_is_minimal_test/minimal_stack_is_minimal_test.vcxproj create mode 100644 vsprojects/vcxproj/test/minimal_stack_is_minimal_test/minimal_stack_is_minimal_test.vcxproj.filters diff --git a/BUILD b/BUILD index 77ea833308..9d183c8e2b 100644 --- a/BUILD +++ b/BUILD @@ -437,7 +437,7 @@ grpc_cc_library( "src/core/lib/channel/http_client_filter.c", "src/core/lib/channel/http_server_filter.c", "src/core/ext/filters/max_age/max_age_filter.c", - "src/core/lib/channel/message_size_filter.c", + "src/core/ext/filters/message_size/message_size_filter.c", "src/core/lib/compression/compression.c", "src/core/lib/compression/message_compress.c", "src/core/lib/debug/trace.c", @@ -565,7 +565,7 @@ grpc_cc_library( "src/core/lib/channel/http_client_filter.h", "src/core/lib/channel/http_server_filter.h", "src/core/ext/filters/max_age/max_age_filter.h", - "src/core/lib/channel/message_size_filter.h", + "src/core/ext/filters/message_size/message_size_filter.h", "src/core/lib/compression/algorithm_metadata.h", "src/core/lib/compression/message_compress.h", "src/core/lib/debug/trace.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 872b782b44..441be29c0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -919,7 +919,6 @@ add_library(grpc src/core/lib/channel/handshaker_registry.c src/core/lib/channel/http_client_filter.c src/core/lib/channel/http_server_filter.c - src/core/lib/channel/message_size_filter.c src/core/lib/compression/compression.c src/core/lib/compression/message_compress.c src/core/lib/debug/trace.c @@ -1139,6 +1138,7 @@ add_library(grpc src/core/ext/census/trace_context.c src/core/ext/census/tracing.c src/core/ext/filters/max_age/max_age_filter.c + src/core/ext/filters/message_size/message_size_filter.c src/core/plugin_registry/grpc_plugin_registry.c ) @@ -1241,7 +1241,6 @@ add_library(grpc_cronet src/core/lib/channel/handshaker_registry.c src/core/lib/channel/http_client_filter.c src/core/lib/channel/http_server_filter.c - src/core/lib/channel/message_size_filter.c src/core/lib/compression/compression.c src/core/lib/compression/message_compress.c src/core/lib/debug/trace.c @@ -1549,7 +1548,6 @@ add_library(grpc_test_util src/core/lib/channel/handshaker_registry.c src/core/lib/channel/http_client_filter.c src/core/lib/channel/http_server_filter.c - src/core/lib/channel/message_size_filter.c src/core/lib/compression/compression.c src/core/lib/compression/message_compress.c src/core/lib/debug/trace.c @@ -1809,7 +1807,6 @@ add_library(grpc_unsecure src/core/lib/channel/handshaker_registry.c src/core/lib/channel/http_client_filter.c src/core/lib/channel/http_server_filter.c - src/core/lib/channel/message_size_filter.c src/core/lib/compression/compression.c src/core/lib/compression/message_compress.c src/core/lib/debug/trace.c @@ -2000,6 +1997,7 @@ add_library(grpc_unsecure src/core/ext/census/trace_context.c src/core/ext/census/tracing.c src/core/ext/filters/max_age/max_age_filter.c + src/core/ext/filters/message_size/message_size_filter.c src/core/plugin_registry/grpc_unsecure_plugin_registry.c ) @@ -2225,7 +2223,6 @@ add_library(grpc++ src/core/lib/channel/handshaker_registry.c src/core/lib/channel/http_client_filter.c src/core/lib/channel/http_server_filter.c - src/core/lib/channel/message_size_filter.c src/core/lib/compression/compression.c src/core/lib/compression/message_compress.c src/core/lib/debug/trace.c @@ -2555,7 +2552,6 @@ add_library(grpc++_cronet src/core/lib/channel/handshaker_registry.c src/core/lib/channel/http_client_filter.c src/core/lib/channel/http_server_filter.c - src/core/lib/channel/message_size_filter.c src/core/lib/compression/compression.c src/core/lib/compression/message_compress.c src/core/lib/debug/trace.c @@ -3253,7 +3249,6 @@ add_library(grpc++_unsecure src/core/lib/channel/handshaker_registry.c src/core/lib/channel/http_client_filter.c src/core/lib/channel/http_server_filter.c - src/core/lib/channel/message_size_filter.c src/core/lib/compression/compression.c src/core/lib/compression/message_compress.c src/core/lib/debug/trace.c diff --git a/Makefile b/Makefile index e8987c85e0..c0d0a63a83 100644 --- a/Makefile +++ b/Makefile @@ -2824,7 +2824,6 @@ LIBGRPC_SRC = \ src/core/lib/channel/handshaker_registry.c \ src/core/lib/channel/http_client_filter.c \ src/core/lib/channel/http_server_filter.c \ - src/core/lib/channel/message_size_filter.c \ src/core/lib/compression/compression.c \ src/core/lib/compression/message_compress.c \ src/core/lib/debug/trace.c \ @@ -3044,6 +3043,7 @@ LIBGRPC_SRC = \ src/core/ext/census/trace_context.c \ src/core/ext/census/tracing.c \ src/core/ext/filters/max_age/max_age_filter.c \ + src/core/ext/filters/message_size/message_size_filter.c \ src/core/plugin_registry/grpc_plugin_registry.c \ PUBLIC_HEADERS_C += \ @@ -3144,7 +3144,6 @@ LIBGRPC_CRONET_SRC = \ src/core/lib/channel/handshaker_registry.c \ src/core/lib/channel/http_client_filter.c \ src/core/lib/channel/http_server_filter.c \ - src/core/lib/channel/message_size_filter.c \ src/core/lib/compression/compression.c \ src/core/lib/compression/message_compress.c \ src/core/lib/debug/trace.c \ @@ -3451,7 +3450,6 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/lib/channel/handshaker_registry.c \ src/core/lib/channel/http_client_filter.c \ src/core/lib/channel/http_server_filter.c \ - src/core/lib/channel/message_size_filter.c \ src/core/lib/compression/compression.c \ src/core/lib/compression/message_compress.c \ src/core/lib/debug/trace.c \ @@ -3683,7 +3681,6 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/channel/handshaker_registry.c \ src/core/lib/channel/http_client_filter.c \ src/core/lib/channel/http_server_filter.c \ - src/core/lib/channel/message_size_filter.c \ src/core/lib/compression/compression.c \ src/core/lib/compression/message_compress.c \ src/core/lib/debug/trace.c \ @@ -3874,6 +3871,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/census/trace_context.c \ src/core/ext/census/tracing.c \ src/core/ext/filters/max_age/max_age_filter.c \ + src/core/ext/filters/message_size/message_size_filter.c \ src/core/plugin_registry/grpc_unsecure_plugin_registry.c \ PUBLIC_HEADERS_C += \ @@ -4076,7 +4074,6 @@ LIBGRPC++_SRC = \ src/core/lib/channel/handshaker_registry.c \ src/core/lib/channel/http_client_filter.c \ src/core/lib/channel/http_server_filter.c \ - src/core/lib/channel/message_size_filter.c \ src/core/lib/compression/compression.c \ src/core/lib/compression/message_compress.c \ src/core/lib/debug/trace.c \ @@ -4414,7 +4411,6 @@ LIBGRPC++_CRONET_SRC = \ src/core/lib/channel/handshaker_registry.c \ src/core/lib/channel/http_client_filter.c \ src/core/lib/channel/http_server_filter.c \ - src/core/lib/channel/message_size_filter.c \ src/core/lib/compression/compression.c \ src/core/lib/compression/message_compress.c \ src/core/lib/debug/trace.c \ @@ -5104,7 +5100,6 @@ LIBGRPC++_UNSECURE_SRC = \ src/core/lib/channel/handshaker_registry.c \ src/core/lib/channel/http_client_filter.c \ src/core/lib/channel/http_server_filter.c \ - src/core/lib/channel/message_size_filter.c \ src/core/lib/compression/compression.c \ src/core/lib/compression/message_compress.c \ src/core/lib/debug/trace.c \ diff --git a/binding.gyp b/binding.gyp index f3c7252d96..01bd1ee43f 100644 --- a/binding.gyp +++ b/binding.gyp @@ -626,7 +626,6 @@ 'src/core/lib/channel/handshaker_registry.c', 'src/core/lib/channel/http_client_filter.c', 'src/core/lib/channel/http_server_filter.c', - 'src/core/lib/channel/message_size_filter.c', 'src/core/lib/compression/compression.c', 'src/core/lib/compression/message_compress.c', 'src/core/lib/debug/trace.c', @@ -846,6 +845,7 @@ 'src/core/ext/census/trace_context.c', 'src/core/ext/census/tracing.c', 'src/core/ext/filters/max_age/max_age_filter.c', + 'src/core/ext/filters/message_size/message_size_filter.c', 'src/core/plugin_registry/grpc_plugin_registry.c', ], "conditions": [ diff --git a/build.yaml b/build.yaml index f14f4c2ec0..6c87210e65 100644 --- a/build.yaml +++ b/build.yaml @@ -185,7 +185,6 @@ filegroups: - src/core/lib/channel/handshaker_registry.h - src/core/lib/channel/http_client_filter.h - src/core/lib/channel/http_server_filter.h - - src/core/lib/channel/message_size_filter.h - src/core/lib/compression/algorithm_metadata.h - src/core/lib/compression/message_compress.h - src/core/lib/debug/trace.h @@ -295,7 +294,6 @@ filegroups: - src/core/lib/channel/handshaker_registry.c - src/core/lib/channel/http_client_filter.c - src/core/lib/channel/http_server_filter.c - - src/core/lib/channel/message_size_filter.c - src/core/lib/compression/compression.c - src/core/lib/compression/message_compress.c - src/core/lib/debug/trace.c @@ -533,6 +531,14 @@ filegroups: plugin: grpc_max_age_filter uses: - grpc_base +- name: grpc_message_size_filter + headers: + - src/core/ext/filters/message_size/message_size_filter.h + src: + - src/core/ext/filters/message_size/message_size_filter.c + plugin: grpc_message_size_filter + uses: + - grpc_base - name: grpc_resolver_dns_ares headers: - src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h @@ -997,6 +1003,7 @@ libs: - grpc_secure - census - grpc_max_age_filter + - grpc_message_size_filter generate_plugin_registry: true secure: true vs_packages: @@ -1094,6 +1101,7 @@ libs: - grpc_lb_policy_round_robin - census - grpc_max_age_filter + - grpc_message_size_filter generate_plugin_registry: true secure: false vs_project_guid: '{46CEDFFF-9692-456A-AA24-38B5D6BCF4C5}' diff --git a/config.m4 b/config.m4 index 2846781031..d830fa17bf 100644 --- a/config.m4 +++ b/config.m4 @@ -94,7 +94,6 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/channel/handshaker_registry.c \ src/core/lib/channel/http_client_filter.c \ src/core/lib/channel/http_server_filter.c \ - src/core/lib/channel/message_size_filter.c \ src/core/lib/compression/compression.c \ src/core/lib/compression/message_compress.c \ src/core/lib/debug/trace.c \ @@ -314,6 +313,7 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/census/trace_context.c \ src/core/ext/census/tracing.c \ src/core/ext/filters/max_age/max_age_filter.c \ + src/core/ext/filters/message_size/message_size_filter.c \ src/core/plugin_registry/grpc_plugin_registry.c \ src/boringssl/err_data.c \ third_party/boringssl/crypto/aes/aes.c \ @@ -639,6 +639,7 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/sockaddr) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/load_reporting) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/max_age) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/message_size) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/alpn) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/client) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/client/insecure) diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 83c19afc24..8f39374693 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -267,7 +267,6 @@ Pod::Spec.new do |s| 'src/core/lib/channel/handshaker_registry.h', 'src/core/lib/channel/http_client_filter.h', 'src/core/lib/channel/http_server_filter.h', - 'src/core/lib/channel/message_size_filter.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/message_compress.h', 'src/core/lib/debug/trace.h', @@ -457,6 +456,7 @@ Pod::Spec.new do |s| 'src/core/ext/census/trace_string.h', 'src/core/ext/census/tracing.h', 'src/core/ext/filters/max_age/max_age_filter.h', + 'src/core/ext/filters/message_size/message_size_filter.h', 'src/core/lib/surface/init.c', 'src/core/lib/channel/channel_args.c', 'src/core/lib/channel/channel_stack.c', @@ -469,7 +469,6 @@ Pod::Spec.new do |s| 'src/core/lib/channel/handshaker_registry.c', 'src/core/lib/channel/http_client_filter.c', 'src/core/lib/channel/http_server_filter.c', - 'src/core/lib/channel/message_size_filter.c', 'src/core/lib/compression/compression.c', 'src/core/lib/compression/message_compress.c', 'src/core/lib/debug/trace.c', @@ -689,6 +688,7 @@ Pod::Spec.new do |s| 'src/core/ext/census/trace_context.c', 'src/core/ext/census/tracing.c', 'src/core/ext/filters/max_age/max_age_filter.c', + 'src/core/ext/filters/message_size/message_size_filter.c', 'src/core/plugin_registry/grpc_plugin_registry.c' ss.private_header_files = 'src/core/lib/profiling/timers.h', @@ -717,7 +717,6 @@ Pod::Spec.new do |s| 'src/core/lib/channel/handshaker_registry.h', 'src/core/lib/channel/http_client_filter.h', 'src/core/lib/channel/http_server_filter.h', - 'src/core/lib/channel/message_size_filter.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/message_compress.h', 'src/core/lib/debug/trace.h', @@ -906,7 +905,8 @@ Pod::Spec.new do |s| 'src/core/ext/census/trace_status.h', 'src/core/ext/census/trace_string.h', 'src/core/ext/census/tracing.h', - 'src/core/ext/filters/max_age/max_age_filter.h' + 'src/core/ext/filters/max_age/max_age_filter.h', + 'src/core/ext/filters/message_size/message_size_filter.h' end s.subspec 'Cronet-Interface' do |ss| diff --git a/grpc.gemspec b/grpc.gemspec index a3a5870761..60fc0a208a 100755 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -183,7 +183,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/handshaker_registry.h ) s.files += %w( src/core/lib/channel/http_client_filter.h ) s.files += %w( src/core/lib/channel/http_server_filter.h ) - s.files += %w( src/core/lib/channel/message_size_filter.h ) s.files += %w( src/core/lib/compression/algorithm_metadata.h ) s.files += %w( src/core/lib/compression/message_compress.h ) s.files += %w( src/core/lib/debug/trace.h ) @@ -373,6 +372,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/census/trace_string.h ) s.files += %w( src/core/ext/census/tracing.h ) s.files += %w( src/core/ext/filters/max_age/max_age_filter.h ) + s.files += %w( src/core/ext/filters/message_size/message_size_filter.h ) s.files += %w( src/core/lib/surface/init.c ) s.files += %w( src/core/lib/channel/channel_args.c ) s.files += %w( src/core/lib/channel/channel_stack.c ) @@ -385,7 +385,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/handshaker_registry.c ) s.files += %w( src/core/lib/channel/http_client_filter.c ) s.files += %w( src/core/lib/channel/http_server_filter.c ) - s.files += %w( src/core/lib/channel/message_size_filter.c ) s.files += %w( src/core/lib/compression/compression.c ) s.files += %w( src/core/lib/compression/message_compress.c ) s.files += %w( src/core/lib/debug/trace.c ) @@ -605,6 +604,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/census/trace_context.c ) s.files += %w( src/core/ext/census/tracing.c ) s.files += %w( src/core/ext/filters/max_age/max_age_filter.c ) + s.files += %w( src/core/ext/filters/message_size/message_size_filter.c ) s.files += %w( src/core/plugin_registry/grpc_plugin_registry.c ) s.files += %w( third_party/boringssl/crypto/aes/internal.h ) s.files += %w( third_party/boringssl/crypto/asn1/asn1_locl.h ) diff --git a/package.xml b/package.xml index 6957ecca73..f2cf6463e5 100644 --- a/package.xml +++ b/package.xml @@ -192,7 +192,6 @@ - @@ -382,6 +381,7 @@ + @@ -394,7 +394,6 @@ - @@ -614,6 +613,7 @@ + diff --git a/src/core/ext/filters/max_age/max_age_filter.c b/src/core/ext/filters/max_age/max_age_filter.c index b03cb0ba0a..3111a91a84 100644 --- a/src/core/ext/filters/max_age/max_age_filter.c +++ b/src/core/ext/filters/max_age/max_age_filter.c @@ -31,7 +31,7 @@ * */ -#include "src/core/lib/channel/message_size_filter.h" +#include "src/core/ext/filters/max_age/max_age_filter.h" #include #include diff --git a/src/core/ext/filters/message_size/message_size_filter.c b/src/core/ext/filters/message_size/message_size_filter.c new file mode 100644 index 0000000000..833639ba6f --- /dev/null +++ b/src/core/ext/filters/message_size/message_size_filter.c @@ -0,0 +1,331 @@ +// +// Copyright 2016, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// + +#include "src/core/ext/filters/message_size/message_size_filter.h" + +#include +#include + +#include +#include +#include +#include + +#include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/channel/channel_stack_builder.h" +#include "src/core/lib/support/string.h" +#include "src/core/lib/surface/channel_init.h" +#include "src/core/lib/transport/service_config.h" + +typedef struct message_size_limits { + int max_send_size; + int max_recv_size; +} message_size_limits; + +static void* message_size_limits_copy(void* value) { + void* new_value = gpr_malloc(sizeof(message_size_limits)); + memcpy(new_value, value, sizeof(message_size_limits)); + return new_value; +} + +static void message_size_limits_free(grpc_exec_ctx* exec_ctx, void* value) { + gpr_free(value); +} + +static const grpc_slice_hash_table_vtable message_size_limits_vtable = { + message_size_limits_free, message_size_limits_copy}; + +static void* message_size_limits_create_from_json(const grpc_json* json) { + int max_request_message_bytes = -1; + int max_response_message_bytes = -1; + for (grpc_json* field = json->child; field != NULL; field = field->next) { + if (field->key == NULL) continue; + if (strcmp(field->key, "maxRequestMessageBytes") == 0) { + if (max_request_message_bytes >= 0) return NULL; // Duplicate. + if (field->type != GRPC_JSON_STRING && field->type != GRPC_JSON_NUMBER) { + return NULL; + } + max_request_message_bytes = gpr_parse_nonnegative_int(field->value); + if (max_request_message_bytes == -1) return NULL; + } else if (strcmp(field->key, "maxResponseMessageBytes") == 0) { + if (max_response_message_bytes >= 0) return NULL; // Duplicate. + if (field->type != GRPC_JSON_STRING && field->type != GRPC_JSON_NUMBER) { + return NULL; + } + max_response_message_bytes = gpr_parse_nonnegative_int(field->value); + if (max_response_message_bytes == -1) return NULL; + } + } + message_size_limits* value = gpr_malloc(sizeof(message_size_limits)); + value->max_send_size = max_request_message_bytes; + value->max_recv_size = max_response_message_bytes; + return value; +} + +typedef struct call_data { + int max_send_size; + int max_recv_size; + // Receive closures are chained: we inject this closure as the + // recv_message_ready up-call on transport_stream_op, and remember to + // call our next_recv_message_ready member after handling it. + grpc_closure recv_message_ready; + // Used by recv_message_ready. + grpc_byte_stream** recv_message; + // Original recv_message_ready callback, invoked after our own. + grpc_closure* next_recv_message_ready; +} call_data; + +typedef struct channel_data { + int max_send_size; + int max_recv_size; + // Maps path names to message_size_limits structs. + grpc_slice_hash_table* method_limit_table; +} channel_data; + +// Callback invoked when we receive a message. Here we check the max +// receive message size. +static void recv_message_ready(grpc_exec_ctx* exec_ctx, void* user_data, + grpc_error* error) { + grpc_call_element* elem = user_data; + call_data* calld = elem->call_data; + if (*calld->recv_message != NULL && calld->max_recv_size >= 0 && + (*calld->recv_message)->length > (size_t)calld->max_recv_size) { + char* message_string; + gpr_asprintf(&message_string, + "Received message larger than max (%u vs. %d)", + (*calld->recv_message)->length, calld->max_recv_size); + grpc_error* new_error = grpc_error_set_int( + GRPC_ERROR_CREATE_FROM_COPIED_STRING(message_string), + GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_INVALID_ARGUMENT); + if (error == GRPC_ERROR_NONE) { + error = new_error; + } else { + error = grpc_error_add_child(error, new_error); + GRPC_ERROR_UNREF(new_error); + } + gpr_free(message_string); + } + // Invoke the next callback. + grpc_closure_sched(exec_ctx, calld->next_recv_message_ready, error); +} + +// Start transport stream op. +static void start_transport_stream_op(grpc_exec_ctx* exec_ctx, + grpc_call_element* elem, + grpc_transport_stream_op* op) { + call_data* calld = elem->call_data; + // Check max send message size. + if (op->send_message != NULL && calld->max_send_size >= 0 && + op->send_message->length > (size_t)calld->max_send_size) { + char* message_string; + gpr_asprintf(&message_string, "Sent message larger than max (%u vs. %d)", + op->send_message->length, calld->max_send_size); + grpc_transport_stream_op_finish_with_failure( + exec_ctx, op, + grpc_error_set_int(GRPC_ERROR_CREATE_FROM_COPIED_STRING(message_string), + GRPC_ERROR_INT_GRPC_STATUS, + GRPC_STATUS_INVALID_ARGUMENT)); + gpr_free(message_string); + return; + } + // Inject callback for receiving a message. + if (op->recv_message_ready != NULL) { + calld->next_recv_message_ready = op->recv_message_ready; + calld->recv_message = op->recv_message; + op->recv_message_ready = &calld->recv_message_ready; + } + // Chain to the next filter. + grpc_call_next_op(exec_ctx, elem, op); +} + +// Constructor for call_data. +static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx, + grpc_call_element* elem, + const grpc_call_element_args* args) { + channel_data* chand = elem->channel_data; + call_data* calld = elem->call_data; + calld->next_recv_message_ready = NULL; + grpc_closure_init(&calld->recv_message_ready, recv_message_ready, elem, + grpc_schedule_on_exec_ctx); + // Get max sizes from channel data, then merge in per-method config values. + // Note: Per-method config is only available on the client, so we + // apply the max request size to the send limit and the max response + // size to the receive limit. + calld->max_send_size = chand->max_send_size; + calld->max_recv_size = chand->max_recv_size; + if (chand->method_limit_table != NULL) { + message_size_limits* limits = grpc_method_config_table_get( + exec_ctx, chand->method_limit_table, args->path); + if (limits != NULL) { + if (limits->max_send_size >= 0 && + (limits->max_send_size < calld->max_send_size || + calld->max_send_size < 0)) { + calld->max_send_size = limits->max_send_size; + } + if (limits->max_recv_size >= 0 && + (limits->max_recv_size < calld->max_recv_size || + calld->max_recv_size < 0)) { + calld->max_recv_size = limits->max_recv_size; + } + } + } + return GRPC_ERROR_NONE; +} + +// Destructor for call_data. +static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* ignored) {} + +static int default_size(const grpc_channel_args* args, + int without_minimal_stack) { + if (grpc_channel_args_want_minimal_stack(args)) { + return INT_MAX; + } + return without_minimal_stack; +} + +typedef struct { + int max_recv_size; + int max_send_size; +} channel_limits; + +channel_limits get_channel_limits(const grpc_channel_args* channel_args) { + channel_limits lim; + lim.max_send_size = + default_size(channel_args, GRPC_DEFAULT_MAX_SEND_MESSAGE_LENGTH); + lim.max_recv_size = + default_size(channel_args, GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH); + for (size_t i = 0; i < channel_args->num_args; ++i) { + if (strcmp(channel_args->args[i].key, GRPC_ARG_MAX_SEND_MESSAGE_LENGTH) == + 0) { + const grpc_integer_options options = { + default_size(channel_args, GRPC_DEFAULT_MAX_SEND_MESSAGE_LENGTH), 0, + INT_MAX}; + lim.max_send_size = + grpc_channel_arg_get_integer(&channel_args->args[i], options); + } + if (strcmp(channel_args->args[i].key, + GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH) == 0) { + const grpc_integer_options options = { + default_size(channel_args, GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH), 0, + INT_MAX}; + lim.max_recv_size = + grpc_channel_arg_get_integer(&channel_args->args[i], options); + } + } + return lim; +} + +// Constructor for channel_data. +static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx, + grpc_channel_element* elem, + grpc_channel_element_args* args) { + GPR_ASSERT(!args->is_last); + channel_data* chand = elem->channel_data; + channel_limits lim = get_channel_limits(args->channel_args); + chand->max_send_size = lim.max_send_size; + chand->max_recv_size = lim.max_recv_size; + // Get method config table from channel args. + const grpc_arg* channel_arg = + grpc_channel_args_find(args->channel_args, GRPC_ARG_SERVICE_CONFIG); + if (channel_arg != NULL) { + GPR_ASSERT(channel_arg->type == GRPC_ARG_STRING); + grpc_service_config* service_config = + grpc_service_config_create(channel_arg->value.string); + if (service_config != NULL) { + chand->method_limit_table = + grpc_service_config_create_method_config_table( + exec_ctx, service_config, message_size_limits_create_from_json, + &message_size_limits_vtable); + grpc_service_config_destroy(service_config); + } + } + return GRPC_ERROR_NONE; +} + +// Destructor for channel_data. +static void destroy_channel_elem(grpc_exec_ctx* exec_ctx, + grpc_channel_element* elem) { + channel_data* chand = elem->channel_data; + grpc_slice_hash_table_unref(exec_ctx, chand->method_limit_table); +} + +const grpc_channel_filter grpc_message_size_filter = { + start_transport_stream_op, + grpc_channel_next_op, + sizeof(call_data), + init_call_elem, + grpc_call_stack_ignore_set_pollset_or_pollset_set, + destroy_call_elem, + sizeof(channel_data), + init_channel_elem, + destroy_channel_elem, + grpc_call_next_get_peer, + grpc_channel_next_get_info, + "message_size"}; + +static bool maybe_add_message_size_filter(grpc_exec_ctx* exec_ctx, + grpc_channel_stack_builder* builder, + void* arg) { + const grpc_channel_args* channel_args = + grpc_channel_stack_builder_get_channel_arguments(builder); + bool enable = false; + channel_limits lim = get_channel_limits(channel_args); + if (lim.max_send_size != INT_MAX || lim.max_recv_size != INT_MAX) { + enable = true; + } + const grpc_arg* a = + grpc_channel_args_find(channel_args, GRPC_ARG_SERVICE_CONFIG); + if (a != NULL) { + enable = true; + } + if (enable) { + return grpc_channel_stack_builder_prepend_filter( + builder, &grpc_message_size_filter, NULL, NULL); + } else { + return true; + } +} + +void grpc_message_size_filter_init(void) { + grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, + GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, + maybe_add_message_size_filter, NULL); + grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL, + GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, + maybe_add_message_size_filter, NULL); + grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, + GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, + maybe_add_message_size_filter, NULL); +} + +void grpc_message_size_filter_shutdown(void) {} diff --git a/src/core/ext/filters/message_size/message_size_filter.h b/src/core/ext/filters/message_size/message_size_filter.h new file mode 100644 index 0000000000..a88ff7f81a --- /dev/null +++ b/src/core/ext/filters/message_size/message_size_filter.h @@ -0,0 +1,39 @@ +// +// Copyright 2016, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef GRPC_CORE_LIB_CHANNEL_MESSAGE_SIZE_FILTER_H +#define GRPC_CORE_LIB_CHANNEL_MESSAGE_SIZE_FILTER_H + +#include "src/core/lib/channel/channel_stack.h" + +extern const grpc_channel_filter grpc_message_size_filter; + +#endif /* GRPC_CORE_LIB_CHANNEL_MESSAGE_SIZE_FILTER_H */ diff --git a/src/core/lib/channel/message_size_filter.c b/src/core/lib/channel/message_size_filter.c deleted file mode 100644 index 63136650a5..0000000000 --- a/src/core/lib/channel/message_size_filter.c +++ /dev/null @@ -1,267 +0,0 @@ -// -// Copyright 2016, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// - -#include "src/core/lib/channel/message_size_filter.h" - -#include -#include - -#include -#include -#include -#include - -#include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/support/string.h" -#include "src/core/lib/transport/service_config.h" - -typedef struct message_size_limits { - int max_send_size; - int max_recv_size; -} message_size_limits; - -static void* message_size_limits_copy(void* value) { - void* new_value = gpr_malloc(sizeof(message_size_limits)); - memcpy(new_value, value, sizeof(message_size_limits)); - return new_value; -} - -static void message_size_limits_free(grpc_exec_ctx* exec_ctx, void* value) { - gpr_free(value); -} - -static const grpc_slice_hash_table_vtable message_size_limits_vtable = { - message_size_limits_free, message_size_limits_copy}; - -static void* message_size_limits_create_from_json(const grpc_json* json) { - int max_request_message_bytes = -1; - int max_response_message_bytes = -1; - for (grpc_json* field = json->child; field != NULL; field = field->next) { - if (field->key == NULL) continue; - if (strcmp(field->key, "maxRequestMessageBytes") == 0) { - if (max_request_message_bytes >= 0) return NULL; // Duplicate. - if (field->type != GRPC_JSON_STRING && field->type != GRPC_JSON_NUMBER) { - return NULL; - } - max_request_message_bytes = gpr_parse_nonnegative_int(field->value); - if (max_request_message_bytes == -1) return NULL; - } else if (strcmp(field->key, "maxResponseMessageBytes") == 0) { - if (max_response_message_bytes >= 0) return NULL; // Duplicate. - if (field->type != GRPC_JSON_STRING && field->type != GRPC_JSON_NUMBER) { - return NULL; - } - max_response_message_bytes = gpr_parse_nonnegative_int(field->value); - if (max_response_message_bytes == -1) return NULL; - } - } - message_size_limits* value = gpr_malloc(sizeof(message_size_limits)); - value->max_send_size = max_request_message_bytes; - value->max_recv_size = max_response_message_bytes; - return value; -} - -typedef struct call_data { - int max_send_size; - int max_recv_size; - // Receive closures are chained: we inject this closure as the - // recv_message_ready up-call on transport_stream_op, and remember to - // call our next_recv_message_ready member after handling it. - grpc_closure recv_message_ready; - // Used by recv_message_ready. - grpc_byte_stream** recv_message; - // Original recv_message_ready callback, invoked after our own. - grpc_closure* next_recv_message_ready; -} call_data; - -typedef struct channel_data { - int max_send_size; - int max_recv_size; - // Maps path names to message_size_limits structs. - grpc_slice_hash_table* method_limit_table; -} channel_data; - -// Callback invoked when we receive a message. Here we check the max -// receive message size. -static void recv_message_ready(grpc_exec_ctx* exec_ctx, void* user_data, - grpc_error* error) { - grpc_call_element* elem = user_data; - call_data* calld = elem->call_data; - if (*calld->recv_message != NULL && calld->max_recv_size >= 0 && - (*calld->recv_message)->length > (size_t)calld->max_recv_size) { - char* message_string; - gpr_asprintf(&message_string, - "Received message larger than max (%u vs. %d)", - (*calld->recv_message)->length, calld->max_recv_size); - grpc_error* new_error = grpc_error_set_int( - GRPC_ERROR_CREATE_FROM_COPIED_STRING(message_string), - GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_INVALID_ARGUMENT); - if (error == GRPC_ERROR_NONE) { - error = new_error; - } else { - error = grpc_error_add_child(error, new_error); - GRPC_ERROR_UNREF(new_error); - } - gpr_free(message_string); - } - // Invoke the next callback. - grpc_closure_sched(exec_ctx, calld->next_recv_message_ready, error); -} - -// Start transport stream op. -static void start_transport_stream_op(grpc_exec_ctx* exec_ctx, - grpc_call_element* elem, - grpc_transport_stream_op* op) { - call_data* calld = elem->call_data; - // Check max send message size. - if (op->send_message != NULL && calld->max_send_size >= 0 && - op->send_message->length > (size_t)calld->max_send_size) { - char* message_string; - gpr_asprintf(&message_string, "Sent message larger than max (%u vs. %d)", - op->send_message->length, calld->max_send_size); - grpc_transport_stream_op_finish_with_failure( - exec_ctx, op, - grpc_error_set_int(GRPC_ERROR_CREATE_FROM_COPIED_STRING(message_string), - GRPC_ERROR_INT_GRPC_STATUS, - GRPC_STATUS_INVALID_ARGUMENT)); - gpr_free(message_string); - return; - } - // Inject callback for receiving a message. - if (op->recv_message_ready != NULL) { - calld->next_recv_message_ready = op->recv_message_ready; - calld->recv_message = op->recv_message; - op->recv_message_ready = &calld->recv_message_ready; - } - // Chain to the next filter. - grpc_call_next_op(exec_ctx, elem, op); -} - -// Constructor for call_data. -static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx, - grpc_call_element* elem, - const grpc_call_element_args* args) { - channel_data* chand = elem->channel_data; - call_data* calld = elem->call_data; - calld->next_recv_message_ready = NULL; - grpc_closure_init(&calld->recv_message_ready, recv_message_ready, elem, - grpc_schedule_on_exec_ctx); - // Get max sizes from channel data, then merge in per-method config values. - // Note: Per-method config is only available on the client, so we - // apply the max request size to the send limit and the max response - // size to the receive limit. - calld->max_send_size = chand->max_send_size; - calld->max_recv_size = chand->max_recv_size; - if (chand->method_limit_table != NULL) { - message_size_limits* limits = grpc_method_config_table_get( - exec_ctx, chand->method_limit_table, args->path); - if (limits != NULL) { - if (limits->max_send_size >= 0 && - (limits->max_send_size < calld->max_send_size || - calld->max_send_size < 0)) { - calld->max_send_size = limits->max_send_size; - } - if (limits->max_recv_size >= 0 && - (limits->max_recv_size < calld->max_recv_size || - calld->max_recv_size < 0)) { - calld->max_recv_size = limits->max_recv_size; - } - } - } - return GRPC_ERROR_NONE; -} - -// Destructor for call_data. -static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* ignored) {} - -// Constructor for channel_data. -static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx, - grpc_channel_element* elem, - grpc_channel_element_args* args) { - GPR_ASSERT(!args->is_last); - channel_data* chand = elem->channel_data; - chand->max_send_size = GRPC_DEFAULT_MAX_SEND_MESSAGE_LENGTH; - chand->max_recv_size = GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH; - for (size_t i = 0; i < args->channel_args->num_args; ++i) { - if (strcmp(args->channel_args->args[i].key, - GRPC_ARG_MAX_SEND_MESSAGE_LENGTH) == 0) { - const grpc_integer_options options = { - GRPC_DEFAULT_MAX_SEND_MESSAGE_LENGTH, 0, INT_MAX}; - chand->max_send_size = - grpc_channel_arg_get_integer(&args->channel_args->args[i], options); - } - if (strcmp(args->channel_args->args[i].key, - GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH) == 0) { - const grpc_integer_options options = { - GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH, 0, INT_MAX}; - chand->max_recv_size = - grpc_channel_arg_get_integer(&args->channel_args->args[i], options); - } - } - // Get method config table from channel args. - const grpc_arg* channel_arg = - grpc_channel_args_find(args->channel_args, GRPC_ARG_SERVICE_CONFIG); - if (channel_arg != NULL) { - GPR_ASSERT(channel_arg->type == GRPC_ARG_STRING); - grpc_service_config* service_config = - grpc_service_config_create(channel_arg->value.string); - if (service_config != NULL) { - chand->method_limit_table = - grpc_service_config_create_method_config_table( - exec_ctx, service_config, message_size_limits_create_from_json, - &message_size_limits_vtable); - grpc_service_config_destroy(service_config); - } - } - return GRPC_ERROR_NONE; -} - -// Destructor for channel_data. -static void destroy_channel_elem(grpc_exec_ctx* exec_ctx, - grpc_channel_element* elem) { - channel_data* chand = elem->channel_data; - grpc_slice_hash_table_unref(exec_ctx, chand->method_limit_table); -} - -const grpc_channel_filter grpc_message_size_filter = { - start_transport_stream_op, - grpc_channel_next_op, - sizeof(call_data), - init_call_elem, - grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, - sizeof(channel_data), - init_channel_elem, - destroy_channel_elem, - grpc_call_next_get_peer, - grpc_channel_next_get_info, - "message_size"}; diff --git a/src/core/lib/channel/message_size_filter.h b/src/core/lib/channel/message_size_filter.h deleted file mode 100644 index a88ff7f81a..0000000000 --- a/src/core/lib/channel/message_size_filter.h +++ /dev/null @@ -1,39 +0,0 @@ -// -// Copyright 2016, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// - -#ifndef GRPC_CORE_LIB_CHANNEL_MESSAGE_SIZE_FILTER_H -#define GRPC_CORE_LIB_CHANNEL_MESSAGE_SIZE_FILTER_H - -#include "src/core/lib/channel/channel_stack.h" - -extern const grpc_channel_filter grpc_message_size_filter; - -#endif /* GRPC_CORE_LIB_CHANNEL_MESSAGE_SIZE_FILTER_H */ diff --git a/src/core/lib/surface/init.c b/src/core/lib/surface/init.c index 91bd014a0e..f9b1675465 100644 --- a/src/core/lib/surface/init.c +++ b/src/core/lib/surface/init.c @@ -47,7 +47,6 @@ #include "src/core/lib/channel/handshaker_registry.h" #include "src/core/lib/channel/http_client_filter.h" #include "src/core/lib/channel/http_server_filter.h" -#include "src/core/lib/channel/message_size_filter.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/http/parser.h" #include "src/core/lib/iomgr/combiner.h" @@ -113,15 +112,6 @@ static void register_builtin_channel_init() { grpc_channel_init_register_stage( GRPC_SERVER_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, prepend_filter, (void *)&grpc_server_deadline_filter); - grpc_channel_init_register_stage( - GRPC_CLIENT_SUBCHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, - prepend_filter, (void *)&grpc_message_size_filter); - grpc_channel_init_register_stage( - GRPC_CLIENT_DIRECT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, - prepend_filter, (void *)&grpc_message_size_filter); - grpc_channel_init_register_stage( - GRPC_SERVER_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, prepend_filter, - (void *)&grpc_message_size_filter); grpc_channel_init_register_stage( GRPC_CLIENT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, prepend_filter, (void *)&grpc_compress_filter); diff --git a/src/core/plugin_registry/grpc_plugin_registry.c b/src/core/plugin_registry/grpc_plugin_registry.c index 803a26b753..3588954631 100644 --- a/src/core/plugin_registry/grpc_plugin_registry.c +++ b/src/core/plugin_registry/grpc_plugin_registry.c @@ -55,6 +55,8 @@ extern void census_grpc_plugin_init(void); extern void census_grpc_plugin_shutdown(void); extern void grpc_max_age_filter_init(void); extern void grpc_max_age_filter_shutdown(void); +extern void grpc_message_size_filter_init(void); +extern void grpc_message_size_filter_shutdown(void); void grpc_register_built_in_plugins(void) { grpc_register_plugin(grpc_chttp2_plugin_init, @@ -79,4 +81,6 @@ void grpc_register_built_in_plugins(void) { census_grpc_plugin_shutdown); grpc_register_plugin(grpc_max_age_filter_init, grpc_max_age_filter_shutdown); + grpc_register_plugin(grpc_message_size_filter_init, + grpc_message_size_filter_shutdown); } diff --git a/src/core/plugin_registry/grpc_unsecure_plugin_registry.c b/src/core/plugin_registry/grpc_unsecure_plugin_registry.c index e65fc2425d..2f0a0d8c96 100644 --- a/src/core/plugin_registry/grpc_unsecure_plugin_registry.c +++ b/src/core/plugin_registry/grpc_unsecure_plugin_registry.c @@ -55,6 +55,8 @@ extern void census_grpc_plugin_init(void); extern void census_grpc_plugin_shutdown(void); extern void grpc_max_age_filter_init(void); extern void grpc_max_age_filter_shutdown(void); +extern void grpc_message_size_filter_init(void); +extern void grpc_message_size_filter_shutdown(void); void grpc_register_built_in_plugins(void) { grpc_register_plugin(grpc_chttp2_plugin_init, @@ -79,4 +81,6 @@ void grpc_register_built_in_plugins(void) { census_grpc_plugin_shutdown); grpc_register_plugin(grpc_max_age_filter_init, grpc_max_age_filter_shutdown); + grpc_register_plugin(grpc_message_size_filter_init, + grpc_message_size_filter_shutdown); } diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 3bcbe667e2..41c309dd3d 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -88,7 +88,6 @@ CORE_SOURCE_FILES = [ 'src/core/lib/channel/handshaker_registry.c', 'src/core/lib/channel/http_client_filter.c', 'src/core/lib/channel/http_server_filter.c', - 'src/core/lib/channel/message_size_filter.c', 'src/core/lib/compression/compression.c', 'src/core/lib/compression/message_compress.c', 'src/core/lib/debug/trace.c', @@ -308,6 +307,7 @@ CORE_SOURCE_FILES = [ 'src/core/ext/census/trace_context.c', 'src/core/ext/census/tracing.c', 'src/core/ext/filters/max_age/max_age_filter.c', + 'src/core/ext/filters/message_size/message_size_filter.c', 'src/core/plugin_registry/grpc_plugin_registry.c', 'src/boringssl/err_data.c', 'third_party/boringssl/crypto/aes/aes.c', diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc index 0c2b170dc2..be18f12d15 100644 --- a/test/cpp/microbenchmarks/bm_call_create.cc +++ b/test/cpp/microbenchmarks/bm_call_create.cc @@ -53,7 +53,7 @@ extern "C" { #include "src/core/lib/channel/deadline_filter.h" #include "src/core/lib/channel/http_client_filter.h" #include "src/core/lib/channel/http_server_filter.h" -#include "src/core/lib/channel/message_size_filter.h" +#include "src/core/ext/filters/message_size/message_size_filter.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/transport/transport_impl.h" } diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 209d5445db..0334434f24 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -923,8 +923,6 @@ src/core/lib/channel/http_client_filter.c \ src/core/lib/channel/http_client_filter.h \ src/core/lib/channel/http_server_filter.c \ src/core/lib/channel/http_server_filter.h \ -src/core/lib/channel/message_size_filter.c \ -src/core/lib/channel/message_size_filter.h \ src/core/lib/compression/algorithm_metadata.h \ src/core/lib/compression/compression.c \ src/core/lib/compression/message_compress.c \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 6903a0e5d5..284cab8e54 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -960,6 +960,8 @@ src/core/ext/filters/load_reporting/load_reporting_filter.c \ src/core/ext/filters/load_reporting/load_reporting_filter.h \ src/core/ext/filters/max_age/max_age_filter.c \ src/core/ext/filters/max_age/max_age_filter.h \ +src/core/ext/filters/message_size/message_size_filter.c \ +src/core/ext/filters/message_size/message_size_filter.h \ src/core/ext/transport/README.md \ src/core/ext/transport/chttp2/README.md \ src/core/ext/transport/chttp2/alpn/alpn.c \ @@ -1042,8 +1044,6 @@ src/core/lib/channel/http_client_filter.c \ src/core/lib/channel/http_client_filter.h \ src/core/lib/channel/http_server_filter.c \ src/core/lib/channel/http_server_filter.h \ -src/core/lib/channel/message_size_filter.c \ -src/core/lib/channel/message_size_filter.h \ src/core/lib/compression/algorithm_metadata.h \ src/core/lib/compression/compression.c \ src/core/lib/compression/message_compress.c \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 254df5568d..e8168ce10b 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -5594,6 +5594,7 @@ "grpc_lb_policy_round_robin", "grpc_load_reporting", "grpc_max_age_filter", + "grpc_message_size_filter", "grpc_resolver_dns_ares", "grpc_resolver_dns_native", "grpc_resolver_sockaddr", @@ -5697,6 +5698,7 @@ "grpc_lb_policy_round_robin", "grpc_load_reporting", "grpc_max_age_filter", + "grpc_message_size_filter", "grpc_resolver_dns_ares", "grpc_resolver_dns_native", "grpc_resolver_sockaddr", @@ -7533,7 +7535,6 @@ "src/core/lib/channel/handshaker_registry.h", "src/core/lib/channel/http_client_filter.h", "src/core/lib/channel/http_server_filter.h", - "src/core/lib/channel/message_size_filter.h", "src/core/lib/compression/algorithm_metadata.h", "src/core/lib/compression/message_compress.h", "src/core/lib/debug/trace.h", @@ -7669,8 +7670,6 @@ "src/core/lib/channel/http_client_filter.h", "src/core/lib/channel/http_server_filter.c", "src/core/lib/channel/http_server_filter.h", - "src/core/lib/channel/message_size_filter.c", - "src/core/lib/channel/message_size_filter.h", "src/core/lib/compression/algorithm_metadata.h", "src/core/lib/compression/compression.c", "src/core/lib/compression/message_compress.c", @@ -8115,6 +8114,24 @@ "third_party": false, "type": "filegroup" }, + { + "deps": [ + "gpr", + "grpc_base" + ], + "headers": [ + "src/core/ext/filters/message_size/message_size_filter.h" + ], + "is_filegroup": true, + "language": "c", + "name": "grpc_message_size_filter", + "src": [ + "src/core/ext/filters/message_size/message_size_filter.c", + "src/core/ext/filters/message_size/message_size_filter.h" + ], + "third_party": false, + "type": "filegroup" + }, { "deps": [ "gpr", diff --git a/vsprojects/vcxproj/grpc++/grpc++.vcxproj b/vsprojects/vcxproj/grpc++/grpc++.vcxproj index caa22a019d..8ec84928bf 100644 --- a/vsprojects/vcxproj/grpc++/grpc++.vcxproj +++ b/vsprojects/vcxproj/grpc++/grpc++.vcxproj @@ -389,7 +389,6 @@ - @@ -597,8 +596,6 @@ - - diff --git a/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters b/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters index 6fc1c96930..a32fdbb8f6 100644 --- a/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters @@ -157,9 +157,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\compression @@ -899,9 +896,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\compression diff --git a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj index 674818182e..0f8fe4a623 100644 --- a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj @@ -383,7 +383,6 @@ - @@ -581,8 +580,6 @@ - - diff --git a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters index 2b9a5b13c1..d29b3ba6fe 100644 --- a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters @@ -142,9 +142,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\compression @@ -866,9 +863,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\compression diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj b/vsprojects/vcxproj/grpc/grpc.vcxproj index 948af2f29e..2a4d0b13a3 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj @@ -312,7 +312,6 @@ - @@ -502,6 +501,7 @@ + @@ -528,8 +528,6 @@ - - @@ -968,6 +966,8 @@ + + diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters index d43b0e3f83..800cea6d1d 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters @@ -37,9 +37,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\compression @@ -697,6 +694,9 @@ src\core\ext\filters\max_age + + src\core\ext\filters\message_size + src\core\plugin_registry @@ -833,9 +833,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\compression @@ -1403,6 +1400,9 @@ src\core\ext\filters\max_age + + src\core\ext\filters\message_size + @@ -1484,6 +1484,9 @@ {5369e83c-4625-fc14-cc40-9db5da3a7af4} + + {5ca3f38c-539f-3c4f-b68c-38b31ba339ba} + {e3abfd0a-064e-0f2f-c8e8-7c5a7e98142a} diff --git a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj index c675cda122..0e9c292384 100644 --- a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj +++ b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj @@ -207,7 +207,6 @@ - @@ -369,8 +368,6 @@ - - diff --git a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters index c6bd2d6c9f..94168a2628 100644 --- a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters +++ b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters @@ -94,9 +94,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\compression @@ -611,9 +608,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\compression diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj index 8799359bb7..11ee7b9563 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj @@ -302,7 +302,6 @@ - @@ -468,6 +467,7 @@ + @@ -496,8 +496,6 @@ - - @@ -878,6 +876,8 @@ + + diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters index cf2def4ff6..a4a46549ae 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters @@ -40,9 +40,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\compression @@ -613,6 +610,9 @@ src\core\ext\filters\max_age + + src\core\ext\filters\message_size + src\core\plugin_registry @@ -746,9 +746,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\compression @@ -1244,6 +1241,9 @@ src\core\ext\filters\max_age + + src\core\ext\filters\message_size + @@ -1325,6 +1325,9 @@ {d3bc80c1-5f2d-e842-42ac-43d8a6ada8de} + + {8cbe7444-caac-49dc-be89-d4c4d1c7966a} + {967c89fe-c97c-27e2-aac0-9ba5854cb5fa} diff --git a/vsprojects/vcxproj/test/minimal_stack_is_minimal_test/minimal_stack_is_minimal_test.vcxproj b/vsprojects/vcxproj/test/minimal_stack_is_minimal_test/minimal_stack_is_minimal_test.vcxproj new file mode 100644 index 0000000000..0473fa9545 --- /dev/null +++ b/vsprojects/vcxproj/test/minimal_stack_is_minimal_test/minimal_stack_is_minimal_test.vcxproj @@ -0,0 +1,199 @@ + + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {68A54124-DFA3-4FF3-081F-70356222C977} + true + $(SolutionDir)IntDir\$(MSBuildProjectName)\ + + + + v100 + + + v110 + + + v120 + + + v140 + + + Application + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + minimal_stack_is_minimal_test + static + Debug + static + Debug + + + minimal_stack_is_minimal_test + static + Release + static + Release + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + MultiThreadedDebug + true + None + false + + + Console + true + false + + + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + MultiThreadedDebug + true + None + false + + + Console + true + false + + + + + + NotUsing + Level3 + MaxSpeed + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + true + true + MultiThreaded + true + None + false + + + Console + true + false + true + true + + + + + + NotUsing + Level3 + MaxSpeed + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + true + true + MultiThreaded + true + None + false + + + Console + true + false + true + true + + + + + + + + + + {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} + + + {29D16885-7228-4C31-81ED-5F9187C7F2A9} + + + {EAB0A629-17A9-44DB-B5FF-E91A721FE037} + + + {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + diff --git a/vsprojects/vcxproj/test/minimal_stack_is_minimal_test/minimal_stack_is_minimal_test.vcxproj.filters b/vsprojects/vcxproj/test/minimal_stack_is_minimal_test/minimal_stack_is_minimal_test.vcxproj.filters new file mode 100644 index 0000000000..7eb2ba551f --- /dev/null +++ b/vsprojects/vcxproj/test/minimal_stack_is_minimal_test/minimal_stack_is_minimal_test.vcxproj.filters @@ -0,0 +1,21 @@ + + + + + test\core\channel + + + + + + {52e0de0c-9f7d-1497-1339-b0ed30ed41f8} + + + {2cd01454-1131-89cc-68a2-10365fa32bb0} + + + {f473b99d-5602-d2df-2d85-99648d00ba4f} + + + + -- cgit v1.2.3 From b0f15ff23b3f6db30345967837781773bb50c7c0 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 3 Apr 2017 13:01:22 -0700 Subject: fix merge --- src/core/lib/surface/init.c | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/src/core/lib/surface/init.c b/src/core/lib/surface/init.c index 15396b1663..f9b1675465 100644 --- a/src/core/lib/surface/init.c +++ b/src/core/lib/surface/init.c @@ -105,22 +105,6 @@ static bool maybe_add_http_filter(grpc_exec_ctx *exec_ctx, return true; } -typedef struct { - const grpc_channel_filter *filter; - const char *controlling_channel_arg; - bool default_on; -} maybe_prepend_filter_args; - -static const maybe_prepend_filter_args message_size_args = { - &grpc_message_size_filter, NULL, true}; - -static bool maybe_prepend_filter(grpc_exec_ctx *exec_ctx, - grpc_channel_stack_builder *builder, - void *arg) { - return grpc_channel_stack_builder_prepend_filter( - builder, (const grpc_channel_filter *)arg, NULL, NULL); -} - static void register_builtin_channel_init() { grpc_channel_init_register_stage( GRPC_CLIENT_DIRECT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, @@ -129,18 +113,6 @@ static void register_builtin_channel_init() { GRPC_SERVER_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, prepend_filter, (void *)&grpc_server_deadline_filter); grpc_channel_init_register_stage( -<<<<<<< HEAD -======= - GRPC_CLIENT_SUBCHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, - maybe_prepend_filter, (void *)&message_size_args); - grpc_channel_init_register_stage( - GRPC_CLIENT_DIRECT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, - prepend_filter, (void *)&grpc_message_size_filter); - grpc_channel_init_register_stage( - GRPC_SERVER_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, prepend_filter, - (void *)&grpc_message_size_filter); - grpc_channel_init_register_stage( ->>>>>>> 6b97e5344f4dddcdad1e0525b733162c0025b770 GRPC_CLIENT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, prepend_filter, (void *)&grpc_compress_filter); grpc_channel_init_register_stage( -- cgit v1.2.3 From af76743e33891f269ff2404ba8a631a97f6b50c0 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 3 Apr 2017 13:54:31 -0700 Subject: Optionalize compress, gather all the http2 filter bits together in ext/ --- BUILD | 27 +- CMakeLists.txt | 37 +- Makefile | 37 +- binding.gyp | 7 +- build.yaml | 19 +- config.m4 | 11 +- gRPC-Core.podspec | 19 +- grpc.gemspec | 13 +- include/grpc/impl/codegen/grpc_types.h | 3 + package.xml | 13 +- .../ext/filters/http/client/http_client_filter.c | 582 +++++++++++++++++++++ .../ext/filters/http/client/http_client_filter.h | 47 ++ .../ext/filters/http/compress/compress_filter.c | 351 +++++++++++++ .../ext/filters/http/compress/compress_filter.h | 67 +++ src/core/ext/filters/http/http_filters_plugin.c | 106 ++++ .../ext/filters/http/server/http_server_filter.c | 429 +++++++++++++++ .../ext/filters/http/server/http_server_filter.h | 42 ++ .../ext/transport/chttp2/server/chttp2_server.c | 2 +- src/core/lib/channel/compress_filter.c | 351 ------------- src/core/lib/channel/compress_filter.h | 67 --- src/core/lib/channel/http_client_filter.c | 582 --------------------- src/core/lib/channel/http_client_filter.h | 47 -- src/core/lib/channel/http_server_filter.c | 429 --------------- src/core/lib/channel/http_server_filter.h | 42 -- src/core/lib/security/credentials/credentials.c | 2 +- .../lib/security/credentials/ssl/ssl_credentials.c | 2 +- src/core/lib/surface/init.c | 33 -- .../plugin_registry/grpc_cronet_plugin_registry.c | 4 + src/core/plugin_registry/grpc_plugin_registry.c | 4 + .../grpc_unsecure_plugin_registry.c | 4 + src/python/grpcio/grpc_core_dependencies.py | 7 +- test/core/bad_client/bad_client.c | 2 +- test/core/channel/minimal_stack_is_minimal_test.c | 116 ++-- test/core/end2end/fixtures/h2_census.c | 2 +- test/core/end2end/fixtures/h2_compress.c | 2 +- test/core/end2end/fixtures/h2_full+pipe.c | 2 +- test/core/end2end/fixtures/h2_full+trace.c | 2 +- test/core/end2end/fixtures/h2_full.c | 2 +- test/core/end2end/fixtures/h2_http_proxy.c | 2 +- test/core/end2end/fixtures/h2_load_reporting.c | 2 +- test/core/end2end/fixtures/h2_proxy.c | 2 +- test/core/end2end/fixtures/h2_sockpair+trace.c | 6 +- test/core/end2end/fixtures/h2_sockpair.c | 6 +- test/core/end2end/fixtures/h2_sockpair_1byte.c | 6 +- test/core/end2end/fixtures/h2_uds.c | 2 +- test/cpp/microbenchmarks/bm_call_create.cc | 6 +- tools/doxygen/Doxyfile.c++.internal | 6 - tools/doxygen/Doxyfile.core.internal | 13 +- tools/run_tests/generated/sources_and_headers.json | 33 +- vsprojects/vcxproj/grpc++/grpc++.vcxproj | 9 - vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters | 18 - .../grpc++_unsecure/grpc++_unsecure.vcxproj | 9 - .../grpc++_unsecure.vcxproj.filters | 18 - vsprojects/vcxproj/grpc/grpc.vcxproj | 20 +- vsprojects/vcxproj/grpc/grpc.vcxproj.filters | 51 +- .../vcxproj/grpc_test_util/grpc_test_util.vcxproj | 9 - .../grpc_test_util/grpc_test_util.vcxproj.filters | 18 - .../vcxproj/grpc_unsecure/grpc_unsecure.vcxproj | 20 +- .../grpc_unsecure/grpc_unsecure.vcxproj.filters | 51 +- 59 files changed, 1951 insertions(+), 1870 deletions(-) create mode 100644 src/core/ext/filters/http/client/http_client_filter.c create mode 100644 src/core/ext/filters/http/client/http_client_filter.h create mode 100644 src/core/ext/filters/http/compress/compress_filter.c create mode 100644 src/core/ext/filters/http/compress/compress_filter.h create mode 100644 src/core/ext/filters/http/http_filters_plugin.c create mode 100644 src/core/ext/filters/http/server/http_server_filter.c create mode 100644 src/core/ext/filters/http/server/http_server_filter.h delete mode 100644 src/core/lib/channel/compress_filter.c delete mode 100644 src/core/lib/channel/compress_filter.h delete mode 100644 src/core/lib/channel/http_client_filter.c delete mode 100644 src/core/lib/channel/http_client_filter.h delete mode 100644 src/core/lib/channel/http_server_filter.c delete mode 100644 src/core/lib/channel/http_server_filter.h diff --git a/BUILD b/BUILD index 98c194c778..59b9702873 100644 --- a/BUILD +++ b/BUILD @@ -91,6 +91,7 @@ grpc_cc_library( "grpc_base", "grpc_transport_chttp2_client_secure", "grpc_transport_cronet_client_secure", + "grpc_http_filters", ], ) @@ -432,14 +433,11 @@ grpc_cc_library( "src/core/lib/channel/channel_args.c", "src/core/lib/channel/channel_stack.c", "src/core/lib/channel/channel_stack_builder.c", - "src/core/lib/channel/compress_filter.c", "src/core/lib/channel/connected_channel.c", "src/core/lib/channel/deadline_filter.c", "src/core/lib/channel/handshaker.c", "src/core/lib/channel/handshaker_factory.c", "src/core/lib/channel/handshaker_registry.c", - "src/core/lib/channel/http_client_filter.c", - "src/core/lib/channel/http_server_filter.c", "src/core/lib/compression/compression.c", "src/core/lib/compression/message_compress.c", "src/core/lib/debug/trace.c", @@ -557,15 +555,12 @@ grpc_cc_library( "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", - "src/core/lib/channel/compress_filter.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", "src/core/lib/channel/deadline_filter.h", "src/core/lib/channel/handshaker.h", "src/core/lib/channel/handshaker_factory.h", "src/core/lib/channel/handshaker_registry.h", - "src/core/lib/channel/http_client_filter.h", - "src/core/lib/channel/http_server_filter.h", "src/core/lib/compression/algorithm_metadata.h", "src/core/lib/compression/message_compress.h", "src/core/lib/debug/trace.h", @@ -764,6 +759,25 @@ grpc_cc_library( ], ) +grpc_cc_library( + name = "grpc_http_filters", + hdrs = [ + "src/core/ext/filters/http/compress/compress_filter.h", + "src/core/ext/filters/http/client/http_client_filter.h", + "src/core/ext/filters/http/server/http_server_filter.h", + ], + srcs = [ + "src/core/ext/filters/http/compress/compress_filter.c", + "src/core/ext/filters/http/client/http_client_filter.c", + "src/core/ext/filters/http/server/http_server_filter.c", + "src/core/ext/filters/http/http_filters_plugin.c" + ], + language = "c", + deps = [ + "grpc_base", + ], +) + grpc_cc_library( name = "grpc_codegen", language = "c", @@ -1024,6 +1038,7 @@ grpc_cc_library( deps = [ "grpc_base", "grpc_transport_chttp2_alpn", + "grpc_http_filters", ], ) diff --git a/CMakeLists.txt b/CMakeLists.txt index 441be29c0b..7e51b53036 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -911,14 +911,11 @@ add_library(grpc src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c - src/core/lib/channel/compress_filter.c src/core/lib/channel/connected_channel.c src/core/lib/channel/deadline_filter.c src/core/lib/channel/handshaker.c src/core/lib/channel/handshaker_factory.c src/core/lib/channel/handshaker_registry.c - src/core/lib/channel/http_client_filter.c - src/core/lib/channel/http_server_filter.c src/core/lib/compression/compression.c src/core/lib/compression/message_compress.c src/core/lib/debug/trace.c @@ -1053,6 +1050,10 @@ add_library(grpc src/core/ext/transport/chttp2/transport/varint.c src/core/ext/transport/chttp2/transport/writing.c src/core/ext/transport/chttp2/alpn/alpn.c + src/core/ext/filters/http/client/http_client_filter.c + src/core/ext/filters/http/compress/compress_filter.c + src/core/ext/filters/http/http_filters_plugin.c + src/core/ext/filters/http/server/http_server_filter.c src/core/lib/http/httpcli_security_connector.c src/core/lib/security/context/security_context.c src/core/lib/security/credentials/composite/composite_credentials.c @@ -1233,14 +1234,11 @@ add_library(grpc_cronet src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c - src/core/lib/channel/compress_filter.c src/core/lib/channel/connected_channel.c src/core/lib/channel/deadline_filter.c src/core/lib/channel/handshaker.c src/core/lib/channel/handshaker_factory.c src/core/lib/channel/handshaker_registry.c - src/core/lib/channel/http_client_filter.c - src/core/lib/channel/http_server_filter.c src/core/lib/compression/compression.c src/core/lib/compression/message_compress.c src/core/lib/debug/trace.c @@ -1378,6 +1376,10 @@ add_library(grpc_cronet src/core/ext/transport/chttp2/transport/varint.c src/core/ext/transport/chttp2/transport/writing.c src/core/ext/transport/chttp2/alpn/alpn.c + src/core/ext/filters/http/client/http_client_filter.c + src/core/ext/filters/http/compress/compress_filter.c + src/core/ext/filters/http/http_filters_plugin.c + src/core/ext/filters/http/server/http_server_filter.c src/core/ext/filters/client_channel/channel_connectivity.c src/core/ext/filters/client_channel/client_channel.c src/core/ext/filters/client_channel/client_channel_factory.c @@ -1540,14 +1542,11 @@ add_library(grpc_test_util src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c - src/core/lib/channel/compress_filter.c src/core/lib/channel/connected_channel.c src/core/lib/channel/deadline_filter.c src/core/lib/channel/handshaker.c src/core/lib/channel/handshaker_factory.c src/core/lib/channel/handshaker_registry.c - src/core/lib/channel/http_client_filter.c - src/core/lib/channel/http_server_filter.c src/core/lib/compression/compression.c src/core/lib/compression/message_compress.c src/core/lib/debug/trace.c @@ -1799,14 +1798,11 @@ add_library(grpc_unsecure src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c - src/core/lib/channel/compress_filter.c src/core/lib/channel/connected_channel.c src/core/lib/channel/deadline_filter.c src/core/lib/channel/handshaker.c src/core/lib/channel/handshaker_factory.c src/core/lib/channel/handshaker_registry.c - src/core/lib/channel/http_client_filter.c - src/core/lib/channel/http_server_filter.c src/core/lib/compression/compression.c src/core/lib/compression/message_compress.c src/core/lib/debug/trace.c @@ -1942,6 +1938,10 @@ add_library(grpc_unsecure src/core/ext/transport/chttp2/transport/varint.c src/core/ext/transport/chttp2/transport/writing.c src/core/ext/transport/chttp2/alpn/alpn.c + src/core/ext/filters/http/client/http_client_filter.c + src/core/ext/filters/http/compress/compress_filter.c + src/core/ext/filters/http/http_filters_plugin.c + src/core/ext/filters/http/server/http_server_filter.c src/core/ext/transport/chttp2/server/chttp2_server.c src/core/ext/transport/chttp2/client/insecure/channel_create.c src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c @@ -2215,14 +2215,11 @@ add_library(grpc++ src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c - src/core/lib/channel/compress_filter.c src/core/lib/channel/connected_channel.c src/core/lib/channel/deadline_filter.c src/core/lib/channel/handshaker.c src/core/lib/channel/handshaker_factory.c src/core/lib/channel/handshaker_registry.c - src/core/lib/channel/http_client_filter.c - src/core/lib/channel/http_server_filter.c src/core/lib/compression/compression.c src/core/lib/compression/message_compress.c src/core/lib/debug/trace.c @@ -2544,14 +2541,11 @@ add_library(grpc++_cronet src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c - src/core/lib/channel/compress_filter.c src/core/lib/channel/connected_channel.c src/core/lib/channel/deadline_filter.c src/core/lib/channel/handshaker.c src/core/lib/channel/handshaker_factory.c src/core/lib/channel/handshaker_registry.c - src/core/lib/channel/http_client_filter.c - src/core/lib/channel/http_server_filter.c src/core/lib/compression/compression.c src/core/lib/compression/message_compress.c src/core/lib/debug/trace.c @@ -2692,6 +2686,10 @@ add_library(grpc++_cronet src/core/ext/transport/chttp2/transport/varint.c src/core/ext/transport/chttp2/transport/writing.c src/core/ext/transport/chttp2/alpn/alpn.c + src/core/ext/filters/http/client/http_client_filter.c + src/core/ext/filters/http/compress/compress_filter.c + src/core/ext/filters/http/http_filters_plugin.c + src/core/ext/filters/http/server/http_server_filter.c src/core/ext/filters/client_channel/channel_connectivity.c src/core/ext/filters/client_channel/client_channel.c src/core/ext/filters/client_channel/client_channel_factory.c @@ -3241,14 +3239,11 @@ add_library(grpc++_unsecure src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c - src/core/lib/channel/compress_filter.c src/core/lib/channel/connected_channel.c src/core/lib/channel/deadline_filter.c src/core/lib/channel/handshaker.c src/core/lib/channel/handshaker_factory.c src/core/lib/channel/handshaker_registry.c - src/core/lib/channel/http_client_filter.c - src/core/lib/channel/http_server_filter.c src/core/lib/compression/compression.c src/core/lib/compression/message_compress.c src/core/lib/debug/trace.c diff --git a/Makefile b/Makefile index c0d0a63a83..4e5e21d566 100644 --- a/Makefile +++ b/Makefile @@ -2816,14 +2816,11 @@ LIBGRPC_SRC = \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ - src/core/lib/channel/compress_filter.c \ src/core/lib/channel/connected_channel.c \ src/core/lib/channel/deadline_filter.c \ src/core/lib/channel/handshaker.c \ src/core/lib/channel/handshaker_factory.c \ src/core/lib/channel/handshaker_registry.c \ - src/core/lib/channel/http_client_filter.c \ - src/core/lib/channel/http_server_filter.c \ src/core/lib/compression/compression.c \ src/core/lib/compression/message_compress.c \ src/core/lib/debug/trace.c \ @@ -2958,6 +2955,10 @@ LIBGRPC_SRC = \ src/core/ext/transport/chttp2/transport/varint.c \ src/core/ext/transport/chttp2/transport/writing.c \ src/core/ext/transport/chttp2/alpn/alpn.c \ + src/core/ext/filters/http/client/http_client_filter.c \ + src/core/ext/filters/http/compress/compress_filter.c \ + src/core/ext/filters/http/http_filters_plugin.c \ + src/core/ext/filters/http/server/http_server_filter.c \ src/core/lib/http/httpcli_security_connector.c \ src/core/lib/security/context/security_context.c \ src/core/lib/security/credentials/composite/composite_credentials.c \ @@ -3136,14 +3137,11 @@ LIBGRPC_CRONET_SRC = \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ - src/core/lib/channel/compress_filter.c \ src/core/lib/channel/connected_channel.c \ src/core/lib/channel/deadline_filter.c \ src/core/lib/channel/handshaker.c \ src/core/lib/channel/handshaker_factory.c \ src/core/lib/channel/handshaker_registry.c \ - src/core/lib/channel/http_client_filter.c \ - src/core/lib/channel/http_server_filter.c \ src/core/lib/compression/compression.c \ src/core/lib/compression/message_compress.c \ src/core/lib/debug/trace.c \ @@ -3281,6 +3279,10 @@ LIBGRPC_CRONET_SRC = \ src/core/ext/transport/chttp2/transport/varint.c \ src/core/ext/transport/chttp2/transport/writing.c \ src/core/ext/transport/chttp2/alpn/alpn.c \ + src/core/ext/filters/http/client/http_client_filter.c \ + src/core/ext/filters/http/compress/compress_filter.c \ + src/core/ext/filters/http/http_filters_plugin.c \ + src/core/ext/filters/http/server/http_server_filter.c \ src/core/ext/filters/client_channel/channel_connectivity.c \ src/core/ext/filters/client_channel/client_channel.c \ src/core/ext/filters/client_channel/client_channel_factory.c \ @@ -3442,14 +3444,11 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ - src/core/lib/channel/compress_filter.c \ src/core/lib/channel/connected_channel.c \ src/core/lib/channel/deadline_filter.c \ src/core/lib/channel/handshaker.c \ src/core/lib/channel/handshaker_factory.c \ src/core/lib/channel/handshaker_registry.c \ - src/core/lib/channel/http_client_filter.c \ - src/core/lib/channel/http_server_filter.c \ src/core/lib/compression/compression.c \ src/core/lib/compression/message_compress.c \ src/core/lib/debug/trace.c \ @@ -3673,14 +3672,11 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ - src/core/lib/channel/compress_filter.c \ src/core/lib/channel/connected_channel.c \ src/core/lib/channel/deadline_filter.c \ src/core/lib/channel/handshaker.c \ src/core/lib/channel/handshaker_factory.c \ src/core/lib/channel/handshaker_registry.c \ - src/core/lib/channel/http_client_filter.c \ - src/core/lib/channel/http_server_filter.c \ src/core/lib/compression/compression.c \ src/core/lib/compression/message_compress.c \ src/core/lib/debug/trace.c \ @@ -3816,6 +3812,10 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/transport/chttp2/transport/varint.c \ src/core/ext/transport/chttp2/transport/writing.c \ src/core/ext/transport/chttp2/alpn/alpn.c \ + src/core/ext/filters/http/client/http_client_filter.c \ + src/core/ext/filters/http/compress/compress_filter.c \ + src/core/ext/filters/http/http_filters_plugin.c \ + src/core/ext/filters/http/server/http_server_filter.c \ src/core/ext/transport/chttp2/server/chttp2_server.c \ src/core/ext/transport/chttp2/client/insecure/channel_create.c \ src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c \ @@ -4066,14 +4066,11 @@ LIBGRPC++_SRC = \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ - src/core/lib/channel/compress_filter.c \ src/core/lib/channel/connected_channel.c \ src/core/lib/channel/deadline_filter.c \ src/core/lib/channel/handshaker.c \ src/core/lib/channel/handshaker_factory.c \ src/core/lib/channel/handshaker_registry.c \ - src/core/lib/channel/http_client_filter.c \ - src/core/lib/channel/http_server_filter.c \ src/core/lib/compression/compression.c \ src/core/lib/compression/message_compress.c \ src/core/lib/debug/trace.c \ @@ -4403,14 +4400,11 @@ LIBGRPC++_CRONET_SRC = \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ - src/core/lib/channel/compress_filter.c \ src/core/lib/channel/connected_channel.c \ src/core/lib/channel/deadline_filter.c \ src/core/lib/channel/handshaker.c \ src/core/lib/channel/handshaker_factory.c \ src/core/lib/channel/handshaker_registry.c \ - src/core/lib/channel/http_client_filter.c \ - src/core/lib/channel/http_server_filter.c \ src/core/lib/compression/compression.c \ src/core/lib/compression/message_compress.c \ src/core/lib/debug/trace.c \ @@ -4551,6 +4545,10 @@ LIBGRPC++_CRONET_SRC = \ src/core/ext/transport/chttp2/transport/varint.c \ src/core/ext/transport/chttp2/transport/writing.c \ src/core/ext/transport/chttp2/alpn/alpn.c \ + src/core/ext/filters/http/client/http_client_filter.c \ + src/core/ext/filters/http/compress/compress_filter.c \ + src/core/ext/filters/http/http_filters_plugin.c \ + src/core/ext/filters/http/server/http_server_filter.c \ src/core/ext/filters/client_channel/channel_connectivity.c \ src/core/ext/filters/client_channel/client_channel.c \ src/core/ext/filters/client_channel/client_channel_factory.c \ @@ -5092,14 +5090,11 @@ LIBGRPC++_UNSECURE_SRC = \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ - src/core/lib/channel/compress_filter.c \ src/core/lib/channel/connected_channel.c \ src/core/lib/channel/deadline_filter.c \ src/core/lib/channel/handshaker.c \ src/core/lib/channel/handshaker_factory.c \ src/core/lib/channel/handshaker_registry.c \ - src/core/lib/channel/http_client_filter.c \ - src/core/lib/channel/http_server_filter.c \ src/core/lib/compression/compression.c \ src/core/lib/compression/message_compress.c \ src/core/lib/debug/trace.c \ diff --git a/binding.gyp b/binding.gyp index 01bd1ee43f..ccfbeedc63 100644 --- a/binding.gyp +++ b/binding.gyp @@ -618,14 +618,11 @@ 'src/core/lib/channel/channel_args.c', 'src/core/lib/channel/channel_stack.c', 'src/core/lib/channel/channel_stack_builder.c', - 'src/core/lib/channel/compress_filter.c', 'src/core/lib/channel/connected_channel.c', 'src/core/lib/channel/deadline_filter.c', 'src/core/lib/channel/handshaker.c', 'src/core/lib/channel/handshaker_factory.c', 'src/core/lib/channel/handshaker_registry.c', - 'src/core/lib/channel/http_client_filter.c', - 'src/core/lib/channel/http_server_filter.c', 'src/core/lib/compression/compression.c', 'src/core/lib/compression/message_compress.c', 'src/core/lib/debug/trace.c', @@ -760,6 +757,10 @@ 'src/core/ext/transport/chttp2/transport/varint.c', 'src/core/ext/transport/chttp2/transport/writing.c', 'src/core/ext/transport/chttp2/alpn/alpn.c', + 'src/core/ext/filters/http/client/http_client_filter.c', + 'src/core/ext/filters/http/compress/compress_filter.c', + 'src/core/ext/filters/http/http_filters_plugin.c', + 'src/core/ext/filters/http/server/http_server_filter.c', 'src/core/lib/http/httpcli_security_connector.c', 'src/core/lib/security/context/security_context.c', 'src/core/lib/security/credentials/composite/composite_credentials.c', diff --git a/build.yaml b/build.yaml index 6c87210e65..6a8abdc8b2 100644 --- a/build.yaml +++ b/build.yaml @@ -176,15 +176,12 @@ filegroups: - src/core/lib/channel/channel_args.h - src/core/lib/channel/channel_stack.h - src/core/lib/channel/channel_stack_builder.h - - src/core/lib/channel/compress_filter.h - src/core/lib/channel/connected_channel.h - src/core/lib/channel/context.h - src/core/lib/channel/deadline_filter.h - src/core/lib/channel/handshaker.h - src/core/lib/channel/handshaker_factory.h - src/core/lib/channel/handshaker_registry.h - - src/core/lib/channel/http_client_filter.h - - src/core/lib/channel/http_server_filter.h - src/core/lib/compression/algorithm_metadata.h - src/core/lib/compression/message_compress.h - src/core/lib/debug/trace.h @@ -286,14 +283,11 @@ filegroups: - src/core/lib/channel/channel_args.c - src/core/lib/channel/channel_stack.c - src/core/lib/channel/channel_stack_builder.c - - src/core/lib/channel/compress_filter.c - src/core/lib/channel/connected_channel.c - src/core/lib/channel/deadline_filter.c - src/core/lib/channel/handshaker.c - src/core/lib/channel/handshaker_factory.c - src/core/lib/channel/handshaker_registry.c - - src/core/lib/channel/http_client_filter.c - - src/core/lib/channel/http_server_filter.c - src/core/lib/compression/compression.c - src/core/lib/compression/message_compress.c - src/core/lib/debug/trace.c @@ -466,6 +460,17 @@ filegroups: - include/grpc/impl/codegen/status.h uses: - gpr_codegen +- name: grpc_http_filters + headers: + - src/core/ext/filters/http/client/http_client_filter.h + - src/core/ext/filters/http/compress/compress_filter.h + - src/core/ext/filters/http/server/http_server_filter.h + src: + - src/core/ext/filters/http/client/http_client_filter.c + - src/core/ext/filters/http/compress/compress_filter.c + - src/core/ext/filters/http/http_filters_plugin.c + - src/core/ext/filters/http/server/http_server_filter.c + plugin: grpc_http_filters - name: grpc_lb_policy_grpclb headers: - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h @@ -700,6 +705,7 @@ filegroups: uses: - grpc_base - grpc_transport_chttp2_alpn + - grpc_http_filters - name: grpc_transport_chttp2_alpn headers: - src/core/ext/transport/chttp2/alpn/alpn.h @@ -773,6 +779,7 @@ filegroups: filegroups: - grpc_base - grpc_transport_chttp2 + - grpc_http_filters - name: nanopb headers: - third_party/nanopb/pb.h diff --git a/config.m4 b/config.m4 index d830fa17bf..77ffaa4db4 100644 --- a/config.m4 +++ b/config.m4 @@ -86,14 +86,11 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ - src/core/lib/channel/compress_filter.c \ src/core/lib/channel/connected_channel.c \ src/core/lib/channel/deadline_filter.c \ src/core/lib/channel/handshaker.c \ src/core/lib/channel/handshaker_factory.c \ src/core/lib/channel/handshaker_registry.c \ - src/core/lib/channel/http_client_filter.c \ - src/core/lib/channel/http_server_filter.c \ src/core/lib/compression/compression.c \ src/core/lib/compression/message_compress.c \ src/core/lib/debug/trace.c \ @@ -228,6 +225,10 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/transport/chttp2/transport/varint.c \ src/core/ext/transport/chttp2/transport/writing.c \ src/core/ext/transport/chttp2/alpn/alpn.c \ + src/core/ext/filters/http/client/http_client_filter.c \ + src/core/ext/filters/http/compress/compress_filter.c \ + src/core/ext/filters/http/http_filters_plugin.c \ + src/core/ext/filters/http/server/http_server_filter.c \ src/core/lib/http/httpcli_security_connector.c \ src/core/lib/security/context/security_context.c \ src/core/lib/security/credentials/composite/composite_credentials.c \ @@ -637,6 +638,10 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/dns/c_ares) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/dns/native) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/sockaddr) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/http) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/http/client) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/http/compress) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/http/server) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/load_reporting) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/max_age) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/message_size) diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 8f39374693..b0b8686a81 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -258,15 +258,12 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', - 'src/core/lib/channel/compress_filter.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/deadline_filter.h', 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', - 'src/core/lib/channel/http_client_filter.h', - 'src/core/lib/channel/http_server_filter.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/message_compress.h', 'src/core/lib/debug/trace.h', @@ -383,6 +380,9 @@ Pod::Spec.new do |s| 'src/core/ext/transport/chttp2/transport/stream_map.h', 'src/core/ext/transport/chttp2/transport/varint.h', 'src/core/ext/transport/chttp2/alpn/alpn.h', + 'src/core/ext/filters/http/client/http_client_filter.h', + 'src/core/ext/filters/http/compress/compress_filter.h', + 'src/core/ext/filters/http/server/http_server_filter.h', 'src/core/lib/security/context/security_context.h', 'src/core/lib/security/credentials/composite/composite_credentials.h', 'src/core/lib/security/credentials/credentials.h', @@ -461,14 +461,11 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.c', 'src/core/lib/channel/channel_stack.c', 'src/core/lib/channel/channel_stack_builder.c', - 'src/core/lib/channel/compress_filter.c', 'src/core/lib/channel/connected_channel.c', 'src/core/lib/channel/deadline_filter.c', 'src/core/lib/channel/handshaker.c', 'src/core/lib/channel/handshaker_factory.c', 'src/core/lib/channel/handshaker_registry.c', - 'src/core/lib/channel/http_client_filter.c', - 'src/core/lib/channel/http_server_filter.c', 'src/core/lib/compression/compression.c', 'src/core/lib/compression/message_compress.c', 'src/core/lib/debug/trace.c', @@ -603,6 +600,10 @@ Pod::Spec.new do |s| 'src/core/ext/transport/chttp2/transport/varint.c', 'src/core/ext/transport/chttp2/transport/writing.c', 'src/core/ext/transport/chttp2/alpn/alpn.c', + 'src/core/ext/filters/http/client/http_client_filter.c', + 'src/core/ext/filters/http/compress/compress_filter.c', + 'src/core/ext/filters/http/http_filters_plugin.c', + 'src/core/ext/filters/http/server/http_server_filter.c', 'src/core/lib/http/httpcli_security_connector.c', 'src/core/lib/security/context/security_context.c', 'src/core/lib/security/credentials/composite/composite_credentials.c', @@ -708,15 +709,12 @@ Pod::Spec.new do |s| 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', - 'src/core/lib/channel/compress_filter.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', 'src/core/lib/channel/deadline_filter.h', 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', - 'src/core/lib/channel/http_client_filter.h', - 'src/core/lib/channel/http_server_filter.h', 'src/core/lib/compression/algorithm_metadata.h', 'src/core/lib/compression/message_compress.h', 'src/core/lib/debug/trace.h', @@ -833,6 +831,9 @@ Pod::Spec.new do |s| 'src/core/ext/transport/chttp2/transport/stream_map.h', 'src/core/ext/transport/chttp2/transport/varint.h', 'src/core/ext/transport/chttp2/alpn/alpn.h', + 'src/core/ext/filters/http/client/http_client_filter.h', + 'src/core/ext/filters/http/compress/compress_filter.h', + 'src/core/ext/filters/http/server/http_server_filter.h', 'src/core/lib/security/context/security_context.h', 'src/core/lib/security/credentials/composite/composite_credentials.h', 'src/core/lib/security/credentials/credentials.h', diff --git a/grpc.gemspec b/grpc.gemspec index 60fc0a208a..2ba0ec953b 100755 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -174,15 +174,12 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/channel_args.h ) s.files += %w( src/core/lib/channel/channel_stack.h ) s.files += %w( src/core/lib/channel/channel_stack_builder.h ) - s.files += %w( src/core/lib/channel/compress_filter.h ) s.files += %w( src/core/lib/channel/connected_channel.h ) s.files += %w( src/core/lib/channel/context.h ) s.files += %w( src/core/lib/channel/deadline_filter.h ) s.files += %w( src/core/lib/channel/handshaker.h ) s.files += %w( src/core/lib/channel/handshaker_factory.h ) s.files += %w( src/core/lib/channel/handshaker_registry.h ) - s.files += %w( src/core/lib/channel/http_client_filter.h ) - s.files += %w( src/core/lib/channel/http_server_filter.h ) s.files += %w( src/core/lib/compression/algorithm_metadata.h ) s.files += %w( src/core/lib/compression/message_compress.h ) s.files += %w( src/core/lib/debug/trace.h ) @@ -299,6 +296,9 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/transport/chttp2/transport/stream_map.h ) s.files += %w( src/core/ext/transport/chttp2/transport/varint.h ) s.files += %w( src/core/ext/transport/chttp2/alpn/alpn.h ) + s.files += %w( src/core/ext/filters/http/client/http_client_filter.h ) + s.files += %w( src/core/ext/filters/http/compress/compress_filter.h ) + s.files += %w( src/core/ext/filters/http/server/http_server_filter.h ) s.files += %w( src/core/lib/security/context/security_context.h ) s.files += %w( src/core/lib/security/credentials/composite/composite_credentials.h ) s.files += %w( src/core/lib/security/credentials/credentials.h ) @@ -377,14 +377,11 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/channel/channel_args.c ) s.files += %w( src/core/lib/channel/channel_stack.c ) s.files += %w( src/core/lib/channel/channel_stack_builder.c ) - s.files += %w( src/core/lib/channel/compress_filter.c ) s.files += %w( src/core/lib/channel/connected_channel.c ) s.files += %w( src/core/lib/channel/deadline_filter.c ) s.files += %w( src/core/lib/channel/handshaker.c ) s.files += %w( src/core/lib/channel/handshaker_factory.c ) s.files += %w( src/core/lib/channel/handshaker_registry.c ) - s.files += %w( src/core/lib/channel/http_client_filter.c ) - s.files += %w( src/core/lib/channel/http_server_filter.c ) s.files += %w( src/core/lib/compression/compression.c ) s.files += %w( src/core/lib/compression/message_compress.c ) s.files += %w( src/core/lib/debug/trace.c ) @@ -519,6 +516,10 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/transport/chttp2/transport/varint.c ) s.files += %w( src/core/ext/transport/chttp2/transport/writing.c ) s.files += %w( src/core/ext/transport/chttp2/alpn/alpn.c ) + s.files += %w( src/core/ext/filters/http/client/http_client_filter.c ) + s.files += %w( src/core/ext/filters/http/compress/compress_filter.c ) + s.files += %w( src/core/ext/filters/http/http_filters_plugin.c ) + s.files += %w( src/core/ext/filters/http/server/http_server_filter.c ) s.files += %w( src/core/lib/http/httpcli_security_connector.c ) s.files += %w( src/core/lib/security/context/security_context.c ) s.files += %w( src/core/lib/security/credentials/composite/composite_credentials.c ) diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index 5beac83a3b..83bdd80f2c 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -175,6 +175,9 @@ typedef struct { /** Grace period after the chennel reaches its max age. Int valued, milliseconds. INT_MAX means unlimited. */ #define GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS "grpc.max_connection_age_grace_ms" +/** Enable/disable support for per-message compression. Defaults to 1, unless + GRPC_ARG_MINIMAL_STACK is enabled, in which case it defaults to 0. */ +#define GRPC_ARG_ENABLE_PER_MESSAGE_COMPRESSION "grpc.per_message_compression" /** Initial sequence number for http2 transports. Int valued. */ #define GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER \ "grpc.http2.initial_sequence_number" diff --git a/package.xml b/package.xml index f2cf6463e5..7faa532082 100644 --- a/package.xml +++ b/package.xml @@ -183,15 +183,12 @@ - - - @@ -308,6 +305,9 @@ + + + @@ -386,14 +386,11 @@ - - - @@ -528,6 +525,10 @@ + + + + diff --git a/src/core/ext/filters/http/client/http_client_filter.c b/src/core/ext/filters/http/client/http_client_filter.c new file mode 100644 index 0000000000..c97bdb31dd --- /dev/null +++ b/src/core/ext/filters/http/client/http_client_filter.c @@ -0,0 +1,582 @@ +/* + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "src/core/ext/filters/http/client/http_client_filter.h" +#include +#include +#include +#include +#include "src/core/lib/profiling/timers.h" +#include "src/core/lib/slice/b64.h" +#include "src/core/lib/slice/percent_encoding.h" +#include "src/core/lib/slice/slice_internal.h" +#include "src/core/lib/slice/slice_string_helpers.h" +#include "src/core/lib/support/string.h" +#include "src/core/lib/transport/static_metadata.h" +#include "src/core/lib/transport/transport_impl.h" + +#define EXPECTED_CONTENT_TYPE "application/grpc" +#define EXPECTED_CONTENT_TYPE_LENGTH sizeof(EXPECTED_CONTENT_TYPE) - 1 + +/* default maximum size of payload eligable for GET request */ +static const size_t kMaxPayloadSizeForGet = 2048; + +typedef struct call_data { + grpc_linked_mdelem method; + grpc_linked_mdelem scheme; + grpc_linked_mdelem authority; + grpc_linked_mdelem te_trailers; + grpc_linked_mdelem content_type; + grpc_linked_mdelem user_agent; + + grpc_metadata_batch *recv_initial_metadata; + grpc_metadata_batch *recv_trailing_metadata; + uint8_t *payload_bytes; + + /* Vars to read data off of send_message */ + grpc_transport_stream_op send_op; + uint32_t send_length; + uint32_t send_flags; + grpc_slice incoming_slice; + grpc_slice_buffer_stream replacement_stream; + grpc_slice_buffer slices; + /* flag that indicates that all slices of send_messages aren't availble */ + bool send_message_blocked; + + /** Closure to call when finished with the hc_on_recv hook */ + grpc_closure *on_done_recv_initial_metadata; + grpc_closure *on_done_recv_trailing_metadata; + grpc_closure *on_complete; + grpc_closure *post_send; + + /** Receive closures are chained: we inject this closure as the on_done_recv + up-call on transport_op, and remember to call our on_done_recv member + after handling it. */ + grpc_closure hc_on_recv_initial_metadata; + grpc_closure hc_on_recv_trailing_metadata; + grpc_closure hc_on_complete; + grpc_closure got_slice; + grpc_closure send_done; +} call_data; + +typedef struct channel_data { + grpc_mdelem static_scheme; + grpc_mdelem user_agent; + size_t max_payload_size_for_get; +} channel_data; + +static grpc_error *client_filter_incoming_metadata(grpc_exec_ctx *exec_ctx, + grpc_call_element *elem, + grpc_metadata_batch *b) { + if (b->idx.named.status != NULL) { + if (grpc_mdelem_eq(b->idx.named.status->md, GRPC_MDELEM_STATUS_200)) { + grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.status); + } else { + char *val = grpc_dump_slice(GRPC_MDVALUE(b->idx.named.status->md), + GPR_DUMP_ASCII); + char *msg; + gpr_asprintf(&msg, "Received http2 header with status: %s", val); + grpc_error *e = grpc_error_set_str( + grpc_error_set_int( + grpc_error_set_str( + GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "Received http2 :status header with non-200 OK status"), + GRPC_ERROR_STR_VALUE, grpc_slice_from_copied_string(val)), + GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_CANCELLED), + GRPC_ERROR_STR_GRPC_MESSAGE, grpc_slice_from_copied_string(msg)); + gpr_free(val); + gpr_free(msg); + return e; + } + } + + if (b->idx.named.grpc_message != NULL) { + grpc_slice pct_decoded_msg = grpc_permissive_percent_decode_slice( + GRPC_MDVALUE(b->idx.named.grpc_message->md)); + if (grpc_slice_is_equivalent(pct_decoded_msg, + GRPC_MDVALUE(b->idx.named.grpc_message->md))) { + grpc_slice_unref_internal(exec_ctx, pct_decoded_msg); + } else { + grpc_metadata_batch_set_value(exec_ctx, b->idx.named.grpc_message, + pct_decoded_msg); + } + } + + if (b->idx.named.content_type != NULL) { + if (!grpc_mdelem_eq(b->idx.named.content_type->md, + GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC)) { + if (grpc_slice_buf_start_eq(GRPC_MDVALUE(b->idx.named.content_type->md), + EXPECTED_CONTENT_TYPE, + EXPECTED_CONTENT_TYPE_LENGTH) && + (GRPC_SLICE_START_PTR(GRPC_MDVALUE( + b->idx.named.content_type->md))[EXPECTED_CONTENT_TYPE_LENGTH] == + '+' || + GRPC_SLICE_START_PTR(GRPC_MDVALUE( + b->idx.named.content_type->md))[EXPECTED_CONTENT_TYPE_LENGTH] == + ';')) { + /* Although the C implementation doesn't (currently) generate them, + any custom +-suffix is explicitly valid. */ + /* TODO(klempner): We should consider preallocating common values such + as +proto or +json, or at least stashing them if we see them. */ + /* TODO(klempner): Should we be surfacing this to application code? */ + } else { + /* TODO(klempner): We're currently allowing this, but we shouldn't + see it without a proxy so log for now. */ + char *val = grpc_dump_slice(GRPC_MDVALUE(b->idx.named.content_type->md), + GPR_DUMP_ASCII); + gpr_log(GPR_INFO, "Unexpected content-type '%s'", val); + gpr_free(val); + } + } + grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.content_type); + } + + return GRPC_ERROR_NONE; +} + +static void hc_on_recv_initial_metadata(grpc_exec_ctx *exec_ctx, + void *user_data, grpc_error *error) { + grpc_call_element *elem = user_data; + call_data *calld = elem->call_data; + if (error == GRPC_ERROR_NONE) { + error = client_filter_incoming_metadata(exec_ctx, elem, + calld->recv_initial_metadata); + } else { + GRPC_ERROR_REF(error); + } + grpc_closure_run(exec_ctx, calld->on_done_recv_initial_metadata, error); +} + +static void hc_on_recv_trailing_metadata(grpc_exec_ctx *exec_ctx, + void *user_data, grpc_error *error) { + grpc_call_element *elem = user_data; + call_data *calld = elem->call_data; + if (error == GRPC_ERROR_NONE) { + error = client_filter_incoming_metadata(exec_ctx, elem, + calld->recv_trailing_metadata); + } else { + GRPC_ERROR_REF(error); + } + grpc_closure_run(exec_ctx, calld->on_done_recv_trailing_metadata, error); +} + +static void hc_on_complete(grpc_exec_ctx *exec_ctx, void *user_data, + grpc_error *error) { + grpc_call_element *elem = user_data; + call_data *calld = elem->call_data; + if (calld->payload_bytes) { + gpr_free(calld->payload_bytes); + calld->payload_bytes = NULL; + } + calld->on_complete->cb(exec_ctx, calld->on_complete->cb_arg, error); +} + +static void send_done(grpc_exec_ctx *exec_ctx, void *elemp, grpc_error *error) { + grpc_call_element *elem = elemp; + call_data *calld = elem->call_data; + grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &calld->slices); + calld->post_send->cb(exec_ctx, calld->post_send->cb_arg, error); +} + +static void remove_if_present(grpc_exec_ctx *exec_ctx, + grpc_metadata_batch *batch, + grpc_metadata_batch_callouts_index idx) { + if (batch->idx.array[idx] != NULL) { + grpc_metadata_batch_remove(exec_ctx, batch, batch->idx.array[idx]); + } +} + +static void continue_send_message(grpc_exec_ctx *exec_ctx, + grpc_call_element *elem) { + call_data *calld = elem->call_data; + uint8_t *wrptr = calld->payload_bytes; + while (grpc_byte_stream_next(exec_ctx, calld->send_op.send_message, + &calld->incoming_slice, ~(size_t)0, + &calld->got_slice)) { + memcpy(wrptr, GRPC_SLICE_START_PTR(calld->incoming_slice), + GRPC_SLICE_LENGTH(calld->incoming_slice)); + wrptr += GRPC_SLICE_LENGTH(calld->incoming_slice); + grpc_slice_buffer_add(&calld->slices, calld->incoming_slice); + if (calld->send_length == calld->slices.length) { + calld->send_message_blocked = false; + break; + } + } +} + +static void got_slice(grpc_exec_ctx *exec_ctx, void *elemp, grpc_error *error) { + grpc_call_element *elem = elemp; + call_data *calld = elem->call_data; + calld->send_message_blocked = false; + grpc_slice_buffer_add(&calld->slices, calld->incoming_slice); + if (calld->send_length == calld->slices.length) { + /* Pass down the original send_message op that was blocked.*/ + grpc_slice_buffer_stream_init(&calld->replacement_stream, &calld->slices, + calld->send_flags); + calld->send_op.send_message = &calld->replacement_stream.base; + calld->post_send = calld->send_op.on_complete; + calld->send_op.on_complete = &calld->send_done; + grpc_call_next_op(exec_ctx, elem, &calld->send_op); + } else { + continue_send_message(exec_ctx, elem); + } +} + +static grpc_error *hc_mutate_op(grpc_exec_ctx *exec_ctx, + grpc_call_element *elem, + grpc_transport_stream_op *op) { + /* grab pointers to our data from the call element */ + call_data *calld = elem->call_data; + channel_data *channeld = elem->channel_data; + grpc_error *error; + + if (op->send_initial_metadata != NULL) { + /* Decide which HTTP VERB to use. We use GET if the request is marked + cacheable, and the operation contains both initial metadata and send + message, and the payload is below the size threshold, and all the data + for this request is immediately available. */ + grpc_mdelem method = GRPC_MDELEM_METHOD_POST; + if ((op->send_initial_metadata_flags & + GRPC_INITIAL_METADATA_CACHEABLE_REQUEST) && + op->send_message != NULL && + op->send_message->length < channeld->max_payload_size_for_get) { + method = GRPC_MDELEM_METHOD_GET; + /* The following write to calld->send_message_blocked isn't racy with + reads in hc_start_transport_op (which deals with SEND_MESSAGE ops) because + being here means ops->send_message is not NULL, which is primarily + guarding the read there. */ + calld->send_message_blocked = true; + } else if (op->send_initial_metadata_flags & + GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST) { + method = GRPC_MDELEM_METHOD_PUT; + } + + /* Attempt to read the data from send_message and create a header field. */ + if (grpc_mdelem_eq(method, GRPC_MDELEM_METHOD_GET)) { + /* allocate memory to hold the entire payload */ + calld->payload_bytes = gpr_malloc(op->send_message->length); + + /* read slices of send_message and copy into payload_bytes */ + calld->send_op = *op; + calld->send_length = op->send_message->length; + calld->send_flags = op->send_message->flags; + continue_send_message(exec_ctx, elem); + + if (calld->send_message_blocked == false) { + /* when all the send_message data is available, then modify the path + * MDELEM by appending base64 encoded query to the path */ + const int k_url_safe = 1; + const int k_multi_line = 0; + const unsigned char k_query_separator = '?'; + + grpc_slice path_slice = + GRPC_MDVALUE(op->send_initial_metadata->idx.named.path->md); + /* sum up individual component's lengths and allocate enough memory to + * hold combined path+query */ + size_t estimated_len = GRPC_SLICE_LENGTH(path_slice); + estimated_len++; /* for the '?' */ + estimated_len += grpc_base64_estimate_encoded_size( + op->send_message->length, k_url_safe, k_multi_line); + estimated_len += 1; /* for the trailing 0 */ + grpc_slice path_with_query_slice = grpc_slice_malloc(estimated_len); + + /* memcopy individual pieces into this slice */ + uint8_t *write_ptr = + (uint8_t *)GRPC_SLICE_START_PTR(path_with_query_slice); + uint8_t *original_path = (uint8_t *)GRPC_SLICE_START_PTR(path_slice); + memcpy(write_ptr, original_path, GRPC_SLICE_LENGTH(path_slice)); + write_ptr += GRPC_SLICE_LENGTH(path_slice); + + *write_ptr = k_query_separator; + write_ptr++; /* for the '?' */ + + grpc_base64_encode_core((char *)write_ptr, calld->payload_bytes, + op->send_message->length, k_url_safe, + k_multi_line); + + /* remove trailing unused memory and add trailing 0 to terminate string + */ + char *t = (char *)GRPC_SLICE_START_PTR(path_with_query_slice); + /* safe to use strlen since base64_encode will always add '\0' */ + size_t path_length = strlen(t) + 1; + *(t + path_length) = '\0'; + path_with_query_slice = + grpc_slice_sub(path_with_query_slice, 0, path_length); + + /* substitute previous path with the new path+query */ + grpc_mdelem mdelem_path_and_query = grpc_mdelem_from_slices( + exec_ctx, GRPC_MDSTR_PATH, path_with_query_slice); + grpc_metadata_batch *b = op->send_initial_metadata; + error = grpc_metadata_batch_substitute(exec_ctx, b, b->idx.named.path, + mdelem_path_and_query); + if (error != GRPC_ERROR_NONE) return error; + + calld->on_complete = op->on_complete; + op->on_complete = &calld->hc_on_complete; + op->send_message = NULL; + grpc_slice_unref_internal(exec_ctx, path_with_query_slice); + } else { + /* Not all data is available. Fall back to POST. */ + gpr_log(GPR_DEBUG, + "Request is marked Cacheable but not all data is available.\ + Falling back to POST"); + method = GRPC_MDELEM_METHOD_POST; + } + } + + remove_if_present(exec_ctx, op->send_initial_metadata, GRPC_BATCH_METHOD); + remove_if_present(exec_ctx, op->send_initial_metadata, GRPC_BATCH_SCHEME); + remove_if_present(exec_ctx, op->send_initial_metadata, GRPC_BATCH_TE); + remove_if_present(exec_ctx, op->send_initial_metadata, + GRPC_BATCH_CONTENT_TYPE); + remove_if_present(exec_ctx, op->send_initial_metadata, + GRPC_BATCH_USER_AGENT); + + /* Send : prefixed headers, which have to be before any application + layer headers. */ + error = grpc_metadata_batch_add_head(exec_ctx, op->send_initial_metadata, + &calld->method, method); + if (error != GRPC_ERROR_NONE) return error; + error = + grpc_metadata_batch_add_head(exec_ctx, op->send_initial_metadata, + &calld->scheme, channeld->static_scheme); + if (error != GRPC_ERROR_NONE) return error; + error = grpc_metadata_batch_add_tail(exec_ctx, op->send_initial_metadata, + &calld->te_trailers, + GRPC_MDELEM_TE_TRAILERS); + if (error != GRPC_ERROR_NONE) return error; + error = grpc_metadata_batch_add_tail( + exec_ctx, op->send_initial_metadata, &calld->content_type, + GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC); + if (error != GRPC_ERROR_NONE) return error; + error = grpc_metadata_batch_add_tail(exec_ctx, op->send_initial_metadata, + &calld->user_agent, + GRPC_MDELEM_REF(channeld->user_agent)); + if (error != GRPC_ERROR_NONE) return error; + } + + if (op->recv_initial_metadata != NULL) { + /* substitute our callback for the higher callback */ + calld->recv_initial_metadata = op->recv_initial_metadata; + calld->on_done_recv_initial_metadata = op->recv_initial_metadata_ready; + op->recv_initial_metadata_ready = &calld->hc_on_recv_initial_metadata; + } + + if (op->recv_trailing_metadata != NULL) { + /* substitute our callback for the higher callback */ + calld->recv_trailing_metadata = op->recv_trailing_metadata; + calld->on_done_recv_trailing_metadata = op->on_complete; + op->on_complete = &calld->hc_on_recv_trailing_metadata; + } + + return GRPC_ERROR_NONE; +} + +static void hc_start_transport_op(grpc_exec_ctx *exec_ctx, + grpc_call_element *elem, + grpc_transport_stream_op *op) { + GPR_TIMER_BEGIN("hc_start_transport_op", 0); + GRPC_CALL_LOG_OP(GPR_INFO, elem, op); + grpc_error *error = hc_mutate_op(exec_ctx, elem, op); + if (error != GRPC_ERROR_NONE) { + grpc_transport_stream_op_finish_with_failure(exec_ctx, op, error); + } else { + call_data *calld = elem->call_data; + if (op->send_message != NULL && calld->send_message_blocked) { + /* Don't forward the op. send_message contains slices that aren't ready + yet. The call will be forwarded by the op_complete of slice read call. + */ + } else { + grpc_call_next_op(exec_ctx, elem, op); + } + } + GPR_TIMER_END("hc_start_transport_op", 0); +} + +/* Constructor for call_data */ +static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx, + grpc_call_element *elem, + const grpc_call_element_args *args) { + call_data *calld = elem->call_data; + calld->on_done_recv_initial_metadata = NULL; + calld->on_done_recv_trailing_metadata = NULL; + calld->on_complete = NULL; + calld->payload_bytes = NULL; + calld->send_message_blocked = false; + grpc_slice_buffer_init(&calld->slices); + grpc_closure_init(&calld->hc_on_recv_initial_metadata, + hc_on_recv_initial_metadata, elem, + grpc_schedule_on_exec_ctx); + grpc_closure_init(&calld->hc_on_recv_trailing_metadata, + hc_on_recv_trailing_metadata, elem, + grpc_schedule_on_exec_ctx); + grpc_closure_init(&calld->hc_on_complete, hc_on_complete, elem, + grpc_schedule_on_exec_ctx); + grpc_closure_init(&calld->got_slice, got_slice, elem, + grpc_schedule_on_exec_ctx); + grpc_closure_init(&calld->send_done, send_done, elem, + grpc_schedule_on_exec_ctx); + return GRPC_ERROR_NONE; +} + +/* Destructor for call_data */ +static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, + const grpc_call_final_info *final_info, + grpc_closure *ignored) { + call_data *calld = elem->call_data; + grpc_slice_buffer_destroy_internal(exec_ctx, &calld->slices); +} + +static grpc_mdelem scheme_from_args(const grpc_channel_args *args) { + unsigned i; + size_t j; + grpc_mdelem valid_schemes[] = {GRPC_MDELEM_SCHEME_HTTP, + GRPC_MDELEM_SCHEME_HTTPS}; + if (args != NULL) { + for (i = 0; i < args->num_args; ++i) { + if (args->args[i].type == GRPC_ARG_STRING && + strcmp(args->args[i].key, GRPC_ARG_HTTP2_SCHEME) == 0) { + for (j = 0; j < GPR_ARRAY_SIZE(valid_schemes); j++) { + if (0 == grpc_slice_str_cmp(GRPC_MDVALUE(valid_schemes[j]), + args->args[i].value.string)) { + return valid_schemes[j]; + } + } + } + } + } + return GRPC_MDELEM_SCHEME_HTTP; +} + +static size_t max_payload_size_from_args(const grpc_channel_args *args) { + if (args != NULL) { + for (size_t i = 0; i < args->num_args; ++i) { + if (0 == strcmp(args->args[i].key, GRPC_ARG_MAX_PAYLOAD_SIZE_FOR_GET)) { + if (args->args[i].type != GRPC_ARG_INTEGER) { + gpr_log(GPR_ERROR, "%s: must be an integer", + GRPC_ARG_MAX_PAYLOAD_SIZE_FOR_GET); + } else { + return (size_t)args->args[i].value.integer; + } + } + } + } + return kMaxPayloadSizeForGet; +} + +static grpc_slice user_agent_from_args(const grpc_channel_args *args, + const char *transport_name) { + gpr_strvec v; + size_t i; + int is_first = 1; + char *tmp; + grpc_slice result; + + gpr_strvec_init(&v); + + for (i = 0; args && i < args->num_args; i++) { + if (0 == strcmp(args->args[i].key, GRPC_ARG_PRIMARY_USER_AGENT_STRING)) { + if (args->args[i].type != GRPC_ARG_STRING) { + gpr_log(GPR_ERROR, "Channel argument '%s' should be a string", + GRPC_ARG_PRIMARY_USER_AGENT_STRING); + } else { + if (!is_first) gpr_strvec_add(&v, gpr_strdup(" ")); + is_first = 0; + gpr_strvec_add(&v, gpr_strdup(args->args[i].value.string)); + } + } + } + + gpr_asprintf(&tmp, "%sgrpc-c/%s (%s; %s; %s)", is_first ? "" : " ", + grpc_version_string(), GPR_PLATFORM_STRING, transport_name, + grpc_g_stands_for()); + is_first = 0; + gpr_strvec_add(&v, tmp); + + for (i = 0; args && i < args->num_args; i++) { + if (0 == strcmp(args->args[i].key, GRPC_ARG_SECONDARY_USER_AGENT_STRING)) { + if (args->args[i].type != GRPC_ARG_STRING) { + gpr_log(GPR_ERROR, "Channel argument '%s' should be a string", + GRPC_ARG_SECONDARY_USER_AGENT_STRING); + } else { + if (!is_first) gpr_strvec_add(&v, gpr_strdup(" ")); + is_first = 0; + gpr_strvec_add(&v, gpr_strdup(args->args[i].value.string)); + } + } + } + + tmp = gpr_strvec_flatten(&v, NULL); + gpr_strvec_destroy(&v); + result = grpc_slice_intern(grpc_slice_from_static_string(tmp)); + gpr_free(tmp); + + return result; +} + +/* Constructor for channel_data */ +static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx, + grpc_channel_element *elem, + grpc_channel_element_args *args) { + channel_data *chand = elem->channel_data; + GPR_ASSERT(!args->is_last); + GPR_ASSERT(args->optional_transport != NULL); + chand->static_scheme = scheme_from_args(args->channel_args); + chand->max_payload_size_for_get = + max_payload_size_from_args(args->channel_args); + chand->user_agent = grpc_mdelem_from_slices( + exec_ctx, GRPC_MDSTR_USER_AGENT, + user_agent_from_args(args->channel_args, + args->optional_transport->vtable->name)); + return GRPC_ERROR_NONE; +} + +/* Destructor for channel data */ +static void destroy_channel_elem(grpc_exec_ctx *exec_ctx, + grpc_channel_element *elem) { + channel_data *chand = elem->channel_data; + GRPC_MDELEM_UNREF(exec_ctx, chand->user_agent); +} + +const grpc_channel_filter grpc_http_client_filter = { + hc_start_transport_op, + grpc_channel_next_op, + sizeof(call_data), + init_call_elem, + grpc_call_stack_ignore_set_pollset_or_pollset_set, + destroy_call_elem, + sizeof(channel_data), + init_channel_elem, + destroy_channel_elem, + grpc_call_next_get_peer, + grpc_channel_next_get_info, + "http-client"}; diff --git a/src/core/ext/filters/http/client/http_client_filter.h b/src/core/ext/filters/http/client/http_client_filter.h new file mode 100644 index 0000000000..9e6e106e9c --- /dev/null +++ b/src/core/ext/filters/http/client/http_client_filter.h @@ -0,0 +1,47 @@ +/* + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_CORE_LIB_CHANNEL_HTTP_CLIENT_FILTER_H +#define GRPC_CORE_LIB_CHANNEL_HTTP_CLIENT_FILTER_H + +#include "src/core/lib/channel/channel_stack.h" + +/* Processes metadata on the client side for HTTP2 transports */ +extern const grpc_channel_filter grpc_http_client_filter; + +/* Channel arg to override the http2 :scheme header */ +#define GRPC_ARG_HTTP2_SCHEME "grpc.http2_scheme" + +/* Channel arg to determine maximum size of payload eligable for GET request */ +#define GRPC_ARG_MAX_PAYLOAD_SIZE_FOR_GET "grpc.max_payload_size_for_get" + +#endif /* GRPC_CORE_LIB_CHANNEL_HTTP_CLIENT_FILTER_H */ diff --git a/src/core/ext/filters/http/compress/compress_filter.c b/src/core/ext/filters/http/compress/compress_filter.c new file mode 100644 index 0000000000..64cc42d165 --- /dev/null +++ b/src/core/ext/filters/http/compress/compress_filter.c @@ -0,0 +1,351 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include + +#include +#include +#include +#include + +#include "src/core/ext/filters/http/compress/compress_filter.h" +#include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/compression/algorithm_metadata.h" +#include "src/core/lib/compression/message_compress.h" +#include "src/core/lib/profiling/timers.h" +#include "src/core/lib/slice/slice_internal.h" +#include "src/core/lib/slice/slice_string_helpers.h" +#include "src/core/lib/support/string.h" +#include "src/core/lib/transport/static_metadata.h" + +int grpc_compression_trace = 0; + +typedef struct call_data { + grpc_slice_buffer slices; /**< Buffers up input slices to be compressed */ + grpc_linked_mdelem compression_algorithm_storage; + grpc_linked_mdelem accept_encoding_storage; + uint32_t remaining_slice_bytes; + /** Compression algorithm we'll try to use. It may be given by incoming + * metadata, or by the channel's default compression settings. */ + grpc_compression_algorithm compression_algorithm; + /** If true, contents of \a compression_algorithm are authoritative */ + int has_compression_algorithm; + + grpc_transport_stream_op *send_op; + uint32_t send_length; + uint32_t send_flags; + grpc_slice incoming_slice; + grpc_slice_buffer_stream replacement_stream; + grpc_closure *post_send; + grpc_closure send_done; + grpc_closure got_slice; +} call_data; + +typedef struct channel_data { + /** The default, channel-level, compression algorithm */ + grpc_compression_algorithm default_compression_algorithm; + /** Bitset of enabled algorithms */ + uint32_t enabled_algorithms_bitset; + /** Supported compression algorithms */ + uint32_t supported_compression_algorithms; +} channel_data; + +static int skip_compression(grpc_call_element *elem, uint32_t flags) { + call_data *calld = elem->call_data; + channel_data *channeld = elem->channel_data; + + if (flags & (GRPC_WRITE_NO_COMPRESS | GRPC_WRITE_INTERNAL_COMPRESS)) { + return 1; + } + if (calld->has_compression_algorithm) { + if (calld->compression_algorithm == GRPC_COMPRESS_NONE) { + return 1; + } + return 0; /* we have an actual call-specific algorithm */ + } + /* no per-call compression override */ + return channeld->default_compression_algorithm == GRPC_COMPRESS_NONE; +} + +/** Filter initial metadata */ +static grpc_error *process_send_initial_metadata( + grpc_exec_ctx *exec_ctx, grpc_call_element *elem, + grpc_metadata_batch *initial_metadata) GRPC_MUST_USE_RESULT; +static grpc_error *process_send_initial_metadata( + grpc_exec_ctx *exec_ctx, grpc_call_element *elem, + grpc_metadata_batch *initial_metadata) { + call_data *calld = elem->call_data; + channel_data *channeld = elem->channel_data; + /* Parse incoming request for compression. If any, it'll be available + * at calld->compression_algorithm */ + if (initial_metadata->idx.named.grpc_internal_encoding_request != NULL) { + grpc_mdelem md = + initial_metadata->idx.named.grpc_internal_encoding_request->md; + if (!grpc_compression_algorithm_parse(GRPC_MDVALUE(md), + &calld->compression_algorithm)) { + char *val = grpc_slice_to_c_string(GRPC_MDVALUE(md)); + gpr_log(GPR_ERROR, + "Invalid compression algorithm: '%s' (unknown). Ignoring.", val); + gpr_free(val); + calld->compression_algorithm = GRPC_COMPRESS_NONE; + } + if (!GPR_BITGET(channeld->enabled_algorithms_bitset, + calld->compression_algorithm)) { + char *val = grpc_slice_to_c_string(GRPC_MDVALUE(md)); + gpr_log(GPR_ERROR, + "Invalid compression algorithm: '%s' (previously disabled). " + "Ignoring.", + val); + gpr_free(val); + calld->compression_algorithm = GRPC_COMPRESS_NONE; + } + calld->has_compression_algorithm = 1; + + grpc_metadata_batch_remove( + exec_ctx, initial_metadata, + initial_metadata->idx.named.grpc_internal_encoding_request); + } else { + /* If no algorithm was found in the metadata and we aren't + * exceptionally skipping compression, fall back to the channel + * default */ + calld->compression_algorithm = channeld->default_compression_algorithm; + calld->has_compression_algorithm = 1; /* GPR_TRUE */ + } + + grpc_error *error = GRPC_ERROR_NONE; + /* hint compression algorithm */ + if (calld->compression_algorithm != GRPC_COMPRESS_NONE) { + error = grpc_metadata_batch_add_tail( + exec_ctx, initial_metadata, &calld->compression_algorithm_storage, + grpc_compression_encoding_mdelem(calld->compression_algorithm)); + } + + if (error != GRPC_ERROR_NONE) return error; + + /* convey supported compression algorithms */ + error = grpc_metadata_batch_add_tail( + exec_ctx, initial_metadata, &calld->accept_encoding_storage, + GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS( + channeld->supported_compression_algorithms)); + + return error; +} + +static void continue_send_message(grpc_exec_ctx *exec_ctx, + grpc_call_element *elem); + +static void send_done(grpc_exec_ctx *exec_ctx, void *elemp, grpc_error *error) { + grpc_call_element *elem = elemp; + call_data *calld = elem->call_data; + grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &calld->slices); + calld->post_send->cb(exec_ctx, calld->post_send->cb_arg, error); +} + +static void finish_send_message(grpc_exec_ctx *exec_ctx, + grpc_call_element *elem) { + call_data *calld = elem->call_data; + int did_compress; + grpc_slice_buffer tmp; + grpc_slice_buffer_init(&tmp); + did_compress = grpc_msg_compress(exec_ctx, calld->compression_algorithm, + &calld->slices, &tmp); + if (did_compress) { + if (grpc_compression_trace) { + char *algo_name; + const size_t before_size = calld->slices.length; + const size_t after_size = tmp.length; + const float savings_ratio = 1.0f - (float)after_size / (float)before_size; + GPR_ASSERT(grpc_compression_algorithm_name(calld->compression_algorithm, + &algo_name)); + gpr_log(GPR_DEBUG, "Compressed[%s] %" PRIuPTR " bytes vs. %" PRIuPTR + " bytes (%.2f%% savings)", + algo_name, before_size, after_size, 100 * savings_ratio); + } + grpc_slice_buffer_swap(&calld->slices, &tmp); + calld->send_flags |= GRPC_WRITE_INTERNAL_COMPRESS; + } else { + if (grpc_compression_trace) { + char *algo_name; + GPR_ASSERT(grpc_compression_algorithm_name(calld->compression_algorithm, + &algo_name)); + gpr_log(GPR_DEBUG, + "Algorithm '%s' enabled but decided not to compress. Input size: " + "%" PRIuPTR, + algo_name, calld->slices.length); + } + } + + grpc_slice_buffer_destroy_internal(exec_ctx, &tmp); + + grpc_slice_buffer_stream_init(&calld->replacement_stream, &calld->slices, + calld->send_flags); + calld->send_op->send_message = &calld->replacement_stream.base; + calld->post_send = calld->send_op->on_complete; + calld->send_op->on_complete = &calld->send_done; + + grpc_call_next_op(exec_ctx, elem, calld->send_op); +} + +static void got_slice(grpc_exec_ctx *exec_ctx, void *elemp, grpc_error *error) { + grpc_call_element *elem = elemp; + call_data *calld = elem->call_data; + grpc_slice_buffer_add(&calld->slices, calld->incoming_slice); + if (calld->send_length == calld->slices.length) { + finish_send_message(exec_ctx, elem); + } else { + continue_send_message(exec_ctx, elem); + } +} + +static void continue_send_message(grpc_exec_ctx *exec_ctx, + grpc_call_element *elem) { + call_data *calld = elem->call_data; + while (grpc_byte_stream_next(exec_ctx, calld->send_op->send_message, + &calld->incoming_slice, ~(size_t)0, + &calld->got_slice)) { + grpc_slice_buffer_add(&calld->slices, calld->incoming_slice); + if (calld->send_length == calld->slices.length) { + finish_send_message(exec_ctx, elem); + break; + } + } +} + +static void compress_start_transport_stream_op(grpc_exec_ctx *exec_ctx, + grpc_call_element *elem, + grpc_transport_stream_op *op) { + call_data *calld = elem->call_data; + + GPR_TIMER_BEGIN("compress_start_transport_stream_op", 0); + + if (op->send_initial_metadata) { + grpc_error *error = process_send_initial_metadata( + exec_ctx, elem, op->send_initial_metadata); + if (error != GRPC_ERROR_NONE) { + grpc_transport_stream_op_finish_with_failure(exec_ctx, op, error); + return; + } + } + if (op->send_message != NULL && + !skip_compression(elem, op->send_message->flags)) { + calld->send_op = op; + calld->send_length = op->send_message->length; + calld->send_flags = op->send_message->flags; + continue_send_message(exec_ctx, elem); + } else { + /* pass control down the stack */ + grpc_call_next_op(exec_ctx, elem, op); + } + + GPR_TIMER_END("compress_start_transport_stream_op", 0); +} + +/* Constructor for call_data */ +static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx, + grpc_call_element *elem, + const grpc_call_element_args *args) { + /* grab pointers to our data from the call element */ + call_data *calld = elem->call_data; + + /* initialize members */ + grpc_slice_buffer_init(&calld->slices); + calld->has_compression_algorithm = 0; + grpc_closure_init(&calld->got_slice, got_slice, elem, + grpc_schedule_on_exec_ctx); + grpc_closure_init(&calld->send_done, send_done, elem, + grpc_schedule_on_exec_ctx); + + return GRPC_ERROR_NONE; +} + +/* Destructor for call_data */ +static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, + const grpc_call_final_info *final_info, + grpc_closure *ignored) { + /* grab pointers to our data from the call element */ + call_data *calld = elem->call_data; + grpc_slice_buffer_destroy_internal(exec_ctx, &calld->slices); +} + +/* Constructor for channel_data */ +static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx, + grpc_channel_element *elem, + grpc_channel_element_args *args) { + channel_data *channeld = elem->channel_data; + + channeld->enabled_algorithms_bitset = + grpc_channel_args_compression_algorithm_get_states(args->channel_args); + + channeld->default_compression_algorithm = + grpc_channel_args_get_compression_algorithm(args->channel_args); + /* Make sure the default isn't disabled. */ + if (!GPR_BITGET(channeld->enabled_algorithms_bitset, + channeld->default_compression_algorithm)) { + gpr_log(GPR_DEBUG, + "compression algorithm %d not enabled: switching to none", + channeld->default_compression_algorithm); + channeld->default_compression_algorithm = GRPC_COMPRESS_NONE; + } + + channeld->supported_compression_algorithms = 1; /* always support identity */ + for (grpc_compression_algorithm algo_idx = 1; + algo_idx < GRPC_COMPRESS_ALGORITHMS_COUNT; ++algo_idx) { + /* skip disabled algorithms */ + if (!GPR_BITGET(channeld->enabled_algorithms_bitset, algo_idx)) { + continue; + } + channeld->supported_compression_algorithms |= 1u << algo_idx; + } + + GPR_ASSERT(!args->is_last); + return GRPC_ERROR_NONE; +} + +/* Destructor for channel data */ +static void destroy_channel_elem(grpc_exec_ctx *exec_ctx, + grpc_channel_element *elem) {} + +const grpc_channel_filter grpc_compress_filter = { + compress_start_transport_stream_op, + grpc_channel_next_op, + sizeof(call_data), + init_call_elem, + grpc_call_stack_ignore_set_pollset_or_pollset_set, + destroy_call_elem, + sizeof(channel_data), + init_channel_elem, + destroy_channel_elem, + grpc_call_next_get_peer, + grpc_channel_next_get_info, + "compress"}; diff --git a/src/core/ext/filters/http/compress/compress_filter.h b/src/core/ext/filters/http/compress/compress_filter.h new file mode 100644 index 0000000000..e4a2a829d5 --- /dev/null +++ b/src/core/ext/filters/http/compress/compress_filter.h @@ -0,0 +1,67 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_CORE_LIB_CHANNEL_COMPRESS_FILTER_H +#define GRPC_CORE_LIB_CHANNEL_COMPRESS_FILTER_H + +#include + +#include "src/core/lib/channel/channel_stack.h" + +extern int grpc_compression_trace; + +/** Compression filter for outgoing data. + * + * See for the available compression settings. + * + * Compression settings may come from: + * - Channel configuration, as established at channel creation time. + * - The metadata accompanying the outgoing data to be compressed. This is + * taken as a request only. We may choose not to honor it. The metadata key + * is given by \a GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY. + * + * Compression can be disabled for concrete messages (for instance in order to + * prevent CRIME/BEAST type attacks) by having the GRPC_WRITE_NO_COMPRESS set in + * the BEGIN_MESSAGE flags. + * + * The attempted compression mechanism is added to the resulting initial + * metadata under the'grpc-encoding' key. + * + * If compression is actually performed, BEGIN_MESSAGE's flag is modified to + * incorporate GRPC_WRITE_INTERNAL_COMPRESS. Otherwise, and regardless of the + * aforementioned 'grpc-encoding' metadata value, data will pass through + * uncompressed. */ + +extern const grpc_channel_filter grpc_compress_filter; + +#endif /* GRPC_CORE_LIB_CHANNEL_COMPRESS_FILTER_H */ diff --git a/src/core/ext/filters/http/http_filters_plugin.c b/src/core/ext/filters/http/http_filters_plugin.c new file mode 100644 index 0000000000..a6e35bc181 --- /dev/null +++ b/src/core/ext/filters/http/http_filters_plugin.c @@ -0,0 +1,106 @@ +/* + * + * Copyright 2017, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include + +#include "src/core/ext/filters/http/client/http_client_filter.h" +#include "src/core/ext/filters/http/compress/compress_filter.h" +#include "src/core/ext/filters/http/server/http_server_filter.h" +#include "src/core/lib/channel/channel_stack_builder.h" +#include "src/core/lib/surface/channel_init.h" +#include "src/core/lib/transport/transport_impl.h" + +typedef struct { + const grpc_channel_filter *filter; + const char *control_channel_arg; +} optional_filter; + +static optional_filter compress_filter = { + &grpc_compress_filter, GRPC_ARG_ENABLE_PER_MESSAGE_COMPRESSION}; + +static bool is_building_http_like_transport( + grpc_channel_stack_builder *builder) { + grpc_transport *t = grpc_channel_stack_builder_get_transport(builder); + return t && strstr(t->vtable->name, "http"); +} + +static bool maybe_add_optional_filter(grpc_exec_ctx *exec_ctx, + grpc_channel_stack_builder *builder, + void *arg) { + if (!is_building_http_like_transport(builder)) return true; + optional_filter *filtarg = arg; + const grpc_channel_args *channel_args = + grpc_channel_stack_builder_get_channel_arguments(builder); + bool enable = !grpc_channel_args_want_minimal_stack(channel_args); + const grpc_arg *ctlarg = + grpc_channel_args_find(channel_args, filtarg->control_channel_arg); + if (ctlarg != NULL) { + enable = !(ctlarg->type == GRPC_ARG_INTEGER && ctlarg->value.integer == 0); + } + return enable ? grpc_channel_stack_builder_prepend_filter( + builder, filtarg->filter, NULL, NULL) + : true; +} + +static bool maybe_add_required_filter(grpc_exec_ctx *exec_ctx, + grpc_channel_stack_builder *builder, + void *arg) { + return is_building_http_like_transport(builder) + ? grpc_channel_stack_builder_prepend_filter( + builder, (const grpc_channel_filter *)arg, NULL, NULL) + : true; +} + +void grpc_http_filters_init(void) { + grpc_register_tracer("compression", &grpc_compression_trace); + grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, + GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, + maybe_add_optional_filter, &compress_filter); + grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL, + GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, + maybe_add_optional_filter, &compress_filter); + grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, + GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, + maybe_add_optional_filter, &compress_filter); + grpc_channel_init_register_stage( + GRPC_CLIENT_SUBCHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, + maybe_add_required_filter, (void *)&grpc_http_client_filter); + grpc_channel_init_register_stage( + GRPC_CLIENT_DIRECT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, + maybe_add_required_filter, (void *)&grpc_http_client_filter); + grpc_channel_init_register_stage( + GRPC_SERVER_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, + maybe_add_required_filter, (void *)&grpc_http_server_filter); +} + +void grpc_http_filters_shutdown(void) {} diff --git a/src/core/ext/filters/http/server/http_server_filter.c b/src/core/ext/filters/http/server/http_server_filter.c new file mode 100644 index 0000000000..03787d25c2 --- /dev/null +++ b/src/core/ext/filters/http/server/http_server_filter.c @@ -0,0 +1,429 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "src/core/ext/filters/http/server/http_server_filter.h" + +#include +#include +#include +#include "src/core/lib/profiling/timers.h" +#include "src/core/lib/slice/b64.h" +#include "src/core/lib/slice/percent_encoding.h" +#include "src/core/lib/slice/slice_internal.h" +#include "src/core/lib/slice/slice_string_helpers.h" +#include "src/core/lib/transport/static_metadata.h" + +#define EXPECTED_CONTENT_TYPE "application/grpc" +#define EXPECTED_CONTENT_TYPE_LENGTH sizeof(EXPECTED_CONTENT_TYPE) - 1 + +extern int grpc_http_trace; + +typedef struct call_data { + grpc_linked_mdelem status; + grpc_linked_mdelem content_type; + + /* did this request come with path query containing request payload */ + bool seen_path_with_query; + /* flag to ensure payload_bin is delivered only once */ + bool payload_bin_delivered; + + grpc_metadata_batch *recv_initial_metadata; + bool *recv_idempotent_request; + bool *recv_cacheable_request; + /** Closure to call when finished with the hs_on_recv hook */ + grpc_closure *on_done_recv; + /** Closure to call when we retrieve read message from the path URI + */ + grpc_closure *recv_message_ready; + grpc_closure *on_complete; + grpc_byte_stream **pp_recv_message; + grpc_slice_buffer read_slice_buffer; + grpc_slice_buffer_stream read_stream; + + /** Receive closures are chained: we inject this closure as the on_done_recv + up-call on transport_op, and remember to call our on_done_recv member + after handling it. */ + grpc_closure hs_on_recv; + grpc_closure hs_on_complete; + grpc_closure hs_recv_message_ready; +} call_data; + +typedef struct channel_data { uint8_t unused; } channel_data; + +static grpc_error *server_filter_outgoing_metadata(grpc_exec_ctx *exec_ctx, + grpc_call_element *elem, + grpc_metadata_batch *b) { + if (b->idx.named.grpc_message != NULL) { + grpc_slice pct_encoded_msg = grpc_percent_encode_slice( + GRPC_MDVALUE(b->idx.named.grpc_message->md), + grpc_compatible_percent_encoding_unreserved_bytes); + if (grpc_slice_is_equivalent(pct_encoded_msg, + GRPC_MDVALUE(b->idx.named.grpc_message->md))) { + grpc_slice_unref_internal(exec_ctx, pct_encoded_msg); + } else { + grpc_metadata_batch_set_value(exec_ctx, b->idx.named.grpc_message, + pct_encoded_msg); + } + } + return GRPC_ERROR_NONE; +} + +static void add_error(const char *error_name, grpc_error **cumulative, + grpc_error *new) { + if (new == GRPC_ERROR_NONE) return; + if (*cumulative == GRPC_ERROR_NONE) { + *cumulative = GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_name); + } + *cumulative = grpc_error_add_child(*cumulative, new); +} + +static grpc_error *server_filter_incoming_metadata(grpc_exec_ctx *exec_ctx, + grpc_call_element *elem, + grpc_metadata_batch *b) { + call_data *calld = elem->call_data; + grpc_error *error = GRPC_ERROR_NONE; + static const char *error_name = "Failed processing incoming headers"; + + if (b->idx.named.method != NULL) { + if (grpc_mdelem_eq(b->idx.named.method->md, GRPC_MDELEM_METHOD_POST)) { + *calld->recv_idempotent_request = false; + *calld->recv_cacheable_request = false; + } else if (grpc_mdelem_eq(b->idx.named.method->md, + GRPC_MDELEM_METHOD_PUT)) { + *calld->recv_idempotent_request = true; + } else if (grpc_mdelem_eq(b->idx.named.method->md, + GRPC_MDELEM_METHOD_GET)) { + *calld->recv_cacheable_request = true; + } else { + add_error(error_name, &error, + grpc_attach_md_to_error( + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Bad header"), + b->idx.named.method->md)); + } + grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.method); + } else { + add_error( + error_name, &error, + grpc_error_set_str( + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Missing header"), + GRPC_ERROR_STR_KEY, grpc_slice_from_static_string(":method"))); + } + + if (b->idx.named.te != NULL) { + if (!grpc_mdelem_eq(b->idx.named.te->md, GRPC_MDELEM_TE_TRAILERS)) { + add_error(error_name, &error, + grpc_attach_md_to_error( + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Bad header"), + b->idx.named.te->md)); + } + grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.te); + } else { + add_error(error_name, &error, + grpc_error_set_str( + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Missing header"), + GRPC_ERROR_STR_KEY, grpc_slice_from_static_string("te"))); + } + + if (b->idx.named.scheme != NULL) { + if (!grpc_mdelem_eq(b->idx.named.scheme->md, GRPC_MDELEM_SCHEME_HTTP) && + !grpc_mdelem_eq(b->idx.named.scheme->md, GRPC_MDELEM_SCHEME_HTTPS) && + !grpc_mdelem_eq(b->idx.named.scheme->md, GRPC_MDELEM_SCHEME_GRPC)) { + add_error(error_name, &error, + grpc_attach_md_to_error( + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Bad header"), + b->idx.named.scheme->md)); + } + grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.scheme); + } else { + add_error( + error_name, &error, + grpc_error_set_str( + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Missing header"), + GRPC_ERROR_STR_KEY, grpc_slice_from_static_string(":scheme"))); + } + + if (b->idx.named.content_type != NULL) { + if (!grpc_mdelem_eq(b->idx.named.content_type->md, + GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC)) { + if (grpc_slice_buf_start_eq(GRPC_MDVALUE(b->idx.named.content_type->md), + EXPECTED_CONTENT_TYPE, + EXPECTED_CONTENT_TYPE_LENGTH) && + (GRPC_SLICE_START_PTR(GRPC_MDVALUE( + b->idx.named.content_type->md))[EXPECTED_CONTENT_TYPE_LENGTH] == + '+' || + GRPC_SLICE_START_PTR(GRPC_MDVALUE( + b->idx.named.content_type->md))[EXPECTED_CONTENT_TYPE_LENGTH] == + ';')) { + /* Although the C implementation doesn't (currently) generate them, + any custom +-suffix is explicitly valid. */ + /* TODO(klempner): We should consider preallocating common values such + as +proto or +json, or at least stashing them if we see them. */ + /* TODO(klempner): Should we be surfacing this to application code? */ + } else { + /* TODO(klempner): We're currently allowing this, but we shouldn't + see it without a proxy so log for now. */ + char *val = grpc_dump_slice(GRPC_MDVALUE(b->idx.named.content_type->md), + GPR_DUMP_ASCII); + gpr_log(GPR_INFO, "Unexpected content-type '%s'", val); + gpr_free(val); + } + } + grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.content_type); + } + + if (b->idx.named.path == NULL) { + add_error(error_name, &error, + grpc_error_set_str( + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Missing header"), + GRPC_ERROR_STR_KEY, grpc_slice_from_static_string(":path"))); + } else if (*calld->recv_cacheable_request == true) { + /* We have a cacheable request made with GET verb. The path contains the + * query parameter which is base64 encoded request payload. */ + const char k_query_separator = '?'; + grpc_slice path_slice = GRPC_MDVALUE(b->idx.named.path->md); + uint8_t *path_ptr = (uint8_t *)GRPC_SLICE_START_PTR(path_slice); + size_t path_length = GRPC_SLICE_LENGTH(path_slice); + /* offset of the character '?' */ + size_t offset = 0; + for (offset = 0; offset < path_length && *path_ptr != k_query_separator; + path_ptr++, offset++) + ; + if (offset < path_length) { + grpc_slice query_slice = + grpc_slice_sub(path_slice, offset + 1, path_length); + + /* substitute path metadata with just the path (not query) */ + grpc_mdelem mdelem_path_without_query = grpc_mdelem_from_slices( + exec_ctx, GRPC_MDSTR_PATH, grpc_slice_sub(path_slice, 0, offset)); + + grpc_metadata_batch_substitute(exec_ctx, b, b->idx.named.path, + mdelem_path_without_query); + + /* decode payload from query and add to the slice buffer to be returned */ + const int k_url_safe = 1; + grpc_slice_buffer_add( + &calld->read_slice_buffer, + grpc_base64_decode(exec_ctx, + (const char *)GRPC_SLICE_START_PTR(query_slice), + k_url_safe)); + grpc_slice_buffer_stream_init(&calld->read_stream, + &calld->read_slice_buffer, 0); + calld->seen_path_with_query = true; + grpc_slice_unref_internal(exec_ctx, query_slice); + } else { + gpr_log(GPR_ERROR, "GET request without QUERY"); + } + } + + if (b->idx.named.host != NULL && b->idx.named.authority == NULL) { + grpc_linked_mdelem *el = b->idx.named.host; + grpc_mdelem md = GRPC_MDELEM_REF(el->md); + grpc_metadata_batch_remove(exec_ctx, b, el); + add_error( + error_name, &error, + grpc_metadata_batch_add_head( + exec_ctx, b, el, grpc_mdelem_from_slices( + exec_ctx, GRPC_MDSTR_AUTHORITY, + grpc_slice_ref_internal(GRPC_MDVALUE(md))))); + GRPC_MDELEM_UNREF(exec_ctx, md); + } + + if (b->idx.named.authority == NULL) { + add_error( + error_name, &error, + grpc_error_set_str( + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Missing header"), + GRPC_ERROR_STR_KEY, grpc_slice_from_static_string(":authority"))); + } + + return error; +} + +static void hs_on_recv(grpc_exec_ctx *exec_ctx, void *user_data, + grpc_error *err) { + grpc_call_element *elem = user_data; + call_data *calld = elem->call_data; + if (err == GRPC_ERROR_NONE) { + err = server_filter_incoming_metadata(exec_ctx, elem, + calld->recv_initial_metadata); + } else { + GRPC_ERROR_REF(err); + } + grpc_closure_run(exec_ctx, calld->on_done_recv, err); +} + +static void hs_on_complete(grpc_exec_ctx *exec_ctx, void *user_data, + grpc_error *err) { + grpc_call_element *elem = user_data; + call_data *calld = elem->call_data; + /* Call recv_message_ready if we got the payload via the path field */ + if (calld->seen_path_with_query && calld->recv_message_ready != NULL) { + *calld->pp_recv_message = calld->payload_bin_delivered + ? NULL + : (grpc_byte_stream *)&calld->read_stream; + grpc_closure_run(exec_ctx, calld->recv_message_ready, GRPC_ERROR_REF(err)); + calld->recv_message_ready = NULL; + calld->payload_bin_delivered = true; + } + grpc_closure_run(exec_ctx, calld->on_complete, GRPC_ERROR_REF(err)); +} + +static void hs_recv_message_ready(grpc_exec_ctx *exec_ctx, void *user_data, + grpc_error *err) { + grpc_call_element *elem = user_data; + call_data *calld = elem->call_data; + if (calld->seen_path_with_query) { + /* do nothing. This is probably a GET request, and payload will be returned + in hs_on_complete callback. */ + } else { + grpc_closure_run(exec_ctx, calld->recv_message_ready, GRPC_ERROR_REF(err)); + } +} + +static void hs_mutate_op(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, + grpc_transport_stream_op *op) { + /* grab pointers to our data from the call element */ + call_data *calld = elem->call_data; + + if (op->send_initial_metadata != NULL) { + grpc_error *error = GRPC_ERROR_NONE; + static const char *error_name = "Failed sending initial metadata"; + add_error(error_name, &error, grpc_metadata_batch_add_head( + exec_ctx, op->send_initial_metadata, + &calld->status, GRPC_MDELEM_STATUS_200)); + add_error(error_name, &error, + grpc_metadata_batch_add_tail( + exec_ctx, op->send_initial_metadata, &calld->content_type, + GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC)); + add_error(error_name, &error, + server_filter_outgoing_metadata(exec_ctx, elem, + op->send_initial_metadata)); + if (error != GRPC_ERROR_NONE) { + grpc_transport_stream_op_finish_with_failure(exec_ctx, op, error); + return; + } + } + + if (op->recv_initial_metadata) { + /* substitute our callback for the higher callback */ + GPR_ASSERT(op->recv_idempotent_request != NULL); + GPR_ASSERT(op->recv_cacheable_request != NULL); + calld->recv_initial_metadata = op->recv_initial_metadata; + calld->recv_idempotent_request = op->recv_idempotent_request; + calld->recv_cacheable_request = op->recv_cacheable_request; + calld->on_done_recv = op->recv_initial_metadata_ready; + op->recv_initial_metadata_ready = &calld->hs_on_recv; + } + + if (op->recv_message) { + calld->recv_message_ready = op->recv_message_ready; + calld->pp_recv_message = op->recv_message; + if (op->recv_message_ready) { + op->recv_message_ready = &calld->hs_recv_message_ready; + } + if (op->on_complete) { + calld->on_complete = op->on_complete; + op->on_complete = &calld->hs_on_complete; + } + } + + if (op->send_trailing_metadata) { + grpc_error *error = server_filter_outgoing_metadata( + exec_ctx, elem, op->send_trailing_metadata); + if (error != GRPC_ERROR_NONE) { + grpc_transport_stream_op_finish_with_failure(exec_ctx, op, error); + return; + } + } +} + +static void hs_start_transport_op(grpc_exec_ctx *exec_ctx, + grpc_call_element *elem, + grpc_transport_stream_op *op) { + GRPC_CALL_LOG_OP(GPR_INFO, elem, op); + GPR_TIMER_BEGIN("hs_start_transport_op", 0); + hs_mutate_op(exec_ctx, elem, op); + grpc_call_next_op(exec_ctx, elem, op); + GPR_TIMER_END("hs_start_transport_op", 0); +} + +/* Constructor for call_data */ +static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx, + grpc_call_element *elem, + const grpc_call_element_args *args) { + /* grab pointers to our data from the call element */ + call_data *calld = elem->call_data; + /* initialize members */ + grpc_closure_init(&calld->hs_on_recv, hs_on_recv, elem, + grpc_schedule_on_exec_ctx); + grpc_closure_init(&calld->hs_on_complete, hs_on_complete, elem, + grpc_schedule_on_exec_ctx); + grpc_closure_init(&calld->hs_recv_message_ready, hs_recv_message_ready, elem, + grpc_schedule_on_exec_ctx); + grpc_slice_buffer_init(&calld->read_slice_buffer); + return GRPC_ERROR_NONE; +} + +/* Destructor for call_data */ +static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, + const grpc_call_final_info *final_info, + grpc_closure *ignored) { + call_data *calld = elem->call_data; + grpc_slice_buffer_destroy_internal(exec_ctx, &calld->read_slice_buffer); +} + +/* Constructor for channel_data */ +static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx, + grpc_channel_element *elem, + grpc_channel_element_args *args) { + GPR_ASSERT(!args->is_last); + return GRPC_ERROR_NONE; +} + +/* Destructor for channel data */ +static void destroy_channel_elem(grpc_exec_ctx *exec_ctx, + grpc_channel_element *elem) {} + +const grpc_channel_filter grpc_http_server_filter = { + hs_start_transport_op, + grpc_channel_next_op, + sizeof(call_data), + init_call_elem, + grpc_call_stack_ignore_set_pollset_or_pollset_set, + destroy_call_elem, + sizeof(channel_data), + init_channel_elem, + destroy_channel_elem, + grpc_call_next_get_peer, + grpc_channel_next_get_info, + "http-server"}; diff --git a/src/core/ext/filters/http/server/http_server_filter.h b/src/core/ext/filters/http/server/http_server_filter.h new file mode 100644 index 0000000000..77ba2d263d --- /dev/null +++ b/src/core/ext/filters/http/server/http_server_filter.h @@ -0,0 +1,42 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_CORE_LIB_CHANNEL_HTTP_SERVER_FILTER_H +#define GRPC_CORE_LIB_CHANNEL_HTTP_SERVER_FILTER_H + +#include "src/core/lib/channel/channel_stack.h" + +/* Processes metadata on the client side for HTTP2 transports */ +extern const grpc_channel_filter grpc_http_server_filter; + +#endif /* GRPC_CORE_LIB_CHANNEL_HTTP_SERVER_FILTER_H */ diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.c b/src/core/ext/transport/chttp2/server/chttp2_server.c index 6433968ca5..ede8eed927 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.c +++ b/src/core/ext/transport/chttp2/server/chttp2_server.c @@ -47,7 +47,7 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/handshaker.h" #include "src/core/lib/channel/handshaker_registry.h" -#include "src/core/lib/channel/http_server_filter.h" +#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/iomgr/tcp_server.h" diff --git a/src/core/lib/channel/compress_filter.c b/src/core/lib/channel/compress_filter.c deleted file mode 100644 index 02dc479f3a..0000000000 --- a/src/core/lib/channel/compress_filter.c +++ /dev/null @@ -1,351 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include -#include - -#include -#include -#include -#include - -#include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/compress_filter.h" -#include "src/core/lib/compression/algorithm_metadata.h" -#include "src/core/lib/compression/message_compress.h" -#include "src/core/lib/profiling/timers.h" -#include "src/core/lib/slice/slice_internal.h" -#include "src/core/lib/slice/slice_string_helpers.h" -#include "src/core/lib/support/string.h" -#include "src/core/lib/transport/static_metadata.h" - -int grpc_compression_trace = 0; - -typedef struct call_data { - grpc_slice_buffer slices; /**< Buffers up input slices to be compressed */ - grpc_linked_mdelem compression_algorithm_storage; - grpc_linked_mdelem accept_encoding_storage; - uint32_t remaining_slice_bytes; - /** Compression algorithm we'll try to use. It may be given by incoming - * metadata, or by the channel's default compression settings. */ - grpc_compression_algorithm compression_algorithm; - /** If true, contents of \a compression_algorithm are authoritative */ - int has_compression_algorithm; - - grpc_transport_stream_op *send_op; - uint32_t send_length; - uint32_t send_flags; - grpc_slice incoming_slice; - grpc_slice_buffer_stream replacement_stream; - grpc_closure *post_send; - grpc_closure send_done; - grpc_closure got_slice; -} call_data; - -typedef struct channel_data { - /** The default, channel-level, compression algorithm */ - grpc_compression_algorithm default_compression_algorithm; - /** Bitset of enabled algorithms */ - uint32_t enabled_algorithms_bitset; - /** Supported compression algorithms */ - uint32_t supported_compression_algorithms; -} channel_data; - -static int skip_compression(grpc_call_element *elem, uint32_t flags) { - call_data *calld = elem->call_data; - channel_data *channeld = elem->channel_data; - - if (flags & (GRPC_WRITE_NO_COMPRESS | GRPC_WRITE_INTERNAL_COMPRESS)) { - return 1; - } - if (calld->has_compression_algorithm) { - if (calld->compression_algorithm == GRPC_COMPRESS_NONE) { - return 1; - } - return 0; /* we have an actual call-specific algorithm */ - } - /* no per-call compression override */ - return channeld->default_compression_algorithm == GRPC_COMPRESS_NONE; -} - -/** Filter initial metadata */ -static grpc_error *process_send_initial_metadata( - grpc_exec_ctx *exec_ctx, grpc_call_element *elem, - grpc_metadata_batch *initial_metadata) GRPC_MUST_USE_RESULT; -static grpc_error *process_send_initial_metadata( - grpc_exec_ctx *exec_ctx, grpc_call_element *elem, - grpc_metadata_batch *initial_metadata) { - call_data *calld = elem->call_data; - channel_data *channeld = elem->channel_data; - /* Parse incoming request for compression. If any, it'll be available - * at calld->compression_algorithm */ - if (initial_metadata->idx.named.grpc_internal_encoding_request != NULL) { - grpc_mdelem md = - initial_metadata->idx.named.grpc_internal_encoding_request->md; - if (!grpc_compression_algorithm_parse(GRPC_MDVALUE(md), - &calld->compression_algorithm)) { - char *val = grpc_slice_to_c_string(GRPC_MDVALUE(md)); - gpr_log(GPR_ERROR, - "Invalid compression algorithm: '%s' (unknown). Ignoring.", val); - gpr_free(val); - calld->compression_algorithm = GRPC_COMPRESS_NONE; - } - if (!GPR_BITGET(channeld->enabled_algorithms_bitset, - calld->compression_algorithm)) { - char *val = grpc_slice_to_c_string(GRPC_MDVALUE(md)); - gpr_log(GPR_ERROR, - "Invalid compression algorithm: '%s' (previously disabled). " - "Ignoring.", - val); - gpr_free(val); - calld->compression_algorithm = GRPC_COMPRESS_NONE; - } - calld->has_compression_algorithm = 1; - - grpc_metadata_batch_remove( - exec_ctx, initial_metadata, - initial_metadata->idx.named.grpc_internal_encoding_request); - } else { - /* If no algorithm was found in the metadata and we aren't - * exceptionally skipping compression, fall back to the channel - * default */ - calld->compression_algorithm = channeld->default_compression_algorithm; - calld->has_compression_algorithm = 1; /* GPR_TRUE */ - } - - grpc_error *error = GRPC_ERROR_NONE; - /* hint compression algorithm */ - if (calld->compression_algorithm != GRPC_COMPRESS_NONE) { - error = grpc_metadata_batch_add_tail( - exec_ctx, initial_metadata, &calld->compression_algorithm_storage, - grpc_compression_encoding_mdelem(calld->compression_algorithm)); - } - - if (error != GRPC_ERROR_NONE) return error; - - /* convey supported compression algorithms */ - error = grpc_metadata_batch_add_tail( - exec_ctx, initial_metadata, &calld->accept_encoding_storage, - GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS( - channeld->supported_compression_algorithms)); - - return error; -} - -static void continue_send_message(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem); - -static void send_done(grpc_exec_ctx *exec_ctx, void *elemp, grpc_error *error) { - grpc_call_element *elem = elemp; - call_data *calld = elem->call_data; - grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &calld->slices); - calld->post_send->cb(exec_ctx, calld->post_send->cb_arg, error); -} - -static void finish_send_message(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem) { - call_data *calld = elem->call_data; - int did_compress; - grpc_slice_buffer tmp; - grpc_slice_buffer_init(&tmp); - did_compress = grpc_msg_compress(exec_ctx, calld->compression_algorithm, - &calld->slices, &tmp); - if (did_compress) { - if (grpc_compression_trace) { - char *algo_name; - const size_t before_size = calld->slices.length; - const size_t after_size = tmp.length; - const float savings_ratio = 1.0f - (float)after_size / (float)before_size; - GPR_ASSERT(grpc_compression_algorithm_name(calld->compression_algorithm, - &algo_name)); - gpr_log(GPR_DEBUG, "Compressed[%s] %" PRIuPTR " bytes vs. %" PRIuPTR - " bytes (%.2f%% savings)", - algo_name, before_size, after_size, 100 * savings_ratio); - } - grpc_slice_buffer_swap(&calld->slices, &tmp); - calld->send_flags |= GRPC_WRITE_INTERNAL_COMPRESS; - } else { - if (grpc_compression_trace) { - char *algo_name; - GPR_ASSERT(grpc_compression_algorithm_name(calld->compression_algorithm, - &algo_name)); - gpr_log(GPR_DEBUG, - "Algorithm '%s' enabled but decided not to compress. Input size: " - "%" PRIuPTR, - algo_name, calld->slices.length); - } - } - - grpc_slice_buffer_destroy_internal(exec_ctx, &tmp); - - grpc_slice_buffer_stream_init(&calld->replacement_stream, &calld->slices, - calld->send_flags); - calld->send_op->send_message = &calld->replacement_stream.base; - calld->post_send = calld->send_op->on_complete; - calld->send_op->on_complete = &calld->send_done; - - grpc_call_next_op(exec_ctx, elem, calld->send_op); -} - -static void got_slice(grpc_exec_ctx *exec_ctx, void *elemp, grpc_error *error) { - grpc_call_element *elem = elemp; - call_data *calld = elem->call_data; - grpc_slice_buffer_add(&calld->slices, calld->incoming_slice); - if (calld->send_length == calld->slices.length) { - finish_send_message(exec_ctx, elem); - } else { - continue_send_message(exec_ctx, elem); - } -} - -static void continue_send_message(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem) { - call_data *calld = elem->call_data; - while (grpc_byte_stream_next(exec_ctx, calld->send_op->send_message, - &calld->incoming_slice, ~(size_t)0, - &calld->got_slice)) { - grpc_slice_buffer_add(&calld->slices, calld->incoming_slice); - if (calld->send_length == calld->slices.length) { - finish_send_message(exec_ctx, elem); - break; - } - } -} - -static void compress_start_transport_stream_op(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, - grpc_transport_stream_op *op) { - call_data *calld = elem->call_data; - - GPR_TIMER_BEGIN("compress_start_transport_stream_op", 0); - - if (op->send_initial_metadata) { - grpc_error *error = process_send_initial_metadata( - exec_ctx, elem, op->send_initial_metadata); - if (error != GRPC_ERROR_NONE) { - grpc_transport_stream_op_finish_with_failure(exec_ctx, op, error); - return; - } - } - if (op->send_message != NULL && - !skip_compression(elem, op->send_message->flags)) { - calld->send_op = op; - calld->send_length = op->send_message->length; - calld->send_flags = op->send_message->flags; - continue_send_message(exec_ctx, elem); - } else { - /* pass control down the stack */ - grpc_call_next_op(exec_ctx, elem, op); - } - - GPR_TIMER_END("compress_start_transport_stream_op", 0); -} - -/* Constructor for call_data */ -static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, - const grpc_call_element_args *args) { - /* grab pointers to our data from the call element */ - call_data *calld = elem->call_data; - - /* initialize members */ - grpc_slice_buffer_init(&calld->slices); - calld->has_compression_algorithm = 0; - grpc_closure_init(&calld->got_slice, got_slice, elem, - grpc_schedule_on_exec_ctx); - grpc_closure_init(&calld->send_done, send_done, elem, - grpc_schedule_on_exec_ctx); - - return GRPC_ERROR_NONE; -} - -/* Destructor for call_data */ -static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, - const grpc_call_final_info *final_info, - grpc_closure *ignored) { - /* grab pointers to our data from the call element */ - call_data *calld = elem->call_data; - grpc_slice_buffer_destroy_internal(exec_ctx, &calld->slices); -} - -/* Constructor for channel_data */ -static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx, - grpc_channel_element *elem, - grpc_channel_element_args *args) { - channel_data *channeld = elem->channel_data; - - channeld->enabled_algorithms_bitset = - grpc_channel_args_compression_algorithm_get_states(args->channel_args); - - channeld->default_compression_algorithm = - grpc_channel_args_get_compression_algorithm(args->channel_args); - /* Make sure the default isn't disabled. */ - if (!GPR_BITGET(channeld->enabled_algorithms_bitset, - channeld->default_compression_algorithm)) { - gpr_log(GPR_DEBUG, - "compression algorithm %d not enabled: switching to none", - channeld->default_compression_algorithm); - channeld->default_compression_algorithm = GRPC_COMPRESS_NONE; - } - - channeld->supported_compression_algorithms = 1; /* always support identity */ - for (grpc_compression_algorithm algo_idx = 1; - algo_idx < GRPC_COMPRESS_ALGORITHMS_COUNT; ++algo_idx) { - /* skip disabled algorithms */ - if (!GPR_BITGET(channeld->enabled_algorithms_bitset, algo_idx)) { - continue; - } - channeld->supported_compression_algorithms |= 1u << algo_idx; - } - - GPR_ASSERT(!args->is_last); - return GRPC_ERROR_NONE; -} - -/* Destructor for channel data */ -static void destroy_channel_elem(grpc_exec_ctx *exec_ctx, - grpc_channel_element *elem) {} - -const grpc_channel_filter grpc_compress_filter = { - compress_start_transport_stream_op, - grpc_channel_next_op, - sizeof(call_data), - init_call_elem, - grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, - sizeof(channel_data), - init_channel_elem, - destroy_channel_elem, - grpc_call_next_get_peer, - grpc_channel_next_get_info, - "compress"}; diff --git a/src/core/lib/channel/compress_filter.h b/src/core/lib/channel/compress_filter.h deleted file mode 100644 index e4a2a829d5..0000000000 --- a/src/core/lib/channel/compress_filter.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef GRPC_CORE_LIB_CHANNEL_COMPRESS_FILTER_H -#define GRPC_CORE_LIB_CHANNEL_COMPRESS_FILTER_H - -#include - -#include "src/core/lib/channel/channel_stack.h" - -extern int grpc_compression_trace; - -/** Compression filter for outgoing data. - * - * See for the available compression settings. - * - * Compression settings may come from: - * - Channel configuration, as established at channel creation time. - * - The metadata accompanying the outgoing data to be compressed. This is - * taken as a request only. We may choose not to honor it. The metadata key - * is given by \a GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY. - * - * Compression can be disabled for concrete messages (for instance in order to - * prevent CRIME/BEAST type attacks) by having the GRPC_WRITE_NO_COMPRESS set in - * the BEGIN_MESSAGE flags. - * - * The attempted compression mechanism is added to the resulting initial - * metadata under the'grpc-encoding' key. - * - * If compression is actually performed, BEGIN_MESSAGE's flag is modified to - * incorporate GRPC_WRITE_INTERNAL_COMPRESS. Otherwise, and regardless of the - * aforementioned 'grpc-encoding' metadata value, data will pass through - * uncompressed. */ - -extern const grpc_channel_filter grpc_compress_filter; - -#endif /* GRPC_CORE_LIB_CHANNEL_COMPRESS_FILTER_H */ diff --git a/src/core/lib/channel/http_client_filter.c b/src/core/lib/channel/http_client_filter.c deleted file mode 100644 index 17af2013d9..0000000000 --- a/src/core/lib/channel/http_client_filter.c +++ /dev/null @@ -1,582 +0,0 @@ -/* - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "src/core/lib/channel/http_client_filter.h" -#include -#include -#include -#include -#include "src/core/lib/profiling/timers.h" -#include "src/core/lib/slice/b64.h" -#include "src/core/lib/slice/percent_encoding.h" -#include "src/core/lib/slice/slice_internal.h" -#include "src/core/lib/slice/slice_string_helpers.h" -#include "src/core/lib/support/string.h" -#include "src/core/lib/transport/static_metadata.h" -#include "src/core/lib/transport/transport_impl.h" - -#define EXPECTED_CONTENT_TYPE "application/grpc" -#define EXPECTED_CONTENT_TYPE_LENGTH sizeof(EXPECTED_CONTENT_TYPE) - 1 - -/* default maximum size of payload eligable for GET request */ -static const size_t kMaxPayloadSizeForGet = 2048; - -typedef struct call_data { - grpc_linked_mdelem method; - grpc_linked_mdelem scheme; - grpc_linked_mdelem authority; - grpc_linked_mdelem te_trailers; - grpc_linked_mdelem content_type; - grpc_linked_mdelem user_agent; - - grpc_metadata_batch *recv_initial_metadata; - grpc_metadata_batch *recv_trailing_metadata; - uint8_t *payload_bytes; - - /* Vars to read data off of send_message */ - grpc_transport_stream_op send_op; - uint32_t send_length; - uint32_t send_flags; - grpc_slice incoming_slice; - grpc_slice_buffer_stream replacement_stream; - grpc_slice_buffer slices; - /* flag that indicates that all slices of send_messages aren't availble */ - bool send_message_blocked; - - /** Closure to call when finished with the hc_on_recv hook */ - grpc_closure *on_done_recv_initial_metadata; - grpc_closure *on_done_recv_trailing_metadata; - grpc_closure *on_complete; - grpc_closure *post_send; - - /** Receive closures are chained: we inject this closure as the on_done_recv - up-call on transport_op, and remember to call our on_done_recv member - after handling it. */ - grpc_closure hc_on_recv_initial_metadata; - grpc_closure hc_on_recv_trailing_metadata; - grpc_closure hc_on_complete; - grpc_closure got_slice; - grpc_closure send_done; -} call_data; - -typedef struct channel_data { - grpc_mdelem static_scheme; - grpc_mdelem user_agent; - size_t max_payload_size_for_get; -} channel_data; - -static grpc_error *client_filter_incoming_metadata(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, - grpc_metadata_batch *b) { - if (b->idx.named.status != NULL) { - if (grpc_mdelem_eq(b->idx.named.status->md, GRPC_MDELEM_STATUS_200)) { - grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.status); - } else { - char *val = grpc_dump_slice(GRPC_MDVALUE(b->idx.named.status->md), - GPR_DUMP_ASCII); - char *msg; - gpr_asprintf(&msg, "Received http2 header with status: %s", val); - grpc_error *e = grpc_error_set_str( - grpc_error_set_int( - grpc_error_set_str( - GRPC_ERROR_CREATE_FROM_STATIC_STRING( - "Received http2 :status header with non-200 OK status"), - GRPC_ERROR_STR_VALUE, grpc_slice_from_copied_string(val)), - GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_CANCELLED), - GRPC_ERROR_STR_GRPC_MESSAGE, grpc_slice_from_copied_string(msg)); - gpr_free(val); - gpr_free(msg); - return e; - } - } - - if (b->idx.named.grpc_message != NULL) { - grpc_slice pct_decoded_msg = grpc_permissive_percent_decode_slice( - GRPC_MDVALUE(b->idx.named.grpc_message->md)); - if (grpc_slice_is_equivalent(pct_decoded_msg, - GRPC_MDVALUE(b->idx.named.grpc_message->md))) { - grpc_slice_unref_internal(exec_ctx, pct_decoded_msg); - } else { - grpc_metadata_batch_set_value(exec_ctx, b->idx.named.grpc_message, - pct_decoded_msg); - } - } - - if (b->idx.named.content_type != NULL) { - if (!grpc_mdelem_eq(b->idx.named.content_type->md, - GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC)) { - if (grpc_slice_buf_start_eq(GRPC_MDVALUE(b->idx.named.content_type->md), - EXPECTED_CONTENT_TYPE, - EXPECTED_CONTENT_TYPE_LENGTH) && - (GRPC_SLICE_START_PTR(GRPC_MDVALUE( - b->idx.named.content_type->md))[EXPECTED_CONTENT_TYPE_LENGTH] == - '+' || - GRPC_SLICE_START_PTR(GRPC_MDVALUE( - b->idx.named.content_type->md))[EXPECTED_CONTENT_TYPE_LENGTH] == - ';')) { - /* Although the C implementation doesn't (currently) generate them, - any custom +-suffix is explicitly valid. */ - /* TODO(klempner): We should consider preallocating common values such - as +proto or +json, or at least stashing them if we see them. */ - /* TODO(klempner): Should we be surfacing this to application code? */ - } else { - /* TODO(klempner): We're currently allowing this, but we shouldn't - see it without a proxy so log for now. */ - char *val = grpc_dump_slice(GRPC_MDVALUE(b->idx.named.content_type->md), - GPR_DUMP_ASCII); - gpr_log(GPR_INFO, "Unexpected content-type '%s'", val); - gpr_free(val); - } - } - grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.content_type); - } - - return GRPC_ERROR_NONE; -} - -static void hc_on_recv_initial_metadata(grpc_exec_ctx *exec_ctx, - void *user_data, grpc_error *error) { - grpc_call_element *elem = user_data; - call_data *calld = elem->call_data; - if (error == GRPC_ERROR_NONE) { - error = client_filter_incoming_metadata(exec_ctx, elem, - calld->recv_initial_metadata); - } else { - GRPC_ERROR_REF(error); - } - grpc_closure_run(exec_ctx, calld->on_done_recv_initial_metadata, error); -} - -static void hc_on_recv_trailing_metadata(grpc_exec_ctx *exec_ctx, - void *user_data, grpc_error *error) { - grpc_call_element *elem = user_data; - call_data *calld = elem->call_data; - if (error == GRPC_ERROR_NONE) { - error = client_filter_incoming_metadata(exec_ctx, elem, - calld->recv_trailing_metadata); - } else { - GRPC_ERROR_REF(error); - } - grpc_closure_run(exec_ctx, calld->on_done_recv_trailing_metadata, error); -} - -static void hc_on_complete(grpc_exec_ctx *exec_ctx, void *user_data, - grpc_error *error) { - grpc_call_element *elem = user_data; - call_data *calld = elem->call_data; - if (calld->payload_bytes) { - gpr_free(calld->payload_bytes); - calld->payload_bytes = NULL; - } - calld->on_complete->cb(exec_ctx, calld->on_complete->cb_arg, error); -} - -static void send_done(grpc_exec_ctx *exec_ctx, void *elemp, grpc_error *error) { - grpc_call_element *elem = elemp; - call_data *calld = elem->call_data; - grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &calld->slices); - calld->post_send->cb(exec_ctx, calld->post_send->cb_arg, error); -} - -static void remove_if_present(grpc_exec_ctx *exec_ctx, - grpc_metadata_batch *batch, - grpc_metadata_batch_callouts_index idx) { - if (batch->idx.array[idx] != NULL) { - grpc_metadata_batch_remove(exec_ctx, batch, batch->idx.array[idx]); - } -} - -static void continue_send_message(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem) { - call_data *calld = elem->call_data; - uint8_t *wrptr = calld->payload_bytes; - while (grpc_byte_stream_next(exec_ctx, calld->send_op.send_message, - &calld->incoming_slice, ~(size_t)0, - &calld->got_slice)) { - memcpy(wrptr, GRPC_SLICE_START_PTR(calld->incoming_slice), - GRPC_SLICE_LENGTH(calld->incoming_slice)); - wrptr += GRPC_SLICE_LENGTH(calld->incoming_slice); - grpc_slice_buffer_add(&calld->slices, calld->incoming_slice); - if (calld->send_length == calld->slices.length) { - calld->send_message_blocked = false; - break; - } - } -} - -static void got_slice(grpc_exec_ctx *exec_ctx, void *elemp, grpc_error *error) { - grpc_call_element *elem = elemp; - call_data *calld = elem->call_data; - calld->send_message_blocked = false; - grpc_slice_buffer_add(&calld->slices, calld->incoming_slice); - if (calld->send_length == calld->slices.length) { - /* Pass down the original send_message op that was blocked.*/ - grpc_slice_buffer_stream_init(&calld->replacement_stream, &calld->slices, - calld->send_flags); - calld->send_op.send_message = &calld->replacement_stream.base; - calld->post_send = calld->send_op.on_complete; - calld->send_op.on_complete = &calld->send_done; - grpc_call_next_op(exec_ctx, elem, &calld->send_op); - } else { - continue_send_message(exec_ctx, elem); - } -} - -static grpc_error *hc_mutate_op(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, - grpc_transport_stream_op *op) { - /* grab pointers to our data from the call element */ - call_data *calld = elem->call_data; - channel_data *channeld = elem->channel_data; - grpc_error *error; - - if (op->send_initial_metadata != NULL) { - /* Decide which HTTP VERB to use. We use GET if the request is marked - cacheable, and the operation contains both initial metadata and send - message, and the payload is below the size threshold, and all the data - for this request is immediately available. */ - grpc_mdelem method = GRPC_MDELEM_METHOD_POST; - if ((op->send_initial_metadata_flags & - GRPC_INITIAL_METADATA_CACHEABLE_REQUEST) && - op->send_message != NULL && - op->send_message->length < channeld->max_payload_size_for_get) { - method = GRPC_MDELEM_METHOD_GET; - /* The following write to calld->send_message_blocked isn't racy with - reads in hc_start_transport_op (which deals with SEND_MESSAGE ops) because - being here means ops->send_message is not NULL, which is primarily - guarding the read there. */ - calld->send_message_blocked = true; - } else if (op->send_initial_metadata_flags & - GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST) { - method = GRPC_MDELEM_METHOD_PUT; - } - - /* Attempt to read the data from send_message and create a header field. */ - if (grpc_mdelem_eq(method, GRPC_MDELEM_METHOD_GET)) { - /* allocate memory to hold the entire payload */ - calld->payload_bytes = gpr_malloc(op->send_message->length); - - /* read slices of send_message and copy into payload_bytes */ - calld->send_op = *op; - calld->send_length = op->send_message->length; - calld->send_flags = op->send_message->flags; - continue_send_message(exec_ctx, elem); - - if (calld->send_message_blocked == false) { - /* when all the send_message data is available, then modify the path - * MDELEM by appending base64 encoded query to the path */ - const int k_url_safe = 1; - const int k_multi_line = 0; - const unsigned char k_query_separator = '?'; - - grpc_slice path_slice = - GRPC_MDVALUE(op->send_initial_metadata->idx.named.path->md); - /* sum up individual component's lengths and allocate enough memory to - * hold combined path+query */ - size_t estimated_len = GRPC_SLICE_LENGTH(path_slice); - estimated_len++; /* for the '?' */ - estimated_len += grpc_base64_estimate_encoded_size( - op->send_message->length, k_url_safe, k_multi_line); - estimated_len += 1; /* for the trailing 0 */ - grpc_slice path_with_query_slice = grpc_slice_malloc(estimated_len); - - /* memcopy individual pieces into this slice */ - uint8_t *write_ptr = - (uint8_t *)GRPC_SLICE_START_PTR(path_with_query_slice); - uint8_t *original_path = (uint8_t *)GRPC_SLICE_START_PTR(path_slice); - memcpy(write_ptr, original_path, GRPC_SLICE_LENGTH(path_slice)); - write_ptr += GRPC_SLICE_LENGTH(path_slice); - - *write_ptr = k_query_separator; - write_ptr++; /* for the '?' */ - - grpc_base64_encode_core((char *)write_ptr, calld->payload_bytes, - op->send_message->length, k_url_safe, - k_multi_line); - - /* remove trailing unused memory and add trailing 0 to terminate string - */ - char *t = (char *)GRPC_SLICE_START_PTR(path_with_query_slice); - /* safe to use strlen since base64_encode will always add '\0' */ - size_t path_length = strlen(t) + 1; - *(t + path_length) = '\0'; - path_with_query_slice = - grpc_slice_sub(path_with_query_slice, 0, path_length); - - /* substitute previous path with the new path+query */ - grpc_mdelem mdelem_path_and_query = grpc_mdelem_from_slices( - exec_ctx, GRPC_MDSTR_PATH, path_with_query_slice); - grpc_metadata_batch *b = op->send_initial_metadata; - error = grpc_metadata_batch_substitute(exec_ctx, b, b->idx.named.path, - mdelem_path_and_query); - if (error != GRPC_ERROR_NONE) return error; - - calld->on_complete = op->on_complete; - op->on_complete = &calld->hc_on_complete; - op->send_message = NULL; - grpc_slice_unref_internal(exec_ctx, path_with_query_slice); - } else { - /* Not all data is available. Fall back to POST. */ - gpr_log(GPR_DEBUG, - "Request is marked Cacheable but not all data is available.\ - Falling back to POST"); - method = GRPC_MDELEM_METHOD_POST; - } - } - - remove_if_present(exec_ctx, op->send_initial_metadata, GRPC_BATCH_METHOD); - remove_if_present(exec_ctx, op->send_initial_metadata, GRPC_BATCH_SCHEME); - remove_if_present(exec_ctx, op->send_initial_metadata, GRPC_BATCH_TE); - remove_if_present(exec_ctx, op->send_initial_metadata, - GRPC_BATCH_CONTENT_TYPE); - remove_if_present(exec_ctx, op->send_initial_metadata, - GRPC_BATCH_USER_AGENT); - - /* Send : prefixed headers, which have to be before any application - layer headers. */ - error = grpc_metadata_batch_add_head(exec_ctx, op->send_initial_metadata, - &calld->method, method); - if (error != GRPC_ERROR_NONE) return error; - error = - grpc_metadata_batch_add_head(exec_ctx, op->send_initial_metadata, - &calld->scheme, channeld->static_scheme); - if (error != GRPC_ERROR_NONE) return error; - error = grpc_metadata_batch_add_tail(exec_ctx, op->send_initial_metadata, - &calld->te_trailers, - GRPC_MDELEM_TE_TRAILERS); - if (error != GRPC_ERROR_NONE) return error; - error = grpc_metadata_batch_add_tail( - exec_ctx, op->send_initial_metadata, &calld->content_type, - GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC); - if (error != GRPC_ERROR_NONE) return error; - error = grpc_metadata_batch_add_tail(exec_ctx, op->send_initial_metadata, - &calld->user_agent, - GRPC_MDELEM_REF(channeld->user_agent)); - if (error != GRPC_ERROR_NONE) return error; - } - - if (op->recv_initial_metadata != NULL) { - /* substitute our callback for the higher callback */ - calld->recv_initial_metadata = op->recv_initial_metadata; - calld->on_done_recv_initial_metadata = op->recv_initial_metadata_ready; - op->recv_initial_metadata_ready = &calld->hc_on_recv_initial_metadata; - } - - if (op->recv_trailing_metadata != NULL) { - /* substitute our callback for the higher callback */ - calld->recv_trailing_metadata = op->recv_trailing_metadata; - calld->on_done_recv_trailing_metadata = op->on_complete; - op->on_complete = &calld->hc_on_recv_trailing_metadata; - } - - return GRPC_ERROR_NONE; -} - -static void hc_start_transport_op(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, - grpc_transport_stream_op *op) { - GPR_TIMER_BEGIN("hc_start_transport_op", 0); - GRPC_CALL_LOG_OP(GPR_INFO, elem, op); - grpc_error *error = hc_mutate_op(exec_ctx, elem, op); - if (error != GRPC_ERROR_NONE) { - grpc_transport_stream_op_finish_with_failure(exec_ctx, op, error); - } else { - call_data *calld = elem->call_data; - if (op->send_message != NULL && calld->send_message_blocked) { - /* Don't forward the op. send_message contains slices that aren't ready - yet. The call will be forwarded by the op_complete of slice read call. - */ - } else { - grpc_call_next_op(exec_ctx, elem, op); - } - } - GPR_TIMER_END("hc_start_transport_op", 0); -} - -/* Constructor for call_data */ -static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, - const grpc_call_element_args *args) { - call_data *calld = elem->call_data; - calld->on_done_recv_initial_metadata = NULL; - calld->on_done_recv_trailing_metadata = NULL; - calld->on_complete = NULL; - calld->payload_bytes = NULL; - calld->send_message_blocked = false; - grpc_slice_buffer_init(&calld->slices); - grpc_closure_init(&calld->hc_on_recv_initial_metadata, - hc_on_recv_initial_metadata, elem, - grpc_schedule_on_exec_ctx); - grpc_closure_init(&calld->hc_on_recv_trailing_metadata, - hc_on_recv_trailing_metadata, elem, - grpc_schedule_on_exec_ctx); - grpc_closure_init(&calld->hc_on_complete, hc_on_complete, elem, - grpc_schedule_on_exec_ctx); - grpc_closure_init(&calld->got_slice, got_slice, elem, - grpc_schedule_on_exec_ctx); - grpc_closure_init(&calld->send_done, send_done, elem, - grpc_schedule_on_exec_ctx); - return GRPC_ERROR_NONE; -} - -/* Destructor for call_data */ -static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, - const grpc_call_final_info *final_info, - grpc_closure *ignored) { - call_data *calld = elem->call_data; - grpc_slice_buffer_destroy_internal(exec_ctx, &calld->slices); -} - -static grpc_mdelem scheme_from_args(const grpc_channel_args *args) { - unsigned i; - size_t j; - grpc_mdelem valid_schemes[] = {GRPC_MDELEM_SCHEME_HTTP, - GRPC_MDELEM_SCHEME_HTTPS}; - if (args != NULL) { - for (i = 0; i < args->num_args; ++i) { - if (args->args[i].type == GRPC_ARG_STRING && - strcmp(args->args[i].key, GRPC_ARG_HTTP2_SCHEME) == 0) { - for (j = 0; j < GPR_ARRAY_SIZE(valid_schemes); j++) { - if (0 == grpc_slice_str_cmp(GRPC_MDVALUE(valid_schemes[j]), - args->args[i].value.string)) { - return valid_schemes[j]; - } - } - } - } - } - return GRPC_MDELEM_SCHEME_HTTP; -} - -static size_t max_payload_size_from_args(const grpc_channel_args *args) { - if (args != NULL) { - for (size_t i = 0; i < args->num_args; ++i) { - if (0 == strcmp(args->args[i].key, GRPC_ARG_MAX_PAYLOAD_SIZE_FOR_GET)) { - if (args->args[i].type != GRPC_ARG_INTEGER) { - gpr_log(GPR_ERROR, "%s: must be an integer", - GRPC_ARG_MAX_PAYLOAD_SIZE_FOR_GET); - } else { - return (size_t)args->args[i].value.integer; - } - } - } - } - return kMaxPayloadSizeForGet; -} - -static grpc_slice user_agent_from_args(const grpc_channel_args *args, - const char *transport_name) { - gpr_strvec v; - size_t i; - int is_first = 1; - char *tmp; - grpc_slice result; - - gpr_strvec_init(&v); - - for (i = 0; args && i < args->num_args; i++) { - if (0 == strcmp(args->args[i].key, GRPC_ARG_PRIMARY_USER_AGENT_STRING)) { - if (args->args[i].type != GRPC_ARG_STRING) { - gpr_log(GPR_ERROR, "Channel argument '%s' should be a string", - GRPC_ARG_PRIMARY_USER_AGENT_STRING); - } else { - if (!is_first) gpr_strvec_add(&v, gpr_strdup(" ")); - is_first = 0; - gpr_strvec_add(&v, gpr_strdup(args->args[i].value.string)); - } - } - } - - gpr_asprintf(&tmp, "%sgrpc-c/%s (%s; %s; %s)", is_first ? "" : " ", - grpc_version_string(), GPR_PLATFORM_STRING, transport_name, - grpc_g_stands_for()); - is_first = 0; - gpr_strvec_add(&v, tmp); - - for (i = 0; args && i < args->num_args; i++) { - if (0 == strcmp(args->args[i].key, GRPC_ARG_SECONDARY_USER_AGENT_STRING)) { - if (args->args[i].type != GRPC_ARG_STRING) { - gpr_log(GPR_ERROR, "Channel argument '%s' should be a string", - GRPC_ARG_SECONDARY_USER_AGENT_STRING); - } else { - if (!is_first) gpr_strvec_add(&v, gpr_strdup(" ")); - is_first = 0; - gpr_strvec_add(&v, gpr_strdup(args->args[i].value.string)); - } - } - } - - tmp = gpr_strvec_flatten(&v, NULL); - gpr_strvec_destroy(&v); - result = grpc_slice_intern(grpc_slice_from_static_string(tmp)); - gpr_free(tmp); - - return result; -} - -/* Constructor for channel_data */ -static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx, - grpc_channel_element *elem, - grpc_channel_element_args *args) { - channel_data *chand = elem->channel_data; - GPR_ASSERT(!args->is_last); - GPR_ASSERT(args->optional_transport != NULL); - chand->static_scheme = scheme_from_args(args->channel_args); - chand->max_payload_size_for_get = - max_payload_size_from_args(args->channel_args); - chand->user_agent = grpc_mdelem_from_slices( - exec_ctx, GRPC_MDSTR_USER_AGENT, - user_agent_from_args(args->channel_args, - args->optional_transport->vtable->name)); - return GRPC_ERROR_NONE; -} - -/* Destructor for channel data */ -static void destroy_channel_elem(grpc_exec_ctx *exec_ctx, - grpc_channel_element *elem) { - channel_data *chand = elem->channel_data; - GRPC_MDELEM_UNREF(exec_ctx, chand->user_agent); -} - -const grpc_channel_filter grpc_http_client_filter = { - hc_start_transport_op, - grpc_channel_next_op, - sizeof(call_data), - init_call_elem, - grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, - sizeof(channel_data), - init_channel_elem, - destroy_channel_elem, - grpc_call_next_get_peer, - grpc_channel_next_get_info, - "http-client"}; diff --git a/src/core/lib/channel/http_client_filter.h b/src/core/lib/channel/http_client_filter.h deleted file mode 100644 index 9e6e106e9c..0000000000 --- a/src/core/lib/channel/http_client_filter.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef GRPC_CORE_LIB_CHANNEL_HTTP_CLIENT_FILTER_H -#define GRPC_CORE_LIB_CHANNEL_HTTP_CLIENT_FILTER_H - -#include "src/core/lib/channel/channel_stack.h" - -/* Processes metadata on the client side for HTTP2 transports */ -extern const grpc_channel_filter grpc_http_client_filter; - -/* Channel arg to override the http2 :scheme header */ -#define GRPC_ARG_HTTP2_SCHEME "grpc.http2_scheme" - -/* Channel arg to determine maximum size of payload eligable for GET request */ -#define GRPC_ARG_MAX_PAYLOAD_SIZE_FOR_GET "grpc.max_payload_size_for_get" - -#endif /* GRPC_CORE_LIB_CHANNEL_HTTP_CLIENT_FILTER_H */ diff --git a/src/core/lib/channel/http_server_filter.c b/src/core/lib/channel/http_server_filter.c deleted file mode 100644 index df0f95010b..0000000000 --- a/src/core/lib/channel/http_server_filter.c +++ /dev/null @@ -1,429 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "src/core/lib/channel/http_server_filter.h" - -#include -#include -#include -#include "src/core/lib/profiling/timers.h" -#include "src/core/lib/slice/b64.h" -#include "src/core/lib/slice/percent_encoding.h" -#include "src/core/lib/slice/slice_internal.h" -#include "src/core/lib/slice/slice_string_helpers.h" -#include "src/core/lib/transport/static_metadata.h" - -#define EXPECTED_CONTENT_TYPE "application/grpc" -#define EXPECTED_CONTENT_TYPE_LENGTH sizeof(EXPECTED_CONTENT_TYPE) - 1 - -extern int grpc_http_trace; - -typedef struct call_data { - grpc_linked_mdelem status; - grpc_linked_mdelem content_type; - - /* did this request come with path query containing request payload */ - bool seen_path_with_query; - /* flag to ensure payload_bin is delivered only once */ - bool payload_bin_delivered; - - grpc_metadata_batch *recv_initial_metadata; - bool *recv_idempotent_request; - bool *recv_cacheable_request; - /** Closure to call when finished with the hs_on_recv hook */ - grpc_closure *on_done_recv; - /** Closure to call when we retrieve read message from the path URI - */ - grpc_closure *recv_message_ready; - grpc_closure *on_complete; - grpc_byte_stream **pp_recv_message; - grpc_slice_buffer read_slice_buffer; - grpc_slice_buffer_stream read_stream; - - /** Receive closures are chained: we inject this closure as the on_done_recv - up-call on transport_op, and remember to call our on_done_recv member - after handling it. */ - grpc_closure hs_on_recv; - grpc_closure hs_on_complete; - grpc_closure hs_recv_message_ready; -} call_data; - -typedef struct channel_data { uint8_t unused; } channel_data; - -static grpc_error *server_filter_outgoing_metadata(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, - grpc_metadata_batch *b) { - if (b->idx.named.grpc_message != NULL) { - grpc_slice pct_encoded_msg = grpc_percent_encode_slice( - GRPC_MDVALUE(b->idx.named.grpc_message->md), - grpc_compatible_percent_encoding_unreserved_bytes); - if (grpc_slice_is_equivalent(pct_encoded_msg, - GRPC_MDVALUE(b->idx.named.grpc_message->md))) { - grpc_slice_unref_internal(exec_ctx, pct_encoded_msg); - } else { - grpc_metadata_batch_set_value(exec_ctx, b->idx.named.grpc_message, - pct_encoded_msg); - } - } - return GRPC_ERROR_NONE; -} - -static void add_error(const char *error_name, grpc_error **cumulative, - grpc_error *new) { - if (new == GRPC_ERROR_NONE) return; - if (*cumulative == GRPC_ERROR_NONE) { - *cumulative = GRPC_ERROR_CREATE_FROM_COPIED_STRING(error_name); - } - *cumulative = grpc_error_add_child(*cumulative, new); -} - -static grpc_error *server_filter_incoming_metadata(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, - grpc_metadata_batch *b) { - call_data *calld = elem->call_data; - grpc_error *error = GRPC_ERROR_NONE; - static const char *error_name = "Failed processing incoming headers"; - - if (b->idx.named.method != NULL) { - if (grpc_mdelem_eq(b->idx.named.method->md, GRPC_MDELEM_METHOD_POST)) { - *calld->recv_idempotent_request = false; - *calld->recv_cacheable_request = false; - } else if (grpc_mdelem_eq(b->idx.named.method->md, - GRPC_MDELEM_METHOD_PUT)) { - *calld->recv_idempotent_request = true; - } else if (grpc_mdelem_eq(b->idx.named.method->md, - GRPC_MDELEM_METHOD_GET)) { - *calld->recv_cacheable_request = true; - } else { - add_error(error_name, &error, - grpc_attach_md_to_error( - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Bad header"), - b->idx.named.method->md)); - } - grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.method); - } else { - add_error( - error_name, &error, - grpc_error_set_str( - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Missing header"), - GRPC_ERROR_STR_KEY, grpc_slice_from_static_string(":method"))); - } - - if (b->idx.named.te != NULL) { - if (!grpc_mdelem_eq(b->idx.named.te->md, GRPC_MDELEM_TE_TRAILERS)) { - add_error(error_name, &error, - grpc_attach_md_to_error( - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Bad header"), - b->idx.named.te->md)); - } - grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.te); - } else { - add_error(error_name, &error, - grpc_error_set_str( - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Missing header"), - GRPC_ERROR_STR_KEY, grpc_slice_from_static_string("te"))); - } - - if (b->idx.named.scheme != NULL) { - if (!grpc_mdelem_eq(b->idx.named.scheme->md, GRPC_MDELEM_SCHEME_HTTP) && - !grpc_mdelem_eq(b->idx.named.scheme->md, GRPC_MDELEM_SCHEME_HTTPS) && - !grpc_mdelem_eq(b->idx.named.scheme->md, GRPC_MDELEM_SCHEME_GRPC)) { - add_error(error_name, &error, - grpc_attach_md_to_error( - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Bad header"), - b->idx.named.scheme->md)); - } - grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.scheme); - } else { - add_error( - error_name, &error, - grpc_error_set_str( - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Missing header"), - GRPC_ERROR_STR_KEY, grpc_slice_from_static_string(":scheme"))); - } - - if (b->idx.named.content_type != NULL) { - if (!grpc_mdelem_eq(b->idx.named.content_type->md, - GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC)) { - if (grpc_slice_buf_start_eq(GRPC_MDVALUE(b->idx.named.content_type->md), - EXPECTED_CONTENT_TYPE, - EXPECTED_CONTENT_TYPE_LENGTH) && - (GRPC_SLICE_START_PTR(GRPC_MDVALUE( - b->idx.named.content_type->md))[EXPECTED_CONTENT_TYPE_LENGTH] == - '+' || - GRPC_SLICE_START_PTR(GRPC_MDVALUE( - b->idx.named.content_type->md))[EXPECTED_CONTENT_TYPE_LENGTH] == - ';')) { - /* Although the C implementation doesn't (currently) generate them, - any custom +-suffix is explicitly valid. */ - /* TODO(klempner): We should consider preallocating common values such - as +proto or +json, or at least stashing them if we see them. */ - /* TODO(klempner): Should we be surfacing this to application code? */ - } else { - /* TODO(klempner): We're currently allowing this, but we shouldn't - see it without a proxy so log for now. */ - char *val = grpc_dump_slice(GRPC_MDVALUE(b->idx.named.content_type->md), - GPR_DUMP_ASCII); - gpr_log(GPR_INFO, "Unexpected content-type '%s'", val); - gpr_free(val); - } - } - grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.content_type); - } - - if (b->idx.named.path == NULL) { - add_error(error_name, &error, - grpc_error_set_str( - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Missing header"), - GRPC_ERROR_STR_KEY, grpc_slice_from_static_string(":path"))); - } else if (*calld->recv_cacheable_request == true) { - /* We have a cacheable request made with GET verb. The path contains the - * query parameter which is base64 encoded request payload. */ - const char k_query_separator = '?'; - grpc_slice path_slice = GRPC_MDVALUE(b->idx.named.path->md); - uint8_t *path_ptr = (uint8_t *)GRPC_SLICE_START_PTR(path_slice); - size_t path_length = GRPC_SLICE_LENGTH(path_slice); - /* offset of the character '?' */ - size_t offset = 0; - for (offset = 0; offset < path_length && *path_ptr != k_query_separator; - path_ptr++, offset++) - ; - if (offset < path_length) { - grpc_slice query_slice = - grpc_slice_sub(path_slice, offset + 1, path_length); - - /* substitute path metadata with just the path (not query) */ - grpc_mdelem mdelem_path_without_query = grpc_mdelem_from_slices( - exec_ctx, GRPC_MDSTR_PATH, grpc_slice_sub(path_slice, 0, offset)); - - grpc_metadata_batch_substitute(exec_ctx, b, b->idx.named.path, - mdelem_path_without_query); - - /* decode payload from query and add to the slice buffer to be returned */ - const int k_url_safe = 1; - grpc_slice_buffer_add( - &calld->read_slice_buffer, - grpc_base64_decode(exec_ctx, - (const char *)GRPC_SLICE_START_PTR(query_slice), - k_url_safe)); - grpc_slice_buffer_stream_init(&calld->read_stream, - &calld->read_slice_buffer, 0); - calld->seen_path_with_query = true; - grpc_slice_unref_internal(exec_ctx, query_slice); - } else { - gpr_log(GPR_ERROR, "GET request without QUERY"); - } - } - - if (b->idx.named.host != NULL && b->idx.named.authority == NULL) { - grpc_linked_mdelem *el = b->idx.named.host; - grpc_mdelem md = GRPC_MDELEM_REF(el->md); - grpc_metadata_batch_remove(exec_ctx, b, el); - add_error( - error_name, &error, - grpc_metadata_batch_add_head( - exec_ctx, b, el, grpc_mdelem_from_slices( - exec_ctx, GRPC_MDSTR_AUTHORITY, - grpc_slice_ref_internal(GRPC_MDVALUE(md))))); - GRPC_MDELEM_UNREF(exec_ctx, md); - } - - if (b->idx.named.authority == NULL) { - add_error( - error_name, &error, - grpc_error_set_str( - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Missing header"), - GRPC_ERROR_STR_KEY, grpc_slice_from_static_string(":authority"))); - } - - return error; -} - -static void hs_on_recv(grpc_exec_ctx *exec_ctx, void *user_data, - grpc_error *err) { - grpc_call_element *elem = user_data; - call_data *calld = elem->call_data; - if (err == GRPC_ERROR_NONE) { - err = server_filter_incoming_metadata(exec_ctx, elem, - calld->recv_initial_metadata); - } else { - GRPC_ERROR_REF(err); - } - grpc_closure_run(exec_ctx, calld->on_done_recv, err); -} - -static void hs_on_complete(grpc_exec_ctx *exec_ctx, void *user_data, - grpc_error *err) { - grpc_call_element *elem = user_data; - call_data *calld = elem->call_data; - /* Call recv_message_ready if we got the payload via the path field */ - if (calld->seen_path_with_query && calld->recv_message_ready != NULL) { - *calld->pp_recv_message = calld->payload_bin_delivered - ? NULL - : (grpc_byte_stream *)&calld->read_stream; - grpc_closure_run(exec_ctx, calld->recv_message_ready, GRPC_ERROR_REF(err)); - calld->recv_message_ready = NULL; - calld->payload_bin_delivered = true; - } - grpc_closure_run(exec_ctx, calld->on_complete, GRPC_ERROR_REF(err)); -} - -static void hs_recv_message_ready(grpc_exec_ctx *exec_ctx, void *user_data, - grpc_error *err) { - grpc_call_element *elem = user_data; - call_data *calld = elem->call_data; - if (calld->seen_path_with_query) { - /* do nothing. This is probably a GET request, and payload will be returned - in hs_on_complete callback. */ - } else { - grpc_closure_run(exec_ctx, calld->recv_message_ready, GRPC_ERROR_REF(err)); - } -} - -static void hs_mutate_op(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, - grpc_transport_stream_op *op) { - /* grab pointers to our data from the call element */ - call_data *calld = elem->call_data; - - if (op->send_initial_metadata != NULL) { - grpc_error *error = GRPC_ERROR_NONE; - static const char *error_name = "Failed sending initial metadata"; - add_error(error_name, &error, grpc_metadata_batch_add_head( - exec_ctx, op->send_initial_metadata, - &calld->status, GRPC_MDELEM_STATUS_200)); - add_error(error_name, &error, - grpc_metadata_batch_add_tail( - exec_ctx, op->send_initial_metadata, &calld->content_type, - GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC)); - add_error(error_name, &error, - server_filter_outgoing_metadata(exec_ctx, elem, - op->send_initial_metadata)); - if (error != GRPC_ERROR_NONE) { - grpc_transport_stream_op_finish_with_failure(exec_ctx, op, error); - return; - } - } - - if (op->recv_initial_metadata) { - /* substitute our callback for the higher callback */ - GPR_ASSERT(op->recv_idempotent_request != NULL); - GPR_ASSERT(op->recv_cacheable_request != NULL); - calld->recv_initial_metadata = op->recv_initial_metadata; - calld->recv_idempotent_request = op->recv_idempotent_request; - calld->recv_cacheable_request = op->recv_cacheable_request; - calld->on_done_recv = op->recv_initial_metadata_ready; - op->recv_initial_metadata_ready = &calld->hs_on_recv; - } - - if (op->recv_message) { - calld->recv_message_ready = op->recv_message_ready; - calld->pp_recv_message = op->recv_message; - if (op->recv_message_ready) { - op->recv_message_ready = &calld->hs_recv_message_ready; - } - if (op->on_complete) { - calld->on_complete = op->on_complete; - op->on_complete = &calld->hs_on_complete; - } - } - - if (op->send_trailing_metadata) { - grpc_error *error = server_filter_outgoing_metadata( - exec_ctx, elem, op->send_trailing_metadata); - if (error != GRPC_ERROR_NONE) { - grpc_transport_stream_op_finish_with_failure(exec_ctx, op, error); - return; - } - } -} - -static void hs_start_transport_op(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, - grpc_transport_stream_op *op) { - GRPC_CALL_LOG_OP(GPR_INFO, elem, op); - GPR_TIMER_BEGIN("hs_start_transport_op", 0); - hs_mutate_op(exec_ctx, elem, op); - grpc_call_next_op(exec_ctx, elem, op); - GPR_TIMER_END("hs_start_transport_op", 0); -} - -/* Constructor for call_data */ -static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, - const grpc_call_element_args *args) { - /* grab pointers to our data from the call element */ - call_data *calld = elem->call_data; - /* initialize members */ - grpc_closure_init(&calld->hs_on_recv, hs_on_recv, elem, - grpc_schedule_on_exec_ctx); - grpc_closure_init(&calld->hs_on_complete, hs_on_complete, elem, - grpc_schedule_on_exec_ctx); - grpc_closure_init(&calld->hs_recv_message_ready, hs_recv_message_ready, elem, - grpc_schedule_on_exec_ctx); - grpc_slice_buffer_init(&calld->read_slice_buffer); - return GRPC_ERROR_NONE; -} - -/* Destructor for call_data */ -static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, - const grpc_call_final_info *final_info, - grpc_closure *ignored) { - call_data *calld = elem->call_data; - grpc_slice_buffer_destroy_internal(exec_ctx, &calld->read_slice_buffer); -} - -/* Constructor for channel_data */ -static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx, - grpc_channel_element *elem, - grpc_channel_element_args *args) { - GPR_ASSERT(!args->is_last); - return GRPC_ERROR_NONE; -} - -/* Destructor for channel data */ -static void destroy_channel_elem(grpc_exec_ctx *exec_ctx, - grpc_channel_element *elem) {} - -const grpc_channel_filter grpc_http_server_filter = { - hs_start_transport_op, - grpc_channel_next_op, - sizeof(call_data), - init_call_elem, - grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, - sizeof(channel_data), - init_channel_elem, - destroy_channel_elem, - grpc_call_next_get_peer, - grpc_channel_next_get_info, - "http-server"}; diff --git a/src/core/lib/channel/http_server_filter.h b/src/core/lib/channel/http_server_filter.h deleted file mode 100644 index 77ba2d263d..0000000000 --- a/src/core/lib/channel/http_server_filter.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef GRPC_CORE_LIB_CHANNEL_HTTP_SERVER_FILTER_H -#define GRPC_CORE_LIB_CHANNEL_HTTP_SERVER_FILTER_H - -#include "src/core/lib/channel/channel_stack.h" - -/* Processes metadata on the client side for HTTP2 transports */ -extern const grpc_channel_filter grpc_http_server_filter; - -#endif /* GRPC_CORE_LIB_CHANNEL_HTTP_SERVER_FILTER_H */ diff --git a/src/core/lib/security/credentials/credentials.c b/src/core/lib/security/credentials/credentials.c index 52b80141d1..18d4604c4a 100644 --- a/src/core/lib/security/credentials/credentials.c +++ b/src/core/lib/security/credentials/credentials.c @@ -37,7 +37,7 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/http_client_filter.h" +#include "src/core/ext/filters/http/client/http_client_filter.h" #include "src/core/lib/http/httpcli.h" #include "src/core/lib/http/parser.h" #include "src/core/lib/iomgr/executor.h" diff --git a/src/core/lib/security/credentials/ssl/ssl_credentials.c b/src/core/lib/security/credentials/ssl/ssl_credentials.c index 4b17ac8098..35dda88ec6 100644 --- a/src/core/lib/security/credentials/ssl/ssl_credentials.c +++ b/src/core/lib/security/credentials/ssl/ssl_credentials.c @@ -36,7 +36,7 @@ #include #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/http_client_filter.h" +#include "src/core/ext/filters/http/client/http_client_filter.h" #include "src/core/lib/surface/api_trace.h" #include diff --git a/src/core/lib/surface/init.c b/src/core/lib/surface/init.c index f9b1675465..bba259c099 100644 --- a/src/core/lib/surface/init.c +++ b/src/core/lib/surface/init.c @@ -41,12 +41,9 @@ #include #include #include "src/core/lib/channel/channel_stack.h" -#include "src/core/lib/channel/compress_filter.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/channel/deadline_filter.h" #include "src/core/lib/channel/handshaker_registry.h" -#include "src/core/lib/channel/http_client_filter.h" -#include "src/core/lib/channel/http_server_filter.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/http/parser.h" #include "src/core/lib/iomgr/combiner.h" @@ -94,17 +91,6 @@ static bool prepend_filter(grpc_exec_ctx *exec_ctx, builder, (const grpc_channel_filter *)arg, NULL, NULL); } -static bool maybe_add_http_filter(grpc_exec_ctx *exec_ctx, - grpc_channel_stack_builder *builder, - void *arg) { - grpc_transport *t = grpc_channel_stack_builder_get_transport(builder); - if (t && strstr(t->vtable->name, "http")) { - return grpc_channel_stack_builder_prepend_filter( - builder, (const grpc_channel_filter *)arg, NULL, NULL); - } - return true; -} - static void register_builtin_channel_init() { grpc_channel_init_register_stage( GRPC_CLIENT_DIRECT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, @@ -112,30 +98,12 @@ static void register_builtin_channel_init() { grpc_channel_init_register_stage( GRPC_SERVER_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, prepend_filter, (void *)&grpc_server_deadline_filter); - grpc_channel_init_register_stage( - GRPC_CLIENT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, prepend_filter, - (void *)&grpc_compress_filter); - grpc_channel_init_register_stage( - GRPC_CLIENT_DIRECT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, - prepend_filter, (void *)&grpc_compress_filter); - grpc_channel_init_register_stage( - GRPC_SERVER_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, prepend_filter, - (void *)&grpc_compress_filter); - grpc_channel_init_register_stage( - GRPC_CLIENT_SUBCHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, - maybe_add_http_filter, (void *)&grpc_http_client_filter); grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, grpc_add_connected_filter, NULL); - grpc_channel_init_register_stage( - GRPC_CLIENT_DIRECT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, - maybe_add_http_filter, (void *)&grpc_http_client_filter); grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, grpc_add_connected_filter, NULL); - grpc_channel_init_register_stage( - GRPC_SERVER_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, - maybe_add_http_filter, (void *)&grpc_http_server_filter); grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, grpc_add_connected_filter, NULL); @@ -179,7 +147,6 @@ void grpc_init(void) { grpc_register_tracer("channel_stack_builder", &grpc_trace_channel_stack_builder); grpc_register_tracer("http1", &grpc_http1_trace); - grpc_register_tracer("compression", &grpc_compression_trace); grpc_register_tracer("queue_pluck", &grpc_cq_pluck_trace); grpc_register_tracer("combiner", &grpc_combiner_trace); grpc_register_tracer("server_channel", &grpc_server_channel_trace); diff --git a/src/core/plugin_registry/grpc_cronet_plugin_registry.c b/src/core/plugin_registry/grpc_cronet_plugin_registry.c index c97f47b397..6cc3a25c55 100644 --- a/src/core/plugin_registry/grpc_cronet_plugin_registry.c +++ b/src/core/plugin_registry/grpc_cronet_plugin_registry.c @@ -33,6 +33,8 @@ #include +extern void grpc_http_filters_init(void); +extern void grpc_http_filters_shutdown(void); extern void grpc_chttp2_plugin_init(void); extern void grpc_chttp2_plugin_shutdown(void); extern void grpc_client_channel_init(void); @@ -41,6 +43,8 @@ extern void grpc_load_reporting_plugin_init(void); extern void grpc_load_reporting_plugin_shutdown(void); void grpc_register_built_in_plugins(void) { + grpc_register_plugin(grpc_http_filters_init, + grpc_http_filters_shutdown); grpc_register_plugin(grpc_chttp2_plugin_init, grpc_chttp2_plugin_shutdown); grpc_register_plugin(grpc_client_channel_init, diff --git a/src/core/plugin_registry/grpc_plugin_registry.c b/src/core/plugin_registry/grpc_plugin_registry.c index 3588954631..40a882d50c 100644 --- a/src/core/plugin_registry/grpc_plugin_registry.c +++ b/src/core/plugin_registry/grpc_plugin_registry.c @@ -33,6 +33,8 @@ #include +extern void grpc_http_filters_init(void); +extern void grpc_http_filters_shutdown(void); extern void grpc_chttp2_plugin_init(void); extern void grpc_chttp2_plugin_shutdown(void); extern void grpc_client_channel_init(void); @@ -59,6 +61,8 @@ extern void grpc_message_size_filter_init(void); extern void grpc_message_size_filter_shutdown(void); void grpc_register_built_in_plugins(void) { + grpc_register_plugin(grpc_http_filters_init, + grpc_http_filters_shutdown); grpc_register_plugin(grpc_chttp2_plugin_init, grpc_chttp2_plugin_shutdown); grpc_register_plugin(grpc_client_channel_init, diff --git a/src/core/plugin_registry/grpc_unsecure_plugin_registry.c b/src/core/plugin_registry/grpc_unsecure_plugin_registry.c index 2f0a0d8c96..ded2aa6a84 100644 --- a/src/core/plugin_registry/grpc_unsecure_plugin_registry.c +++ b/src/core/plugin_registry/grpc_unsecure_plugin_registry.c @@ -33,6 +33,8 @@ #include +extern void grpc_http_filters_init(void); +extern void grpc_http_filters_shutdown(void); extern void grpc_chttp2_plugin_init(void); extern void grpc_chttp2_plugin_shutdown(void); extern void grpc_client_channel_init(void); @@ -59,6 +61,8 @@ extern void grpc_message_size_filter_init(void); extern void grpc_message_size_filter_shutdown(void); void grpc_register_built_in_plugins(void) { + grpc_register_plugin(grpc_http_filters_init, + grpc_http_filters_shutdown); grpc_register_plugin(grpc_chttp2_plugin_init, grpc_chttp2_plugin_shutdown); grpc_register_plugin(grpc_client_channel_init, diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 41c309dd3d..f99e777532 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -80,14 +80,11 @@ CORE_SOURCE_FILES = [ 'src/core/lib/channel/channel_args.c', 'src/core/lib/channel/channel_stack.c', 'src/core/lib/channel/channel_stack_builder.c', - 'src/core/lib/channel/compress_filter.c', 'src/core/lib/channel/connected_channel.c', 'src/core/lib/channel/deadline_filter.c', 'src/core/lib/channel/handshaker.c', 'src/core/lib/channel/handshaker_factory.c', 'src/core/lib/channel/handshaker_registry.c', - 'src/core/lib/channel/http_client_filter.c', - 'src/core/lib/channel/http_server_filter.c', 'src/core/lib/compression/compression.c', 'src/core/lib/compression/message_compress.c', 'src/core/lib/debug/trace.c', @@ -222,6 +219,10 @@ CORE_SOURCE_FILES = [ 'src/core/ext/transport/chttp2/transport/varint.c', 'src/core/ext/transport/chttp2/transport/writing.c', 'src/core/ext/transport/chttp2/alpn/alpn.c', + 'src/core/ext/filters/http/client/http_client_filter.c', + 'src/core/ext/filters/http/compress/compress_filter.c', + 'src/core/ext/filters/http/http_filters_plugin.c', + 'src/core/ext/filters/http/server/http_server_filter.c', 'src/core/lib/http/httpcli_security_connector.c', 'src/core/lib/security/context/security_context.c', 'src/core/lib/security/credentials/composite/composite_credentials.c', diff --git a/test/core/bad_client/bad_client.c b/test/core/bad_client/bad_client.c index 4870dc1a53..3f22351e6d 100644 --- a/test/core/bad_client/bad_client.c +++ b/test/core/bad_client/bad_client.c @@ -42,7 +42,7 @@ #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/channel_stack.h" -#include "src/core/lib/channel/http_server_filter.h" +#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/lib/iomgr/endpoint_pair.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/support/murmur_hash.h" diff --git a/test/core/channel/minimal_stack_is_minimal_test.c b/test/core/channel/minimal_stack_is_minimal_test.c index de8f78fb1a..f7bdc1b843 100644 --- a/test/core/channel/minimal_stack_is_minimal_test.c +++ b/test/core/channel/minimal_stack_is_minimal_test.c @@ -43,6 +43,62 @@ #include "src/core/lib/transport/transport_impl.h" #include "test/core/util/test_config.h" +static int check_stack(const char *file, int line, const char *transport_name, + grpc_channel_args *init_args, + grpc_channel_stack_type channel_stack_type, ...); + +#define CHECK_STACK(...) check_stack(__FILE__, __LINE__, __VA_ARGS__) + +int main(int argc, char **argv) { + grpc_test_init(argc, argv); + grpc_init(); + int errors = 0; + + // tests with a minimal stack + grpc_arg minimal_stack_arg = {.type = GRPC_ARG_INTEGER, + .key = GRPC_ARG_MINIMAL_STACK, + .value.integer = 1}; + grpc_channel_args minimal_stack_args = {.num_args = 1, + .args = &minimal_stack_arg}; + errors += CHECK_STACK("unknown", &minimal_stack_args, + GRPC_CLIENT_DIRECT_CHANNEL, "connected", NULL); + errors += CHECK_STACK("unknown", &minimal_stack_args, GRPC_CLIENT_SUBCHANNEL, + "connected", NULL); + errors += CHECK_STACK("unknown", &minimal_stack_args, GRPC_SERVER_CHANNEL, + "server", "connected", NULL); + errors += + CHECK_STACK("chttp2", &minimal_stack_args, GRPC_CLIENT_DIRECT_CHANNEL, + "http-client", "connected", NULL); + errors += CHECK_STACK("chttp2", &minimal_stack_args, GRPC_CLIENT_SUBCHANNEL, + "http-client", "connected", NULL); + errors += CHECK_STACK("chttp2", &minimal_stack_args, GRPC_SERVER_CHANNEL, + "server", "http-server", "connected", NULL); + errors += CHECK_STACK(NULL, &minimal_stack_args, GRPC_CLIENT_CHANNEL, + "client-channel", NULL); + + // tests with a default stack + errors += CHECK_STACK("unknown", NULL, GRPC_CLIENT_DIRECT_CHANNEL, "deadline", + "message_size", "connected", NULL); + errors += CHECK_STACK("unknown", NULL, GRPC_CLIENT_SUBCHANNEL, "message_size", + "connected", NULL); + errors += CHECK_STACK("unknown", NULL, GRPC_SERVER_CHANNEL, "server", + "deadline", "message_size", "connected", NULL); + errors += + CHECK_STACK("chttp2", NULL, GRPC_CLIENT_DIRECT_CHANNEL, "deadline", + "message_size", "http-client", "compress", "connected", NULL); + errors += CHECK_STACK("chttp2", NULL, GRPC_CLIENT_SUBCHANNEL, "message_size", + "http-client", "compress", "connected", NULL); + errors += + CHECK_STACK("chttp2", NULL, GRPC_SERVER_CHANNEL, "server", "deadline", + "message_size", "http-server", "compress", "connected", NULL); + errors += + CHECK_STACK(NULL, NULL, GRPC_CLIENT_CHANNEL, "client-channel", NULL); + + GPR_ASSERT(errors == 0); + grpc_shutdown(); + return 0; +} + static int check_stack(const char *file, int line, const char *transport_name, grpc_channel_args *init_args, grpc_channel_stack_type channel_stack_type, ...) { @@ -124,9 +180,13 @@ static int check_stack(const char *file, int line, const char *transport_name, gpr_strvec_destroy(&v); gpr_log(file, line, GPR_LOG_SEVERITY_ERROR, - "FAILED transport=%s; stack_type=%s; %s: expected '%s'; got '%s'", + "**************************************************"); + gpr_log(file, line, GPR_LOG_SEVERITY_ERROR, + "FAILED transport=%s; stack_type=%s; channel_args=%s:", transport_name, grpc_channel_stack_type_string(channel_stack_type), - args_str, expect, got); + args_str); + gpr_log(file, line, GPR_LOG_SEVERITY_ERROR, "EXPECTED: %s", expect); + gpr_log(file, line, GPR_LOG_SEVERITY_ERROR, "GOT: %s", got); result = 1; gpr_free(args_str); @@ -144,55 +204,3 @@ static int check_stack(const char *file, int line, const char *transport_name, return result; } - -#define CHECK_STACK(...) check_stack(__FILE__, __LINE__, __VA_ARGS__) - -int main(int argc, char **argv) { - grpc_test_init(argc, argv); - grpc_init(); - int errors = 0; - - // tests with a minimal stack - grpc_arg minimal_stack_arg = {.type = GRPC_ARG_INTEGER, - .key = GRPC_ARG_MINIMAL_STACK, - .value.integer = 1}; - grpc_channel_args minimal_stack_args = {.num_args = 1, - .args = &minimal_stack_arg}; - errors += CHECK_STACK("unknown", &minimal_stack_args, - GRPC_CLIENT_DIRECT_CHANNEL, "connected", NULL); - errors += CHECK_STACK("unknown", &minimal_stack_args, GRPC_CLIENT_SUBCHANNEL, - "connected", NULL); - errors += CHECK_STACK("unknown", &minimal_stack_args, GRPC_SERVER_CHANNEL, - "server", "connected", NULL); - errors += - CHECK_STACK("chttp2", &minimal_stack_args, GRPC_CLIENT_DIRECT_CHANNEL, - "http-client", "connected", NULL); - errors += CHECK_STACK("chttp2", &minimal_stack_args, GRPC_CLIENT_SUBCHANNEL, - "connected", NULL); - errors += CHECK_STACK("chttp2", &minimal_stack_args, GRPC_SERVER_CHANNEL, - "server", "http-server", "connected", NULL); - errors += CHECK_STACK(NULL, &minimal_stack_args, GRPC_CLIENT_CHANNEL, - "client-channel", NULL); - - // tests with a default stack - errors += CHECK_STACK("unknown", NULL, GRPC_CLIENT_DIRECT_CHANNEL, "compress", - "deadline", "connected", NULL); - errors += - CHECK_STACK("unknown", NULL, GRPC_CLIENT_SUBCHANNEL, "connected", NULL); - errors += CHECK_STACK("unknown", NULL, GRPC_SERVER_CHANNEL, "server", - "compress", "deadline", "connected", NULL); - errors += - CHECK_STACK("chttp2", NULL, GRPC_CLIENT_DIRECT_CHANNEL, "http-client", - "compress", "deadline", "connected", NULL); - errors += CHECK_STACK("chttp2", NULL, GRPC_CLIENT_SUBCHANNEL, "http-client", - "connected", NULL); - errors += - CHECK_STACK("chttp2", NULL, GRPC_SERVER_CHANNEL, "server", "http-server", - "compress", "deadline", "connected", NULL); - errors += CHECK_STACK(NULL, NULL, GRPC_CLIENT_CHANNEL, "compress", - "client-channel", NULL); - - GPR_ASSERT(errors == 0); - grpc_shutdown(); - return 0; -} diff --git a/test/core/end2end/fixtures/h2_census.c b/test/core/end2end/fixtures/h2_census.c index 97b27b2496..8db0acf47f 100644 --- a/test/core/end2end/fixtures/h2_census.c +++ b/test/core/end2end/fixtures/h2_census.c @@ -45,7 +45,7 @@ #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/channel/http_server_filter.h" +#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/fixtures/h2_compress.c b/test/core/end2end/fixtures/h2_compress.c index 8aec94d601..aa2b3bf069 100644 --- a/test/core/end2end/fixtures/h2_compress.c +++ b/test/core/end2end/fixtures/h2_compress.c @@ -45,7 +45,7 @@ #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/channel/http_server_filter.h" +#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/fixtures/h2_full+pipe.c b/test/core/end2end/fixtures/h2_full+pipe.c index 0191e59fc8..9280aa13d4 100644 --- a/test/core/end2end/fixtures/h2_full+pipe.c +++ b/test/core/end2end/fixtures/h2_full+pipe.c @@ -49,7 +49,7 @@ #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/channel/http_server_filter.h" +#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/lib/iomgr/wakeup_fd_posix.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" diff --git a/test/core/end2end/fixtures/h2_full+trace.c b/test/core/end2end/fixtures/h2_full+trace.c index 9dbb27fc4b..f32521cb58 100644 --- a/test/core/end2end/fixtures/h2_full+trace.c +++ b/test/core/end2end/fixtures/h2_full+trace.c @@ -49,7 +49,7 @@ #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/channel/http_server_filter.h" +#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/lib/support/env.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" diff --git a/test/core/end2end/fixtures/h2_full.c b/test/core/end2end/fixtures/h2_full.c index 49c62b3429..28474507b9 100644 --- a/test/core/end2end/fixtures/h2_full.c +++ b/test/core/end2end/fixtures/h2_full.c @@ -44,7 +44,7 @@ #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/channel/http_server_filter.h" +#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/fixtures/h2_http_proxy.c b/test/core/end2end/fixtures/h2_http_proxy.c index 62c435557d..fb4f56e88d 100644 --- a/test/core/end2end/fixtures/h2_http_proxy.c +++ b/test/core/end2end/fixtures/h2_http_proxy.c @@ -45,7 +45,7 @@ #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/channel/http_server_filter.h" +#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/lib/support/env.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" diff --git a/test/core/end2end/fixtures/h2_load_reporting.c b/test/core/end2end/fixtures/h2_load_reporting.c index 79f26ed2bc..4cf3b445d5 100644 --- a/test/core/end2end/fixtures/h2_load_reporting.c +++ b/test/core/end2end/fixtures/h2_load_reporting.c @@ -46,7 +46,7 @@ #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/channel/http_server_filter.h" +#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/fixtures/h2_proxy.c b/test/core/end2end/fixtures/h2_proxy.c index a10738fa0b..d8658eca64 100644 --- a/test/core/end2end/fixtures/h2_proxy.c +++ b/test/core/end2end/fixtures/h2_proxy.c @@ -44,7 +44,7 @@ #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/channel/http_server_filter.h" +#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/end2end/fixtures/proxy.h" diff --git a/test/core/end2end/fixtures/h2_sockpair+trace.c b/test/core/end2end/fixtures/h2_sockpair+trace.c index 5ace922f05..b3a158650e 100644 --- a/test/core/end2end/fixtures/h2_sockpair+trace.c +++ b/test/core/end2end/fixtures/h2_sockpair+trace.c @@ -47,10 +47,10 @@ #include #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" -#include "src/core/lib/channel/compress_filter.h" +#include "src/core/ext/filters/http/compress/compress_filter.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/channel/http_client_filter.h" -#include "src/core/lib/channel/http_server_filter.h" +#include "src/core/ext/filters/http/client/http_client_filter.h" +#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/lib/iomgr/endpoint_pair.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/support/env.h" diff --git a/test/core/end2end/fixtures/h2_sockpair.c b/test/core/end2end/fixtures/h2_sockpair.c index 3079a42dce..3fe1b8fc36 100644 --- a/test/core/end2end/fixtures/h2_sockpair.c +++ b/test/core/end2end/fixtures/h2_sockpair.c @@ -42,10 +42,10 @@ #include #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" -#include "src/core/lib/channel/compress_filter.h" +#include "src/core/ext/filters/http/compress/compress_filter.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/channel/http_client_filter.h" -#include "src/core/lib/channel/http_server_filter.h" +#include "src/core/ext/filters/http/client/http_client_filter.h" +#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/lib/iomgr/endpoint_pair.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/surface/channel.h" diff --git a/test/core/end2end/fixtures/h2_sockpair_1byte.c b/test/core/end2end/fixtures/h2_sockpair_1byte.c index 70410d75f4..149902673d 100644 --- a/test/core/end2end/fixtures/h2_sockpair_1byte.c +++ b/test/core/end2end/fixtures/h2_sockpair_1byte.c @@ -42,10 +42,10 @@ #include #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" -#include "src/core/lib/channel/compress_filter.h" +#include "src/core/ext/filters/http/compress/compress_filter.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/channel/http_client_filter.h" -#include "src/core/lib/channel/http_server_filter.h" +#include "src/core/ext/filters/http/client/http_client_filter.h" +#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/lib/iomgr/endpoint_pair.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/surface/channel.h" diff --git a/test/core/end2end/fixtures/h2_uds.c b/test/core/end2end/fixtures/h2_uds.c index 7bde69d82a..c0a4d69418 100644 --- a/test/core/end2end/fixtures/h2_uds.c +++ b/test/core/end2end/fixtures/h2_uds.c @@ -47,7 +47,7 @@ #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/channel/http_server_filter.h" +#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/lib/support/string.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc index be18f12d15..3fcd5bc6ab 100644 --- a/test/cpp/microbenchmarks/bm_call_create.cc +++ b/test/cpp/microbenchmarks/bm_call_create.cc @@ -48,11 +48,11 @@ extern "C" { #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/load_reporting/load_reporting_filter.h" #include "src/core/lib/channel/channel_stack.h" -#include "src/core/lib/channel/compress_filter.h" +#include "src/core/ext/filters/http/compress/compress_filter.h" #include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/channel/deadline_filter.h" -#include "src/core/lib/channel/http_client_filter.h" -#include "src/core/lib/channel/http_server_filter.h" +#include "src/core/ext/filters/http/client/http_client_filter.h" +#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/filters/message_size/message_size_filter.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/transport/transport_impl.h" diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 0334434f24..add3cb1857 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -906,8 +906,6 @@ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack.h \ src/core/lib/channel/channel_stack_builder.c \ src/core/lib/channel/channel_stack_builder.h \ -src/core/lib/channel/compress_filter.c \ -src/core/lib/channel/compress_filter.h \ src/core/lib/channel/connected_channel.c \ src/core/lib/channel/connected_channel.h \ src/core/lib/channel/context.h \ @@ -919,10 +917,6 @@ src/core/lib/channel/handshaker_factory.c \ src/core/lib/channel/handshaker_factory.h \ src/core/lib/channel/handshaker_registry.c \ src/core/lib/channel/handshaker_registry.h \ -src/core/lib/channel/http_client_filter.c \ -src/core/lib/channel/http_client_filter.h \ -src/core/lib/channel/http_server_filter.c \ -src/core/lib/channel/http_server_filter.h \ src/core/lib/compression/algorithm_metadata.h \ src/core/lib/compression/compression.c \ src/core/lib/compression/message_compress.c \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 284cab8e54..8db6e146a3 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -954,6 +954,13 @@ src/core/ext/filters/client_channel/subchannel_index.c \ src/core/ext/filters/client_channel/subchannel_index.h \ src/core/ext/filters/client_channel/uri_parser.c \ src/core/ext/filters/client_channel/uri_parser.h \ +src/core/ext/filters/http/client/http_client_filter.c \ +src/core/ext/filters/http/client/http_client_filter.h \ +src/core/ext/filters/http/compress/compress_filter.c \ +src/core/ext/filters/http/compress/compress_filter.h \ +src/core/ext/filters/http/http_filters_plugin.c \ +src/core/ext/filters/http/server/http_server_filter.c \ +src/core/ext/filters/http/server/http_server_filter.h \ src/core/ext/filters/load_reporting/load_reporting.c \ src/core/ext/filters/load_reporting/load_reporting.h \ src/core/ext/filters/load_reporting/load_reporting_filter.c \ @@ -1027,8 +1034,6 @@ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack.h \ src/core/lib/channel/channel_stack_builder.c \ src/core/lib/channel/channel_stack_builder.h \ -src/core/lib/channel/compress_filter.c \ -src/core/lib/channel/compress_filter.h \ src/core/lib/channel/connected_channel.c \ src/core/lib/channel/connected_channel.h \ src/core/lib/channel/context.h \ @@ -1040,10 +1045,6 @@ src/core/lib/channel/handshaker_factory.c \ src/core/lib/channel/handshaker_factory.h \ src/core/lib/channel/handshaker_registry.c \ src/core/lib/channel/handshaker_registry.h \ -src/core/lib/channel/http_client_filter.c \ -src/core/lib/channel/http_client_filter.h \ -src/core/lib/channel/http_server_filter.c \ -src/core/lib/channel/http_server_filter.h \ src/core/lib/compression/algorithm_metadata.h \ src/core/lib/compression/compression.c \ src/core/lib/compression/message_compress.c \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index e8168ce10b..03cf01be0f 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -7526,15 +7526,12 @@ "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", - "src/core/lib/channel/compress_filter.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", "src/core/lib/channel/deadline_filter.h", "src/core/lib/channel/handshaker.h", "src/core/lib/channel/handshaker_factory.h", "src/core/lib/channel/handshaker_registry.h", - "src/core/lib/channel/http_client_filter.h", - "src/core/lib/channel/http_server_filter.h", "src/core/lib/compression/algorithm_metadata.h", "src/core/lib/compression/message_compress.h", "src/core/lib/debug/trace.h", @@ -7653,8 +7650,6 @@ "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.c", "src/core/lib/channel/channel_stack_builder.h", - "src/core/lib/channel/compress_filter.c", - "src/core/lib/channel/compress_filter.h", "src/core/lib/channel/connected_channel.c", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", @@ -7666,10 +7661,6 @@ "src/core/lib/channel/handshaker_factory.h", "src/core/lib/channel/handshaker_registry.c", "src/core/lib/channel/handshaker_registry.h", - "src/core/lib/channel/http_client_filter.c", - "src/core/lib/channel/http_client_filter.h", - "src/core/lib/channel/http_server_filter.c", - "src/core/lib/channel/http_server_filter.h", "src/core/lib/compression/algorithm_metadata.h", "src/core/lib/compression/compression.c", "src/core/lib/compression/message_compress.c", @@ -7984,6 +7975,28 @@ "third_party": false, "type": "filegroup" }, + { + "deps": [], + "headers": [ + "src/core/ext/filters/http/client/http_client_filter.h", + "src/core/ext/filters/http/compress/compress_filter.h", + "src/core/ext/filters/http/server/http_server_filter.h" + ], + "is_filegroup": true, + "language": "c", + "name": "grpc_http_filters", + "src": [ + "src/core/ext/filters/http/client/http_client_filter.c", + "src/core/ext/filters/http/client/http_client_filter.h", + "src/core/ext/filters/http/compress/compress_filter.c", + "src/core/ext/filters/http/compress/compress_filter.h", + "src/core/ext/filters/http/http_filters_plugin.c", + "src/core/ext/filters/http/server/http_server_filter.c", + "src/core/ext/filters/http/server/http_server_filter.h" + ], + "third_party": false, + "type": "filegroup" + }, { "deps": [ "gpr", @@ -8332,6 +8345,7 @@ "deps": [ "gpr", "grpc_base", + "grpc_http_filters", "grpc_transport_chttp2_alpn" ], "headers": [ @@ -8533,6 +8547,7 @@ { "deps": [ "grpc_base", + "grpc_http_filters", "grpc_transport_chttp2" ], "headers": [ diff --git a/vsprojects/vcxproj/grpc++/grpc++.vcxproj b/vsprojects/vcxproj/grpc++/grpc++.vcxproj index 8ec84928bf..c37cb77d5b 100644 --- a/vsprojects/vcxproj/grpc++/grpc++.vcxproj +++ b/vsprojects/vcxproj/grpc++/grpc++.vcxproj @@ -380,15 +380,12 @@ - - - @@ -580,8 +577,6 @@ - - @@ -592,10 +587,6 @@ - - - - diff --git a/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters b/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters index a32fdbb8f6..8f7e576998 100644 --- a/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters @@ -133,9 +133,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\channel @@ -151,12 +148,6 @@ src\core\lib\channel - - src\core\lib\channel - - - src\core\lib\channel - src\core\lib\compression @@ -869,9 +860,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\channel @@ -890,12 +878,6 @@ src\core\lib\channel - - src\core\lib\channel - - - src\core\lib\channel - src\core\lib\compression diff --git a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj index 0f8fe4a623..973c016305 100644 --- a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj @@ -374,15 +374,12 @@ - - - @@ -564,8 +561,6 @@ - - @@ -576,10 +571,6 @@ - - - - diff --git a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters index d29b3ba6fe..6da1a2bcba 100644 --- a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters @@ -118,9 +118,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\channel @@ -136,12 +133,6 @@ src\core\lib\channel - - src\core\lib\channel - - - src\core\lib\channel - src\core\lib\compression @@ -836,9 +827,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\channel @@ -857,12 +845,6 @@ src\core\lib\channel - - src\core\lib\channel - - - src\core\lib\channel - src\core\lib\compression diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj b/vsprojects/vcxproj/grpc/grpc.vcxproj index 2a4d0b13a3..47d28e06ca 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj @@ -303,15 +303,12 @@ - - - @@ -428,6 +425,9 @@ + + + @@ -512,8 +512,6 @@ - - @@ -524,10 +522,6 @@ - - - - @@ -796,6 +790,14 @@ + + + + + + + + diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters index 800cea6d1d..f67b7ab3f8 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters @@ -13,9 +13,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\channel @@ -31,12 +28,6 @@ src\core\lib\channel - - src\core\lib\channel - - - src\core\lib\channel - src\core\lib\compression @@ -439,6 +430,18 @@ src\core\ext\transport\chttp2\alpn + + src\core\ext\filters\http\client + + + src\core\ext\filters\http\compress + + + src\core\ext\filters\http + + + src\core\ext\filters\http\server + src\core\lib\http @@ -806,9 +809,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\channel @@ -827,12 +827,6 @@ src\core\lib\channel - - src\core\lib\channel - - - src\core\lib\channel - src\core\lib\compression @@ -1181,6 +1175,15 @@ src\core\ext\transport\chttp2\alpn + + src\core\ext\filters\http\client + + + src\core\ext\filters\http\compress + + + src\core\ext\filters\http\server + src\core\lib\security\context @@ -1478,6 +1481,18 @@ {bd317dd5-323e-5b27-4c05-d85786be36ab} + + {2e3ab9f3-39ca-db39-cb3e-2196cbc68098} + + + {e4f7616b-2b49-7df9-8ca3-eb7848d4609d} + + + {8f3d6045-e672-b61f-437e-052557970f41} + + + {a40e82ca-0c04-35b8-898d-7ad5f323d110} + {12559ba7-9445-92ae-0c5a-2d79570d4c9b} diff --git a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj index 0e9c292384..382e5af7e3 100644 --- a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj +++ b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj @@ -198,15 +198,12 @@ - - - @@ -352,8 +349,6 @@ - - @@ -364,10 +359,6 @@ - - - - diff --git a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters index 94168a2628..db22acc685 100644 --- a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters +++ b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters @@ -70,9 +70,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\channel @@ -88,12 +85,6 @@ src\core\lib\channel - - src\core\lib\channel - - - src\core\lib\channel - src\core\lib\compression @@ -581,9 +572,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\channel @@ -602,12 +590,6 @@ src\core\lib\channel - - src\core\lib\channel - - - src\core\lib\channel - src\core\lib\compression diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj index 11ee7b9563..336902647a 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj @@ -293,15 +293,12 @@ - - - @@ -418,6 +415,9 @@ + + + @@ -480,8 +480,6 @@ - - @@ -492,10 +490,6 @@ - - - - @@ -766,6 +760,14 @@ + + + + + + + + diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters index a4a46549ae..53a4748232 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters @@ -16,9 +16,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\channel @@ -34,12 +31,6 @@ src\core\lib\channel - - src\core\lib\channel - - - src\core\lib\channel - src\core\lib\compression @@ -445,6 +436,18 @@ src\core\ext\transport\chttp2\alpn + + src\core\ext\filters\http\client + + + src\core\ext\filters\http\compress + + + src\core\ext\filters\http + + + src\core\ext\filters\http\server + src\core\ext\transport\chttp2\server @@ -719,9 +722,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\channel @@ -740,12 +740,6 @@ src\core\lib\channel - - src\core\lib\channel - - - src\core\lib\channel - src\core\lib\compression @@ -1094,6 +1088,15 @@ src\core\ext\transport\chttp2\alpn + + src\core\ext\filters\http\client + + + src\core\ext\filters\http\compress + + + src\core\ext\filters\http\server + src\core\ext\transport\chttp2\server @@ -1319,6 +1322,18 @@ {99210f5e-b2a0-ecd1-024f-fc152db68a11} + + {33287f7d-739b-d30d-a9f3-b338103456b0} + + + {95cd5972-7339-6f09-2332-e6769b3cba3f} + + + {b257d9a5-2100-4b83-9a03-d28707827b1e} + + + {2c1e7897-6f69-f8b9-0b90-5c3fae59a48f} + {0aef07b4-39d2-f862-15ac-65b4bf00dabb} -- cgit v1.2.3 From 3be7dd0e793799b6a3e22e245230789dc80aa853 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 3 Apr 2017 14:30:03 -0700 Subject: Optionalize deadline checking --- BUILD | 20 +- CMakeLists.txt | 14 +- Makefile | 14 +- binding.gyp | 2 +- build.yaml | 15 +- config.m4 | 3 +- gRPC-Core.podspec | 6 +- grpc.gemspec | 4 +- include/grpc/impl/codegen/grpc_types.h | 3 + package.xml | 4 +- .../ext/filters/client_channel/client_channel.c | 26 +- src/core/ext/filters/deadline/deadline_filter.c | 377 +++++++++++++++++++++ src/core/ext/filters/deadline/deadline_filter.h | 105 ++++++ src/core/lib/channel/deadline_filter.c | 344 ------------------- src/core/lib/channel/deadline_filter.h | 102 ------ src/core/lib/surface/init.c | 7 - .../plugin_registry/grpc_cronet_plugin_registry.c | 4 + src/core/plugin_registry/grpc_plugin_registry.c | 4 + .../grpc_unsecure_plugin_registry.c | 4 + src/python/grpcio/grpc_core_dependencies.py | 2 +- test/core/channel/minimal_stack_is_minimal_test.c | 15 +- test/cpp/microbenchmarks/bm_call_create.cc | 2 +- tools/doxygen/Doxyfile.c++.internal | 4 +- tools/doxygen/Doxyfile.core.internal | 4 +- tools/run_tests/generated/sources_and_headers.json | 29 +- vsprojects/vcxproj/grpc++/grpc++.vcxproj | 6 +- vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters | 21 +- .../grpc++_unsecure/grpc++_unsecure.vcxproj | 6 +- .../grpc++_unsecure.vcxproj.filters | 21 +- vsprojects/vcxproj/grpc/grpc.vcxproj | 6 +- vsprojects/vcxproj/grpc/grpc.vcxproj.filters | 15 +- .../vcxproj/grpc_test_util/grpc_test_util.vcxproj | 6 +- .../grpc_test_util/grpc_test_util.vcxproj.filters | 21 +- .../vcxproj/grpc_unsecure/grpc_unsecure.vcxproj | 6 +- .../grpc_unsecure/grpc_unsecure.vcxproj.filters | 15 +- 35 files changed, 689 insertions(+), 548 deletions(-) create mode 100644 src/core/ext/filters/deadline/deadline_filter.c create mode 100644 src/core/ext/filters/deadline/deadline_filter.h delete mode 100644 src/core/lib/channel/deadline_filter.c delete mode 100644 src/core/lib/channel/deadline_filter.h diff --git a/BUILD b/BUILD index 59b9702873..a7c757c728 100644 --- a/BUILD +++ b/BUILD @@ -77,6 +77,7 @@ grpc_cc_library( "grpc_transport_chttp2_server_secure", "grpc_max_age_filter", "grpc_message_size_filter", + "grpc_deadline_filter", ], ) @@ -117,6 +118,7 @@ grpc_cc_library( "grpc_transport_chttp2_server_insecure", "grpc_max_age_filter", "grpc_message_size_filter", + "grpc_deadline_filter", ], ) @@ -434,7 +436,7 @@ grpc_cc_library( "src/core/lib/channel/channel_stack.c", "src/core/lib/channel/channel_stack_builder.c", "src/core/lib/channel/connected_channel.c", - "src/core/lib/channel/deadline_filter.c", + "src/core/ext/filters/deadline/deadline_filter.c", "src/core/lib/channel/handshaker.c", "src/core/lib/channel/handshaker_factory.c", "src/core/lib/channel/handshaker_registry.c", @@ -557,7 +559,7 @@ grpc_cc_library( "src/core/lib/channel/channel_stack_builder.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", - "src/core/lib/channel/deadline_filter.h", + "src/core/ext/filters/deadline/deadline_filter.h", "src/core/lib/channel/handshaker.h", "src/core/lib/channel/handshaker_factory.h", "src/core/lib/channel/handshaker_registry.h", @@ -745,6 +747,20 @@ grpc_cc_library( ], ) +grpc_cc_library( + name = "grpc_deadline_filter", + srcs = [ + "src/core/ext/filters/deadline/deadline_filter.c", + ], + hdrs = [ + "src/core/ext/filters/deadline/deadline_filter.h", + ], + language = "c", + deps = [ + "grpc_base", + ], +) + grpc_cc_library( name = "grpc_message_size_filter", srcs = [ diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e51b53036..50eb04a143 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -908,11 +908,11 @@ endif (gRPC_BUILD_TESTS) add_library(grpc src/core/lib/surface/init.c + src/core/ext/filters/deadline/deadline_filter.c src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c src/core/lib/channel/connected_channel.c - src/core/lib/channel/deadline_filter.c src/core/lib/channel/handshaker.c src/core/lib/channel/handshaker_factory.c src/core/lib/channel/handshaker_registry.c @@ -1231,11 +1231,11 @@ endif() add_library(grpc_cronet src/core/lib/surface/init.c + src/core/ext/filters/deadline/deadline_filter.c src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c src/core/lib/channel/connected_channel.c - src/core/lib/channel/deadline_filter.c src/core/lib/channel/handshaker.c src/core/lib/channel/handshaker_factory.c src/core/lib/channel/handshaker_registry.c @@ -1539,11 +1539,11 @@ add_library(grpc_test_util test/core/util/port_server_client.c test/core/util/slice_splitter.c test/core/util/trickle_endpoint.c + src/core/ext/filters/deadline/deadline_filter.c src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c src/core/lib/channel/connected_channel.c - src/core/lib/channel/deadline_filter.c src/core/lib/channel/handshaker.c src/core/lib/channel/handshaker_factory.c src/core/lib/channel/handshaker_registry.c @@ -1795,11 +1795,11 @@ endif (gRPC_BUILD_TESTS) add_library(grpc_unsecure src/core/lib/surface/init.c src/core/lib/surface/init_unsecure.c + src/core/ext/filters/deadline/deadline_filter.c src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c src/core/lib/channel/connected_channel.c - src/core/lib/channel/deadline_filter.c src/core/lib/channel/handshaker.c src/core/lib/channel/handshaker_factory.c src/core/lib/channel/handshaker_registry.c @@ -2212,11 +2212,11 @@ add_library(grpc++ src/cpp/util/status.cc src/cpp/util/string_ref.cc src/cpp/util/time_cc.cc + src/core/ext/filters/deadline/deadline_filter.c src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c src/core/lib/channel/connected_channel.c - src/core/lib/channel/deadline_filter.c src/core/lib/channel/handshaker.c src/core/lib/channel/handshaker_factory.c src/core/lib/channel/handshaker_registry.c @@ -2538,11 +2538,11 @@ add_library(grpc++_cronet src/cpp/util/status.cc src/cpp/util/string_ref.cc src/cpp/util/time_cc.cc + src/core/ext/filters/deadline/deadline_filter.c src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c src/core/lib/channel/connected_channel.c - src/core/lib/channel/deadline_filter.c src/core/lib/channel/handshaker.c src/core/lib/channel/handshaker_factory.c src/core/lib/channel/handshaker_registry.c @@ -3236,11 +3236,11 @@ add_library(grpc++_unsecure src/cpp/util/status.cc src/cpp/util/string_ref.cc src/cpp/util/time_cc.cc + src/core/ext/filters/deadline/deadline_filter.c src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c src/core/lib/channel/connected_channel.c - src/core/lib/channel/deadline_filter.c src/core/lib/channel/handshaker.c src/core/lib/channel/handshaker_factory.c src/core/lib/channel/handshaker_registry.c diff --git a/Makefile b/Makefile index 4e5e21d566..d9f5d773da 100644 --- a/Makefile +++ b/Makefile @@ -2813,11 +2813,11 @@ endif LIBGRPC_SRC = \ src/core/lib/surface/init.c \ + src/core/ext/filters/deadline/deadline_filter.c \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ src/core/lib/channel/connected_channel.c \ - src/core/lib/channel/deadline_filter.c \ src/core/lib/channel/handshaker.c \ src/core/lib/channel/handshaker_factory.c \ src/core/lib/channel/handshaker_registry.c \ @@ -3134,11 +3134,11 @@ endif LIBGRPC_CRONET_SRC = \ src/core/lib/surface/init.c \ + src/core/ext/filters/deadline/deadline_filter.c \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ src/core/lib/channel/connected_channel.c \ - src/core/lib/channel/deadline_filter.c \ src/core/lib/channel/handshaker.c \ src/core/lib/channel/handshaker_factory.c \ src/core/lib/channel/handshaker_registry.c \ @@ -3441,11 +3441,11 @@ LIBGRPC_TEST_UTIL_SRC = \ test/core/util/port_server_client.c \ test/core/util/slice_splitter.c \ test/core/util/trickle_endpoint.c \ + src/core/ext/filters/deadline/deadline_filter.c \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ src/core/lib/channel/connected_channel.c \ - src/core/lib/channel/deadline_filter.c \ src/core/lib/channel/handshaker.c \ src/core/lib/channel/handshaker_factory.c \ src/core/lib/channel/handshaker_registry.c \ @@ -3669,11 +3669,11 @@ endif LIBGRPC_UNSECURE_SRC = \ src/core/lib/surface/init.c \ src/core/lib/surface/init_unsecure.c \ + src/core/ext/filters/deadline/deadline_filter.c \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ src/core/lib/channel/connected_channel.c \ - src/core/lib/channel/deadline_filter.c \ src/core/lib/channel/handshaker.c \ src/core/lib/channel/handshaker_factory.c \ src/core/lib/channel/handshaker_registry.c \ @@ -4063,11 +4063,11 @@ LIBGRPC++_SRC = \ src/cpp/util/status.cc \ src/cpp/util/string_ref.cc \ src/cpp/util/time_cc.cc \ + src/core/ext/filters/deadline/deadline_filter.c \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ src/core/lib/channel/connected_channel.c \ - src/core/lib/channel/deadline_filter.c \ src/core/lib/channel/handshaker.c \ src/core/lib/channel/handshaker_factory.c \ src/core/lib/channel/handshaker_registry.c \ @@ -4397,11 +4397,11 @@ LIBGRPC++_CRONET_SRC = \ src/cpp/util/status.cc \ src/cpp/util/string_ref.cc \ src/cpp/util/time_cc.cc \ + src/core/ext/filters/deadline/deadline_filter.c \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ src/core/lib/channel/connected_channel.c \ - src/core/lib/channel/deadline_filter.c \ src/core/lib/channel/handshaker.c \ src/core/lib/channel/handshaker_factory.c \ src/core/lib/channel/handshaker_registry.c \ @@ -5087,11 +5087,11 @@ LIBGRPC++_UNSECURE_SRC = \ src/cpp/util/status.cc \ src/cpp/util/string_ref.cc \ src/cpp/util/time_cc.cc \ + src/core/ext/filters/deadline/deadline_filter.c \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ src/core/lib/channel/connected_channel.c \ - src/core/lib/channel/deadline_filter.c \ src/core/lib/channel/handshaker.c \ src/core/lib/channel/handshaker_factory.c \ src/core/lib/channel/handshaker_registry.c \ diff --git a/binding.gyp b/binding.gyp index ccfbeedc63..8cd5bd50f5 100644 --- a/binding.gyp +++ b/binding.gyp @@ -615,11 +615,11 @@ ], 'sources': [ 'src/core/lib/surface/init.c', + 'src/core/ext/filters/deadline/deadline_filter.c', 'src/core/lib/channel/channel_args.c', 'src/core/lib/channel/channel_stack.c', 'src/core/lib/channel/channel_stack_builder.c', 'src/core/lib/channel/connected_channel.c', - 'src/core/lib/channel/deadline_filter.c', 'src/core/lib/channel/handshaker.c', 'src/core/lib/channel/handshaker_factory.c', 'src/core/lib/channel/handshaker_registry.c', diff --git a/build.yaml b/build.yaml index 6a8abdc8b2..2414180ffe 100644 --- a/build.yaml +++ b/build.yaml @@ -173,12 +173,12 @@ filegroups: - include/grpc/slice_buffer.h - include/grpc/status.h headers: + - src/core/ext/filters/deadline/deadline_filter.h - src/core/lib/channel/channel_args.h - src/core/lib/channel/channel_stack.h - src/core/lib/channel/channel_stack_builder.h - src/core/lib/channel/connected_channel.h - src/core/lib/channel/context.h - - src/core/lib/channel/deadline_filter.h - src/core/lib/channel/handshaker.h - src/core/lib/channel/handshaker_factory.h - src/core/lib/channel/handshaker_registry.h @@ -280,11 +280,11 @@ filegroups: - src/core/lib/transport/transport.h - src/core/lib/transport/transport_impl.h src: + - src/core/ext/filters/deadline/deadline_filter.c - src/core/lib/channel/channel_args.c - src/core/lib/channel/channel_stack.c - src/core/lib/channel/channel_stack_builder.c - src/core/lib/channel/connected_channel.c - - src/core/lib/channel/deadline_filter.c - src/core/lib/channel/handshaker.c - src/core/lib/channel/handshaker_factory.c - src/core/lib/channel/handshaker_registry.c @@ -448,6 +448,7 @@ filegroups: plugin: grpc_client_channel uses: - grpc_base + - grpc_deadline_filter - name: grpc_codegen public_headers: - include/grpc/impl/codegen/byte_buffer_reader.h @@ -460,6 +461,14 @@ filegroups: - include/grpc/impl/codegen/status.h uses: - gpr_codegen +- name: grpc_deadline_filter + headers: + - src/core/ext/filters/deadline/deadline_filter.h + src: + - src/core/ext/filters/deadline/deadline_filter.c + plugin: grpc_deadline_filter + uses: + - grpc_base - name: grpc_http_filters headers: - src/core/ext/filters/http/client/http_client_filter.h @@ -1011,6 +1020,7 @@ libs: - census - grpc_max_age_filter - grpc_message_size_filter + - grpc_deadline_filter generate_plugin_registry: true secure: true vs_packages: @@ -1109,6 +1119,7 @@ libs: - census - grpc_max_age_filter - grpc_message_size_filter + - grpc_deadline_filter generate_plugin_registry: true secure: false vs_project_guid: '{46CEDFFF-9692-456A-AA24-38B5D6BCF4C5}' diff --git a/config.m4 b/config.m4 index 77ffaa4db4..85593afd3c 100644 --- a/config.m4 +++ b/config.m4 @@ -83,11 +83,11 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/support/tmpfile_windows.c \ src/core/lib/support/wrap_memcpy.c \ src/core/lib/surface/init.c \ + src/core/ext/filters/deadline/deadline_filter.c \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ src/core/lib/channel/connected_channel.c \ - src/core/lib/channel/deadline_filter.c \ src/core/lib/channel/handshaker.c \ src/core/lib/channel/handshaker_factory.c \ src/core/lib/channel/handshaker_registry.c \ @@ -638,6 +638,7 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/dns/c_ares) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/dns/native) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/client_channel/resolver/sockaddr) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/deadline) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/http) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/http/client) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/http/compress) diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index b0b8686a81..9cd92835ac 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -255,12 +255,12 @@ Pod::Spec.new do |s| 'src/core/lib/support/tmpfile_posix.c', 'src/core/lib/support/tmpfile_windows.c', 'src/core/lib/support/wrap_memcpy.c', + 'src/core/ext/filters/deadline/deadline_filter.h', 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', - 'src/core/lib/channel/deadline_filter.h', 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', @@ -458,11 +458,11 @@ Pod::Spec.new do |s| 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', 'src/core/lib/surface/init.c', + 'src/core/ext/filters/deadline/deadline_filter.c', 'src/core/lib/channel/channel_args.c', 'src/core/lib/channel/channel_stack.c', 'src/core/lib/channel/channel_stack_builder.c', 'src/core/lib/channel/connected_channel.c', - 'src/core/lib/channel/deadline_filter.c', 'src/core/lib/channel/handshaker.c', 'src/core/lib/channel/handshaker_factory.c', 'src/core/lib/channel/handshaker_registry.c', @@ -706,12 +706,12 @@ Pod::Spec.new do |s| 'src/core/lib/support/thd_internal.h', 'src/core/lib/support/time_precise.h', 'src/core/lib/support/tmpfile.h', + 'src/core/ext/filters/deadline/deadline_filter.h', 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', 'src/core/lib/channel/connected_channel.h', 'src/core/lib/channel/context.h', - 'src/core/lib/channel/deadline_filter.h', 'src/core/lib/channel/handshaker.h', 'src/core/lib/channel/handshaker_factory.h', 'src/core/lib/channel/handshaker_registry.h', diff --git a/grpc.gemspec b/grpc.gemspec index 2ba0ec953b..0e4a3d6fec 100755 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -171,12 +171,12 @@ Gem::Specification.new do |s| s.files += %w( include/grpc/impl/codegen/sync_windows.h ) s.files += %w( include/grpc/grpc_security.h ) s.files += %w( include/grpc/census.h ) + s.files += %w( src/core/ext/filters/deadline/deadline_filter.h ) s.files += %w( src/core/lib/channel/channel_args.h ) s.files += %w( src/core/lib/channel/channel_stack.h ) s.files += %w( src/core/lib/channel/channel_stack_builder.h ) s.files += %w( src/core/lib/channel/connected_channel.h ) s.files += %w( src/core/lib/channel/context.h ) - s.files += %w( src/core/lib/channel/deadline_filter.h ) s.files += %w( src/core/lib/channel/handshaker.h ) s.files += %w( src/core/lib/channel/handshaker_factory.h ) s.files += %w( src/core/lib/channel/handshaker_registry.h ) @@ -374,11 +374,11 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/max_age/max_age_filter.h ) s.files += %w( src/core/ext/filters/message_size/message_size_filter.h ) s.files += %w( src/core/lib/surface/init.c ) + s.files += %w( src/core/ext/filters/deadline/deadline_filter.c ) s.files += %w( src/core/lib/channel/channel_args.c ) s.files += %w( src/core/lib/channel/channel_stack.c ) s.files += %w( src/core/lib/channel/channel_stack_builder.c ) s.files += %w( src/core/lib/channel/connected_channel.c ) - s.files += %w( src/core/lib/channel/deadline_filter.c ) s.files += %w( src/core/lib/channel/handshaker.c ) s.files += %w( src/core/lib/channel/handshaker_factory.c ) s.files += %w( src/core/lib/channel/handshaker_registry.c ) diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index 83bdd80f2c..30fe8d216b 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -178,6 +178,9 @@ typedef struct { /** Enable/disable support for per-message compression. Defaults to 1, unless GRPC_ARG_MINIMAL_STACK is enabled, in which case it defaults to 0. */ #define GRPC_ARG_ENABLE_PER_MESSAGE_COMPRESSION "grpc.per_message_compression" +/** Enable/disable support for deadline checking. Defaults to 1, unless + GRPC_ARG_MINIMAL_STACK is enabled, in which case it defaults to 0 */ +#define GRPC_ARG_ENABLE_DEADLINE_CHECKS "grpc.enable_deadline_checking" /** Initial sequence number for http2 transports. Int valued. */ #define GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER \ "grpc.http2.initial_sequence_number" diff --git a/package.xml b/package.xml index 7faa532082..8cda68a266 100644 --- a/package.xml +++ b/package.xml @@ -180,12 +180,12 @@ + - @@ -383,11 +383,11 @@ + - diff --git a/src/core/ext/filters/client_channel/client_channel.c b/src/core/ext/filters/client_channel/client_channel.c index d289272489..4b6c532820 100644 --- a/src/core/ext/filters/client_channel/client_channel.c +++ b/src/core/ext/filters/client_channel/client_channel.c @@ -49,9 +49,9 @@ #include "src/core/ext/filters/client_channel/resolver_registry.h" #include "src/core/ext/filters/client_channel/retry_throttle.h" #include "src/core/ext/filters/client_channel/subchannel.h" +#include "src/core/ext/filters/deadline/deadline_filter.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/channel/deadline_filter.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/iomgr/polling_entity.h" @@ -183,6 +183,8 @@ typedef struct client_channel_channel_data { grpc_resolver *resolver; /** have we started resolving this channel */ bool started_resolving; + /** is deadline checking enabled? */ + bool deadline_checking_enabled; /** client channel factory */ grpc_client_channel_factory *client_channel_factory; @@ -676,6 +678,8 @@ static grpc_error *cc_init_channel_elem(grpc_exec_ctx *exec_ctx, if (chand->resolver == NULL) { return GRPC_ERROR_CREATE_FROM_STATIC_STRING("resolver creation failed"); } + chand->deadline_checking_enabled = + grpc_deadline_checking_enabled(args->channel_args); return GRPC_ERROR_NONE; } @@ -863,12 +867,14 @@ static void apply_final_configuration_locked(grpc_exec_ctx *exec_ctx, /* apply service-config level configuration to the call (now that we're * certain it exists) */ call_data *calld = elem->call_data; + channel_data *chand = elem->channel_data; gpr_timespec per_method_deadline; if (set_call_method_params_from_service_config_locked(exec_ctx, elem, &per_method_deadline)) { // If the deadline from the service config is shorter than the one // from the client API, reset the deadline timer. - if (gpr_time_cmp(per_method_deadline, calld->deadline) < 0) { + if (chand->deadline_checking_enabled && + gpr_time_cmp(per_method_deadline, calld->deadline) < 0) { calld->deadline = per_method_deadline; grpc_deadline_state_reset(exec_ctx, elem, calld->deadline); } @@ -1222,7 +1228,9 @@ static void cc_start_transport_stream_op(grpc_exec_ctx *exec_ctx, call_data *calld = elem->call_data; channel_data *chand = elem->channel_data; GRPC_CALL_LOG_OP(GPR_INFO, elem, op); - grpc_deadline_state_client_start_transport_stream_op(exec_ctx, elem, op); + if (chand->deadline_checking_enabled) { + grpc_deadline_state_client_start_transport_stream_op(exec_ctx, elem, op); + } /* try to (atomically) get the call */ grpc_subchannel_call *call = GET_CALL(calld); GPR_TIMER_BEGIN("cc_start_transport_stream_op", 0); @@ -1256,14 +1264,17 @@ static grpc_error *cc_init_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, const grpc_call_element_args *args) { call_data *calld = elem->call_data; + channel_data *chand = elem->channel_data; // Initialize data members. - grpc_deadline_state_init(exec_ctx, elem, args->call_stack); calld->path = grpc_slice_ref_internal(args->path); calld->call_start_time = args->start_time; calld->deadline = gpr_convert_clock_type(args->deadline, GPR_CLOCK_MONOTONIC); calld->owning_call = args->call_stack; calld->arena = args->arena; - grpc_deadline_state_start(exec_ctx, elem, calld->deadline); + if (chand->deadline_checking_enabled) { + grpc_deadline_state_init(exec_ctx, elem, args->call_stack); + grpc_deadline_state_start(exec_ctx, elem, calld->deadline); + } return GRPC_ERROR_NONE; } @@ -1273,7 +1284,10 @@ static void cc_destroy_call_elem(grpc_exec_ctx *exec_ctx, const grpc_call_final_info *final_info, grpc_closure *then_schedule_closure) { call_data *calld = elem->call_data; - grpc_deadline_state_destroy(exec_ctx, elem); + channel_data *chand = elem->channel_data; + if (chand->deadline_checking_enabled) { + grpc_deadline_state_destroy(exec_ctx, elem); + } grpc_slice_unref_internal(exec_ctx, calld->path); if (calld->method_params != NULL) { method_parameters_unref(calld->method_params); diff --git a/src/core/ext/filters/deadline/deadline_filter.c b/src/core/ext/filters/deadline/deadline_filter.c new file mode 100644 index 0000000000..18f7145ceb --- /dev/null +++ b/src/core/ext/filters/deadline/deadline_filter.c @@ -0,0 +1,377 @@ +// +// Copyright 2016, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// + +#include "src/core/ext/filters/deadline/deadline_filter.h" + +#include +#include + +#include +#include +#include +#include + +#include "src/core/lib/channel/channel_stack_builder.h" +#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/iomgr/timer.h" +#include "src/core/lib/slice/slice_internal.h" +#include "src/core/lib/surface/channel_init.h" + +// +// grpc_deadline_state +// + +// Timer callback. +static void timer_callback(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { + grpc_call_element* elem = arg; + grpc_deadline_state* deadline_state = elem->call_data; + if (error != GRPC_ERROR_CANCELLED) { + grpc_call_element_signal_error( + exec_ctx, elem, + grpc_error_set_int( + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Deadline Exceeded"), + GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_DEADLINE_EXCEEDED)); + } + GRPC_CALL_STACK_UNREF(exec_ctx, deadline_state->call_stack, "deadline_timer"); +} + +// Starts the deadline timer. +static void start_timer_if_needed(grpc_exec_ctx* exec_ctx, + grpc_call_element* elem, + gpr_timespec deadline) { + deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC); + if (gpr_time_cmp(deadline, gpr_inf_future(GPR_CLOCK_MONOTONIC)) == 0) { + return; + } + grpc_deadline_state* deadline_state = elem->call_data; + grpc_deadline_timer_state cur_state; + grpc_closure* closure = NULL; +retry: + cur_state = + (grpc_deadline_timer_state)gpr_atm_acq_load(&deadline_state->timer_state); + switch (cur_state) { + case GRPC_DEADLINE_STATE_PENDING: + // Note: We do not start the timer if there is already a timer + return; + case GRPC_DEADLINE_STATE_FINISHED: + if (gpr_atm_rel_cas(&deadline_state->timer_state, + GRPC_DEADLINE_STATE_FINISHED, + GRPC_DEADLINE_STATE_PENDING)) { + // If we've already created and destroyed a timer, we always create a + // new closure: we have no other guarantee that the inlined closure is + // not in use (it may hold a pending call to timer_callback) + closure = grpc_closure_create(timer_callback, elem, + grpc_schedule_on_exec_ctx); + } else { + goto retry; + } + break; + case GRPC_DEADLINE_STATE_INITIAL: + if (gpr_atm_rel_cas(&deadline_state->timer_state, + GRPC_DEADLINE_STATE_INITIAL, + GRPC_DEADLINE_STATE_PENDING)) { + closure = + grpc_closure_init(&deadline_state->timer_callback, timer_callback, + elem, grpc_schedule_on_exec_ctx); + } else { + goto retry; + } + break; + } + GPR_ASSERT(closure); + GRPC_CALL_STACK_REF(deadline_state->call_stack, "deadline_timer"); + grpc_timer_init(exec_ctx, &deadline_state->timer, deadline, closure, + gpr_now(GPR_CLOCK_MONOTONIC)); +} + +// Cancels the deadline timer. +static void cancel_timer_if_needed(grpc_exec_ctx* exec_ctx, + grpc_deadline_state* deadline_state) { + if (gpr_atm_rel_cas(&deadline_state->timer_state, GRPC_DEADLINE_STATE_PENDING, + GRPC_DEADLINE_STATE_FINISHED)) { + grpc_timer_cancel(exec_ctx, &deadline_state->timer); + } else { + // timer was either in STATE_INITAL (nothing to cancel) + // OR in STATE_FINISHED (again nothing to cancel) + } +} + +// Callback run when the call is complete. +static void on_complete(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { + grpc_deadline_state* deadline_state = arg; + cancel_timer_if_needed(exec_ctx, deadline_state); + // Invoke the next callback. + grpc_closure_run(exec_ctx, deadline_state->next_on_complete, + GRPC_ERROR_REF(error)); +} + +// Inject our own on_complete callback into op. +static void inject_on_complete_cb(grpc_deadline_state* deadline_state, + grpc_transport_stream_op* op) { + deadline_state->next_on_complete = op->on_complete; + grpc_closure_init(&deadline_state->on_complete, on_complete, deadline_state, + grpc_schedule_on_exec_ctx); + op->on_complete = &deadline_state->on_complete; +} + +void grpc_deadline_state_init(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, + grpc_call_stack* call_stack) { + grpc_deadline_state* deadline_state = elem->call_data; + deadline_state->call_stack = call_stack; +} + +void grpc_deadline_state_destroy(grpc_exec_ctx* exec_ctx, + grpc_call_element* elem) { + grpc_deadline_state* deadline_state = elem->call_data; + cancel_timer_if_needed(exec_ctx, deadline_state); +} + +// Callback and associated state for starting the timer after call stack +// initialization has been completed. +struct start_timer_after_init_state { + grpc_call_element* elem; + gpr_timespec deadline; + grpc_closure closure; +}; +static void start_timer_after_init(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { + struct start_timer_after_init_state* state = arg; + start_timer_if_needed(exec_ctx, state->elem, state->deadline); + gpr_free(state); +} + +void grpc_deadline_state_start(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, + gpr_timespec deadline) { + // Deadline will always be infinite on servers, so the timer will only be + // set on clients with a finite deadline. + deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC); + if (gpr_time_cmp(deadline, gpr_inf_future(GPR_CLOCK_MONOTONIC)) != 0) { + // When the deadline passes, we indicate the failure by sending down + // an op with cancel_error set. However, we can't send down any ops + // until after the call stack is fully initialized. If we start the + // timer here, we have no guarantee that the timer won't pop before + // call stack initialization is finished. To avoid that problem, we + // create a closure to start the timer, and we schedule that closure + // to be run after call stack initialization is done. + struct start_timer_after_init_state* state = gpr_malloc(sizeof(*state)); + state->elem = elem; + state->deadline = deadline; + grpc_closure_init(&state->closure, start_timer_after_init, state, + grpc_schedule_on_exec_ctx); + grpc_closure_sched(exec_ctx, &state->closure, GRPC_ERROR_NONE); + } +} + +void grpc_deadline_state_reset(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, + gpr_timespec new_deadline) { + grpc_deadline_state* deadline_state = elem->call_data; + cancel_timer_if_needed(exec_ctx, deadline_state); + start_timer_if_needed(exec_ctx, elem, new_deadline); +} + +void grpc_deadline_state_client_start_transport_stream_op( + grpc_exec_ctx* exec_ctx, grpc_call_element* elem, + grpc_transport_stream_op* op) { + grpc_deadline_state* deadline_state = elem->call_data; + if (op->cancel_error != GRPC_ERROR_NONE) { + cancel_timer_if_needed(exec_ctx, deadline_state); + } else { + // Make sure we know when the call is complete, so that we can cancel + // the timer. + if (op->recv_trailing_metadata != NULL) { + inject_on_complete_cb(deadline_state, op); + } + } +} + +// +// filter code +// + +// Constructor for channel_data. Used for both client and server filters. +static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx, + grpc_channel_element* elem, + grpc_channel_element_args* args) { + GPR_ASSERT(!args->is_last); + return GRPC_ERROR_NONE; +} + +// Destructor for channel_data. Used for both client and server filters. +static void destroy_channel_elem(grpc_exec_ctx* exec_ctx, + grpc_channel_element* elem) {} + +// Call data used for both client and server filter. +typedef struct base_call_data { + grpc_deadline_state deadline_state; +} base_call_data; + +// Additional call data used only for the server filter. +typedef struct server_call_data { + base_call_data base; // Must be first. + // The closure for receiving initial metadata. + grpc_closure recv_initial_metadata_ready; + // Received initial metadata batch. + grpc_metadata_batch* recv_initial_metadata; + // The original recv_initial_metadata_ready closure, which we chain to + // after our own closure is invoked. + grpc_closure* next_recv_initial_metadata_ready; +} server_call_data; + +// Constructor for call_data. Used for both client and server filters. +static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx, + grpc_call_element* elem, + const grpc_call_element_args* args) { + grpc_deadline_state_init(exec_ctx, elem, args->call_stack); + grpc_deadline_state_start(exec_ctx, elem, args->deadline); + return GRPC_ERROR_NONE; +} + +// Destructor for call_data. Used for both client and server filters. +static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, + const grpc_call_final_info* final_info, + grpc_closure* ignored) { + grpc_deadline_state_destroy(exec_ctx, elem); +} + +// Method for starting a call op for client filter. +static void client_start_transport_stream_op(grpc_exec_ctx* exec_ctx, + grpc_call_element* elem, + grpc_transport_stream_op* op) { + grpc_deadline_state_client_start_transport_stream_op(exec_ctx, elem, op); + // Chain to next filter. + grpc_call_next_op(exec_ctx, elem, op); +} + +// Callback for receiving initial metadata on the server. +static void recv_initial_metadata_ready(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { + grpc_call_element* elem = arg; + server_call_data* calld = elem->call_data; + // Get deadline from metadata and start the timer if needed. + start_timer_if_needed(exec_ctx, elem, calld->recv_initial_metadata->deadline); + // Invoke the next callback. + calld->next_recv_initial_metadata_ready->cb( + exec_ctx, calld->next_recv_initial_metadata_ready->cb_arg, error); +} + +// Method for starting a call op for server filter. +static void server_start_transport_stream_op(grpc_exec_ctx* exec_ctx, + grpc_call_element* elem, + grpc_transport_stream_op* op) { + server_call_data* calld = elem->call_data; + if (op->cancel_error != GRPC_ERROR_NONE) { + cancel_timer_if_needed(exec_ctx, &calld->base.deadline_state); + } else { + // If we're receiving initial metadata, we need to get the deadline + // from the recv_initial_metadata_ready callback. So we inject our + // own callback into that hook. + if (op->recv_initial_metadata_ready != NULL) { + calld->next_recv_initial_metadata_ready = op->recv_initial_metadata_ready; + calld->recv_initial_metadata = op->recv_initial_metadata; + grpc_closure_init(&calld->recv_initial_metadata_ready, + recv_initial_metadata_ready, elem, + grpc_schedule_on_exec_ctx); + op->recv_initial_metadata_ready = &calld->recv_initial_metadata_ready; + } + // Make sure we know when the call is complete, so that we can cancel + // the timer. + // Note that we trigger this on recv_trailing_metadata, even though + // the client never sends trailing metadata, because this is the + // hook that tells us when the call is complete on the server side. + if (op->recv_trailing_metadata != NULL) { + inject_on_complete_cb(&calld->base.deadline_state, op); + } + } + // Chain to next filter. + grpc_call_next_op(exec_ctx, elem, op); +} + +const grpc_channel_filter grpc_client_deadline_filter = { + client_start_transport_stream_op, + grpc_channel_next_op, + sizeof(base_call_data), + init_call_elem, + grpc_call_stack_ignore_set_pollset_or_pollset_set, + destroy_call_elem, + 0, // sizeof(channel_data) + init_channel_elem, + destroy_channel_elem, + grpc_call_next_get_peer, + grpc_channel_next_get_info, + "deadline", +}; + +const grpc_channel_filter grpc_server_deadline_filter = { + server_start_transport_stream_op, + grpc_channel_next_op, + sizeof(server_call_data), + init_call_elem, + grpc_call_stack_ignore_set_pollset_or_pollset_set, + destroy_call_elem, + 0, // sizeof(channel_data) + init_channel_elem, + destroy_channel_elem, + grpc_call_next_get_peer, + grpc_channel_next_get_info, + "deadline", +}; + +bool grpc_deadline_checking_enabled(const grpc_channel_args* channel_args) { + bool enable = !grpc_channel_args_want_minimal_stack(channel_args); + const grpc_arg* a = + grpc_channel_args_find(channel_args, GRPC_ARG_ENABLE_DEADLINE_CHECKS); + if (a != NULL && a->type == GRPC_ARG_INTEGER && a->value.integer != 0) { + enable = true; + } + return enable; +} + +static bool maybe_add_deadline_filter(grpc_exec_ctx* exec_ctx, + grpc_channel_stack_builder* builder, + void* arg) { + return grpc_deadline_checking_enabled( + grpc_channel_stack_builder_get_channel_arguments(builder)) + ? grpc_channel_stack_builder_prepend_filter(builder, arg, NULL, + NULL) + : true; +} + +void grpc_deadline_filter_init(void) { + grpc_channel_init_register_stage( + GRPC_CLIENT_DIRECT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, + maybe_add_deadline_filter, (void*)&grpc_client_deadline_filter); + grpc_channel_init_register_stage( + GRPC_SERVER_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, + maybe_add_deadline_filter, (void*)&grpc_server_deadline_filter); +} + +void grpc_deadline_filter_shutdown(void) {} diff --git a/src/core/ext/filters/deadline/deadline_filter.h b/src/core/ext/filters/deadline/deadline_filter.h new file mode 100644 index 0000000000..e1e3f5280b --- /dev/null +++ b/src/core/ext/filters/deadline/deadline_filter.h @@ -0,0 +1,105 @@ +// +// Copyright 2016, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef GRPC_CORE_LIB_CHANNEL_DEADLINE_FILTER_H +#define GRPC_CORE_LIB_CHANNEL_DEADLINE_FILTER_H + +#include "src/core/lib/channel/channel_stack.h" +#include "src/core/lib/iomgr/timer.h" + +typedef enum grpc_deadline_timer_state { + GRPC_DEADLINE_STATE_INITIAL, + GRPC_DEADLINE_STATE_PENDING, + GRPC_DEADLINE_STATE_FINISHED +} grpc_deadline_timer_state; + +// State used for filters that enforce call deadlines. +// Must be the first field in the filter's call_data. +typedef struct grpc_deadline_state { + // We take a reference to the call stack for the timer callback. + grpc_call_stack* call_stack; + gpr_atm timer_state; + grpc_timer timer; + grpc_closure timer_callback; + // Closure to invoke when the call is complete. + // We use this to cancel the timer. + grpc_closure on_complete; + // The original on_complete closure, which we chain to after our own + // closure is invoked. + grpc_closure* next_on_complete; +} grpc_deadline_state; + +// +// NOTE: All of these functions require that the first field in +// elem->call_data is a grpc_deadline_state. +// + +// assumes elem->call_data is zero'd +void grpc_deadline_state_init(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, + grpc_call_stack* call_stack); +void grpc_deadline_state_destroy(grpc_exec_ctx* exec_ctx, + grpc_call_element* elem); + +// Starts the timer with the specified deadline. +// Should be called from the filter's init_call_elem() method. +void grpc_deadline_state_start(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, + gpr_timespec deadline); + +// Cancels the existing timer and starts a new one with new_deadline. +// +// Note: It is generally safe to call this with an earlier deadline +// value than the current one, but not the reverse. No checks are done +// to ensure that the timer callback is not invoked while it is in the +// process of being reset, which means that attempting to increase the +// deadline may result in the timer being called twice. +void grpc_deadline_state_reset(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, + gpr_timespec new_deadline); + +// To be called from the client-side filter's start_transport_stream_op() +// method. Ensures that the deadline timer is cancelled when the call +// is completed. +// +// Note: It is the caller's responsibility to chain to the next filter if +// necessary after this function returns. +void grpc_deadline_state_client_start_transport_stream_op( + grpc_exec_ctx* exec_ctx, grpc_call_element* elem, + grpc_transport_stream_op* op); + +// Should deadline checking be performed (according to channel args) +bool grpc_deadline_checking_enabled(const grpc_channel_args* args); + +// Deadline filters for direct client channels and server channels. +// Note: Deadlines for non-direct client channels are handled by the +// client_channel filter. +extern const grpc_channel_filter grpc_client_deadline_filter; +extern const grpc_channel_filter grpc_server_deadline_filter; + +#endif /* GRPC_CORE_LIB_CHANNEL_DEADLINE_FILTER_H */ diff --git a/src/core/lib/channel/deadline_filter.c b/src/core/lib/channel/deadline_filter.c deleted file mode 100644 index ca701ed457..0000000000 --- a/src/core/lib/channel/deadline_filter.c +++ /dev/null @@ -1,344 +0,0 @@ -// -// Copyright 2016, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// - -#include "src/core/lib/channel/deadline_filter.h" - -#include -#include - -#include -#include -#include -#include - -#include "src/core/lib/iomgr/exec_ctx.h" -#include "src/core/lib/iomgr/timer.h" -#include "src/core/lib/slice/slice_internal.h" - -// -// grpc_deadline_state -// - -// Timer callback. -static void timer_callback(grpc_exec_ctx* exec_ctx, void* arg, - grpc_error* error) { - grpc_call_element* elem = arg; - grpc_deadline_state* deadline_state = elem->call_data; - if (error != GRPC_ERROR_CANCELLED) { - grpc_call_element_signal_error( - exec_ctx, elem, - grpc_error_set_int( - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Deadline Exceeded"), - GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_DEADLINE_EXCEEDED)); - } - GRPC_CALL_STACK_UNREF(exec_ctx, deadline_state->call_stack, "deadline_timer"); -} - -// Starts the deadline timer. -static void start_timer_if_needed(grpc_exec_ctx* exec_ctx, - grpc_call_element* elem, - gpr_timespec deadline) { - deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC); - if (gpr_time_cmp(deadline, gpr_inf_future(GPR_CLOCK_MONOTONIC)) == 0) { - return; - } - grpc_deadline_state* deadline_state = elem->call_data; - grpc_deadline_timer_state cur_state; - grpc_closure* closure = NULL; -retry: - cur_state = - (grpc_deadline_timer_state)gpr_atm_acq_load(&deadline_state->timer_state); - switch (cur_state) { - case GRPC_DEADLINE_STATE_PENDING: - // Note: We do not start the timer if there is already a timer - return; - case GRPC_DEADLINE_STATE_FINISHED: - if (gpr_atm_rel_cas(&deadline_state->timer_state, - GRPC_DEADLINE_STATE_FINISHED, - GRPC_DEADLINE_STATE_PENDING)) { - // If we've already created and destroyed a timer, we always create a - // new closure: we have no other guarantee that the inlined closure is - // not in use (it may hold a pending call to timer_callback) - closure = grpc_closure_create(timer_callback, elem, - grpc_schedule_on_exec_ctx); - } else { - goto retry; - } - break; - case GRPC_DEADLINE_STATE_INITIAL: - if (gpr_atm_rel_cas(&deadline_state->timer_state, - GRPC_DEADLINE_STATE_INITIAL, - GRPC_DEADLINE_STATE_PENDING)) { - closure = - grpc_closure_init(&deadline_state->timer_callback, timer_callback, - elem, grpc_schedule_on_exec_ctx); - } else { - goto retry; - } - break; - } - GPR_ASSERT(closure); - GRPC_CALL_STACK_REF(deadline_state->call_stack, "deadline_timer"); - grpc_timer_init(exec_ctx, &deadline_state->timer, deadline, closure, - gpr_now(GPR_CLOCK_MONOTONIC)); -} - -// Cancels the deadline timer. -static void cancel_timer_if_needed(grpc_exec_ctx* exec_ctx, - grpc_deadline_state* deadline_state) { - if (gpr_atm_rel_cas(&deadline_state->timer_state, GRPC_DEADLINE_STATE_PENDING, - GRPC_DEADLINE_STATE_FINISHED)) { - grpc_timer_cancel(exec_ctx, &deadline_state->timer); - } else { - // timer was either in STATE_INITAL (nothing to cancel) - // OR in STATE_FINISHED (again nothing to cancel) - } -} - -// Callback run when the call is complete. -static void on_complete(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { - grpc_deadline_state* deadline_state = arg; - cancel_timer_if_needed(exec_ctx, deadline_state); - // Invoke the next callback. - grpc_closure_run(exec_ctx, deadline_state->next_on_complete, - GRPC_ERROR_REF(error)); -} - -// Inject our own on_complete callback into op. -static void inject_on_complete_cb(grpc_deadline_state* deadline_state, - grpc_transport_stream_op* op) { - deadline_state->next_on_complete = op->on_complete; - grpc_closure_init(&deadline_state->on_complete, on_complete, deadline_state, - grpc_schedule_on_exec_ctx); - op->on_complete = &deadline_state->on_complete; -} - -void grpc_deadline_state_init(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, - grpc_call_stack* call_stack) { - grpc_deadline_state* deadline_state = elem->call_data; - deadline_state->call_stack = call_stack; -} - -void grpc_deadline_state_destroy(grpc_exec_ctx* exec_ctx, - grpc_call_element* elem) { - grpc_deadline_state* deadline_state = elem->call_data; - cancel_timer_if_needed(exec_ctx, deadline_state); -} - -// Callback and associated state for starting the timer after call stack -// initialization has been completed. -struct start_timer_after_init_state { - grpc_call_element* elem; - gpr_timespec deadline; - grpc_closure closure; -}; -static void start_timer_after_init(grpc_exec_ctx* exec_ctx, void* arg, - grpc_error* error) { - struct start_timer_after_init_state* state = arg; - start_timer_if_needed(exec_ctx, state->elem, state->deadline); - gpr_free(state); -} - -void grpc_deadline_state_start(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, - gpr_timespec deadline) { - // Deadline will always be infinite on servers, so the timer will only be - // set on clients with a finite deadline. - deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC); - if (gpr_time_cmp(deadline, gpr_inf_future(GPR_CLOCK_MONOTONIC)) != 0) { - // When the deadline passes, we indicate the failure by sending down - // an op with cancel_error set. However, we can't send down any ops - // until after the call stack is fully initialized. If we start the - // timer here, we have no guarantee that the timer won't pop before - // call stack initialization is finished. To avoid that problem, we - // create a closure to start the timer, and we schedule that closure - // to be run after call stack initialization is done. - struct start_timer_after_init_state* state = gpr_malloc(sizeof(*state)); - state->elem = elem; - state->deadline = deadline; - grpc_closure_init(&state->closure, start_timer_after_init, state, - grpc_schedule_on_exec_ctx); - grpc_closure_sched(exec_ctx, &state->closure, GRPC_ERROR_NONE); - } -} - -void grpc_deadline_state_reset(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, - gpr_timespec new_deadline) { - grpc_deadline_state* deadline_state = elem->call_data; - cancel_timer_if_needed(exec_ctx, deadline_state); - start_timer_if_needed(exec_ctx, elem, new_deadline); -} - -void grpc_deadline_state_client_start_transport_stream_op( - grpc_exec_ctx* exec_ctx, grpc_call_element* elem, - grpc_transport_stream_op* op) { - grpc_deadline_state* deadline_state = elem->call_data; - if (op->cancel_error != GRPC_ERROR_NONE) { - cancel_timer_if_needed(exec_ctx, deadline_state); - } else { - // Make sure we know when the call is complete, so that we can cancel - // the timer. - if (op->recv_trailing_metadata != NULL) { - inject_on_complete_cb(deadline_state, op); - } - } -} - -// -// filter code -// - -// Constructor for channel_data. Used for both client and server filters. -static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx, - grpc_channel_element* elem, - grpc_channel_element_args* args) { - GPR_ASSERT(!args->is_last); - return GRPC_ERROR_NONE; -} - -// Destructor for channel_data. Used for both client and server filters. -static void destroy_channel_elem(grpc_exec_ctx* exec_ctx, - grpc_channel_element* elem) {} - -// Call data used for both client and server filter. -typedef struct base_call_data { - grpc_deadline_state deadline_state; -} base_call_data; - -// Additional call data used only for the server filter. -typedef struct server_call_data { - base_call_data base; // Must be first. - // The closure for receiving initial metadata. - grpc_closure recv_initial_metadata_ready; - // Received initial metadata batch. - grpc_metadata_batch* recv_initial_metadata; - // The original recv_initial_metadata_ready closure, which we chain to - // after our own closure is invoked. - grpc_closure* next_recv_initial_metadata_ready; -} server_call_data; - -// Constructor for call_data. Used for both client and server filters. -static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx, - grpc_call_element* elem, - const grpc_call_element_args* args) { - grpc_deadline_state_init(exec_ctx, elem, args->call_stack); - grpc_deadline_state_start(exec_ctx, elem, args->deadline); - return GRPC_ERROR_NONE; -} - -// Destructor for call_data. Used for both client and server filters. -static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* ignored) { - grpc_deadline_state_destroy(exec_ctx, elem); -} - -// Method for starting a call op for client filter. -static void client_start_transport_stream_op(grpc_exec_ctx* exec_ctx, - grpc_call_element* elem, - grpc_transport_stream_op* op) { - grpc_deadline_state_client_start_transport_stream_op(exec_ctx, elem, op); - // Chain to next filter. - grpc_call_next_op(exec_ctx, elem, op); -} - -// Callback for receiving initial metadata on the server. -static void recv_initial_metadata_ready(grpc_exec_ctx* exec_ctx, void* arg, - grpc_error* error) { - grpc_call_element* elem = arg; - server_call_data* calld = elem->call_data; - // Get deadline from metadata and start the timer if needed. - start_timer_if_needed(exec_ctx, elem, calld->recv_initial_metadata->deadline); - // Invoke the next callback. - calld->next_recv_initial_metadata_ready->cb( - exec_ctx, calld->next_recv_initial_metadata_ready->cb_arg, error); -} - -// Method for starting a call op for server filter. -static void server_start_transport_stream_op(grpc_exec_ctx* exec_ctx, - grpc_call_element* elem, - grpc_transport_stream_op* op) { - server_call_data* calld = elem->call_data; - if (op->cancel_error != GRPC_ERROR_NONE) { - cancel_timer_if_needed(exec_ctx, &calld->base.deadline_state); - } else { - // If we're receiving initial metadata, we need to get the deadline - // from the recv_initial_metadata_ready callback. So we inject our - // own callback into that hook. - if (op->recv_initial_metadata_ready != NULL) { - calld->next_recv_initial_metadata_ready = op->recv_initial_metadata_ready; - calld->recv_initial_metadata = op->recv_initial_metadata; - grpc_closure_init(&calld->recv_initial_metadata_ready, - recv_initial_metadata_ready, elem, - grpc_schedule_on_exec_ctx); - op->recv_initial_metadata_ready = &calld->recv_initial_metadata_ready; - } - // Make sure we know when the call is complete, so that we can cancel - // the timer. - // Note that we trigger this on recv_trailing_metadata, even though - // the client never sends trailing metadata, because this is the - // hook that tells us when the call is complete on the server side. - if (op->recv_trailing_metadata != NULL) { - inject_on_complete_cb(&calld->base.deadline_state, op); - } - } - // Chain to next filter. - grpc_call_next_op(exec_ctx, elem, op); -} - -const grpc_channel_filter grpc_client_deadline_filter = { - client_start_transport_stream_op, - grpc_channel_next_op, - sizeof(base_call_data), - init_call_elem, - grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, - 0, // sizeof(channel_data) - init_channel_elem, - destroy_channel_elem, - grpc_call_next_get_peer, - grpc_channel_next_get_info, - "deadline", -}; - -const grpc_channel_filter grpc_server_deadline_filter = { - server_start_transport_stream_op, - grpc_channel_next_op, - sizeof(server_call_data), - init_call_elem, - grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, - 0, // sizeof(channel_data) - init_channel_elem, - destroy_channel_elem, - grpc_call_next_get_peer, - grpc_channel_next_get_info, - "deadline", -}; diff --git a/src/core/lib/channel/deadline_filter.h b/src/core/lib/channel/deadline_filter.h deleted file mode 100644 index 72cd5cb929..0000000000 --- a/src/core/lib/channel/deadline_filter.h +++ /dev/null @@ -1,102 +0,0 @@ -// -// Copyright 2016, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// - -#ifndef GRPC_CORE_LIB_CHANNEL_DEADLINE_FILTER_H -#define GRPC_CORE_LIB_CHANNEL_DEADLINE_FILTER_H - -#include "src/core/lib/channel/channel_stack.h" -#include "src/core/lib/iomgr/timer.h" - -typedef enum grpc_deadline_timer_state { - GRPC_DEADLINE_STATE_INITIAL, - GRPC_DEADLINE_STATE_PENDING, - GRPC_DEADLINE_STATE_FINISHED -} grpc_deadline_timer_state; - -// State used for filters that enforce call deadlines. -// Must be the first field in the filter's call_data. -typedef struct grpc_deadline_state { - // We take a reference to the call stack for the timer callback. - grpc_call_stack* call_stack; - gpr_atm timer_state; - grpc_timer timer; - grpc_closure timer_callback; - // Closure to invoke when the call is complete. - // We use this to cancel the timer. - grpc_closure on_complete; - // The original on_complete closure, which we chain to after our own - // closure is invoked. - grpc_closure* next_on_complete; -} grpc_deadline_state; - -// -// NOTE: All of these functions require that the first field in -// elem->call_data is a grpc_deadline_state. -// - -// assumes elem->call_data is zero'd -void grpc_deadline_state_init(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, - grpc_call_stack* call_stack); -void grpc_deadline_state_destroy(grpc_exec_ctx* exec_ctx, - grpc_call_element* elem); - -// Starts the timer with the specified deadline. -// Should be called from the filter's init_call_elem() method. -void grpc_deadline_state_start(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, - gpr_timespec deadline); - -// Cancels the existing timer and starts a new one with new_deadline. -// -// Note: It is generally safe to call this with an earlier deadline -// value than the current one, but not the reverse. No checks are done -// to ensure that the timer callback is not invoked while it is in the -// process of being reset, which means that attempting to increase the -// deadline may result in the timer being called twice. -void grpc_deadline_state_reset(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, - gpr_timespec new_deadline); - -// To be called from the client-side filter's start_transport_stream_op() -// method. Ensures that the deadline timer is cancelled when the call -// is completed. -// -// Note: It is the caller's responsibility to chain to the next filter if -// necessary after this function returns. -void grpc_deadline_state_client_start_transport_stream_op( - grpc_exec_ctx* exec_ctx, grpc_call_element* elem, - grpc_transport_stream_op* op); - -// Deadline filters for direct client channels and server channels. -// Note: Deadlines for non-direct client channels are handled by the -// client_channel filter. -extern const grpc_channel_filter grpc_client_deadline_filter; -extern const grpc_channel_filter grpc_server_deadline_filter; - -#endif /* GRPC_CORE_LIB_CHANNEL_DEADLINE_FILTER_H */ diff --git a/src/core/lib/surface/init.c b/src/core/lib/surface/init.c index bba259c099..4b381b1954 100644 --- a/src/core/lib/surface/init.c +++ b/src/core/lib/surface/init.c @@ -42,7 +42,6 @@ #include #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/channel/deadline_filter.h" #include "src/core/lib/channel/handshaker_registry.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/http/parser.h" @@ -92,12 +91,6 @@ static bool prepend_filter(grpc_exec_ctx *exec_ctx, } static void register_builtin_channel_init() { - grpc_channel_init_register_stage( - GRPC_CLIENT_DIRECT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, - prepend_filter, (void *)&grpc_client_deadline_filter); - grpc_channel_init_register_stage( - GRPC_SERVER_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, prepend_filter, - (void *)&grpc_server_deadline_filter); grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, grpc_add_connected_filter, NULL); diff --git a/src/core/plugin_registry/grpc_cronet_plugin_registry.c b/src/core/plugin_registry/grpc_cronet_plugin_registry.c index 6cc3a25c55..907e5a0f39 100644 --- a/src/core/plugin_registry/grpc_cronet_plugin_registry.c +++ b/src/core/plugin_registry/grpc_cronet_plugin_registry.c @@ -37,6 +37,8 @@ extern void grpc_http_filters_init(void); extern void grpc_http_filters_shutdown(void); extern void grpc_chttp2_plugin_init(void); extern void grpc_chttp2_plugin_shutdown(void); +extern void grpc_deadline_filter_init(void); +extern void grpc_deadline_filter_shutdown(void); extern void grpc_client_channel_init(void); extern void grpc_client_channel_shutdown(void); extern void grpc_load_reporting_plugin_init(void); @@ -47,6 +49,8 @@ void grpc_register_built_in_plugins(void) { grpc_http_filters_shutdown); grpc_register_plugin(grpc_chttp2_plugin_init, grpc_chttp2_plugin_shutdown); + grpc_register_plugin(grpc_deadline_filter_init, + grpc_deadline_filter_shutdown); grpc_register_plugin(grpc_client_channel_init, grpc_client_channel_shutdown); grpc_register_plugin(grpc_load_reporting_plugin_init, diff --git a/src/core/plugin_registry/grpc_plugin_registry.c b/src/core/plugin_registry/grpc_plugin_registry.c index 40a882d50c..25bda7a262 100644 --- a/src/core/plugin_registry/grpc_plugin_registry.c +++ b/src/core/plugin_registry/grpc_plugin_registry.c @@ -37,6 +37,8 @@ extern void grpc_http_filters_init(void); extern void grpc_http_filters_shutdown(void); extern void grpc_chttp2_plugin_init(void); extern void grpc_chttp2_plugin_shutdown(void); +extern void grpc_deadline_filter_init(void); +extern void grpc_deadline_filter_shutdown(void); extern void grpc_client_channel_init(void); extern void grpc_client_channel_shutdown(void); extern void grpc_lb_policy_grpclb_init(void); @@ -65,6 +67,8 @@ void grpc_register_built_in_plugins(void) { grpc_http_filters_shutdown); grpc_register_plugin(grpc_chttp2_plugin_init, grpc_chttp2_plugin_shutdown); + grpc_register_plugin(grpc_deadline_filter_init, + grpc_deadline_filter_shutdown); grpc_register_plugin(grpc_client_channel_init, grpc_client_channel_shutdown); grpc_register_plugin(grpc_lb_policy_grpclb_init, diff --git a/src/core/plugin_registry/grpc_unsecure_plugin_registry.c b/src/core/plugin_registry/grpc_unsecure_plugin_registry.c index ded2aa6a84..05d4771bce 100644 --- a/src/core/plugin_registry/grpc_unsecure_plugin_registry.c +++ b/src/core/plugin_registry/grpc_unsecure_plugin_registry.c @@ -37,6 +37,8 @@ extern void grpc_http_filters_init(void); extern void grpc_http_filters_shutdown(void); extern void grpc_chttp2_plugin_init(void); extern void grpc_chttp2_plugin_shutdown(void); +extern void grpc_deadline_filter_init(void); +extern void grpc_deadline_filter_shutdown(void); extern void grpc_client_channel_init(void); extern void grpc_client_channel_shutdown(void); extern void grpc_resolver_dns_ares_init(void); @@ -65,6 +67,8 @@ void grpc_register_built_in_plugins(void) { grpc_http_filters_shutdown); grpc_register_plugin(grpc_chttp2_plugin_init, grpc_chttp2_plugin_shutdown); + grpc_register_plugin(grpc_deadline_filter_init, + grpc_deadline_filter_shutdown); grpc_register_plugin(grpc_client_channel_init, grpc_client_channel_shutdown); grpc_register_plugin(grpc_resolver_dns_ares_init, diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index f99e777532..c858dc9e1f 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -77,11 +77,11 @@ CORE_SOURCE_FILES = [ 'src/core/lib/support/tmpfile_windows.c', 'src/core/lib/support/wrap_memcpy.c', 'src/core/lib/surface/init.c', + 'src/core/ext/filters/deadline/deadline_filter.c', 'src/core/lib/channel/channel_args.c', 'src/core/lib/channel/channel_stack.c', 'src/core/lib/channel/channel_stack_builder.c', 'src/core/lib/channel/connected_channel.c', - 'src/core/lib/channel/deadline_filter.c', 'src/core/lib/channel/handshaker.c', 'src/core/lib/channel/handshaker_factory.c', 'src/core/lib/channel/handshaker_registry.c', diff --git a/test/core/channel/minimal_stack_is_minimal_test.c b/test/core/channel/minimal_stack_is_minimal_test.c index f7bdc1b843..b76e812a61 100644 --- a/test/core/channel/minimal_stack_is_minimal_test.c +++ b/test/core/channel/minimal_stack_is_minimal_test.c @@ -77,20 +77,20 @@ int main(int argc, char **argv) { "client-channel", NULL); // tests with a default stack - errors += CHECK_STACK("unknown", NULL, GRPC_CLIENT_DIRECT_CHANNEL, "deadline", - "message_size", "connected", NULL); + errors += CHECK_STACK("unknown", NULL, GRPC_CLIENT_DIRECT_CHANNEL, + "message_size", "deadline", "connected", NULL); errors += CHECK_STACK("unknown", NULL, GRPC_CLIENT_SUBCHANNEL, "message_size", "connected", NULL); errors += CHECK_STACK("unknown", NULL, GRPC_SERVER_CHANNEL, "server", - "deadline", "message_size", "connected", NULL); + "message_size", "deadline", "connected", NULL); errors += - CHECK_STACK("chttp2", NULL, GRPC_CLIENT_DIRECT_CHANNEL, "deadline", - "message_size", "http-client", "compress", "connected", NULL); + CHECK_STACK("chttp2", NULL, GRPC_CLIENT_DIRECT_CHANNEL, "message_size", + "deadline", "http-client", "compress", "connected", NULL); errors += CHECK_STACK("chttp2", NULL, GRPC_CLIENT_SUBCHANNEL, "message_size", "http-client", "compress", "connected", NULL); errors += - CHECK_STACK("chttp2", NULL, GRPC_SERVER_CHANNEL, "server", "deadline", - "message_size", "http-server", "compress", "connected", NULL); + CHECK_STACK("chttp2", NULL, GRPC_SERVER_CHANNEL, "server", "message_size", + "deadline", "http-server", "compress", "connected", NULL); errors += CHECK_STACK(NULL, NULL, GRPC_CLIENT_CHANNEL, "client-channel", NULL); @@ -147,6 +147,7 @@ static int check_stack(const char *file, int line, const char *transport_name, } char *got = gpr_strvec_flatten(&v, NULL); gpr_strvec_destroy(&v); + grpc_channel_stack_builder_iterator_destroy(it); // figure out result, log if there's an error int result = 0; diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc index 3fcd5bc6ab..694765e013 100644 --- a/test/cpp/microbenchmarks/bm_call_create.cc +++ b/test/cpp/microbenchmarks/bm_call_create.cc @@ -50,7 +50,7 @@ extern "C" { #include "src/core/lib/channel/channel_stack.h" #include "src/core/ext/filters/http/compress/compress_filter.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/channel/deadline_filter.h" +#include "src/core/ext/filters/deadline/deadline_filter.h" #include "src/core/ext/filters/http/client/http_client_filter.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/filters/message_size/message_size_filter.h" diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index add3cb1857..759c7071d0 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -900,6 +900,8 @@ include/grpc/load_reporting.h \ include/grpc/slice.h \ include/grpc/slice_buffer.h \ include/grpc/status.h \ +src/core/ext/filters/deadline/deadline_filter.c \ +src/core/ext/filters/deadline/deadline_filter.h \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_args.h \ src/core/lib/channel/channel_stack.c \ @@ -909,8 +911,6 @@ src/core/lib/channel/channel_stack_builder.h \ src/core/lib/channel/connected_channel.c \ src/core/lib/channel/connected_channel.h \ src/core/lib/channel/context.h \ -src/core/lib/channel/deadline_filter.c \ -src/core/lib/channel/deadline_filter.h \ src/core/lib/channel/handshaker.c \ src/core/lib/channel/handshaker.h \ src/core/lib/channel/handshaker_factory.c \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 8db6e146a3..8bc5896e88 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -954,6 +954,8 @@ src/core/ext/filters/client_channel/subchannel_index.c \ src/core/ext/filters/client_channel/subchannel_index.h \ src/core/ext/filters/client_channel/uri_parser.c \ src/core/ext/filters/client_channel/uri_parser.h \ +src/core/ext/filters/deadline/deadline_filter.c \ +src/core/ext/filters/deadline/deadline_filter.h \ src/core/ext/filters/http/client/http_client_filter.c \ src/core/ext/filters/http/client/http_client_filter.h \ src/core/ext/filters/http/compress/compress_filter.c \ @@ -1037,8 +1039,6 @@ src/core/lib/channel/channel_stack_builder.h \ src/core/lib/channel/connected_channel.c \ src/core/lib/channel/connected_channel.h \ src/core/lib/channel/context.h \ -src/core/lib/channel/deadline_filter.c \ -src/core/lib/channel/deadline_filter.h \ src/core/lib/channel/handshaker.c \ src/core/lib/channel/handshaker.h \ src/core/lib/channel/handshaker_factory.c \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 03cf01be0f..894a8953de 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -5589,6 +5589,7 @@ "census", "gpr", "grpc_base", + "grpc_deadline_filter", "grpc_lb_policy_grpclb_secure", "grpc_lb_policy_pick_first", "grpc_lb_policy_round_robin", @@ -5693,6 +5694,7 @@ "census", "gpr", "grpc_base", + "grpc_deadline_filter", "grpc_lb_policy_grpclb", "grpc_lb_policy_pick_first", "grpc_lb_policy_round_robin", @@ -7523,12 +7525,12 @@ "include/grpc/slice.h", "include/grpc/slice_buffer.h", "include/grpc/status.h", + "src/core/ext/filters/deadline/deadline_filter.h", "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", - "src/core/lib/channel/deadline_filter.h", "src/core/lib/channel/handshaker.h", "src/core/lib/channel/handshaker_factory.h", "src/core/lib/channel/handshaker_registry.h", @@ -7644,6 +7646,8 @@ "include/grpc/slice.h", "include/grpc/slice_buffer.h", "include/grpc/status.h", + "src/core/ext/filters/deadline/deadline_filter.c", + "src/core/ext/filters/deadline/deadline_filter.h", "src/core/lib/channel/channel_args.c", "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.c", @@ -7653,8 +7657,6 @@ "src/core/lib/channel/connected_channel.c", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", - "src/core/lib/channel/deadline_filter.c", - "src/core/lib/channel/deadline_filter.h", "src/core/lib/channel/handshaker.c", "src/core/lib/channel/handshaker.h", "src/core/lib/channel/handshaker_factory.c", @@ -7877,7 +7879,8 @@ { "deps": [ "gpr", - "grpc_base" + "grpc_base", + "grpc_deadline_filter" ], "headers": [ "src/core/ext/filters/client_channel/client_channel.h", @@ -7975,6 +7978,24 @@ "third_party": false, "type": "filegroup" }, + { + "deps": [ + "gpr", + "grpc_base" + ], + "headers": [ + "src/core/ext/filters/deadline/deadline_filter.h" + ], + "is_filegroup": true, + "language": "c", + "name": "grpc_deadline_filter", + "src": [ + "src/core/ext/filters/deadline/deadline_filter.c", + "src/core/ext/filters/deadline/deadline_filter.h" + ], + "third_party": false, + "type": "filegroup" + }, { "deps": [], "headers": [ diff --git a/vsprojects/vcxproj/grpc++/grpc++.vcxproj b/vsprojects/vcxproj/grpc++/grpc++.vcxproj index c37cb77d5b..7ffd0202e0 100644 --- a/vsprojects/vcxproj/grpc++/grpc++.vcxproj +++ b/vsprojects/vcxproj/grpc++/grpc++.vcxproj @@ -377,12 +377,12 @@ + - @@ -571,6 +571,8 @@ + + @@ -579,8 +581,6 @@ - - diff --git a/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters b/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters index 8f7e576998..5390d96a13 100644 --- a/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters @@ -124,6 +124,9 @@ src\cpp\util + + src\core\ext\filters\deadline + src\core\lib\channel @@ -136,9 +139,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\channel @@ -851,6 +851,9 @@ src\cpp\thread_manager + + src\core\ext\filters\deadline + src\core\lib\channel @@ -866,9 +869,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\channel @@ -1226,6 +1226,15 @@ {d02f1155-7e7e-3736-3c69-dc9146dc523d} + + {96d09c4a-59f9-3486-6c2f-cbf695b285d8} + + + {ec936f3c-c278-59b3-1fcf-d17ab77c8546} + + + {136a9e7f-2e8b-7cff-c961-5149529ca0f5} + {80567a8f-622f-a3ce-c12d-aebb63984b07} diff --git a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj index 973c016305..c954241d31 100644 --- a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj @@ -371,12 +371,12 @@ + - @@ -555,6 +555,8 @@ + + @@ -563,8 +565,6 @@ - - diff --git a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters index 6da1a2bcba..9b2463fdee 100644 --- a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters @@ -109,6 +109,9 @@ src\cpp\util + + src\core\ext\filters\deadline + src\core\lib\channel @@ -121,9 +124,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\channel @@ -818,6 +818,9 @@ src\cpp\thread_manager + + src\core\ext\filters\deadline + src\core\lib\channel @@ -833,9 +836,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\channel @@ -1193,6 +1193,15 @@ {595f2ea0-aafb-87e5-c938-db3ff0b0c69a} + + {52eca76b-9502-3d96-9064-6415226a860f} + + + {d2564ab1-6815-d425-3f8a-31693cc2ac81} + + + {0cc70f19-99bb-5e9e-99d9-b103398c0e76} + {cf8fd5d8-ff54-331d-2d20-36d6cae0e14b} diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj b/vsprojects/vcxproj/grpc/grpc.vcxproj index 47d28e06ca..093ac413bb 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj @@ -300,12 +300,12 @@ + - @@ -506,6 +506,8 @@ + + @@ -514,8 +516,6 @@ - - diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters index f67b7ab3f8..14a30993c8 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters @@ -4,6 +4,9 @@ src\core\lib\surface + + src\core\ext\filters\deadline + src\core\lib\channel @@ -16,9 +19,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\channel @@ -800,6 +800,9 @@ + + src\core\ext\filters\deadline + src\core\lib\channel @@ -815,9 +818,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\channel @@ -1481,6 +1481,9 @@ {bd317dd5-323e-5b27-4c05-d85786be36ab} + + {c8dcda4e-dbaa-1ae8-67a9-0dd26046f652} + {2e3ab9f3-39ca-db39-cb3e-2196cbc68098} diff --git a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj index 382e5af7e3..f549452cc9 100644 --- a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj +++ b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj @@ -195,12 +195,12 @@ + - @@ -343,6 +343,8 @@ + + @@ -351,8 +353,6 @@ - - diff --git a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters index db22acc685..11dfb8baa5 100644 --- a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters +++ b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters @@ -61,6 +61,9 @@ test\core\util + + src\core\ext\filters\deadline + src\core\lib\channel @@ -73,9 +76,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\channel @@ -563,6 +563,9 @@ test\core\util + + src\core\ext\filters\deadline + src\core\lib\channel @@ -578,9 +581,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\channel @@ -902,6 +902,15 @@ {f7bfac91-5eb2-dea7-4601-6c63edbbf997} + + {5db70e06-741d-708c-bf0a-b59f8ca1f8bd} + + + {f0f88514-c2d8-c4c9-c3bd-591682207751} + + + {2c9ab189-bb7e-355d-9f37-385472e86b9f} + {f4e8c61e-1ca6-0fdd-7b5e-b7f9a30c9a21} diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj index 336902647a..cfad8b85b9 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj @@ -290,12 +290,12 @@ + - @@ -474,6 +474,8 @@ + + @@ -482,8 +484,6 @@ - - diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters index 53a4748232..153fb856ee 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters @@ -7,6 +7,9 @@ src\core\lib\surface + + src\core\ext\filters\deadline + src\core\lib\channel @@ -19,9 +22,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\channel @@ -713,6 +713,9 @@ + + src\core\ext\filters\deadline + src\core\lib\channel @@ -728,9 +731,6 @@ src\core\lib\channel - - src\core\lib\channel - src\core\lib\channel @@ -1322,6 +1322,9 @@ {99210f5e-b2a0-ecd1-024f-fc152db68a11} + + {ac374be1-7a3f-14a8-69fe-badac2d9f9ec} + {33287f7d-739b-d30d-a9f3-b338103456b0} -- cgit v1.2.3 From f795feb3c8b73bc0a79ad64abf72fa33a1ebdb83 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 3 Apr 2017 14:37:09 -0700 Subject: Document this test --- test/core/channel/minimal_stack_is_minimal_test.c | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/core/channel/minimal_stack_is_minimal_test.c b/test/core/channel/minimal_stack_is_minimal_test.c index b76e812a61..bac94cbd64 100644 --- a/test/core/channel/minimal_stack_is_minimal_test.c +++ b/test/core/channel/minimal_stack_is_minimal_test.c @@ -31,6 +31,19 @@ * */ +/******************************************************************************* + * This test verifies that various stack configurations result in the set of + * filters that we expect. + * + * This is akin to a golden-file test, and suffers the same disadvantages and + * advantages: it reflects that the code as written has not been modified - and + * valid code modifications WILL break this test and it will need updating. + * + * The intent therefore is to allow code reviewers to more easily catch changes + * that perturb the generated list of channel filters in different + * configurations and assess whether such a change is correct and desirable. + */ + #include #include #include @@ -43,10 +56,18 @@ #include "src/core/lib/transport/transport_impl.h" #include "test/core/util/test_config.h" +// use CHECK_STACK instead static int check_stack(const char *file, int line, const char *transport_name, grpc_channel_args *init_args, grpc_channel_stack_type channel_stack_type, ...); +// arguments: const char *transport_name - the name of the transport type to +// simulate +// grpc_channel_args *init_args - channel args to pass down +// grpc_channel_stack_type channel_stack_type - the archetype of +// channel stack to create +// variadic arguments - the (in-order) expected list of channel +// filters to instantiate, terminated with NULL #define CHECK_STACK(...) check_stack(__FILE__, __LINE__, __VA_ARGS__) int main(int argc, char **argv) { @@ -99,6 +120,10 @@ int main(int argc, char **argv) { return 0; } +/******************************************************************************* + * End of tests definitions, start of test infrastructure + */ + static int check_stack(const char *file, int line, const char *transport_name, grpc_channel_args *init_args, grpc_channel_stack_type channel_stack_type, ...) { -- cgit v1.2.3 From e3593d912bc851e8ee7be89a7fb2c484dbc7e902 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 3 Apr 2017 14:51:02 -0700 Subject: Fix sanity --- src/core/ext/filters/deadline/deadline_filter.h | 6 +++--- src/core/ext/filters/http/client/http_client_filter.h | 6 +++--- src/core/ext/filters/http/compress/compress_filter.h | 6 +++--- src/core/ext/filters/http/server/http_server_filter.h | 6 +++--- src/core/ext/filters/message_size/message_size_filter.h | 6 +++--- src/core/ext/transport/chttp2/server/chttp2_server.c | 2 +- src/core/lib/security/credentials/credentials.c | 2 +- src/core/lib/security/credentials/ssl/ssl_credentials.c | 2 +- test/core/bad_client/bad_client.c | 2 +- test/core/end2end/fixtures/h2_census.c | 2 +- test/core/end2end/fixtures/h2_compress.c | 2 +- test/core/end2end/fixtures/h2_full+pipe.c | 2 +- test/core/end2end/fixtures/h2_full+trace.c | 2 +- test/core/end2end/fixtures/h2_full.c | 2 +- test/core/end2end/fixtures/h2_http_proxy.c | 2 +- test/core/end2end/fixtures/h2_load_reporting.c | 2 +- test/core/end2end/fixtures/h2_proxy.c | 2 +- test/core/end2end/fixtures/h2_sockpair+trace.c | 6 +++--- test/core/end2end/fixtures/h2_sockpair.c | 6 +++--- test/core/end2end/fixtures/h2_sockpair_1byte.c | 6 +++--- test/core/end2end/fixtures/h2_uds.c | 2 +- test/cpp/microbenchmarks/bm_call_create.cc | 8 ++++---- 22 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/core/ext/filters/deadline/deadline_filter.h b/src/core/ext/filters/deadline/deadline_filter.h index e1e3f5280b..060d2f12a8 100644 --- a/src/core/ext/filters/deadline/deadline_filter.h +++ b/src/core/ext/filters/deadline/deadline_filter.h @@ -29,8 +29,8 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // -#ifndef GRPC_CORE_LIB_CHANNEL_DEADLINE_FILTER_H -#define GRPC_CORE_LIB_CHANNEL_DEADLINE_FILTER_H +#ifndef GRPC_CORE_EXT_FILTERS_DEADLINE_DEADLINE_FILTER_H +#define GRPC_CORE_EXT_FILTERS_DEADLINE_DEADLINE_FILTER_H #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/iomgr/timer.h" @@ -102,4 +102,4 @@ bool grpc_deadline_checking_enabled(const grpc_channel_args* args); extern const grpc_channel_filter grpc_client_deadline_filter; extern const grpc_channel_filter grpc_server_deadline_filter; -#endif /* GRPC_CORE_LIB_CHANNEL_DEADLINE_FILTER_H */ +#endif /* GRPC_CORE_EXT_FILTERS_DEADLINE_DEADLINE_FILTER_H */ diff --git a/src/core/ext/filters/http/client/http_client_filter.h b/src/core/ext/filters/http/client/http_client_filter.h index 9e6e106e9c..109702f667 100644 --- a/src/core/ext/filters/http/client/http_client_filter.h +++ b/src/core/ext/filters/http/client/http_client_filter.h @@ -30,8 +30,8 @@ * */ -#ifndef GRPC_CORE_LIB_CHANNEL_HTTP_CLIENT_FILTER_H -#define GRPC_CORE_LIB_CHANNEL_HTTP_CLIENT_FILTER_H +#ifndef GRPC_CORE_EXT_FILTERS_HTTP_CLIENT_HTTP_CLIENT_FILTER_H +#define GRPC_CORE_EXT_FILTERS_HTTP_CLIENT_HTTP_CLIENT_FILTER_H #include "src/core/lib/channel/channel_stack.h" @@ -44,4 +44,4 @@ extern const grpc_channel_filter grpc_http_client_filter; /* Channel arg to determine maximum size of payload eligable for GET request */ #define GRPC_ARG_MAX_PAYLOAD_SIZE_FOR_GET "grpc.max_payload_size_for_get" -#endif /* GRPC_CORE_LIB_CHANNEL_HTTP_CLIENT_FILTER_H */ +#endif /* GRPC_CORE_EXT_FILTERS_HTTP_CLIENT_HTTP_CLIENT_FILTER_H */ diff --git a/src/core/ext/filters/http/compress/compress_filter.h b/src/core/ext/filters/http/compress/compress_filter.h index e4a2a829d5..68d2b8766a 100644 --- a/src/core/ext/filters/http/compress/compress_filter.h +++ b/src/core/ext/filters/http/compress/compress_filter.h @@ -31,8 +31,8 @@ * */ -#ifndef GRPC_CORE_LIB_CHANNEL_COMPRESS_FILTER_H -#define GRPC_CORE_LIB_CHANNEL_COMPRESS_FILTER_H +#ifndef GRPC_CORE_EXT_FILTERS_HTTP_COMPRESS_COMPRESS_FILTER_H +#define GRPC_CORE_EXT_FILTERS_HTTP_COMPRESS_COMPRESS_FILTER_H #include @@ -64,4 +64,4 @@ extern int grpc_compression_trace; extern const grpc_channel_filter grpc_compress_filter; -#endif /* GRPC_CORE_LIB_CHANNEL_COMPRESS_FILTER_H */ +#endif /* GRPC_CORE_EXT_FILTERS_HTTP_COMPRESS_COMPRESS_FILTER_H */ diff --git a/src/core/ext/filters/http/server/http_server_filter.h b/src/core/ext/filters/http/server/http_server_filter.h index 77ba2d263d..8a2b2196ae 100644 --- a/src/core/ext/filters/http/server/http_server_filter.h +++ b/src/core/ext/filters/http/server/http_server_filter.h @@ -31,12 +31,12 @@ * */ -#ifndef GRPC_CORE_LIB_CHANNEL_HTTP_SERVER_FILTER_H -#define GRPC_CORE_LIB_CHANNEL_HTTP_SERVER_FILTER_H +#ifndef GRPC_CORE_EXT_FILTERS_HTTP_SERVER_HTTP_SERVER_FILTER_H +#define GRPC_CORE_EXT_FILTERS_HTTP_SERVER_HTTP_SERVER_FILTER_H #include "src/core/lib/channel/channel_stack.h" /* Processes metadata on the client side for HTTP2 transports */ extern const grpc_channel_filter grpc_http_server_filter; -#endif /* GRPC_CORE_LIB_CHANNEL_HTTP_SERVER_FILTER_H */ +#endif /* GRPC_CORE_EXT_FILTERS_HTTP_SERVER_HTTP_SERVER_FILTER_H */ diff --git a/src/core/ext/filters/message_size/message_size_filter.h b/src/core/ext/filters/message_size/message_size_filter.h index a88ff7f81a..83980e738c 100644 --- a/src/core/ext/filters/message_size/message_size_filter.h +++ b/src/core/ext/filters/message_size/message_size_filter.h @@ -29,11 +29,11 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // -#ifndef GRPC_CORE_LIB_CHANNEL_MESSAGE_SIZE_FILTER_H -#define GRPC_CORE_LIB_CHANNEL_MESSAGE_SIZE_FILTER_H +#ifndef GRPC_CORE_EXT_FILTERS_MESSAGE_SIZE_MESSAGE_SIZE_FILTER_H +#define GRPC_CORE_EXT_FILTERS_MESSAGE_SIZE_MESSAGE_SIZE_FILTER_H #include "src/core/lib/channel/channel_stack.h" extern const grpc_channel_filter grpc_message_size_filter; -#endif /* GRPC_CORE_LIB_CHANNEL_MESSAGE_SIZE_FILTER_H */ +#endif /* GRPC_CORE_EXT_FILTERS_MESSAGE_SIZE_MESSAGE_SIZE_FILTER_H */ diff --git a/src/core/ext/transport/chttp2/server/chttp2_server.c b/src/core/ext/transport/chttp2/server/chttp2_server.c index ede8eed927..b463506a98 100644 --- a/src/core/ext/transport/chttp2/server/chttp2_server.c +++ b/src/core/ext/transport/chttp2/server/chttp2_server.c @@ -43,11 +43,11 @@ #include #include +#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/handshaker.h" #include "src/core/lib/channel/handshaker_registry.h" -#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/resolve_address.h" #include "src/core/lib/iomgr/tcp_server.h" diff --git a/src/core/lib/security/credentials/credentials.c b/src/core/lib/security/credentials/credentials.c index 18d4604c4a..700aae1bc5 100644 --- a/src/core/lib/security/credentials/credentials.c +++ b/src/core/lib/security/credentials/credentials.c @@ -36,8 +36,8 @@ #include #include -#include "src/core/lib/channel/channel_args.h" #include "src/core/ext/filters/http/client/http_client_filter.h" +#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/http/httpcli.h" #include "src/core/lib/http/parser.h" #include "src/core/lib/iomgr/executor.h" diff --git a/src/core/lib/security/credentials/ssl/ssl_credentials.c b/src/core/lib/security/credentials/ssl/ssl_credentials.c index 35dda88ec6..9dccbb1e5d 100644 --- a/src/core/lib/security/credentials/ssl/ssl_credentials.c +++ b/src/core/lib/security/credentials/ssl/ssl_credentials.c @@ -35,8 +35,8 @@ #include -#include "src/core/lib/channel/channel_args.h" #include "src/core/ext/filters/http/client/http_client_filter.h" +#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/surface/api_trace.h" #include diff --git a/test/core/bad_client/bad_client.c b/test/core/bad_client/bad_client.c index 3f22351e6d..c7e55a1357 100644 --- a/test/core/bad_client/bad_client.c +++ b/test/core/bad_client/bad_client.c @@ -40,9 +40,9 @@ #include #include +#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/channel_stack.h" -#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/lib/iomgr/endpoint_pair.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/support/murmur_hash.h" diff --git a/test/core/end2end/fixtures/h2_census.c b/test/core/end2end/fixtures/h2_census.c index 8db0acf47f..7f906fa72b 100644 --- a/test/core/end2end/fixtures/h2_census.c +++ b/test/core/end2end/fixtures/h2_census.c @@ -42,10 +42,10 @@ #include #include #include "src/core/ext/filters/client_channel/client_channel.h" +#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/fixtures/h2_compress.c b/test/core/end2end/fixtures/h2_compress.c index aa2b3bf069..ba8092e96e 100644 --- a/test/core/end2end/fixtures/h2_compress.c +++ b/test/core/end2end/fixtures/h2_compress.c @@ -42,10 +42,10 @@ #include #include #include "src/core/ext/filters/client_channel/client_channel.h" +#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/fixtures/h2_full+pipe.c b/test/core/end2end/fixtures/h2_full+pipe.c index 9280aa13d4..8d7a1f0cfe 100644 --- a/test/core/end2end/fixtures/h2_full+pipe.c +++ b/test/core/end2end/fixtures/h2_full+pipe.c @@ -47,9 +47,9 @@ #include #include #include "src/core/ext/filters/client_channel/client_channel.h" +#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/lib/iomgr/wakeup_fd_posix.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" diff --git a/test/core/end2end/fixtures/h2_full+trace.c b/test/core/end2end/fixtures/h2_full+trace.c index f32521cb58..477bfdd5bb 100644 --- a/test/core/end2end/fixtures/h2_full+trace.c +++ b/test/core/end2end/fixtures/h2_full+trace.c @@ -47,9 +47,9 @@ #include #include #include "src/core/ext/filters/client_channel/client_channel.h" +#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/lib/support/env.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" diff --git a/test/core/end2end/fixtures/h2_full.c b/test/core/end2end/fixtures/h2_full.c index 28474507b9..ccb1e2ac02 100644 --- a/test/core/end2end/fixtures/h2_full.c +++ b/test/core/end2end/fixtures/h2_full.c @@ -42,9 +42,9 @@ #include #include #include "src/core/ext/filters/client_channel/client_channel.h" +#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/fixtures/h2_http_proxy.c b/test/core/end2end/fixtures/h2_http_proxy.c index fb4f56e88d..850b3e720b 100644 --- a/test/core/end2end/fixtures/h2_http_proxy.c +++ b/test/core/end2end/fixtures/h2_http_proxy.c @@ -43,9 +43,9 @@ #include #include #include "src/core/ext/filters/client_channel/client_channel.h" +#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/lib/support/env.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" diff --git a/test/core/end2end/fixtures/h2_load_reporting.c b/test/core/end2end/fixtures/h2_load_reporting.c index 4cf3b445d5..70d6f9e605 100644 --- a/test/core/end2end/fixtures/h2_load_reporting.c +++ b/test/core/end2end/fixtures/h2_load_reporting.c @@ -42,11 +42,11 @@ #include #include #include "src/core/ext/filters/client_channel/client_channel.h" +#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/filters/load_reporting/load_reporting.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/fixtures/h2_proxy.c b/test/core/end2end/fixtures/h2_proxy.c index d8658eca64..f0b9f77653 100644 --- a/test/core/end2end/fixtures/h2_proxy.c +++ b/test/core/end2end/fixtures/h2_proxy.c @@ -42,9 +42,9 @@ #include #include #include "src/core/ext/filters/client_channel/client_channel.h" +#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" #include "test/core/end2end/fixtures/proxy.h" diff --git a/test/core/end2end/fixtures/h2_sockpair+trace.c b/test/core/end2end/fixtures/h2_sockpair+trace.c index b3a158650e..5fc0e4ea73 100644 --- a/test/core/end2end/fixtures/h2_sockpair+trace.c +++ b/test/core/end2end/fixtures/h2_sockpair+trace.c @@ -46,11 +46,11 @@ #include #include #include "src/core/ext/filters/client_channel/client_channel.h" -#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" -#include "src/core/ext/filters/http/compress/compress_filter.h" -#include "src/core/lib/channel/connected_channel.h" #include "src/core/ext/filters/http/client/http_client_filter.h" +#include "src/core/ext/filters/http/compress/compress_filter.h" #include "src/core/ext/filters/http/server/http_server_filter.h" +#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" +#include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/iomgr/endpoint_pair.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/support/env.h" diff --git a/test/core/end2end/fixtures/h2_sockpair.c b/test/core/end2end/fixtures/h2_sockpair.c index 3fe1b8fc36..24ed048e7d 100644 --- a/test/core/end2end/fixtures/h2_sockpair.c +++ b/test/core/end2end/fixtures/h2_sockpair.c @@ -41,11 +41,11 @@ #include #include #include "src/core/ext/filters/client_channel/client_channel.h" -#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" -#include "src/core/ext/filters/http/compress/compress_filter.h" -#include "src/core/lib/channel/connected_channel.h" #include "src/core/ext/filters/http/client/http_client_filter.h" +#include "src/core/ext/filters/http/compress/compress_filter.h" #include "src/core/ext/filters/http/server/http_server_filter.h" +#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" +#include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/iomgr/endpoint_pair.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/surface/channel.h" diff --git a/test/core/end2end/fixtures/h2_sockpair_1byte.c b/test/core/end2end/fixtures/h2_sockpair_1byte.c index 149902673d..fee30946c4 100644 --- a/test/core/end2end/fixtures/h2_sockpair_1byte.c +++ b/test/core/end2end/fixtures/h2_sockpair_1byte.c @@ -41,11 +41,11 @@ #include #include #include "src/core/ext/filters/client_channel/client_channel.h" -#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" -#include "src/core/ext/filters/http/compress/compress_filter.h" -#include "src/core/lib/channel/connected_channel.h" #include "src/core/ext/filters/http/client/http_client_filter.h" +#include "src/core/ext/filters/http/compress/compress_filter.h" #include "src/core/ext/filters/http/server/http_server_filter.h" +#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" +#include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/iomgr/endpoint_pair.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/surface/channel.h" diff --git a/test/core/end2end/fixtures/h2_uds.c b/test/core/end2end/fixtures/h2_uds.c index c0a4d69418..316bfb8541 100644 --- a/test/core/end2end/fixtures/h2_uds.c +++ b/test/core/end2end/fixtures/h2_uds.c @@ -45,9 +45,9 @@ #include #include #include "src/core/ext/filters/client_channel/client_channel.h" +#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/lib/support/string.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/server.h" diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc index 694765e013..4417e0e829 100644 --- a/test/cpp/microbenchmarks/bm_call_create.cc +++ b/test/cpp/microbenchmarks/bm_call_create.cc @@ -46,14 +46,14 @@ extern "C" { #include "src/core/ext/filters/client_channel/client_channel.h" -#include "src/core/ext/filters/load_reporting/load_reporting_filter.h" -#include "src/core/lib/channel/channel_stack.h" -#include "src/core/ext/filters/http/compress/compress_filter.h" -#include "src/core/lib/channel/connected_channel.h" #include "src/core/ext/filters/deadline/deadline_filter.h" #include "src/core/ext/filters/http/client/http_client_filter.h" +#include "src/core/ext/filters/http/compress/compress_filter.h" #include "src/core/ext/filters/http/server/http_server_filter.h" +#include "src/core/ext/filters/load_reporting/load_reporting_filter.h" #include "src/core/ext/filters/message_size/message_size_filter.h" +#include "src/core/lib/channel/channel_stack.h" +#include "src/core/lib/channel/connected_channel.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/transport/transport_impl.h" } -- cgit v1.2.3 From 97a598365077a217d6cb80e2f24bb6575a0e41b7 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 4 Apr 2017 13:00:13 -0700 Subject: Reprioritize to fix test --- src/core/ext/filters/client_channel/client_channel_plugin.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/ext/filters/client_channel/client_channel_plugin.c b/src/core/ext/filters/client_channel/client_channel_plugin.c index 944af01af4..113de6927b 100644 --- a/src/core/ext/filters/client_channel/client_channel_plugin.c +++ b/src/core/ext/filters/client_channel/client_channel_plugin.c @@ -89,8 +89,9 @@ void grpc_client_channel_init(void) { grpc_subchannel_index_init(); grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MIN, set_default_host_if_unset, NULL); - grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX, append_filter, - (void *)&grpc_client_channel_filter); + grpc_channel_init_register_stage( + GRPC_CLIENT_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, append_filter, + (void *)&grpc_client_channel_filter); grpc_http_connect_register_handshaker_factory(); } -- cgit v1.2.3 From 6f9bb71c2bb3aeeee5d6dc0fee7ff1d81d2b3b41 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 4 Apr 2017 13:03:27 -0700 Subject: Fix BUILD --- BUILD | 2 -- 1 file changed, 2 deletions(-) diff --git a/BUILD b/BUILD index 78f5b16f6f..bc4f4eb978 100644 --- a/BUILD +++ b/BUILD @@ -440,7 +440,6 @@ grpc_cc_library( "src/core/lib/channel/channel_stack.c", "src/core/lib/channel/channel_stack_builder.c", "src/core/lib/channel/connected_channel.c", - "src/core/ext/filters/deadline/deadline_filter.c", "src/core/lib/channel/handshaker.c", "src/core/lib/channel/handshaker_factory.c", "src/core/lib/channel/handshaker_registry.c", @@ -563,7 +562,6 @@ grpc_cc_library( "src/core/lib/channel/channel_stack_builder.h", "src/core/lib/channel/connected_channel.h", "src/core/lib/channel/context.h", - "src/core/ext/filters/deadline/deadline_filter.h", "src/core/lib/channel/handshaker.h", "src/core/lib/channel/handshaker_factory.h", "src/core/lib/channel/handshaker_registry.h", -- cgit v1.2.3 From 1d77b44c0031bb49205d2716013439a0f925aaa2 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 4 Apr 2017 13:23:09 -0700 Subject: Add representative benchmarks of minimal stacks on chttp2 --- .../bm_fullstack_streaming_ping_pong.cc | 15 ++++++++ .../microbenchmarks/bm_fullstack_streaming_pump.cc | 8 ++++ .../bm_fullstack_unary_ping_pong.cc | 9 +++++ test/cpp/microbenchmarks/fullstack_fixtures.h | 43 +++++++++++++++++----- 4 files changed, 65 insertions(+), 10 deletions(-) diff --git a/test/cpp/microbenchmarks/bm_fullstack_streaming_ping_pong.cc b/test/cpp/microbenchmarks/bm_fullstack_streaming_ping_pong.cc index c536e15a2c..fd2210c474 100644 --- a/test/cpp/microbenchmarks/bm_fullstack_streaming_ping_pong.cc +++ b/test/cpp/microbenchmarks/bm_fullstack_streaming_ping_pong.cc @@ -436,6 +436,18 @@ BENCHMARK_TEMPLATE(BM_StreamingPingPongMsgs, InProcessCHTTP2, NoOpMutator, BENCHMARK_TEMPLATE(BM_StreamingPingPongMsgs, TCP, NoOpMutator, NoOpMutator) ->Range(0, 128 * 1024 * 1024); +BENCHMARK_TEMPLATE(BM_StreamingPingPong, MinInProcessCHTTP2, NoOpMutator, + NoOpMutator) + ->Apply(StreamingPingPongArgs); +BENCHMARK_TEMPLATE(BM_StreamingPingPong, MinTCP, NoOpMutator, NoOpMutator) + ->Apply(StreamingPingPongArgs); + +BENCHMARK_TEMPLATE(BM_StreamingPingPongMsgs, MinInProcessCHTTP2, NoOpMutator, + NoOpMutator) + ->Range(0, 128 * 1024 * 1024); +BENCHMARK_TEMPLATE(BM_StreamingPingPongMsgs, MinTCP, NoOpMutator, NoOpMutator) + ->Range(0, 128 * 1024 * 1024); + // Generate Args for StreamingPingPongWithCoalescingApi benchmarks. Currently // generates args for only "small streams" (i.e streams with 0, 1 or 2 messages) static void StreamingPingPongWithCoalescingApiArgs( @@ -459,6 +471,9 @@ static void StreamingPingPongWithCoalescingApiArgs( BENCHMARK_TEMPLATE(BM_StreamingPingPongWithCoalescingApi, InProcessCHTTP2, NoOpMutator, NoOpMutator) ->Apply(StreamingPingPongWithCoalescingApiArgs); +BENCHMARK_TEMPLATE(BM_StreamingPingPongWithCoalescingApi, MinInProcessCHTTP2, + NoOpMutator, NoOpMutator) + ->Apply(StreamingPingPongWithCoalescingApiArgs); } // namespace testing } // namespace grpc diff --git a/test/cpp/microbenchmarks/bm_fullstack_streaming_pump.cc b/test/cpp/microbenchmarks/bm_fullstack_streaming_pump.cc index 5c1eb1165b..47705d3031 100644 --- a/test/cpp/microbenchmarks/bm_fullstack_streaming_pump.cc +++ b/test/cpp/microbenchmarks/bm_fullstack_streaming_pump.cc @@ -189,6 +189,14 @@ BENCHMARK_TEMPLATE(BM_PumpStreamServerToClient, SockPair) ->Range(0, 128 * 1024 * 1024); BENCHMARK_TEMPLATE(BM_PumpStreamServerToClient, InProcessCHTTP2) ->Range(0, 128 * 1024 * 1024); +BENCHMARK_TEMPLATE(BM_PumpStreamClientToServer, MinTCP)->Arg(0); +BENCHMARK_TEMPLATE(BM_PumpStreamClientToServer, MinUDS)->Arg(0); +BENCHMARK_TEMPLATE(BM_PumpStreamClientToServer, MinSockPair)->Arg(0); +BENCHMARK_TEMPLATE(BM_PumpStreamClientToServer, MinInProcessCHTTP2)->Arg(0); +BENCHMARK_TEMPLATE(BM_PumpStreamServerToClient, MinTCP)->Arg(0); +BENCHMARK_TEMPLATE(BM_PumpStreamServerToClient, MinUDS)->Arg(0); +BENCHMARK_TEMPLATE(BM_PumpStreamServerToClient, MinSockPair)->Arg(0); +BENCHMARK_TEMPLATE(BM_PumpStreamServerToClient, MinInProcessCHTTP2)->Arg(0); } // namespace testing } // namespace grpc diff --git a/test/cpp/microbenchmarks/bm_fullstack_unary_ping_pong.cc b/test/cpp/microbenchmarks/bm_fullstack_unary_ping_pong.cc index 615b05b7c7..7524751fbc 100644 --- a/test/cpp/microbenchmarks/bm_fullstack_unary_ping_pong.cc +++ b/test/cpp/microbenchmarks/bm_fullstack_unary_ping_pong.cc @@ -141,12 +141,21 @@ static void SweepSizesArgs(benchmark::internal::Benchmark* b) { BENCHMARK_TEMPLATE(BM_UnaryPingPong, TCP, NoOpMutator, NoOpMutator) ->Apply(SweepSizesArgs); +BENCHMARK_TEMPLATE(BM_UnaryPingPong, MinTCP, NoOpMutator, NoOpMutator) + ->Apply(SweepSizesArgs); BENCHMARK_TEMPLATE(BM_UnaryPingPong, UDS, NoOpMutator, NoOpMutator) ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_UnaryPingPong, MinUDS, NoOpMutator, NoOpMutator) + ->Args({0, 0}); BENCHMARK_TEMPLATE(BM_UnaryPingPong, SockPair, NoOpMutator, NoOpMutator) ->Args({0, 0}); +BENCHMARK_TEMPLATE(BM_UnaryPingPong, MinSockPair, NoOpMutator, NoOpMutator) + ->Args({0, 0}); BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator, NoOpMutator) ->Apply(SweepSizesArgs); +BENCHMARK_TEMPLATE(BM_UnaryPingPong, MinInProcessCHTTP2, NoOpMutator, + NoOpMutator) + ->Apply(SweepSizesArgs); BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, Client_AddMetadata, 1>, NoOpMutator) ->Args({0, 0}); diff --git a/test/cpp/microbenchmarks/fullstack_fixtures.h b/test/cpp/microbenchmarks/fullstack_fixtures.h index dc29701059..0aa3536120 100644 --- a/test/cpp/microbenchmarks/fullstack_fixtures.h +++ b/test/cpp/microbenchmarks/fullstack_fixtures.h @@ -61,17 +61,18 @@ extern "C" { namespace grpc { namespace testing { -static void ApplyCommonServerBuilderConfig(ServerBuilder* b) { - b->SetMaxReceiveMessageSize(INT_MAX); - b->SetMaxSendMessageSize(INT_MAX); -} - -static void ApplyCommonChannelArguments(ChannelArguments* c) { - c->SetInt(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH, INT_MAX); - c->SetInt(GRPC_ARG_MAX_SEND_MESSAGE_LENGTH, INT_MAX); -} +class BaseFixture : public TrackCounters { + public: + virtual void ApplyCommonChannelArguments(ChannelArguments* c) { + c->SetInt(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH, INT_MAX); + c->SetInt(GRPC_ARG_MAX_SEND_MESSAGE_LENGTH, INT_MAX); + } -class BaseFixture : public TrackCounters {}; + virtual void ApplyCommonServerBuilderConfig(ServerBuilder* b) { + b->SetMaxReceiveMessageSize(INT_MAX); + b->SetMaxSendMessageSize(INT_MAX); + } +}; class FullstackFixture : public BaseFixture { public: @@ -238,6 +239,28 @@ class InProcessCHTTP2 : public EndpointPairFixture { } }; +//////////////////////////////////////////////////////////////////////////////// +// Minimal stack fixtures + +template +class MinStackize : public Base { + public: + MinStackize(Service* service) : Base(service) {} + + void ApplyCommonChannelArguments(ChannelArguments* a) { + a->SetInt(GRPC_ARG_MINIMAL_STACK, 1); + } + + void ApplyCommonServerBuilderConfig(ServerBuilder* b) { + b->AddChannelArgument(GRPC_ARG_MINIMAL_STACK, 1); + } +}; + +typedef MinStackize MinTCP; +typedef MinStackize MinUDS; +typedef MinStackize MinSockPair; +typedef MinStackize MinInProcessCHTTP2; + } // namespace testing } // namespace grpc -- cgit v1.2.3 From 794952733368b1f56ce13d1736479ef3769fc537 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 4 Apr 2017 13:36:47 -0700 Subject: Actually instantiate minstack --- test/cpp/microbenchmarks/fullstack_fixtures.h | 60 +++++++++++++++++---------- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/test/cpp/microbenchmarks/fullstack_fixtures.h b/test/cpp/microbenchmarks/fullstack_fixtures.h index 0aa3536120..ada1b5747f 100644 --- a/test/cpp/microbenchmarks/fullstack_fixtures.h +++ b/test/cpp/microbenchmarks/fullstack_fixtures.h @@ -61,30 +61,33 @@ extern "C" { namespace grpc { namespace testing { -class BaseFixture : public TrackCounters { +class FixtureConfiguration { public: - virtual void ApplyCommonChannelArguments(ChannelArguments* c) { + virtual void ApplyCommonChannelArguments(ChannelArguments* c) const { c->SetInt(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH, INT_MAX); c->SetInt(GRPC_ARG_MAX_SEND_MESSAGE_LENGTH, INT_MAX); } - virtual void ApplyCommonServerBuilderConfig(ServerBuilder* b) { + virtual void ApplyCommonServerBuilderConfig(ServerBuilder* b) const { b->SetMaxReceiveMessageSize(INT_MAX); b->SetMaxSendMessageSize(INT_MAX); } }; +class BaseFixture : public TrackCounters {}; + class FullstackFixture : public BaseFixture { public: - FullstackFixture(Service* service, const grpc::string& address) { + FullstackFixture(Service* service, const FixtureConfiguration& config, + const grpc::string& address) { ServerBuilder b; b.AddListeningPort(address, InsecureServerCredentials()); cq_ = b.AddCompletionQueue(true); b.RegisterService(service); - ApplyCommonServerBuilderConfig(&b); + config.ApplyCommonServerBuilderConfig(&b); server_ = b.BuildAndStart(); ChannelArguments args; - ApplyCommonChannelArguments(&args); + config.ApplyCommonChannelArguments(&args); channel_ = CreateCustomChannel(address, InsecureChannelCredentials(), args); } @@ -108,7 +111,9 @@ class FullstackFixture : public BaseFixture { class TCP : public FullstackFixture { public: - TCP(Service* service) : FullstackFixture(service, MakeAddress()) {} + TCP(Service* service, const FixtureConfiguration& fixture_configuration = + FixtureConfiguration()) + : FullstackFixture(service, fixture_configuration, MakeAddress()) {} private: static grpc::string MakeAddress() { @@ -121,7 +126,9 @@ class TCP : public FullstackFixture { class UDS : public FullstackFixture { public: - UDS(Service* service) : FullstackFixture(service, MakeAddress()) {} + UDS(Service* service, const FixtureConfiguration& fixture_configuration = + FixtureConfiguration()) + : FullstackFixture(service, fixture_configuration, MakeAddress()) {} private: static grpc::string MakeAddress() { @@ -135,12 +142,13 @@ class UDS : public FullstackFixture { class EndpointPairFixture : public BaseFixture { public: - EndpointPairFixture(Service* service, grpc_endpoint_pair endpoints) + EndpointPairFixture(Service* service, grpc_endpoint_pair endpoints, + const FixtureConfiguration& fixture_configuration) : endpoint_pair_(endpoints) { ServerBuilder b; cq_ = b.AddCompletionQueue(true); b.RegisterService(service); - ApplyCommonServerBuilderConfig(&b); + fixture_configuration.ApplyCommonServerBuilderConfig(&b); server_ = b.BuildAndStart(); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -170,7 +178,7 @@ class EndpointPairFixture : public BaseFixture { { ChannelArguments args; args.SetString(GRPC_ARG_DEFAULT_AUTHORITY, "test.authority"); - ApplyCommonChannelArguments(&args); + fixture_configuration.ApplyCommonChannelArguments(&args); grpc_channel_args c_args = args.c_channel_args(); client_transport_ = @@ -212,15 +220,19 @@ class EndpointPairFixture : public BaseFixture { class SockPair : public EndpointPairFixture { public: - SockPair(Service* service) + SockPair(Service* service, const FixtureConfiguration& fixture_configuration = + FixtureConfiguration()) : EndpointPairFixture(service, grpc_iomgr_create_endpoint_pair( - "test", Library::get().rq(), 8192)) {} + "test", Library::get().rq(), 8192), + fixture_configuration) {} }; class InProcessCHTTP2 : public EndpointPairFixture { public: - InProcessCHTTP2(Service* service) - : EndpointPairFixture(service, MakeEndpoints()) {} + InProcessCHTTP2(Service* service, + const FixtureConfiguration& fixture_configuration = + FixtureConfiguration()) + : EndpointPairFixture(service, MakeEndpoints(), fixture_configuration) {} void AddToLabel(std::ostream& out, benchmark::State& state) { EndpointPairFixture::AddToLabel(out, state); @@ -242,20 +254,24 @@ class InProcessCHTTP2 : public EndpointPairFixture { //////////////////////////////////////////////////////////////////////////////// // Minimal stack fixtures -template -class MinStackize : public Base { - public: - MinStackize(Service* service) : Base(service) {} - - void ApplyCommonChannelArguments(ChannelArguments* a) { +class MinStackConfiguration : public FixtureConfiguration { + void ApplyCommonChannelArguments(ChannelArguments* a) const override { a->SetInt(GRPC_ARG_MINIMAL_STACK, 1); + FixtureConfiguration::ApplyCommonChannelArguments(a); } - void ApplyCommonServerBuilderConfig(ServerBuilder* b) { + void ApplyCommonServerBuilderConfig(ServerBuilder* b) const override { b->AddChannelArgument(GRPC_ARG_MINIMAL_STACK, 1); + FixtureConfiguration::ApplyCommonServerBuilderConfig(b); } }; +template +class MinStackize : public Base { + public: + MinStackize(Service* service) : Base(service, MinStackConfiguration()) {} +}; + typedef MinStackize MinTCP; typedef MinStackize MinUDS; typedef MinStackize MinSockPair; -- cgit v1.2.3 From 43f774e4d4077e60abe0be6211f3d9b67559b1ff Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Tue, 4 Apr 2017 16:35:37 -0700 Subject: Add check that we don't schedule the same closure twice at once. --- src/core/lib/iomgr/closure.c | 11 +++++++++++ src/core/lib/iomgr/closure.h | 4 ++++ src/core/lib/iomgr/combiner.c | 6 ++++++ src/core/lib/iomgr/ev_epoll_linux.c | 3 +++ src/core/lib/iomgr/exec_ctx.c | 6 ++++++ src/core/lib/iomgr/executor.c | 6 ++++++ 6 files changed, 36 insertions(+) diff --git a/src/core/lib/iomgr/closure.c b/src/core/lib/iomgr/closure.c index 6633fb68ec..8ef0b210ad 100644 --- a/src/core/lib/iomgr/closure.c +++ b/src/core/lib/iomgr/closure.c @@ -45,6 +45,9 @@ grpc_closure *grpc_closure_init(grpc_closure *closure, grpc_iomgr_cb_func cb, closure->cb = cb; closure->cb_arg = cb_arg; closure->scheduler = scheduler; +#ifndef NDEBUG + closure->scheduled = false; +#endif return closure; } @@ -137,6 +140,10 @@ void grpc_closure_sched(grpc_exec_ctx *exec_ctx, grpc_closure *c, grpc_error *error) { GPR_TIMER_BEGIN("grpc_closure_sched", 0); if (c != NULL) { +#ifndef NDEBUG + GPR_ASSERT(!c->scheduled); + c->scheduled = true; +#endif assert(c->cb); c->scheduler->vtable->sched(exec_ctx, c, error); } else { @@ -149,6 +156,10 @@ void grpc_closure_list_sched(grpc_exec_ctx *exec_ctx, grpc_closure_list *list) { grpc_closure *c = list->head; while (c != NULL) { grpc_closure *next = c->next_data.next; +#ifndef NDEBUG + GPR_ASSERT(!c->scheduled); + c->scheduled = true; +#endif assert(c->cb); c->scheduler->vtable->sched(exec_ctx, c, c->error_data.error); c = next; diff --git a/src/core/lib/iomgr/closure.h b/src/core/lib/iomgr/closure.h index 2510d50b42..2bedbf00d6 100644 --- a/src/core/lib/iomgr/closure.h +++ b/src/core/lib/iomgr/closure.h @@ -99,6 +99,10 @@ struct grpc_closure { grpc_error *error; uintptr_t scratch; } error_data; + +#ifndef NDEBUG + bool scheduled; +#endif }; /** Initializes \a closure with \a cb and \a cb_arg. Returns \a closure. */ diff --git a/src/core/lib/iomgr/combiner.c b/src/core/lib/iomgr/combiner.c index 2bc476bbef..05cdbdad2b 100644 --- a/src/core/lib/iomgr/combiner.c +++ b/src/core/lib/iomgr/combiner.c @@ -319,6 +319,9 @@ bool grpc_combiner_continue_exec_ctx(grpc_exec_ctx *exec_ctx) { GPR_TIMER_BEGIN("combiner.exec1", 0); grpc_closure *cl = (grpc_closure *)n; error_data err = unpack_error_data(cl->error_data.scratch); +#ifndef NDEBUG + cl->scheduled = false; +#endif cl->cb(exec_ctx, cl->cb_arg, err.error); if (err.covered_by_poller) { gpr_atm_no_barrier_fetch_add(&lock->elements_covered_by_poller, -1); @@ -337,6 +340,9 @@ bool grpc_combiner_continue_exec_ctx(grpc_exec_ctx *exec_ctx) { gpr_log(GPR_DEBUG, "C:%p execute_final[%d] c=%p", lock, loops, c)); grpc_closure *next = c->next_data.next; grpc_error *error = c->error_data.error; +#ifndef NDEBUG + c->scheduled = false; +#endif c->cb(exec_ctx, c->cb_arg, error); GRPC_ERROR_UNREF(error); c = next; diff --git a/src/core/lib/iomgr/ev_epoll_linux.c b/src/core/lib/iomgr/ev_epoll_linux.c index 7014b98349..748b4c4f98 100644 --- a/src/core/lib/iomgr/ev_epoll_linux.c +++ b/src/core/lib/iomgr/ev_epoll_linux.c @@ -1549,6 +1549,9 @@ static bool maybe_do_workqueue_work(grpc_exec_ctx *exec_ctx, } grpc_closure *c = (grpc_closure *)n; grpc_error *error = c->error_data.error; +#ifndef NDEBUG + c->scheduled = false; +#endif c->cb(exec_ctx, c->cb_arg, error); GRPC_ERROR_UNREF(error); return true; diff --git a/src/core/lib/iomgr/exec_ctx.c b/src/core/lib/iomgr/exec_ctx.c index 83bb436bd0..2532a708e7 100644 --- a/src/core/lib/iomgr/exec_ctx.c +++ b/src/core/lib/iomgr/exec_ctx.c @@ -73,6 +73,9 @@ bool grpc_exec_ctx_flush(grpc_exec_ctx *exec_ctx) { grpc_closure *next = c->next_data.next; grpc_error *error = c->error_data.error; did_something = true; +#ifndef NDEBUG + c->scheduled = false; +#endif c->cb(exec_ctx, c->cb_arg, error); GRPC_ERROR_UNREF(error); c = next; @@ -93,6 +96,9 @@ void grpc_exec_ctx_finish(grpc_exec_ctx *exec_ctx) { static void exec_ctx_run(grpc_exec_ctx *exec_ctx, grpc_closure *closure, grpc_error *error) { +#ifndef NDEBUG + closure->scheduled = false; +#endif closure->cb(exec_ctx, closure->cb_arg, error); GRPC_ERROR_UNREF(error); } diff --git a/src/core/lib/iomgr/executor.c b/src/core/lib/iomgr/executor.c index ae3e2eabc3..75fd5b1c50 100644 --- a/src/core/lib/iomgr/executor.c +++ b/src/core/lib/iomgr/executor.c @@ -83,6 +83,9 @@ static void closure_exec_thread_func(void *ignored) { while (c != NULL) { grpc_closure *next = c->next_data.next; grpc_error *error = c->error_data.error; +#ifndef NDEBUG + c->scheduled = false; +#endif c->cb(&exec_ctx, c->cb_arg, error); GRPC_ERROR_UNREF(error); c = next; @@ -146,6 +149,9 @@ void grpc_executor_shutdown(grpc_exec_ctx *exec_ctx) { while (c != NULL) { grpc_closure *next = c->next_data.next; grpc_error *error = c->error_data.error; +#ifndef NDEBUG + c->scheduled = false; +#endif c->cb(exec_ctx, c->cb_arg, error); GRPC_ERROR_UNREF(error); c = next; -- cgit v1.2.3 From f3ba6a0133f654109f2484a081f5e8a97f16e3a4 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 5 Apr 2017 12:29:06 -0700 Subject: Fix sanity --- build.yaml | 2 ++ include/grpc/impl/codegen/grpc_types.h | 2 ++ src/core/ext/filters/http/client/http_client_filter.h | 3 --- src/core/lib/security/credentials/credentials.c | 1 - src/core/lib/security/credentials/ssl/ssl_credentials.c | 1 - tools/run_tests/generated/sources_and_headers.json | 5 ++++- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/build.yaml b/build.yaml index 383090fa6f..1df62654a4 100644 --- a/build.yaml +++ b/build.yaml @@ -480,6 +480,8 @@ filegroups: - src/core/ext/filters/http/http_filters_plugin.c - src/core/ext/filters/http/server/http_server_filter.c plugin: grpc_http_filters + uses: + - grpc_base - name: grpc_lb_policy_grpclb headers: - src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index 37f5a49ece..e0276f6e43 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -205,6 +205,8 @@ typedef struct { /** Minimum time (in milliseconds) between successive ping frames being sent */ #define GRPC_ARG_HTTP2_MIN_TIME_BETWEEN_PINGS_MS \ "grpc.http2.min_time_between_pings_ms" +/* Channel arg to override the http2 :scheme header */ +#define GRPC_ARG_HTTP2_SCHEME "grpc.http2_scheme" /** How many pings can we send before needing to send a data frame or header frame? (0 indicates that an infinite number of pings can be sent without sending diff --git a/src/core/ext/filters/http/client/http_client_filter.h b/src/core/ext/filters/http/client/http_client_filter.h index 109702f667..6e1eb3937b 100644 --- a/src/core/ext/filters/http/client/http_client_filter.h +++ b/src/core/ext/filters/http/client/http_client_filter.h @@ -38,9 +38,6 @@ /* Processes metadata on the client side for HTTP2 transports */ extern const grpc_channel_filter grpc_http_client_filter; -/* Channel arg to override the http2 :scheme header */ -#define GRPC_ARG_HTTP2_SCHEME "grpc.http2_scheme" - /* Channel arg to determine maximum size of payload eligable for GET request */ #define GRPC_ARG_MAX_PAYLOAD_SIZE_FOR_GET "grpc.max_payload_size_for_get" diff --git a/src/core/lib/security/credentials/credentials.c b/src/core/lib/security/credentials/credentials.c index 700aae1bc5..d89da47fc1 100644 --- a/src/core/lib/security/credentials/credentials.c +++ b/src/core/lib/security/credentials/credentials.c @@ -36,7 +36,6 @@ #include #include -#include "src/core/ext/filters/http/client/http_client_filter.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/http/httpcli.h" #include "src/core/lib/http/parser.h" diff --git a/src/core/lib/security/credentials/ssl/ssl_credentials.c b/src/core/lib/security/credentials/ssl/ssl_credentials.c index 9dccbb1e5d..b63bb6b6e9 100644 --- a/src/core/lib/security/credentials/ssl/ssl_credentials.c +++ b/src/core/lib/security/credentials/ssl/ssl_credentials.c @@ -35,7 +35,6 @@ #include -#include "src/core/ext/filters/http/client/http_client_filter.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/surface/api_trace.h" diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index afa52f391f..6cf4494b12 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -8007,7 +8007,10 @@ "type": "filegroup" }, { - "deps": [], + "deps": [ + "gpr", + "grpc_base" + ], "headers": [ "src/core/ext/filters/http/client/http_client_filter.h", "src/core/ext/filters/http/compress/compress_filter.h", -- cgit v1.2.3 From ff558bac5c7be1571db720f23974d70b75385415 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 5 Apr 2017 14:44:42 -0700 Subject: Fix trickle --- test/cpp/microbenchmarks/bm_fullstack_trickle.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc index c563f28b55..a5cfeb4f95 100644 --- a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc +++ b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc @@ -53,7 +53,8 @@ static void* tag(intptr_t x) { return reinterpret_cast(x); } class TrickledCHTTP2 : public EndpointPairFixture { public: TrickledCHTTP2(Service* service, size_t megabits_per_second) - : EndpointPairFixture(service, MakeEndpoints(megabits_per_second)) {} + : EndpointPairFixture(service, MakeEndpoints(megabits_per_second), + FixtureConfiguration()) {} void AddToLabel(std::ostream& out, benchmark::State& state) { out << " writes/iter:" -- cgit v1.2.3 From 6cb260af72cbadead2aa28e662581e94f2e901b3 Mon Sep 17 00:00:00 2001 From: Yuchen Zeng Date: Wed, 5 Apr 2017 18:44:36 -0700 Subject: Fix the server-side keepalive shutdown process --- .../transport/chttp2/transport/chttp2_transport.c | 30 ++++++++++++---------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index e2816b0e04..5ad31c7d2c 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -543,6 +543,10 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, exec_ctx, &t->keepalive_ping_timer, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), t->keepalive_time), &t->init_keepalive_ping_locked, gpr_now(GPR_CLOCK_MONOTONIC)); + } else { + /* Use GRPC_CHTTP2_KEEPALIVE_STATE_DYING to indicate there are no inflight + keeaplive timers */ + t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_DYING; } grpc_chttp2_initiate_write(exec_ctx, t, false, "init"); @@ -591,20 +595,18 @@ static void close_transport_locked(grpc_exec_ctx *exec_ctx, connectivity_state_set(exec_ctx, t, GRPC_CHANNEL_SHUTDOWN, GRPC_ERROR_REF(error), "close_transport"); grpc_endpoint_shutdown(exec_ctx, t->ep, GRPC_ERROR_REF(error)); - if (t->is_client) { - switch (t->keepalive_state) { - case GRPC_CHTTP2_KEEPALIVE_STATE_WAITING: { - grpc_timer_cancel(exec_ctx, &t->keepalive_ping_timer); - break; - } - case GRPC_CHTTP2_KEEPALIVE_STATE_PINGING: { - grpc_timer_cancel(exec_ctx, &t->keepalive_ping_timer); - grpc_timer_cancel(exec_ctx, &t->keepalive_watchdog_timer); - break; - } - case GRPC_CHTTP2_KEEPALIVE_STATE_DYING: { - break; - } + switch (t->keepalive_state) { + case GRPC_CHTTP2_KEEPALIVE_STATE_WAITING: { + grpc_timer_cancel(exec_ctx, &t->keepalive_ping_timer); + break; + } + case GRPC_CHTTP2_KEEPALIVE_STATE_PINGING: { + grpc_timer_cancel(exec_ctx, &t->keepalive_ping_timer); + grpc_timer_cancel(exec_ctx, &t->keepalive_watchdog_timer); + break; + } + case GRPC_CHTTP2_KEEPALIVE_STATE_DYING: { + break; } } -- cgit v1.2.3 From a24b971214a3d95ddb86f6c04171b84c26da2a61 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 6 Apr 2017 09:03:21 -0700 Subject: Rename compress_filter --> message_compress_filter --- BUILD | 4 +- CMakeLists.txt | 8 +- Makefile | 8 +- binding.gyp | 2 +- build.yaml | 4 +- config.m4 | 2 +- gRPC-Core.podspec | 6 +- grpc.gemspec | 4 +- package.xml | 4 +- .../ext/filters/http/compress/compress_filter.c | 353 --------------------- .../ext/filters/http/compress/compress_filter.h | 67 ---- src/core/ext/filters/http/http_filters_plugin.c | 2 +- .../message_compress/message_compress_filter.c | 353 +++++++++++++++++++++ .../message_compress/message_compress_filter.h | 67 ++++ src/python/grpcio/grpc_core_dependencies.py | 2 +- test/core/end2end/fixtures/h2_sockpair+trace.c | 2 +- test/core/end2end/fixtures/h2_sockpair.c | 2 +- test/core/end2end/fixtures/h2_sockpair_1byte.c | 2 +- test/cpp/microbenchmarks/bm_call_create.cc | 2 +- tools/doxygen/Doxyfile.core.internal | 4 +- tools/run_tests/generated/sources_and_headers.json | 6 +- 21 files changed, 452 insertions(+), 452 deletions(-) delete mode 100644 src/core/ext/filters/http/compress/compress_filter.c delete mode 100644 src/core/ext/filters/http/compress/compress_filter.h create mode 100644 src/core/ext/filters/http/message_compress/message_compress_filter.c create mode 100644 src/core/ext/filters/http/message_compress/message_compress_filter.h diff --git a/BUILD b/BUILD index bc4f4eb978..83cf3e651a 100644 --- a/BUILD +++ b/BUILD @@ -780,12 +780,12 @@ grpc_cc_library( grpc_cc_library( name = "grpc_http_filters", hdrs = [ - "src/core/ext/filters/http/compress/compress_filter.h", + "src/core/ext/filters/http/message_compress/message_compress_filter.h", "src/core/ext/filters/http/client/http_client_filter.h", "src/core/ext/filters/http/server/http_server_filter.h", ], srcs = [ - "src/core/ext/filters/http/compress/compress_filter.c", + "src/core/ext/filters/http/message_compress/message_compress_filter.c", "src/core/ext/filters/http/client/http_client_filter.c", "src/core/ext/filters/http/server/http_server_filter.c", "src/core/ext/filters/http/http_filters_plugin.c" diff --git a/CMakeLists.txt b/CMakeLists.txt index 089e028bff..f79d7154a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1051,7 +1051,7 @@ add_library(grpc src/core/ext/transport/chttp2/transport/writing.c src/core/ext/transport/chttp2/alpn/alpn.c src/core/ext/filters/http/client/http_client_filter.c - src/core/ext/filters/http/compress/compress_filter.c + src/core/ext/filters/http/message_compress/message_compress_filter.c src/core/ext/filters/http/http_filters_plugin.c src/core/ext/filters/http/server/http_server_filter.c src/core/lib/http/httpcli_security_connector.c @@ -1377,7 +1377,7 @@ add_library(grpc_cronet src/core/ext/transport/chttp2/transport/writing.c src/core/ext/transport/chttp2/alpn/alpn.c src/core/ext/filters/http/client/http_client_filter.c - src/core/ext/filters/http/compress/compress_filter.c + src/core/ext/filters/http/message_compress/message_compress_filter.c src/core/ext/filters/http/http_filters_plugin.c src/core/ext/filters/http/server/http_server_filter.c src/core/ext/filters/client_channel/channel_connectivity.c @@ -1939,7 +1939,7 @@ add_library(grpc_unsecure src/core/ext/transport/chttp2/transport/writing.c src/core/ext/transport/chttp2/alpn/alpn.c src/core/ext/filters/http/client/http_client_filter.c - src/core/ext/filters/http/compress/compress_filter.c + src/core/ext/filters/http/message_compress/message_compress_filter.c src/core/ext/filters/http/http_filters_plugin.c src/core/ext/filters/http/server/http_server_filter.c src/core/ext/transport/chttp2/server/chttp2_server.c @@ -2687,7 +2687,7 @@ add_library(grpc++_cronet src/core/ext/transport/chttp2/transport/writing.c src/core/ext/transport/chttp2/alpn/alpn.c src/core/ext/filters/http/client/http_client_filter.c - src/core/ext/filters/http/compress/compress_filter.c + src/core/ext/filters/http/message_compress/message_compress_filter.c src/core/ext/filters/http/http_filters_plugin.c src/core/ext/filters/http/server/http_server_filter.c src/core/ext/filters/client_channel/channel_connectivity.c diff --git a/Makefile b/Makefile index 035e92f8e4..f2ee6901cf 100644 --- a/Makefile +++ b/Makefile @@ -2956,7 +2956,7 @@ LIBGRPC_SRC = \ src/core/ext/transport/chttp2/transport/writing.c \ src/core/ext/transport/chttp2/alpn/alpn.c \ src/core/ext/filters/http/client/http_client_filter.c \ - src/core/ext/filters/http/compress/compress_filter.c \ + src/core/ext/filters/http/message_compress/message_compress_filter.c \ src/core/ext/filters/http/http_filters_plugin.c \ src/core/ext/filters/http/server/http_server_filter.c \ src/core/lib/http/httpcli_security_connector.c \ @@ -3280,7 +3280,7 @@ LIBGRPC_CRONET_SRC = \ src/core/ext/transport/chttp2/transport/writing.c \ src/core/ext/transport/chttp2/alpn/alpn.c \ src/core/ext/filters/http/client/http_client_filter.c \ - src/core/ext/filters/http/compress/compress_filter.c \ + src/core/ext/filters/http/message_compress/message_compress_filter.c \ src/core/ext/filters/http/http_filters_plugin.c \ src/core/ext/filters/http/server/http_server_filter.c \ src/core/ext/filters/client_channel/channel_connectivity.c \ @@ -3813,7 +3813,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/transport/chttp2/transport/writing.c \ src/core/ext/transport/chttp2/alpn/alpn.c \ src/core/ext/filters/http/client/http_client_filter.c \ - src/core/ext/filters/http/compress/compress_filter.c \ + src/core/ext/filters/http/message_compress/message_compress_filter.c \ src/core/ext/filters/http/http_filters_plugin.c \ src/core/ext/filters/http/server/http_server_filter.c \ src/core/ext/transport/chttp2/server/chttp2_server.c \ @@ -4546,7 +4546,7 @@ LIBGRPC++_CRONET_SRC = \ src/core/ext/transport/chttp2/transport/writing.c \ src/core/ext/transport/chttp2/alpn/alpn.c \ src/core/ext/filters/http/client/http_client_filter.c \ - src/core/ext/filters/http/compress/compress_filter.c \ + src/core/ext/filters/http/message_compress/message_compress_filter.c \ src/core/ext/filters/http/http_filters_plugin.c \ src/core/ext/filters/http/server/http_server_filter.c \ src/core/ext/filters/client_channel/channel_connectivity.c \ diff --git a/binding.gyp b/binding.gyp index ad9d7c8f28..21cd56e684 100644 --- a/binding.gyp +++ b/binding.gyp @@ -792,7 +792,7 @@ 'src/core/ext/transport/chttp2/transport/writing.c', 'src/core/ext/transport/chttp2/alpn/alpn.c', 'src/core/ext/filters/http/client/http_client_filter.c', - 'src/core/ext/filters/http/compress/compress_filter.c', + 'src/core/ext/filters/http/message_compress/message_compress_filter.c', 'src/core/ext/filters/http/http_filters_plugin.c', 'src/core/ext/filters/http/server/http_server_filter.c', 'src/core/lib/http/httpcli_security_connector.c', diff --git a/build.yaml b/build.yaml index 1df62654a4..2d52b38fbf 100644 --- a/build.yaml +++ b/build.yaml @@ -472,11 +472,11 @@ filegroups: - name: grpc_http_filters headers: - src/core/ext/filters/http/client/http_client_filter.h - - src/core/ext/filters/http/compress/compress_filter.h + - src/core/ext/filters/http/message_compress/message_compress_filter.h - src/core/ext/filters/http/server/http_server_filter.h src: - src/core/ext/filters/http/client/http_client_filter.c - - src/core/ext/filters/http/compress/compress_filter.c + - src/core/ext/filters/http/message_compress/message_compress_filter.c - src/core/ext/filters/http/http_filters_plugin.c - src/core/ext/filters/http/server/http_server_filter.c plugin: grpc_http_filters diff --git a/config.m4 b/config.m4 index 85593afd3c..985de08562 100644 --- a/config.m4 +++ b/config.m4 @@ -226,7 +226,7 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/transport/chttp2/transport/writing.c \ src/core/ext/transport/chttp2/alpn/alpn.c \ src/core/ext/filters/http/client/http_client_filter.c \ - src/core/ext/filters/http/compress/compress_filter.c \ + src/core/ext/filters/http/message_compress/message_compress_filter.c \ src/core/ext/filters/http/http_filters_plugin.c \ src/core/ext/filters/http/server/http_server_filter.c \ src/core/lib/http/httpcli_security_connector.c \ diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 9cd92835ac..b79a759438 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -381,7 +381,7 @@ Pod::Spec.new do |s| 'src/core/ext/transport/chttp2/transport/varint.h', 'src/core/ext/transport/chttp2/alpn/alpn.h', 'src/core/ext/filters/http/client/http_client_filter.h', - 'src/core/ext/filters/http/compress/compress_filter.h', + 'src/core/ext/filters/http/message_compress/message_compress_filter.h', 'src/core/ext/filters/http/server/http_server_filter.h', 'src/core/lib/security/context/security_context.h', 'src/core/lib/security/credentials/composite/composite_credentials.h', @@ -601,7 +601,7 @@ Pod::Spec.new do |s| 'src/core/ext/transport/chttp2/transport/writing.c', 'src/core/ext/transport/chttp2/alpn/alpn.c', 'src/core/ext/filters/http/client/http_client_filter.c', - 'src/core/ext/filters/http/compress/compress_filter.c', + 'src/core/ext/filters/http/message_compress/message_compress_filter.c', 'src/core/ext/filters/http/http_filters_plugin.c', 'src/core/ext/filters/http/server/http_server_filter.c', 'src/core/lib/http/httpcli_security_connector.c', @@ -832,7 +832,7 @@ Pod::Spec.new do |s| 'src/core/ext/transport/chttp2/transport/varint.h', 'src/core/ext/transport/chttp2/alpn/alpn.h', 'src/core/ext/filters/http/client/http_client_filter.h', - 'src/core/ext/filters/http/compress/compress_filter.h', + 'src/core/ext/filters/http/message_compress/message_compress_filter.h', 'src/core/ext/filters/http/server/http_server_filter.h', 'src/core/lib/security/context/security_context.h', 'src/core/lib/security/credentials/composite/composite_credentials.h', diff --git a/grpc.gemspec b/grpc.gemspec index 0e4a3d6fec..2a6563f879 100755 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -297,7 +297,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/transport/chttp2/transport/varint.h ) s.files += %w( src/core/ext/transport/chttp2/alpn/alpn.h ) s.files += %w( src/core/ext/filters/http/client/http_client_filter.h ) - s.files += %w( src/core/ext/filters/http/compress/compress_filter.h ) + s.files += %w( src/core/ext/filters/http/message_compress/message_compress_filter.h ) s.files += %w( src/core/ext/filters/http/server/http_server_filter.h ) s.files += %w( src/core/lib/security/context/security_context.h ) s.files += %w( src/core/lib/security/credentials/composite/composite_credentials.h ) @@ -517,7 +517,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/transport/chttp2/transport/writing.c ) s.files += %w( src/core/ext/transport/chttp2/alpn/alpn.c ) s.files += %w( src/core/ext/filters/http/client/http_client_filter.c ) - s.files += %w( src/core/ext/filters/http/compress/compress_filter.c ) + s.files += %w( src/core/ext/filters/http/message_compress/message_compress_filter.c ) s.files += %w( src/core/ext/filters/http/http_filters_plugin.c ) s.files += %w( src/core/ext/filters/http/server/http_server_filter.c ) s.files += %w( src/core/lib/http/httpcli_security_connector.c ) diff --git a/package.xml b/package.xml index 8cda68a266..0771774b4c 100644 --- a/package.xml +++ b/package.xml @@ -306,7 +306,7 @@ - + @@ -526,7 +526,7 @@ - + diff --git a/src/core/ext/filters/http/compress/compress_filter.c b/src/core/ext/filters/http/compress/compress_filter.c deleted file mode 100644 index ab6c94a153..0000000000 --- a/src/core/ext/filters/http/compress/compress_filter.c +++ /dev/null @@ -1,353 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include -#include - -#include -#include -#include -#include - -#include "src/core/ext/filters/http/compress/compress_filter.h" -#include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/compression/algorithm_metadata.h" -#include "src/core/lib/compression/message_compress.h" -#include "src/core/lib/profiling/timers.h" -#include "src/core/lib/slice/slice_internal.h" -#include "src/core/lib/slice/slice_string_helpers.h" -#include "src/core/lib/support/string.h" -#include "src/core/lib/transport/static_metadata.h" - -int grpc_compression_trace = 0; - -typedef struct call_data { - grpc_slice_buffer slices; /**< Buffers up input slices to be compressed */ - grpc_linked_mdelem compression_algorithm_storage; - grpc_linked_mdelem accept_encoding_storage; - uint32_t remaining_slice_bytes; - /** Compression algorithm we'll try to use. It may be given by incoming - * metadata, or by the channel's default compression settings. */ - grpc_compression_algorithm compression_algorithm; - /** If true, contents of \a compression_algorithm are authoritative */ - int has_compression_algorithm; - - grpc_transport_stream_op_batch *send_op; - uint32_t send_length; - uint32_t send_flags; - grpc_slice incoming_slice; - grpc_slice_buffer_stream replacement_stream; - grpc_closure *post_send; - grpc_closure send_done; - grpc_closure got_slice; -} call_data; - -typedef struct channel_data { - /** The default, channel-level, compression algorithm */ - grpc_compression_algorithm default_compression_algorithm; - /** Bitset of enabled algorithms */ - uint32_t enabled_algorithms_bitset; - /** Supported compression algorithms */ - uint32_t supported_compression_algorithms; -} channel_data; - -static int skip_compression(grpc_call_element *elem, uint32_t flags) { - call_data *calld = elem->call_data; - channel_data *channeld = elem->channel_data; - - if (flags & (GRPC_WRITE_NO_COMPRESS | GRPC_WRITE_INTERNAL_COMPRESS)) { - return 1; - } - if (calld->has_compression_algorithm) { - if (calld->compression_algorithm == GRPC_COMPRESS_NONE) { - return 1; - } - return 0; /* we have an actual call-specific algorithm */ - } - /* no per-call compression override */ - return channeld->default_compression_algorithm == GRPC_COMPRESS_NONE; -} - -/** Filter initial metadata */ -static grpc_error *process_send_initial_metadata( - grpc_exec_ctx *exec_ctx, grpc_call_element *elem, - grpc_metadata_batch *initial_metadata) GRPC_MUST_USE_RESULT; -static grpc_error *process_send_initial_metadata( - grpc_exec_ctx *exec_ctx, grpc_call_element *elem, - grpc_metadata_batch *initial_metadata) { - call_data *calld = elem->call_data; - channel_data *channeld = elem->channel_data; - /* Parse incoming request for compression. If any, it'll be available - * at calld->compression_algorithm */ - if (initial_metadata->idx.named.grpc_internal_encoding_request != NULL) { - grpc_mdelem md = - initial_metadata->idx.named.grpc_internal_encoding_request->md; - if (!grpc_compression_algorithm_parse(GRPC_MDVALUE(md), - &calld->compression_algorithm)) { - char *val = grpc_slice_to_c_string(GRPC_MDVALUE(md)); - gpr_log(GPR_ERROR, - "Invalid compression algorithm: '%s' (unknown). Ignoring.", val); - gpr_free(val); - calld->compression_algorithm = GRPC_COMPRESS_NONE; - } - if (!GPR_BITGET(channeld->enabled_algorithms_bitset, - calld->compression_algorithm)) { - char *val = grpc_slice_to_c_string(GRPC_MDVALUE(md)); - gpr_log(GPR_ERROR, - "Invalid compression algorithm: '%s' (previously disabled). " - "Ignoring.", - val); - gpr_free(val); - calld->compression_algorithm = GRPC_COMPRESS_NONE; - } - calld->has_compression_algorithm = 1; - - grpc_metadata_batch_remove( - exec_ctx, initial_metadata, - initial_metadata->idx.named.grpc_internal_encoding_request); - } else { - /* If no algorithm was found in the metadata and we aren't - * exceptionally skipping compression, fall back to the channel - * default */ - calld->compression_algorithm = channeld->default_compression_algorithm; - calld->has_compression_algorithm = 1; /* GPR_TRUE */ - } - - grpc_error *error = GRPC_ERROR_NONE; - /* hint compression algorithm */ - if (calld->compression_algorithm != GRPC_COMPRESS_NONE) { - error = grpc_metadata_batch_add_tail( - exec_ctx, initial_metadata, &calld->compression_algorithm_storage, - grpc_compression_encoding_mdelem(calld->compression_algorithm)); - } - - if (error != GRPC_ERROR_NONE) return error; - - /* convey supported compression algorithms */ - error = grpc_metadata_batch_add_tail( - exec_ctx, initial_metadata, &calld->accept_encoding_storage, - GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS( - channeld->supported_compression_algorithms)); - - return error; -} - -static void continue_send_message(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem); - -static void send_done(grpc_exec_ctx *exec_ctx, void *elemp, grpc_error *error) { - grpc_call_element *elem = elemp; - call_data *calld = elem->call_data; - grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &calld->slices); - calld->post_send->cb(exec_ctx, calld->post_send->cb_arg, error); -} - -static void finish_send_message(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem) { - call_data *calld = elem->call_data; - int did_compress; - grpc_slice_buffer tmp; - grpc_slice_buffer_init(&tmp); - did_compress = grpc_msg_compress(exec_ctx, calld->compression_algorithm, - &calld->slices, &tmp); - if (did_compress) { - if (grpc_compression_trace) { - char *algo_name; - const size_t before_size = calld->slices.length; - const size_t after_size = tmp.length; - const float savings_ratio = 1.0f - (float)after_size / (float)before_size; - GPR_ASSERT(grpc_compression_algorithm_name(calld->compression_algorithm, - &algo_name)); - gpr_log(GPR_DEBUG, "Compressed[%s] %" PRIuPTR " bytes vs. %" PRIuPTR - " bytes (%.2f%% savings)", - algo_name, before_size, after_size, 100 * savings_ratio); - } - grpc_slice_buffer_swap(&calld->slices, &tmp); - calld->send_flags |= GRPC_WRITE_INTERNAL_COMPRESS; - } else { - if (grpc_compression_trace) { - char *algo_name; - GPR_ASSERT(grpc_compression_algorithm_name(calld->compression_algorithm, - &algo_name)); - gpr_log(GPR_DEBUG, - "Algorithm '%s' enabled but decided not to compress. Input size: " - "%" PRIuPTR, - algo_name, calld->slices.length); - } - } - - grpc_slice_buffer_destroy_internal(exec_ctx, &tmp); - - grpc_slice_buffer_stream_init(&calld->replacement_stream, &calld->slices, - calld->send_flags); - calld->send_op->payload->send_message.send_message = - &calld->replacement_stream.base; - calld->post_send = calld->send_op->on_complete; - calld->send_op->on_complete = &calld->send_done; - - grpc_call_next_op(exec_ctx, elem, calld->send_op); -} - -static void got_slice(grpc_exec_ctx *exec_ctx, void *elemp, grpc_error *error) { - grpc_call_element *elem = elemp; - call_data *calld = elem->call_data; - grpc_slice_buffer_add(&calld->slices, calld->incoming_slice); - if (calld->send_length == calld->slices.length) { - finish_send_message(exec_ctx, elem); - } else { - continue_send_message(exec_ctx, elem); - } -} - -static void continue_send_message(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem) { - call_data *calld = elem->call_data; - while (grpc_byte_stream_next( - exec_ctx, calld->send_op->payload->send_message.send_message, - &calld->incoming_slice, ~(size_t)0, &calld->got_slice)) { - grpc_slice_buffer_add(&calld->slices, calld->incoming_slice); - if (calld->send_length == calld->slices.length) { - finish_send_message(exec_ctx, elem); - break; - } - } -} - -static void compress_start_transport_stream_op_batch( - grpc_exec_ctx *exec_ctx, grpc_call_element *elem, - grpc_transport_stream_op_batch *op) { - call_data *calld = elem->call_data; - - GPR_TIMER_BEGIN("compress_start_transport_stream_op_batch", 0); - - if (op->send_initial_metadata) { - grpc_error *error = process_send_initial_metadata( - exec_ctx, elem, - op->payload->send_initial_metadata.send_initial_metadata); - if (error != GRPC_ERROR_NONE) { - grpc_transport_stream_op_batch_finish_with_failure(exec_ctx, op, error); - return; - } - } - if (op->send_message && - !skip_compression(elem, op->payload->send_message.send_message->flags)) { - calld->send_op = op; - calld->send_length = op->payload->send_message.send_message->length; - calld->send_flags = op->payload->send_message.send_message->flags; - continue_send_message(exec_ctx, elem); - } else { - /* pass control down the stack */ - grpc_call_next_op(exec_ctx, elem, op); - } - - GPR_TIMER_END("compress_start_transport_stream_op_batch", 0); -} - -/* Constructor for call_data */ -static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, - const grpc_call_element_args *args) { - /* grab pointers to our data from the call element */ - call_data *calld = elem->call_data; - - /* initialize members */ - grpc_slice_buffer_init(&calld->slices); - calld->has_compression_algorithm = 0; - grpc_closure_init(&calld->got_slice, got_slice, elem, - grpc_schedule_on_exec_ctx); - grpc_closure_init(&calld->send_done, send_done, elem, - grpc_schedule_on_exec_ctx); - - return GRPC_ERROR_NONE; -} - -/* Destructor for call_data */ -static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, - const grpc_call_final_info *final_info, - grpc_closure *ignored) { - /* grab pointers to our data from the call element */ - call_data *calld = elem->call_data; - grpc_slice_buffer_destroy_internal(exec_ctx, &calld->slices); -} - -/* Constructor for channel_data */ -static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx, - grpc_channel_element *elem, - grpc_channel_element_args *args) { - channel_data *channeld = elem->channel_data; - - channeld->enabled_algorithms_bitset = - grpc_channel_args_compression_algorithm_get_states(args->channel_args); - - channeld->default_compression_algorithm = - grpc_channel_args_get_compression_algorithm(args->channel_args); - /* Make sure the default isn't disabled. */ - if (!GPR_BITGET(channeld->enabled_algorithms_bitset, - channeld->default_compression_algorithm)) { - gpr_log(GPR_DEBUG, - "compression algorithm %d not enabled: switching to none", - channeld->default_compression_algorithm); - channeld->default_compression_algorithm = GRPC_COMPRESS_NONE; - } - - channeld->supported_compression_algorithms = 1; /* always support identity */ - for (grpc_compression_algorithm algo_idx = 1; - algo_idx < GRPC_COMPRESS_ALGORITHMS_COUNT; ++algo_idx) { - /* skip disabled algorithms */ - if (!GPR_BITGET(channeld->enabled_algorithms_bitset, algo_idx)) { - continue; - } - channeld->supported_compression_algorithms |= 1u << algo_idx; - } - - GPR_ASSERT(!args->is_last); - return GRPC_ERROR_NONE; -} - -/* Destructor for channel data */ -static void destroy_channel_elem(grpc_exec_ctx *exec_ctx, - grpc_channel_element *elem) {} - -const grpc_channel_filter grpc_compress_filter = { - compress_start_transport_stream_op_batch, - grpc_channel_next_op, - sizeof(call_data), - init_call_elem, - grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, - sizeof(channel_data), - init_channel_elem, - destroy_channel_elem, - grpc_call_next_get_peer, - grpc_channel_next_get_info, - "compress"}; diff --git a/src/core/ext/filters/http/compress/compress_filter.h b/src/core/ext/filters/http/compress/compress_filter.h deleted file mode 100644 index 68d2b8766a..0000000000 --- a/src/core/ext/filters/http/compress/compress_filter.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef GRPC_CORE_EXT_FILTERS_HTTP_COMPRESS_COMPRESS_FILTER_H -#define GRPC_CORE_EXT_FILTERS_HTTP_COMPRESS_COMPRESS_FILTER_H - -#include - -#include "src/core/lib/channel/channel_stack.h" - -extern int grpc_compression_trace; - -/** Compression filter for outgoing data. - * - * See for the available compression settings. - * - * Compression settings may come from: - * - Channel configuration, as established at channel creation time. - * - The metadata accompanying the outgoing data to be compressed. This is - * taken as a request only. We may choose not to honor it. The metadata key - * is given by \a GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY. - * - * Compression can be disabled for concrete messages (for instance in order to - * prevent CRIME/BEAST type attacks) by having the GRPC_WRITE_NO_COMPRESS set in - * the BEGIN_MESSAGE flags. - * - * The attempted compression mechanism is added to the resulting initial - * metadata under the'grpc-encoding' key. - * - * If compression is actually performed, BEGIN_MESSAGE's flag is modified to - * incorporate GRPC_WRITE_INTERNAL_COMPRESS. Otherwise, and regardless of the - * aforementioned 'grpc-encoding' metadata value, data will pass through - * uncompressed. */ - -extern const grpc_channel_filter grpc_compress_filter; - -#endif /* GRPC_CORE_EXT_FILTERS_HTTP_COMPRESS_COMPRESS_FILTER_H */ diff --git a/src/core/ext/filters/http/http_filters_plugin.c b/src/core/ext/filters/http/http_filters_plugin.c index a6e35bc181..825c21cb6a 100644 --- a/src/core/ext/filters/http/http_filters_plugin.c +++ b/src/core/ext/filters/http/http_filters_plugin.c @@ -34,7 +34,7 @@ #include #include "src/core/ext/filters/http/client/http_client_filter.h" -#include "src/core/ext/filters/http/compress/compress_filter.h" +#include "src/core/ext/filters/http/message_compress/message_compress_filter.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/lib/channel/channel_stack_builder.h" #include "src/core/lib/surface/channel_init.h" diff --git a/src/core/ext/filters/http/message_compress/message_compress_filter.c b/src/core/ext/filters/http/message_compress/message_compress_filter.c new file mode 100644 index 0000000000..f110e7beb6 --- /dev/null +++ b/src/core/ext/filters/http/message_compress/message_compress_filter.c @@ -0,0 +1,353 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include + +#include +#include +#include +#include + +#include "src/core/ext/filters/http/message_compress/message_compress_filter.h" +#include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/compression/algorithm_metadata.h" +#include "src/core/lib/compression/message_compress.h" +#include "src/core/lib/profiling/timers.h" +#include "src/core/lib/slice/slice_internal.h" +#include "src/core/lib/slice/slice_string_helpers.h" +#include "src/core/lib/support/string.h" +#include "src/core/lib/transport/static_metadata.h" + +int grpc_compression_trace = 0; + +typedef struct call_data { + grpc_slice_buffer slices; /**< Buffers up input slices to be compressed */ + grpc_linked_mdelem compression_algorithm_storage; + grpc_linked_mdelem accept_encoding_storage; + uint32_t remaining_slice_bytes; + /** Compression algorithm we'll try to use. It may be given by incoming + * metadata, or by the channel's default compression settings. */ + grpc_compression_algorithm compression_algorithm; + /** If true, contents of \a compression_algorithm are authoritative */ + int has_compression_algorithm; + + grpc_transport_stream_op_batch *send_op; + uint32_t send_length; + uint32_t send_flags; + grpc_slice incoming_slice; + grpc_slice_buffer_stream replacement_stream; + grpc_closure *post_send; + grpc_closure send_done; + grpc_closure got_slice; +} call_data; + +typedef struct channel_data { + /** The default, channel-level, compression algorithm */ + grpc_compression_algorithm default_compression_algorithm; + /** Bitset of enabled algorithms */ + uint32_t enabled_algorithms_bitset; + /** Supported compression algorithms */ + uint32_t supported_compression_algorithms; +} channel_data; + +static int skip_compression(grpc_call_element *elem, uint32_t flags) { + call_data *calld = elem->call_data; + channel_data *channeld = elem->channel_data; + + if (flags & (GRPC_WRITE_NO_COMPRESS | GRPC_WRITE_INTERNAL_COMPRESS)) { + return 1; + } + if (calld->has_compression_algorithm) { + if (calld->compression_algorithm == GRPC_COMPRESS_NONE) { + return 1; + } + return 0; /* we have an actual call-specific algorithm */ + } + /* no per-call compression override */ + return channeld->default_compression_algorithm == GRPC_COMPRESS_NONE; +} + +/** Filter initial metadata */ +static grpc_error *process_send_initial_metadata( + grpc_exec_ctx *exec_ctx, grpc_call_element *elem, + grpc_metadata_batch *initial_metadata) GRPC_MUST_USE_RESULT; +static grpc_error *process_send_initial_metadata( + grpc_exec_ctx *exec_ctx, grpc_call_element *elem, + grpc_metadata_batch *initial_metadata) { + call_data *calld = elem->call_data; + channel_data *channeld = elem->channel_data; + /* Parse incoming request for compression. If any, it'll be available + * at calld->compression_algorithm */ + if (initial_metadata->idx.named.grpc_internal_encoding_request != NULL) { + grpc_mdelem md = + initial_metadata->idx.named.grpc_internal_encoding_request->md; + if (!grpc_compression_algorithm_parse(GRPC_MDVALUE(md), + &calld->compression_algorithm)) { + char *val = grpc_slice_to_c_string(GRPC_MDVALUE(md)); + gpr_log(GPR_ERROR, + "Invalid compression algorithm: '%s' (unknown). Ignoring.", val); + gpr_free(val); + calld->compression_algorithm = GRPC_COMPRESS_NONE; + } + if (!GPR_BITGET(channeld->enabled_algorithms_bitset, + calld->compression_algorithm)) { + char *val = grpc_slice_to_c_string(GRPC_MDVALUE(md)); + gpr_log(GPR_ERROR, + "Invalid compression algorithm: '%s' (previously disabled). " + "Ignoring.", + val); + gpr_free(val); + calld->compression_algorithm = GRPC_COMPRESS_NONE; + } + calld->has_compression_algorithm = 1; + + grpc_metadata_batch_remove( + exec_ctx, initial_metadata, + initial_metadata->idx.named.grpc_internal_encoding_request); + } else { + /* If no algorithm was found in the metadata and we aren't + * exceptionally skipping compression, fall back to the channel + * default */ + calld->compression_algorithm = channeld->default_compression_algorithm; + calld->has_compression_algorithm = 1; /* GPR_TRUE */ + } + + grpc_error *error = GRPC_ERROR_NONE; + /* hint compression algorithm */ + if (calld->compression_algorithm != GRPC_COMPRESS_NONE) { + error = grpc_metadata_batch_add_tail( + exec_ctx, initial_metadata, &calld->compression_algorithm_storage, + grpc_compression_encoding_mdelem(calld->compression_algorithm)); + } + + if (error != GRPC_ERROR_NONE) return error; + + /* convey supported compression algorithms */ + error = grpc_metadata_batch_add_tail( + exec_ctx, initial_metadata, &calld->accept_encoding_storage, + GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS( + channeld->supported_compression_algorithms)); + + return error; +} + +static void continue_send_message(grpc_exec_ctx *exec_ctx, + grpc_call_element *elem); + +static void send_done(grpc_exec_ctx *exec_ctx, void *elemp, grpc_error *error) { + grpc_call_element *elem = elemp; + call_data *calld = elem->call_data; + grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &calld->slices); + calld->post_send->cb(exec_ctx, calld->post_send->cb_arg, error); +} + +static void finish_send_message(grpc_exec_ctx *exec_ctx, + grpc_call_element *elem) { + call_data *calld = elem->call_data; + int did_compress; + grpc_slice_buffer tmp; + grpc_slice_buffer_init(&tmp); + did_compress = grpc_msg_compress(exec_ctx, calld->compression_algorithm, + &calld->slices, &tmp); + if (did_compress) { + if (grpc_compression_trace) { + char *algo_name; + const size_t before_size = calld->slices.length; + const size_t after_size = tmp.length; + const float savings_ratio = 1.0f - (float)after_size / (float)before_size; + GPR_ASSERT(grpc_compression_algorithm_name(calld->compression_algorithm, + &algo_name)); + gpr_log(GPR_DEBUG, "Compressed[%s] %" PRIuPTR " bytes vs. %" PRIuPTR + " bytes (%.2f%% savings)", + algo_name, before_size, after_size, 100 * savings_ratio); + } + grpc_slice_buffer_swap(&calld->slices, &tmp); + calld->send_flags |= GRPC_WRITE_INTERNAL_COMPRESS; + } else { + if (grpc_compression_trace) { + char *algo_name; + GPR_ASSERT(grpc_compression_algorithm_name(calld->compression_algorithm, + &algo_name)); + gpr_log(GPR_DEBUG, + "Algorithm '%s' enabled but decided not to compress. Input size: " + "%" PRIuPTR, + algo_name, calld->slices.length); + } + } + + grpc_slice_buffer_destroy_internal(exec_ctx, &tmp); + + grpc_slice_buffer_stream_init(&calld->replacement_stream, &calld->slices, + calld->send_flags); + calld->send_op->payload->send_message.send_message = + &calld->replacement_stream.base; + calld->post_send = calld->send_op->on_complete; + calld->send_op->on_complete = &calld->send_done; + + grpc_call_next_op(exec_ctx, elem, calld->send_op); +} + +static void got_slice(grpc_exec_ctx *exec_ctx, void *elemp, grpc_error *error) { + grpc_call_element *elem = elemp; + call_data *calld = elem->call_data; + grpc_slice_buffer_add(&calld->slices, calld->incoming_slice); + if (calld->send_length == calld->slices.length) { + finish_send_message(exec_ctx, elem); + } else { + continue_send_message(exec_ctx, elem); + } +} + +static void continue_send_message(grpc_exec_ctx *exec_ctx, + grpc_call_element *elem) { + call_data *calld = elem->call_data; + while (grpc_byte_stream_next( + exec_ctx, calld->send_op->payload->send_message.send_message, + &calld->incoming_slice, ~(size_t)0, &calld->got_slice)) { + grpc_slice_buffer_add(&calld->slices, calld->incoming_slice); + if (calld->send_length == calld->slices.length) { + finish_send_message(exec_ctx, elem); + break; + } + } +} + +static void compress_start_transport_stream_op_batch( + grpc_exec_ctx *exec_ctx, grpc_call_element *elem, + grpc_transport_stream_op_batch *op) { + call_data *calld = elem->call_data; + + GPR_TIMER_BEGIN("compress_start_transport_stream_op_batch", 0); + + if (op->send_initial_metadata) { + grpc_error *error = process_send_initial_metadata( + exec_ctx, elem, + op->payload->send_initial_metadata.send_initial_metadata); + if (error != GRPC_ERROR_NONE) { + grpc_transport_stream_op_batch_finish_with_failure(exec_ctx, op, error); + return; + } + } + if (op->send_message && + !skip_compression(elem, op->payload->send_message.send_message->flags)) { + calld->send_op = op; + calld->send_length = op->payload->send_message.send_message->length; + calld->send_flags = op->payload->send_message.send_message->flags; + continue_send_message(exec_ctx, elem); + } else { + /* pass control down the stack */ + grpc_call_next_op(exec_ctx, elem, op); + } + + GPR_TIMER_END("compress_start_transport_stream_op_batch", 0); +} + +/* Constructor for call_data */ +static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx, + grpc_call_element *elem, + const grpc_call_element_args *args) { + /* grab pointers to our data from the call element */ + call_data *calld = elem->call_data; + + /* initialize members */ + grpc_slice_buffer_init(&calld->slices); + calld->has_compression_algorithm = 0; + grpc_closure_init(&calld->got_slice, got_slice, elem, + grpc_schedule_on_exec_ctx); + grpc_closure_init(&calld->send_done, send_done, elem, + grpc_schedule_on_exec_ctx); + + return GRPC_ERROR_NONE; +} + +/* Destructor for call_data */ +static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, + const grpc_call_final_info *final_info, + grpc_closure *ignored) { + /* grab pointers to our data from the call element */ + call_data *calld = elem->call_data; + grpc_slice_buffer_destroy_internal(exec_ctx, &calld->slices); +} + +/* Constructor for channel_data */ +static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx, + grpc_channel_element *elem, + grpc_channel_element_args *args) { + channel_data *channeld = elem->channel_data; + + channeld->enabled_algorithms_bitset = + grpc_channel_args_compression_algorithm_get_states(args->channel_args); + + channeld->default_compression_algorithm = + grpc_channel_args_get_compression_algorithm(args->channel_args); + /* Make sure the default isn't disabled. */ + if (!GPR_BITGET(channeld->enabled_algorithms_bitset, + channeld->default_compression_algorithm)) { + gpr_log(GPR_DEBUG, + "compression algorithm %d not enabled: switching to none", + channeld->default_compression_algorithm); + channeld->default_compression_algorithm = GRPC_COMPRESS_NONE; + } + + channeld->supported_compression_algorithms = 1; /* always support identity */ + for (grpc_compression_algorithm algo_idx = 1; + algo_idx < GRPC_COMPRESS_ALGORITHMS_COUNT; ++algo_idx) { + /* skip disabled algorithms */ + if (!GPR_BITGET(channeld->enabled_algorithms_bitset, algo_idx)) { + continue; + } + channeld->supported_compression_algorithms |= 1u << algo_idx; + } + + GPR_ASSERT(!args->is_last); + return GRPC_ERROR_NONE; +} + +/* Destructor for channel data */ +static void destroy_channel_elem(grpc_exec_ctx *exec_ctx, + grpc_channel_element *elem) {} + +const grpc_channel_filter grpc_compress_filter = { + compress_start_transport_stream_op_batch, + grpc_channel_next_op, + sizeof(call_data), + init_call_elem, + grpc_call_stack_ignore_set_pollset_or_pollset_set, + destroy_call_elem, + sizeof(channel_data), + init_channel_elem, + destroy_channel_elem, + grpc_call_next_get_peer, + grpc_channel_next_get_info, + "compress"}; diff --git a/src/core/ext/filters/http/message_compress/message_compress_filter.h b/src/core/ext/filters/http/message_compress/message_compress_filter.h new file mode 100644 index 0000000000..68d2b8766a --- /dev/null +++ b/src/core/ext/filters/http/message_compress/message_compress_filter.h @@ -0,0 +1,67 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_CORE_EXT_FILTERS_HTTP_COMPRESS_COMPRESS_FILTER_H +#define GRPC_CORE_EXT_FILTERS_HTTP_COMPRESS_COMPRESS_FILTER_H + +#include + +#include "src/core/lib/channel/channel_stack.h" + +extern int grpc_compression_trace; + +/** Compression filter for outgoing data. + * + * See for the available compression settings. + * + * Compression settings may come from: + * - Channel configuration, as established at channel creation time. + * - The metadata accompanying the outgoing data to be compressed. This is + * taken as a request only. We may choose not to honor it. The metadata key + * is given by \a GRPC_COMPRESSION_REQUEST_ALGORITHM_MD_KEY. + * + * Compression can be disabled for concrete messages (for instance in order to + * prevent CRIME/BEAST type attacks) by having the GRPC_WRITE_NO_COMPRESS set in + * the BEGIN_MESSAGE flags. + * + * The attempted compression mechanism is added to the resulting initial + * metadata under the'grpc-encoding' key. + * + * If compression is actually performed, BEGIN_MESSAGE's flag is modified to + * incorporate GRPC_WRITE_INTERNAL_COMPRESS. Otherwise, and regardless of the + * aforementioned 'grpc-encoding' metadata value, data will pass through + * uncompressed. */ + +extern const grpc_channel_filter grpc_compress_filter; + +#endif /* GRPC_CORE_EXT_FILTERS_HTTP_COMPRESS_COMPRESS_FILTER_H */ diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index c858dc9e1f..afaf2acaa4 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -220,7 +220,7 @@ CORE_SOURCE_FILES = [ 'src/core/ext/transport/chttp2/transport/writing.c', 'src/core/ext/transport/chttp2/alpn/alpn.c', 'src/core/ext/filters/http/client/http_client_filter.c', - 'src/core/ext/filters/http/compress/compress_filter.c', + 'src/core/ext/filters/http/message_compress/message_compress_filter.c', 'src/core/ext/filters/http/http_filters_plugin.c', 'src/core/ext/filters/http/server/http_server_filter.c', 'src/core/lib/http/httpcli_security_connector.c', diff --git a/test/core/end2end/fixtures/h2_sockpair+trace.c b/test/core/end2end/fixtures/h2_sockpair+trace.c index 5fc0e4ea73..c59b544902 100644 --- a/test/core/end2end/fixtures/h2_sockpair+trace.c +++ b/test/core/end2end/fixtures/h2_sockpair+trace.c @@ -47,7 +47,7 @@ #include #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/client/http_client_filter.h" -#include "src/core/ext/filters/http/compress/compress_filter.h" +#include "src/core/ext/filters/http/message_compress/message_compress_filter.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" diff --git a/test/core/end2end/fixtures/h2_sockpair.c b/test/core/end2end/fixtures/h2_sockpair.c index 24ed048e7d..1cb4e70727 100644 --- a/test/core/end2end/fixtures/h2_sockpair.c +++ b/test/core/end2end/fixtures/h2_sockpair.c @@ -42,7 +42,7 @@ #include #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/client/http_client_filter.h" -#include "src/core/ext/filters/http/compress/compress_filter.h" +#include "src/core/ext/filters/http/message_compress/message_compress_filter.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" diff --git a/test/core/end2end/fixtures/h2_sockpair_1byte.c b/test/core/end2end/fixtures/h2_sockpair_1byte.c index fee30946c4..9cd93c234a 100644 --- a/test/core/end2end/fixtures/h2_sockpair_1byte.c +++ b/test/core/end2end/fixtures/h2_sockpair_1byte.c @@ -42,7 +42,7 @@ #include #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/client/http_client_filter.h" -#include "src/core/ext/filters/http/compress/compress_filter.h" +#include "src/core/ext/filters/http/message_compress/message_compress_filter.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/connected_channel.h" diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc index ae6041733c..7221cf5512 100644 --- a/test/cpp/microbenchmarks/bm_call_create.cc +++ b/test/cpp/microbenchmarks/bm_call_create.cc @@ -48,7 +48,7 @@ extern "C" { #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/deadline/deadline_filter.h" #include "src/core/ext/filters/http/client/http_client_filter.h" -#include "src/core/ext/filters/http/compress/compress_filter.h" +#include "src/core/ext/filters/http/message_compress/message_compress_filter.h" #include "src/core/ext/filters/http/server/http_server_filter.h" #include "src/core/ext/filters/load_reporting/load_reporting_filter.h" #include "src/core/ext/filters/message_size/message_size_filter.h" diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 8bc5896e88..ca38e2fe0f 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -958,8 +958,8 @@ src/core/ext/filters/deadline/deadline_filter.c \ src/core/ext/filters/deadline/deadline_filter.h \ src/core/ext/filters/http/client/http_client_filter.c \ src/core/ext/filters/http/client/http_client_filter.h \ -src/core/ext/filters/http/compress/compress_filter.c \ -src/core/ext/filters/http/compress/compress_filter.h \ +src/core/ext/filters/http/message_compress/message_compress_filter.c \ +src/core/ext/filters/http/message_compress/message_compress_filter.h \ src/core/ext/filters/http/http_filters_plugin.c \ src/core/ext/filters/http/server/http_server_filter.c \ src/core/ext/filters/http/server/http_server_filter.h \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 6cf4494b12..63d6419146 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -8013,7 +8013,7 @@ ], "headers": [ "src/core/ext/filters/http/client/http_client_filter.h", - "src/core/ext/filters/http/compress/compress_filter.h", + "src/core/ext/filters/http/message_compress/message_compress_filter.h", "src/core/ext/filters/http/server/http_server_filter.h" ], "is_filegroup": true, @@ -8022,8 +8022,8 @@ "src": [ "src/core/ext/filters/http/client/http_client_filter.c", "src/core/ext/filters/http/client/http_client_filter.h", - "src/core/ext/filters/http/compress/compress_filter.c", - "src/core/ext/filters/http/compress/compress_filter.h", + "src/core/ext/filters/http/message_compress/message_compress_filter.c", + "src/core/ext/filters/http/message_compress/message_compress_filter.h", "src/core/ext/filters/http/http_filters_plugin.c", "src/core/ext/filters/http/server/http_server_filter.c", "src/core/ext/filters/http/server/http_server_filter.h" -- cgit v1.2.3 From 3bd7a2111ed9ada00868ffc8c5175228262194e3 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 6 Apr 2017 09:04:18 -0700 Subject: Fixup code --- src/core/ext/filters/http/http_filters_plugin.c | 2 +- src/core/ext/filters/http/message_compress/message_compress_filter.c | 2 +- test/cpp/microbenchmarks/bm_call_create.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/ext/filters/http/http_filters_plugin.c b/src/core/ext/filters/http/http_filters_plugin.c index 825c21cb6a..093a8c7dce 100644 --- a/src/core/ext/filters/http/http_filters_plugin.c +++ b/src/core/ext/filters/http/http_filters_plugin.c @@ -46,7 +46,7 @@ typedef struct { } optional_filter; static optional_filter compress_filter = { - &grpc_compress_filter, GRPC_ARG_ENABLE_PER_MESSAGE_COMPRESSION}; + &grpc_message_compress_filter, GRPC_ARG_ENABLE_PER_MESSAGE_COMPRESSION}; static bool is_building_http_like_transport( grpc_channel_stack_builder *builder) { diff --git a/src/core/ext/filters/http/message_compress/message_compress_filter.c b/src/core/ext/filters/http/message_compress/message_compress_filter.c index f110e7beb6..1cbc852686 100644 --- a/src/core/ext/filters/http/message_compress/message_compress_filter.c +++ b/src/core/ext/filters/http/message_compress/message_compress_filter.c @@ -338,7 +338,7 @@ static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx, static void destroy_channel_elem(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem) {} -const grpc_channel_filter grpc_compress_filter = { +const grpc_channel_filter grpc_message_compress_filter = { compress_start_transport_stream_op_batch, grpc_channel_next_op, sizeof(call_data), diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc index 7221cf5512..0acfb9402f 100644 --- a/test/cpp/microbenchmarks/bm_call_create.cc +++ b/test/cpp/microbenchmarks/bm_call_create.cc @@ -461,7 +461,7 @@ BENCHMARK_TEMPLATE(BM_IsolatedFilter, DummyFilter, NoOp); BENCHMARK_TEMPLATE(BM_IsolatedFilter, DummyFilter, SendEmptyMetadata); typedef Fixture<&grpc_client_channel_filter, 0> ClientChannelFilter; BENCHMARK_TEMPLATE(BM_IsolatedFilter, ClientChannelFilter, NoOp); -typedef Fixture<&grpc_compress_filter, CHECKS_NOT_LAST> CompressFilter; +typedef Fixture<&grpc_message_compress_filter, CHECKS_NOT_LAST> CompressFilter; BENCHMARK_TEMPLATE(BM_IsolatedFilter, CompressFilter, NoOp); BENCHMARK_TEMPLATE(BM_IsolatedFilter, CompressFilter, SendEmptyMetadata); typedef Fixture<&grpc_client_deadline_filter, CHECKS_NOT_LAST> -- cgit v1.2.3 From 71d6ce65d4f69e289f40c5c5f38928091285d46e Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 6 Apr 2017 09:10:09 -0700 Subject: Merge deadline_init/deadline_start --- CMakeLists.txt | 19 +++++++-------- Makefile | 19 +++++++-------- binding.gyp | 4 ++-- build.yaml | 4 +--- config.m4 | 6 ++--- gRPC-Core.podspec | 8 +++---- grpc.gemspec | 6 ++--- package.xml | 6 ++--- .../ext/filters/client_channel/client_channel.c | 3 +-- src/core/ext/filters/deadline/deadline_filter.c | 28 ++++++++++------------ src/core/ext/filters/deadline/deadline_filter.h | 8 ++----- .../message_compress/message_compress_filter.h | 2 +- src/python/grpcio/grpc_core_dependencies.py | 4 ++-- tools/doxygen/Doxyfile.c++.internal | 2 -- tools/doxygen/Doxyfile.core.internal | 2 +- tools/run_tests/generated/sources_and_headers.json | 5 +--- vsprojects/vcxproj/grpc++/grpc++.vcxproj | 3 --- vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters | 15 ------------ .../grpc++_unsecure/grpc++_unsecure.vcxproj | 3 --- .../grpc++_unsecure.vcxproj.filters | 15 ------------ vsprojects/vcxproj/grpc/grpc.vcxproj | 12 +++++----- vsprojects/vcxproj/grpc/grpc.vcxproj.filters | 26 ++++++++++---------- .../vcxproj/grpc_test_util/grpc_test_util.vcxproj | 3 --- .../grpc_test_util/grpc_test_util.vcxproj.filters | 15 ------------ .../vcxproj/grpc_unsecure/grpc_unsecure.vcxproj | 12 +++++----- .../grpc_unsecure/grpc_unsecure.vcxproj.filters | 26 ++++++++++---------- 26 files changed, 90 insertions(+), 166 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f79d7154a9..2ec5c57d74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -908,7 +908,6 @@ endif (gRPC_BUILD_TESTS) add_library(grpc src/core/lib/surface/init.c - src/core/ext/filters/deadline/deadline_filter.c src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c @@ -1051,8 +1050,8 @@ add_library(grpc src/core/ext/transport/chttp2/transport/writing.c src/core/ext/transport/chttp2/alpn/alpn.c src/core/ext/filters/http/client/http_client_filter.c - src/core/ext/filters/http/message_compress/message_compress_filter.c src/core/ext/filters/http/http_filters_plugin.c + src/core/ext/filters/http/message_compress/message_compress_filter.c src/core/ext/filters/http/server/http_server_filter.c src/core/lib/http/httpcli_security_connector.c src/core/lib/security/context/security_context.c @@ -1103,6 +1102,7 @@ add_library(grpc src/core/ext/filters/client_channel/subchannel.c src/core/ext/filters/client_channel/subchannel_index.c src/core/ext/filters/client_channel/uri_parser.c + src/core/ext/filters/deadline/deadline_filter.c src/core/ext/transport/chttp2/client/chttp2_connector.c src/core/ext/transport/chttp2/server/insecure/server_chttp2.c src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c @@ -1231,7 +1231,6 @@ endif() add_library(grpc_cronet src/core/lib/surface/init.c - src/core/ext/filters/deadline/deadline_filter.c src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c @@ -1377,8 +1376,8 @@ add_library(grpc_cronet src/core/ext/transport/chttp2/transport/writing.c src/core/ext/transport/chttp2/alpn/alpn.c src/core/ext/filters/http/client/http_client_filter.c - src/core/ext/filters/http/message_compress/message_compress_filter.c src/core/ext/filters/http/http_filters_plugin.c + src/core/ext/filters/http/message_compress/message_compress_filter.c src/core/ext/filters/http/server/http_server_filter.c src/core/ext/filters/client_channel/channel_connectivity.c src/core/ext/filters/client_channel/client_channel.c @@ -1400,6 +1399,7 @@ add_library(grpc_cronet src/core/ext/filters/client_channel/subchannel.c src/core/ext/filters/client_channel/subchannel_index.c src/core/ext/filters/client_channel/uri_parser.c + src/core/ext/filters/deadline/deadline_filter.c src/core/lib/http/httpcli_security_connector.c src/core/lib/security/context/security_context.c src/core/lib/security/credentials/composite/composite_credentials.c @@ -1539,7 +1539,6 @@ add_library(grpc_test_util test/core/util/port_server_client.c test/core/util/slice_splitter.c test/core/util/trickle_endpoint.c - src/core/ext/filters/deadline/deadline_filter.c src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c @@ -1795,7 +1794,6 @@ endif (gRPC_BUILD_TESTS) add_library(grpc_unsecure src/core/lib/surface/init.c src/core/lib/surface/init_unsecure.c - src/core/ext/filters/deadline/deadline_filter.c src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c @@ -1939,8 +1937,8 @@ add_library(grpc_unsecure src/core/ext/transport/chttp2/transport/writing.c src/core/ext/transport/chttp2/alpn/alpn.c src/core/ext/filters/http/client/http_client_filter.c - src/core/ext/filters/http/message_compress/message_compress_filter.c src/core/ext/filters/http/http_filters_plugin.c + src/core/ext/filters/http/message_compress/message_compress_filter.c src/core/ext/filters/http/server/http_server_filter.c src/core/ext/transport/chttp2/server/chttp2_server.c src/core/ext/transport/chttp2/client/insecure/channel_create.c @@ -1966,6 +1964,7 @@ add_library(grpc_unsecure src/core/ext/filters/client_channel/subchannel.c src/core/ext/filters/client_channel/subchannel_index.c src/core/ext/filters/client_channel/uri_parser.c + src/core/ext/filters/deadline/deadline_filter.c src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c @@ -2212,7 +2211,6 @@ add_library(grpc++ src/cpp/util/status.cc src/cpp/util/string_ref.cc src/cpp/util/time_cc.cc - src/core/ext/filters/deadline/deadline_filter.c src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c @@ -2538,7 +2536,6 @@ add_library(grpc++_cronet src/cpp/util/status.cc src/cpp/util/string_ref.cc src/cpp/util/time_cc.cc - src/core/ext/filters/deadline/deadline_filter.c src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c @@ -2687,8 +2684,8 @@ add_library(grpc++_cronet src/core/ext/transport/chttp2/transport/writing.c src/core/ext/transport/chttp2/alpn/alpn.c src/core/ext/filters/http/client/http_client_filter.c - src/core/ext/filters/http/message_compress/message_compress_filter.c src/core/ext/filters/http/http_filters_plugin.c + src/core/ext/filters/http/message_compress/message_compress_filter.c src/core/ext/filters/http/server/http_server_filter.c src/core/ext/filters/client_channel/channel_connectivity.c src/core/ext/filters/client_channel/client_channel.c @@ -2710,6 +2707,7 @@ add_library(grpc++_cronet src/core/ext/filters/client_channel/subchannel.c src/core/ext/filters/client_channel/subchannel_index.c src/core/ext/filters/client_channel/uri_parser.c + src/core/ext/filters/deadline/deadline_filter.c src/core/ext/transport/chttp2/server/insecure/server_chttp2.c src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c src/core/ext/transport/chttp2/server/chttp2_server.c @@ -3236,7 +3234,6 @@ add_library(grpc++_unsecure src/cpp/util/status.cc src/cpp/util/string_ref.cc src/cpp/util/time_cc.cc - src/core/ext/filters/deadline/deadline_filter.c src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c diff --git a/Makefile b/Makefile index f2ee6901cf..d932882bc2 100644 --- a/Makefile +++ b/Makefile @@ -2813,7 +2813,6 @@ endif LIBGRPC_SRC = \ src/core/lib/surface/init.c \ - src/core/ext/filters/deadline/deadline_filter.c \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ @@ -2956,8 +2955,8 @@ LIBGRPC_SRC = \ src/core/ext/transport/chttp2/transport/writing.c \ src/core/ext/transport/chttp2/alpn/alpn.c \ src/core/ext/filters/http/client/http_client_filter.c \ - src/core/ext/filters/http/message_compress/message_compress_filter.c \ src/core/ext/filters/http/http_filters_plugin.c \ + src/core/ext/filters/http/message_compress/message_compress_filter.c \ src/core/ext/filters/http/server/http_server_filter.c \ src/core/lib/http/httpcli_security_connector.c \ src/core/lib/security/context/security_context.c \ @@ -3008,6 +3007,7 @@ LIBGRPC_SRC = \ src/core/ext/filters/client_channel/subchannel.c \ src/core/ext/filters/client_channel/subchannel_index.c \ src/core/ext/filters/client_channel/uri_parser.c \ + src/core/ext/filters/deadline/deadline_filter.c \ src/core/ext/transport/chttp2/client/chttp2_connector.c \ src/core/ext/transport/chttp2/server/insecure/server_chttp2.c \ src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c \ @@ -3134,7 +3134,6 @@ endif LIBGRPC_CRONET_SRC = \ src/core/lib/surface/init.c \ - src/core/ext/filters/deadline/deadline_filter.c \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ @@ -3280,8 +3279,8 @@ LIBGRPC_CRONET_SRC = \ src/core/ext/transport/chttp2/transport/writing.c \ src/core/ext/transport/chttp2/alpn/alpn.c \ src/core/ext/filters/http/client/http_client_filter.c \ - src/core/ext/filters/http/message_compress/message_compress_filter.c \ src/core/ext/filters/http/http_filters_plugin.c \ + src/core/ext/filters/http/message_compress/message_compress_filter.c \ src/core/ext/filters/http/server/http_server_filter.c \ src/core/ext/filters/client_channel/channel_connectivity.c \ src/core/ext/filters/client_channel/client_channel.c \ @@ -3303,6 +3302,7 @@ LIBGRPC_CRONET_SRC = \ src/core/ext/filters/client_channel/subchannel.c \ src/core/ext/filters/client_channel/subchannel_index.c \ src/core/ext/filters/client_channel/uri_parser.c \ + src/core/ext/filters/deadline/deadline_filter.c \ src/core/lib/http/httpcli_security_connector.c \ src/core/lib/security/context/security_context.c \ src/core/lib/security/credentials/composite/composite_credentials.c \ @@ -3441,7 +3441,6 @@ LIBGRPC_TEST_UTIL_SRC = \ test/core/util/port_server_client.c \ test/core/util/slice_splitter.c \ test/core/util/trickle_endpoint.c \ - src/core/ext/filters/deadline/deadline_filter.c \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ @@ -3669,7 +3668,6 @@ endif LIBGRPC_UNSECURE_SRC = \ src/core/lib/surface/init.c \ src/core/lib/surface/init_unsecure.c \ - src/core/ext/filters/deadline/deadline_filter.c \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ @@ -3813,8 +3811,8 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/transport/chttp2/transport/writing.c \ src/core/ext/transport/chttp2/alpn/alpn.c \ src/core/ext/filters/http/client/http_client_filter.c \ - src/core/ext/filters/http/message_compress/message_compress_filter.c \ src/core/ext/filters/http/http_filters_plugin.c \ + src/core/ext/filters/http/message_compress/message_compress_filter.c \ src/core/ext/filters/http/server/http_server_filter.c \ src/core/ext/transport/chttp2/server/chttp2_server.c \ src/core/ext/transport/chttp2/client/insecure/channel_create.c \ @@ -3840,6 +3838,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/filters/client_channel/subchannel.c \ src/core/ext/filters/client_channel/subchannel_index.c \ src/core/ext/filters/client_channel/uri_parser.c \ + src/core/ext/filters/deadline/deadline_filter.c \ src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.c \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c \ @@ -4063,7 +4062,6 @@ LIBGRPC++_SRC = \ src/cpp/util/status.cc \ src/cpp/util/string_ref.cc \ src/cpp/util/time_cc.cc \ - src/core/ext/filters/deadline/deadline_filter.c \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ @@ -4397,7 +4395,6 @@ LIBGRPC++_CRONET_SRC = \ src/cpp/util/status.cc \ src/cpp/util/string_ref.cc \ src/cpp/util/time_cc.cc \ - src/core/ext/filters/deadline/deadline_filter.c \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ @@ -4546,8 +4543,8 @@ LIBGRPC++_CRONET_SRC = \ src/core/ext/transport/chttp2/transport/writing.c \ src/core/ext/transport/chttp2/alpn/alpn.c \ src/core/ext/filters/http/client/http_client_filter.c \ - src/core/ext/filters/http/message_compress/message_compress_filter.c \ src/core/ext/filters/http/http_filters_plugin.c \ + src/core/ext/filters/http/message_compress/message_compress_filter.c \ src/core/ext/filters/http/server/http_server_filter.c \ src/core/ext/filters/client_channel/channel_connectivity.c \ src/core/ext/filters/client_channel/client_channel.c \ @@ -4569,6 +4566,7 @@ LIBGRPC++_CRONET_SRC = \ src/core/ext/filters/client_channel/subchannel.c \ src/core/ext/filters/client_channel/subchannel_index.c \ src/core/ext/filters/client_channel/uri_parser.c \ + src/core/ext/filters/deadline/deadline_filter.c \ src/core/ext/transport/chttp2/server/insecure/server_chttp2.c \ src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c \ src/core/ext/transport/chttp2/server/chttp2_server.c \ @@ -5087,7 +5085,6 @@ LIBGRPC++_UNSECURE_SRC = \ src/cpp/util/status.cc \ src/cpp/util/string_ref.cc \ src/cpp/util/time_cc.cc \ - src/core/ext/filters/deadline/deadline_filter.c \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ diff --git a/binding.gyp b/binding.gyp index 21cd56e684..cb12489e41 100644 --- a/binding.gyp +++ b/binding.gyp @@ -649,7 +649,6 @@ ], 'sources': [ 'src/core/lib/surface/init.c', - 'src/core/ext/filters/deadline/deadline_filter.c', 'src/core/lib/channel/channel_args.c', 'src/core/lib/channel/channel_stack.c', 'src/core/lib/channel/channel_stack_builder.c', @@ -792,8 +791,8 @@ 'src/core/ext/transport/chttp2/transport/writing.c', 'src/core/ext/transport/chttp2/alpn/alpn.c', 'src/core/ext/filters/http/client/http_client_filter.c', - 'src/core/ext/filters/http/message_compress/message_compress_filter.c', 'src/core/ext/filters/http/http_filters_plugin.c', + 'src/core/ext/filters/http/message_compress/message_compress_filter.c', 'src/core/ext/filters/http/server/http_server_filter.c', 'src/core/lib/http/httpcli_security_connector.c', 'src/core/lib/security/context/security_context.c', @@ -844,6 +843,7 @@ 'src/core/ext/filters/client_channel/subchannel.c', 'src/core/ext/filters/client_channel/subchannel_index.c', 'src/core/ext/filters/client_channel/uri_parser.c', + 'src/core/ext/filters/deadline/deadline_filter.c', 'src/core/ext/transport/chttp2/client/chttp2_connector.c', 'src/core/ext/transport/chttp2/server/insecure/server_chttp2.c', 'src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c', diff --git a/build.yaml b/build.yaml index 2d52b38fbf..f88c13c0c9 100644 --- a/build.yaml +++ b/build.yaml @@ -173,7 +173,6 @@ filegroups: - include/grpc/slice_buffer.h - include/grpc/status.h headers: - - src/core/ext/filters/deadline/deadline_filter.h - src/core/lib/channel/channel_args.h - src/core/lib/channel/channel_stack.h - src/core/lib/channel/channel_stack_builder.h @@ -280,7 +279,6 @@ filegroups: - src/core/lib/transport/transport.h - src/core/lib/transport/transport_impl.h src: - - src/core/ext/filters/deadline/deadline_filter.c - src/core/lib/channel/channel_args.c - src/core/lib/channel/channel_stack.c - src/core/lib/channel/channel_stack_builder.c @@ -476,8 +474,8 @@ filegroups: - src/core/ext/filters/http/server/http_server_filter.h src: - src/core/ext/filters/http/client/http_client_filter.c - - src/core/ext/filters/http/message_compress/message_compress_filter.c - src/core/ext/filters/http/http_filters_plugin.c + - src/core/ext/filters/http/message_compress/message_compress_filter.c - src/core/ext/filters/http/server/http_server_filter.c plugin: grpc_http_filters uses: diff --git a/config.m4 b/config.m4 index 985de08562..ffbbe927c9 100644 --- a/config.m4 +++ b/config.m4 @@ -83,7 +83,6 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/support/tmpfile_windows.c \ src/core/lib/support/wrap_memcpy.c \ src/core/lib/surface/init.c \ - src/core/ext/filters/deadline/deadline_filter.c \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ @@ -226,8 +225,8 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/transport/chttp2/transport/writing.c \ src/core/ext/transport/chttp2/alpn/alpn.c \ src/core/ext/filters/http/client/http_client_filter.c \ - src/core/ext/filters/http/message_compress/message_compress_filter.c \ src/core/ext/filters/http/http_filters_plugin.c \ + src/core/ext/filters/http/message_compress/message_compress_filter.c \ src/core/ext/filters/http/server/http_server_filter.c \ src/core/lib/http/httpcli_security_connector.c \ src/core/lib/security/context/security_context.c \ @@ -278,6 +277,7 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/filters/client_channel/subchannel.c \ src/core/ext/filters/client_channel/subchannel_index.c \ src/core/ext/filters/client_channel/uri_parser.c \ + src/core/ext/filters/deadline/deadline_filter.c \ src/core/ext/transport/chttp2/client/chttp2_connector.c \ src/core/ext/transport/chttp2/server/insecure/server_chttp2.c \ src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c \ @@ -641,7 +641,7 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/deadline) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/http) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/http/client) - PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/http/compress) + PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/http/message_compress) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/http/server) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/load_reporting) PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/filters/max_age) diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index b79a759438..c67b83408b 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -255,7 +255,6 @@ Pod::Spec.new do |s| 'src/core/lib/support/tmpfile_posix.c', 'src/core/lib/support/tmpfile_windows.c', 'src/core/lib/support/wrap_memcpy.c', - 'src/core/ext/filters/deadline/deadline_filter.h', 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', @@ -426,6 +425,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/subchannel.h', 'src/core/ext/filters/client_channel/subchannel_index.h', 'src/core/ext/filters/client_channel/uri_parser.h', + 'src/core/ext/filters/deadline/deadline_filter.h', 'src/core/ext/transport/chttp2/client/chttp2_connector.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h', @@ -458,7 +458,6 @@ Pod::Spec.new do |s| 'src/core/ext/filters/max_age/max_age_filter.h', 'src/core/ext/filters/message_size/message_size_filter.h', 'src/core/lib/surface/init.c', - 'src/core/ext/filters/deadline/deadline_filter.c', 'src/core/lib/channel/channel_args.c', 'src/core/lib/channel/channel_stack.c', 'src/core/lib/channel/channel_stack_builder.c', @@ -601,8 +600,8 @@ Pod::Spec.new do |s| 'src/core/ext/transport/chttp2/transport/writing.c', 'src/core/ext/transport/chttp2/alpn/alpn.c', 'src/core/ext/filters/http/client/http_client_filter.c', - 'src/core/ext/filters/http/message_compress/message_compress_filter.c', 'src/core/ext/filters/http/http_filters_plugin.c', + 'src/core/ext/filters/http/message_compress/message_compress_filter.c', 'src/core/ext/filters/http/server/http_server_filter.c', 'src/core/lib/http/httpcli_security_connector.c', 'src/core/lib/security/context/security_context.c', @@ -653,6 +652,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/subchannel.c', 'src/core/ext/filters/client_channel/subchannel_index.c', 'src/core/ext/filters/client_channel/uri_parser.c', + 'src/core/ext/filters/deadline/deadline_filter.c', 'src/core/ext/transport/chttp2/client/chttp2_connector.c', 'src/core/ext/transport/chttp2/server/insecure/server_chttp2.c', 'src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c', @@ -706,7 +706,6 @@ Pod::Spec.new do |s| 'src/core/lib/support/thd_internal.h', 'src/core/lib/support/time_precise.h', 'src/core/lib/support/tmpfile.h', - 'src/core/ext/filters/deadline/deadline_filter.h', 'src/core/lib/channel/channel_args.h', 'src/core/lib/channel/channel_stack.h', 'src/core/lib/channel/channel_stack_builder.h', @@ -877,6 +876,7 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/subchannel.h', 'src/core/ext/filters/client_channel/subchannel_index.h', 'src/core/ext/filters/client_channel/uri_parser.h', + 'src/core/ext/filters/deadline/deadline_filter.h', 'src/core/ext/transport/chttp2/client/chttp2_connector.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h', diff --git a/grpc.gemspec b/grpc.gemspec index 2a6563f879..a1a32a6bd2 100755 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -171,7 +171,6 @@ Gem::Specification.new do |s| s.files += %w( include/grpc/impl/codegen/sync_windows.h ) s.files += %w( include/grpc/grpc_security.h ) s.files += %w( include/grpc/census.h ) - s.files += %w( src/core/ext/filters/deadline/deadline_filter.h ) s.files += %w( src/core/lib/channel/channel_args.h ) s.files += %w( src/core/lib/channel/channel_stack.h ) s.files += %w( src/core/lib/channel/channel_stack_builder.h ) @@ -342,6 +341,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/subchannel.h ) s.files += %w( src/core/ext/filters/client_channel/subchannel_index.h ) s.files += %w( src/core/ext/filters/client_channel/uri_parser.h ) + s.files += %w( src/core/ext/filters/deadline/deadline_filter.h ) s.files += %w( src/core/ext/transport/chttp2/client/chttp2_connector.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h ) s.files += %w( src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h ) @@ -374,7 +374,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/max_age/max_age_filter.h ) s.files += %w( src/core/ext/filters/message_size/message_size_filter.h ) s.files += %w( src/core/lib/surface/init.c ) - s.files += %w( src/core/ext/filters/deadline/deadline_filter.c ) s.files += %w( src/core/lib/channel/channel_args.c ) s.files += %w( src/core/lib/channel/channel_stack.c ) s.files += %w( src/core/lib/channel/channel_stack_builder.c ) @@ -517,8 +516,8 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/transport/chttp2/transport/writing.c ) s.files += %w( src/core/ext/transport/chttp2/alpn/alpn.c ) s.files += %w( src/core/ext/filters/http/client/http_client_filter.c ) - s.files += %w( src/core/ext/filters/http/message_compress/message_compress_filter.c ) s.files += %w( src/core/ext/filters/http/http_filters_plugin.c ) + s.files += %w( src/core/ext/filters/http/message_compress/message_compress_filter.c ) s.files += %w( src/core/ext/filters/http/server/http_server_filter.c ) s.files += %w( src/core/lib/http/httpcli_security_connector.c ) s.files += %w( src/core/lib/security/context/security_context.c ) @@ -569,6 +568,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/subchannel.c ) s.files += %w( src/core/ext/filters/client_channel/subchannel_index.c ) s.files += %w( src/core/ext/filters/client_channel/uri_parser.c ) + s.files += %w( src/core/ext/filters/deadline/deadline_filter.c ) s.files += %w( src/core/ext/transport/chttp2/client/chttp2_connector.c ) s.files += %w( src/core/ext/transport/chttp2/server/insecure/server_chttp2.c ) s.files += %w( src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c ) diff --git a/package.xml b/package.xml index 0771774b4c..a1ad15b108 100644 --- a/package.xml +++ b/package.xml @@ -180,7 +180,6 @@ - @@ -351,6 +350,7 @@ + @@ -383,7 +383,6 @@ - @@ -526,8 +525,8 @@ - + @@ -578,6 +577,7 @@ + diff --git a/src/core/ext/filters/client_channel/client_channel.c b/src/core/ext/filters/client_channel/client_channel.c index 1cc324ed3f..16be2c70e9 100644 --- a/src/core/ext/filters/client_channel/client_channel.c +++ b/src/core/ext/filters/client_channel/client_channel.c @@ -1278,8 +1278,7 @@ static grpc_error *cc_init_call_elem(grpc_exec_ctx *exec_ctx, calld->owning_call = args->call_stack; calld->arena = args->arena; if (chand->deadline_checking_enabled) { - grpc_deadline_state_init(exec_ctx, elem, args->call_stack); - grpc_deadline_state_start(exec_ctx, elem, calld->deadline); + grpc_deadline_state_init(exec_ctx, elem, args->call_stack, calld->deadline); } return GRPC_ERROR_NONE; } diff --git a/src/core/ext/filters/deadline/deadline_filter.c b/src/core/ext/filters/deadline/deadline_filter.c index ae2398c831..da12cc3e78 100644 --- a/src/core/ext/filters/deadline/deadline_filter.c +++ b/src/core/ext/filters/deadline/deadline_filter.c @@ -143,18 +143,6 @@ static void inject_on_complete_cb(grpc_deadline_state* deadline_state, op->on_complete = &deadline_state->on_complete; } -void grpc_deadline_state_init(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, - grpc_call_stack* call_stack) { - grpc_deadline_state* deadline_state = elem->call_data; - deadline_state->call_stack = call_stack; -} - -void grpc_deadline_state_destroy(grpc_exec_ctx* exec_ctx, - grpc_call_element* elem) { - grpc_deadline_state* deadline_state = elem->call_data; - cancel_timer_if_needed(exec_ctx, deadline_state); -} - // Callback and associated state for starting the timer after call stack // initialization has been completed. struct start_timer_after_init_state { @@ -169,8 +157,11 @@ static void start_timer_after_init(grpc_exec_ctx* exec_ctx, void* arg, gpr_free(state); } -void grpc_deadline_state_start(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, - gpr_timespec deadline) { +void grpc_deadline_state_init(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, + grpc_call_stack* call_stack, + gpr_timespec deadline) { + grpc_deadline_state* deadline_state = elem->call_data; + deadline_state->call_stack = call_stack; // Deadline will always be infinite on servers, so the timer will only be // set on clients with a finite deadline. deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC); @@ -191,6 +182,12 @@ void grpc_deadline_state_start(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, } } +void grpc_deadline_state_destroy(grpc_exec_ctx* exec_ctx, + grpc_call_element* elem) { + grpc_deadline_state* deadline_state = elem->call_data; + cancel_timer_if_needed(exec_ctx, deadline_state); +} + void grpc_deadline_state_reset(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, gpr_timespec new_deadline) { grpc_deadline_state* deadline_state = elem->call_data; @@ -250,8 +247,7 @@ typedef struct server_call_data { static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, const grpc_call_element_args* args) { - grpc_deadline_state_init(exec_ctx, elem, args->call_stack); - grpc_deadline_state_start(exec_ctx, elem, args->deadline); + grpc_deadline_state_init(exec_ctx, elem, args->call_stack, args->deadline); return GRPC_ERROR_NONE; } diff --git a/src/core/ext/filters/deadline/deadline_filter.h b/src/core/ext/filters/deadline/deadline_filter.h index 830dcd5eaa..5050453fa1 100644 --- a/src/core/ext/filters/deadline/deadline_filter.h +++ b/src/core/ext/filters/deadline/deadline_filter.h @@ -64,15 +64,11 @@ typedef struct grpc_deadline_state { // assumes elem->call_data is zero'd void grpc_deadline_state_init(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, - grpc_call_stack* call_stack); + grpc_call_stack* call_stack, + gpr_timespec deadline); void grpc_deadline_state_destroy(grpc_exec_ctx* exec_ctx, grpc_call_element* elem); -// Starts the timer with the specified deadline. -// Should be called from the filter's init_call_elem() method. -void grpc_deadline_state_start(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, - gpr_timespec deadline); - // Cancels the existing timer and starts a new one with new_deadline. // // Note: It is generally safe to call this with an earlier deadline diff --git a/src/core/ext/filters/http/message_compress/message_compress_filter.h b/src/core/ext/filters/http/message_compress/message_compress_filter.h index 68d2b8766a..d80d3a79ca 100644 --- a/src/core/ext/filters/http/message_compress/message_compress_filter.h +++ b/src/core/ext/filters/http/message_compress/message_compress_filter.h @@ -62,6 +62,6 @@ extern int grpc_compression_trace; * aforementioned 'grpc-encoding' metadata value, data will pass through * uncompressed. */ -extern const grpc_channel_filter grpc_compress_filter; +extern const grpc_channel_filter grpc_message_compress_filter; #endif /* GRPC_CORE_EXT_FILTERS_HTTP_COMPRESS_COMPRESS_FILTER_H */ diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index afaf2acaa4..a5c38012b3 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -77,7 +77,6 @@ CORE_SOURCE_FILES = [ 'src/core/lib/support/tmpfile_windows.c', 'src/core/lib/support/wrap_memcpy.c', 'src/core/lib/surface/init.c', - 'src/core/ext/filters/deadline/deadline_filter.c', 'src/core/lib/channel/channel_args.c', 'src/core/lib/channel/channel_stack.c', 'src/core/lib/channel/channel_stack_builder.c', @@ -220,8 +219,8 @@ CORE_SOURCE_FILES = [ 'src/core/ext/transport/chttp2/transport/writing.c', 'src/core/ext/transport/chttp2/alpn/alpn.c', 'src/core/ext/filters/http/client/http_client_filter.c', - 'src/core/ext/filters/http/message_compress/message_compress_filter.c', 'src/core/ext/filters/http/http_filters_plugin.c', + 'src/core/ext/filters/http/message_compress/message_compress_filter.c', 'src/core/ext/filters/http/server/http_server_filter.c', 'src/core/lib/http/httpcli_security_connector.c', 'src/core/lib/security/context/security_context.c', @@ -272,6 +271,7 @@ CORE_SOURCE_FILES = [ 'src/core/ext/filters/client_channel/subchannel.c', 'src/core/ext/filters/client_channel/subchannel_index.c', 'src/core/ext/filters/client_channel/uri_parser.c', + 'src/core/ext/filters/deadline/deadline_filter.c', 'src/core/ext/transport/chttp2/client/chttp2_connector.c', 'src/core/ext/transport/chttp2/server/insecure/server_chttp2.c', 'src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c', diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 759c7071d0..32df90f35d 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -900,8 +900,6 @@ include/grpc/load_reporting.h \ include/grpc/slice.h \ include/grpc/slice_buffer.h \ include/grpc/status.h \ -src/core/ext/filters/deadline/deadline_filter.c \ -src/core/ext/filters/deadline/deadline_filter.h \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_args.h \ src/core/lib/channel/channel_stack.c \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index ca38e2fe0f..3378bc19c9 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -958,9 +958,9 @@ src/core/ext/filters/deadline/deadline_filter.c \ src/core/ext/filters/deadline/deadline_filter.h \ src/core/ext/filters/http/client/http_client_filter.c \ src/core/ext/filters/http/client/http_client_filter.h \ +src/core/ext/filters/http/http_filters_plugin.c \ src/core/ext/filters/http/message_compress/message_compress_filter.c \ src/core/ext/filters/http/message_compress/message_compress_filter.h \ -src/core/ext/filters/http/http_filters_plugin.c \ src/core/ext/filters/http/server/http_server_filter.c \ src/core/ext/filters/http/server/http_server_filter.h \ src/core/ext/filters/load_reporting/load_reporting.c \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 63d6419146..b7aefd4175 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -7535,7 +7535,6 @@ "include/grpc/slice.h", "include/grpc/slice_buffer.h", "include/grpc/status.h", - "src/core/ext/filters/deadline/deadline_filter.h", "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.h", "src/core/lib/channel/channel_stack_builder.h", @@ -7656,8 +7655,6 @@ "include/grpc/slice.h", "include/grpc/slice_buffer.h", "include/grpc/status.h", - "src/core/ext/filters/deadline/deadline_filter.c", - "src/core/ext/filters/deadline/deadline_filter.h", "src/core/lib/channel/channel_args.c", "src/core/lib/channel/channel_args.h", "src/core/lib/channel/channel_stack.c", @@ -8022,9 +8019,9 @@ "src": [ "src/core/ext/filters/http/client/http_client_filter.c", "src/core/ext/filters/http/client/http_client_filter.h", + "src/core/ext/filters/http/http_filters_plugin.c", "src/core/ext/filters/http/message_compress/message_compress_filter.c", "src/core/ext/filters/http/message_compress/message_compress_filter.h", - "src/core/ext/filters/http/http_filters_plugin.c", "src/core/ext/filters/http/server/http_server_filter.c", "src/core/ext/filters/http/server/http_server_filter.h" ], diff --git a/vsprojects/vcxproj/grpc++/grpc++.vcxproj b/vsprojects/vcxproj/grpc++/grpc++.vcxproj index 7ffd0202e0..36a805d842 100644 --- a/vsprojects/vcxproj/grpc++/grpc++.vcxproj +++ b/vsprojects/vcxproj/grpc++/grpc++.vcxproj @@ -377,7 +377,6 @@ - @@ -571,8 +570,6 @@ - - diff --git a/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters b/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters index 5390d96a13..f526a929a8 100644 --- a/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters @@ -124,9 +124,6 @@ src\cpp\util - - src\core\ext\filters\deadline - src\core\lib\channel @@ -851,9 +848,6 @@ src\cpp\thread_manager - - src\core\ext\filters\deadline - src\core\lib\channel @@ -1226,15 +1220,6 @@ {d02f1155-7e7e-3736-3c69-dc9146dc523d} - - {96d09c4a-59f9-3486-6c2f-cbf695b285d8} - - - {ec936f3c-c278-59b3-1fcf-d17ab77c8546} - - - {136a9e7f-2e8b-7cff-c961-5149529ca0f5} - {80567a8f-622f-a3ce-c12d-aebb63984b07} diff --git a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj index c954241d31..d71f09d88e 100644 --- a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj @@ -371,7 +371,6 @@ - @@ -555,8 +554,6 @@ - - diff --git a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters index 9b2463fdee..fedd2c57d4 100644 --- a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters @@ -109,9 +109,6 @@ src\cpp\util - - src\core\ext\filters\deadline - src\core\lib\channel @@ -818,9 +815,6 @@ src\cpp\thread_manager - - src\core\ext\filters\deadline - src\core\lib\channel @@ -1193,15 +1187,6 @@ {595f2ea0-aafb-87e5-c938-db3ff0b0c69a} - - {52eca76b-9502-3d96-9064-6415226a860f} - - - {d2564ab1-6815-d425-3f8a-31693cc2ac81} - - - {0cc70f19-99bb-5e9e-99d9-b103398c0e76} - {cf8fd5d8-ff54-331d-2d20-36d6cae0e14b} diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj b/vsprojects/vcxproj/grpc/grpc.vcxproj index 093ac413bb..da8b2ea8fb 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj @@ -300,7 +300,6 @@ - @@ -426,7 +425,7 @@ - + @@ -471,6 +470,7 @@ + @@ -506,8 +506,6 @@ - - @@ -792,10 +790,10 @@ - - + + @@ -896,6 +894,8 @@ + + diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters index 14a30993c8..3eac38b539 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters @@ -4,9 +4,6 @@ src\core\lib\surface - - src\core\ext\filters\deadline - src\core\lib\channel @@ -433,12 +430,12 @@ src\core\ext\filters\http\client - - src\core\ext\filters\http\compress - src\core\ext\filters\http + + src\core\ext\filters\http\message_compress + src\core\ext\filters\http\server @@ -589,6 +586,9 @@ src\core\ext\filters\client_channel + + src\core\ext\filters\deadline + src\core\ext\transport\chttp2\client @@ -800,9 +800,6 @@ - - src\core\ext\filters\deadline - src\core\lib\channel @@ -1178,8 +1175,8 @@ src\core\ext\filters\http\client - - src\core\ext\filters\http\compress + + src\core\ext\filters\http\message_compress src\core\ext\filters\http\server @@ -1313,6 +1310,9 @@ src\core\ext\filters\client_channel + + src\core\ext\filters\deadline + src\core\ext\transport\chttp2\client @@ -1490,8 +1490,8 @@ {e4f7616b-2b49-7df9-8ca3-eb7848d4609d} - - {8f3d6045-e672-b61f-437e-052557970f41} + + {7b595f5a-c5b5-29fe-74c2-5ec5fd5c94d2} {a40e82ca-0c04-35b8-898d-7ad5f323d110} diff --git a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj index f549452cc9..6118d5982b 100644 --- a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj +++ b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj @@ -195,7 +195,6 @@ - @@ -343,8 +342,6 @@ - - diff --git a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters index 11dfb8baa5..89c6413a47 100644 --- a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters +++ b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters @@ -61,9 +61,6 @@ test\core\util - - src\core\ext\filters\deadline - src\core\lib\channel @@ -563,9 +560,6 @@ test\core\util - - src\core\ext\filters\deadline - src\core\lib\channel @@ -902,15 +896,6 @@ {f7bfac91-5eb2-dea7-4601-6c63edbbf997} - - {5db70e06-741d-708c-bf0a-b59f8ca1f8bd} - - - {f0f88514-c2d8-c4c9-c3bd-591682207751} - - - {2c9ab189-bb7e-355d-9f37-385472e86b9f} - {f4e8c61e-1ca6-0fdd-7b5e-b7f9a30c9a21} diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj index cfad8b85b9..f71771dcb8 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj @@ -290,7 +290,6 @@ - @@ -416,7 +415,7 @@ - + @@ -438,6 +437,7 @@ + @@ -474,8 +474,6 @@ - - @@ -762,10 +760,10 @@ - - + + @@ -816,6 +814,8 @@ + + diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters index 153fb856ee..fdcd668a2f 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters @@ -7,9 +7,6 @@ src\core\lib\surface - - src\core\ext\filters\deadline - src\core\lib\channel @@ -439,12 +436,12 @@ src\core\ext\filters\http\client - - src\core\ext\filters\http\compress - src\core\ext\filters\http + + src\core\ext\filters\http\message_compress + src\core\ext\filters\http\server @@ -520,6 +517,9 @@ src\core\ext\filters\client_channel + + src\core\ext\filters\deadline + src\core\ext\filters\client_channel\resolver\dns\c_ares @@ -713,9 +713,6 @@ - - src\core\ext\filters\deadline - src\core\lib\channel @@ -1091,8 +1088,8 @@ src\core\ext\filters\http\client - - src\core\ext\filters\http\compress + + src\core\ext\filters\http\message_compress src\core\ext\filters\http\server @@ -1157,6 +1154,9 @@ src\core\ext\filters\client_channel + + src\core\ext\filters\deadline + src\core\ext\filters\client_channel\resolver\dns\c_ares @@ -1331,8 +1331,8 @@ {95cd5972-7339-6f09-2332-e6769b3cba3f} - - {b257d9a5-2100-4b83-9a03-d28707827b1e} + + {cf8cb886-3020-e143-317e-730ff9bbddc3} {2c1e7897-6f69-f8b9-0b90-5c3fae59a48f} -- cgit v1.2.3 From e376970691b972e54bf5242a7ede9305bb508f1d Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 6 Apr 2017 09:13:34 -0700 Subject: Fix bool/pointer mixup --- src/core/ext/filters/http/http_filters_plugin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/ext/filters/http/http_filters_plugin.c b/src/core/ext/filters/http/http_filters_plugin.c index 093a8c7dce..a6ba194e69 100644 --- a/src/core/ext/filters/http/http_filters_plugin.c +++ b/src/core/ext/filters/http/http_filters_plugin.c @@ -51,7 +51,7 @@ static optional_filter compress_filter = { static bool is_building_http_like_transport( grpc_channel_stack_builder *builder) { grpc_transport *t = grpc_channel_stack_builder_get_transport(builder); - return t && strstr(t->vtable->name, "http"); + return t != NULL && strstr(t->vtable->name, "http"); } static bool maybe_add_optional_filter(grpc_exec_ctx *exec_ctx, -- cgit v1.2.3 From 41f2ed68c41fda998aa99e98b97ae4982233e6b8 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 6 Apr 2017 09:33:48 -0700 Subject: Cleanup filter selection --- src/core/ext/filters/deadline/deadline_filter.c | 10 ++--- src/core/ext/filters/http/http_filters_plugin.c | 9 ++-- .../ext/filters/load_reporting/load_reporting.c | 10 +---- src/core/ext/filters/max_age/max_age_filter.c | 28 ++++++------- .../ext/filters/message_size/message_size_filter.c | 49 +++++++++------------- src/core/lib/channel/channel_args.c | 28 ++++++++++--- src/core/lib/channel/channel_args.h | 5 ++- 7 files changed, 69 insertions(+), 70 deletions(-) diff --git a/src/core/ext/filters/deadline/deadline_filter.c b/src/core/ext/filters/deadline/deadline_filter.c index da12cc3e78..2e03d16bf6 100644 --- a/src/core/ext/filters/deadline/deadline_filter.c +++ b/src/core/ext/filters/deadline/deadline_filter.c @@ -346,13 +346,9 @@ const grpc_channel_filter grpc_server_deadline_filter = { }; bool grpc_deadline_checking_enabled(const grpc_channel_args* channel_args) { - bool enable = !grpc_channel_args_want_minimal_stack(channel_args); - const grpc_arg* a = - grpc_channel_args_find(channel_args, GRPC_ARG_ENABLE_DEADLINE_CHECKS); - if (a != NULL && a->type == GRPC_ARG_INTEGER && a->value.integer != 0) { - enable = true; - } - return enable; + return grpc_channel_arg_get_bool( + grpc_channel_args_find(channel_args, GRPC_ARG_ENABLE_DEADLINE_CHECKS), + !grpc_channel_args_want_minimal_stack(channel_args)); } static bool maybe_add_deadline_filter(grpc_exec_ctx* exec_ctx, diff --git a/src/core/ext/filters/http/http_filters_plugin.c b/src/core/ext/filters/http/http_filters_plugin.c index a6ba194e69..195a1a8119 100644 --- a/src/core/ext/filters/http/http_filters_plugin.c +++ b/src/core/ext/filters/http/http_filters_plugin.c @@ -61,12 +61,9 @@ static bool maybe_add_optional_filter(grpc_exec_ctx *exec_ctx, optional_filter *filtarg = arg; const grpc_channel_args *channel_args = grpc_channel_stack_builder_get_channel_arguments(builder); - bool enable = !grpc_channel_args_want_minimal_stack(channel_args); - const grpc_arg *ctlarg = - grpc_channel_args_find(channel_args, filtarg->control_channel_arg); - if (ctlarg != NULL) { - enable = !(ctlarg->type == GRPC_ARG_INTEGER && ctlarg->value.integer == 0); - } + bool enable = grpc_channel_arg_get_bool( + grpc_channel_args_find(channel_args, filtarg->control_channel_arg), + !grpc_channel_args_want_minimal_stack(channel_args)); return enable ? grpc_channel_stack_builder_prepend_filter( builder, filtarg->filter, NULL, NULL) : true; diff --git a/src/core/ext/filters/load_reporting/load_reporting.c b/src/core/ext/filters/load_reporting/load_reporting.c index 9fb33bab71..adb5e8b93b 100644 --- a/src/core/ext/filters/load_reporting/load_reporting.c +++ b/src/core/ext/filters/load_reporting/load_reporting.c @@ -63,14 +63,8 @@ void grpc_call_set_load_reporting_cost_context( } static bool is_load_reporting_enabled(const grpc_channel_args *a) { - if (a == NULL) return false; - for (size_t i = 0; i < a->num_args; i++) { - if (0 == strcmp(a->args[i].key, GRPC_ARG_ENABLE_LOAD_REPORTING)) { - return a->args[i].type == GRPC_ARG_INTEGER && - a->args[i].value.integer != 0; - } - } - return false; + return grpc_channel_arg_get_bool( + grpc_channel_args_find(a, GRPC_ARG_ENABLE_LOAD_REPORTING), false); } static bool maybe_add_load_reporting_filter(grpc_exec_ctx *exec_ctx, diff --git a/src/core/ext/filters/max_age/max_age_filter.c b/src/core/ext/filters/max_age/max_age_filter.c index 72c1d9174d..0ae2357276 100644 --- a/src/core/ext/filters/max_age/max_age_filter.c +++ b/src/core/ext/filters/max_age/max_age_filter.c @@ -48,6 +48,11 @@ #define DEFAULT_MAX_CONNECTION_IDLE_MS INT_MAX #define MAX_CONNECTION_AGE_JITTER 0.1 +#define MAX_CONNECTION_AGE_INTEGER_OPTIONS \ + (grpc_integer_options) { DEFAULT_MAX_CONNECTION_AGE_MS, 1, INT_MAX } +#define MAX_CONNECTION_IDLE_INTEGER_OPTIONS \ + (grpc_integer_options) { DEFAULT_MAX_CONNECTION_IDLE_MS, 1, INT_MAX } + typedef struct channel_data { /* We take a reference to the channel stack for the timer callback */ grpc_channel_stack* channel_stack; @@ -315,8 +320,7 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx, if (0 == strcmp(args->channel_args->args[i].key, GRPC_ARG_MAX_CONNECTION_AGE_MS)) { const int value = grpc_channel_arg_get_integer( - &args->channel_args->args[i], - (grpc_integer_options){DEFAULT_MAX_CONNECTION_AGE_MS, 1, INT_MAX}); + &args->channel_args->args[i], MAX_CONNECTION_AGE_INTEGER_OPTIONS); chand->max_connection_age = value == INT_MAX ? gpr_inf_future(GPR_TIMESPAN) @@ -334,8 +338,7 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx, } else if (0 == strcmp(args->channel_args->args[i].key, GRPC_ARG_MAX_CONNECTION_IDLE_MS)) { const int value = grpc_channel_arg_get_integer( - &args->channel_args->args[i], - (grpc_integer_options){DEFAULT_MAX_CONNECTION_IDLE_MS, 1, INT_MAX}); + &args->channel_args->args[i], MAX_CONNECTION_IDLE_INTEGER_OPTIONS); chand->max_connection_idle = value == INT_MAX ? gpr_inf_future(GPR_TIMESPAN) : gpr_time_from_millis(value, GPR_TIMESPAN); @@ -412,16 +415,13 @@ static bool maybe_add_max_age_filter(grpc_exec_ctx* exec_ctx, void* arg) { const grpc_channel_args* channel_args = grpc_channel_stack_builder_get_channel_arguments(builder); - const grpc_arg* a = - grpc_channel_args_find(channel_args, GRPC_ARG_MAX_CONNECTION_AGE_MS); - bool enable = false; - if (a != NULL && a->type == GRPC_ARG_INTEGER && a->value.integer != INT_MAX) { - enable = true; - } - a = grpc_channel_args_find(channel_args, GRPC_ARG_MAX_CONNECTION_IDLE_MS); - if (a != NULL && a->type == GRPC_ARG_INTEGER && a->value.integer != INT_MAX) { - enable = true; - } + bool enable = + grpc_channel_arg_get_integer( + grpc_channel_args_find(channel_args, GRPC_ARG_MAX_CONNECTION_AGE_MS), + MAX_CONNECTION_AGE_INTEGER_OPTIONS) != INT_MAX && + grpc_channel_arg_get_integer( + grpc_channel_args_find(channel_args, GRPC_ARG_MAX_CONNECTION_IDLE_MS), + MAX_CONNECTION_IDLE_INTEGER_OPTIONS) != INT_MAX; if (enable) { return grpc_channel_stack_builder_prepend_filter( builder, &grpc_max_age_filter, NULL, NULL); diff --git a/src/core/ext/filters/message_size/message_size_filter.c b/src/core/ext/filters/message_size/message_size_filter.c index d152d82968..7cb2c346fd 100644 --- a/src/core/ext/filters/message_size/message_size_filter.c +++ b/src/core/ext/filters/message_size/message_size_filter.c @@ -91,8 +91,7 @@ static void* message_size_limits_create_from_json(const grpc_json* json) { } typedef struct call_data { - int max_send_size; - int max_recv_size; + message_size_limits limits; // Receive closures are chained: we inject this closure as the // recv_message_ready up-call on transport_stream_op, and remember to // call our next_recv_message_ready member after handling it. @@ -104,8 +103,7 @@ typedef struct call_data { } call_data; typedef struct channel_data { - int max_send_size; - int max_recv_size; + message_size_limits limits; // Maps path names to message_size_limits structs. grpc_slice_hash_table* method_limit_table; } channel_data; @@ -116,12 +114,12 @@ static void recv_message_ready(grpc_exec_ctx* exec_ctx, void* user_data, grpc_error* error) { grpc_call_element* elem = user_data; call_data* calld = elem->call_data; - if (*calld->recv_message != NULL && calld->max_recv_size >= 0 && - (*calld->recv_message)->length > (size_t)calld->max_recv_size) { + if (*calld->recv_message != NULL && calld->limits.max_recv_size >= 0 && + (*calld->recv_message)->length > (size_t)calld->limits.max_recv_size) { char* message_string; gpr_asprintf(&message_string, "Received message larger than max (%u vs. %d)", - (*calld->recv_message)->length, calld->max_recv_size); + (*calld->recv_message)->length, calld->limits.max_recv_size); grpc_error* new_error = grpc_error_set_int( GRPC_ERROR_CREATE_FROM_COPIED_STRING(message_string), GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_INVALID_ARGUMENT); @@ -143,13 +141,13 @@ static void start_transport_stream_op_batch( grpc_transport_stream_op_batch* op) { call_data* calld = elem->call_data; // Check max send message size. - if (op->send_message && calld->max_send_size >= 0 && + if (op->send_message && calld->limits.max_send_size >= 0 && op->payload->send_message.send_message->length > - (size_t)calld->max_send_size) { + (size_t)calld->limits.max_send_size) { char* message_string; gpr_asprintf(&message_string, "Sent message larger than max (%u vs. %d)", op->payload->send_message.send_message->length, - calld->max_send_size); + calld->limits.max_send_size); grpc_transport_stream_op_batch_finish_with_failure( exec_ctx, op, grpc_error_set_int(GRPC_ERROR_CREATE_FROM_COPIED_STRING(message_string), @@ -182,21 +180,20 @@ static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx, // Note: Per-method config is only available on the client, so we // apply the max request size to the send limit and the max response // size to the receive limit. - calld->max_send_size = chand->max_send_size; - calld->max_recv_size = chand->max_recv_size; + calld->limits = chand->limits; if (chand->method_limit_table != NULL) { message_size_limits* limits = grpc_method_config_table_get( exec_ctx, chand->method_limit_table, args->path); if (limits != NULL) { if (limits->max_send_size >= 0 && - (limits->max_send_size < calld->max_send_size || - calld->max_send_size < 0)) { - calld->max_send_size = limits->max_send_size; + (limits->max_send_size < calld->limits.max_send_size || + calld->limits.max_send_size < 0)) { + calld->limits.max_send_size = limits->max_send_size; } if (limits->max_recv_size >= 0 && - (limits->max_recv_size < calld->max_recv_size || - calld->max_recv_size < 0)) { - calld->max_recv_size = limits->max_recv_size; + (limits->max_recv_size < calld->limits.max_recv_size || + calld->limits.max_recv_size < 0)) { + calld->limits.max_recv_size = limits->max_recv_size; } } } @@ -216,13 +213,9 @@ static int default_size(const grpc_channel_args* args, return without_minimal_stack; } -typedef struct { - int max_recv_size; - int max_send_size; -} channel_limits; - -channel_limits get_channel_limits(const grpc_channel_args* channel_args) { - channel_limits lim; +message_size_limits get_message_size_limits( + const grpc_channel_args* channel_args) { + message_size_limits lim; lim.max_send_size = default_size(channel_args, GRPC_DEFAULT_MAX_SEND_MESSAGE_LENGTH); lim.max_recv_size = @@ -254,9 +247,7 @@ static grpc_error* init_channel_elem(grpc_exec_ctx* exec_ctx, grpc_channel_element_args* args) { GPR_ASSERT(!args->is_last); channel_data* chand = elem->channel_data; - channel_limits lim = get_channel_limits(args->channel_args); - chand->max_send_size = lim.max_send_size; - chand->max_recv_size = lim.max_recv_size; + chand->limits = get_message_size_limits(args->channel_args); // Get method config table from channel args. const grpc_arg* channel_arg = grpc_channel_args_find(args->channel_args, GRPC_ARG_SERVICE_CONFIG); @@ -302,7 +293,7 @@ static bool maybe_add_message_size_filter(grpc_exec_ctx* exec_ctx, const grpc_channel_args* channel_args = grpc_channel_stack_builder_get_channel_arguments(builder); bool enable = false; - channel_limits lim = get_channel_limits(channel_args); + message_size_limits lim = get_message_size_limits(channel_args); if (lim.max_send_size != INT_MAX || lim.max_recv_size != INT_MAX) { enable = true; } diff --git a/src/core/lib/channel/channel_args.c b/src/core/lib/channel/channel_args.c index a6d124c719..3de31d99da 100644 --- a/src/core/lib/channel/channel_args.c +++ b/src/core/lib/channel/channel_args.c @@ -329,7 +329,9 @@ const grpc_arg *grpc_channel_args_find(const grpc_channel_args *args, return NULL; } -int grpc_channel_arg_get_integer(grpc_arg *arg, grpc_integer_options options) { +int grpc_channel_arg_get_integer(const grpc_arg *arg, + grpc_integer_options options) { + if (arg == NULL) return options.default_value; if (arg->type != GRPC_ARG_INTEGER) { gpr_log(GPR_ERROR, "%s ignored: it must be an integer", arg->key); return options.default_value; @@ -347,9 +349,25 @@ int grpc_channel_arg_get_integer(grpc_arg *arg, grpc_integer_options options) { return arg->value.integer; } +bool grpc_channel_arg_get_bool(const grpc_arg *arg, bool default_value) { + if (arg == NULL) return default_value; + if (arg->type != GRPC_ARG_INTEGER) { + gpr_log(GPR_ERROR, "%s ignored: it must be an integer", arg->key); + return default_value; + } + switch (arg->value.integer) { + case 0: + return false; + case 1: + return true; + default: + gpr_log(GPR_ERROR, "%s treated as bool but set to %d (assuming true)", + arg->key, arg->value.integer); + return true; + } +} + bool grpc_channel_args_want_minimal_stack(const grpc_channel_args *args) { - const grpc_arg *arg = grpc_channel_args_find(args, GRPC_ARG_MINIMAL_STACK); - if (arg == NULL) return false; - if (arg->type == GRPC_ARG_INTEGER && arg->value.integer == 0) return false; - return true; + return grpc_channel_arg_get_bool( + grpc_channel_args_find(args, GRPC_ARG_MINIMAL_STACK), false); } diff --git a/src/core/lib/channel/channel_args.h b/src/core/lib/channel/channel_args.h index 158cda5b21..5ffcacb7fd 100644 --- a/src/core/lib/channel/channel_args.h +++ b/src/core/lib/channel/channel_args.h @@ -121,6 +121,9 @@ typedef struct grpc_integer_options { int max_value; } grpc_integer_options; /** Returns the value of \a arg, subject to the contraints in \a options. */ -int grpc_channel_arg_get_integer(grpc_arg *arg, grpc_integer_options options); +int grpc_channel_arg_get_integer(const grpc_arg *arg, + grpc_integer_options options); + +bool grpc_channel_arg_get_bool(const grpc_arg *arg, bool default_value); #endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_ARGS_H */ -- cgit v1.2.3 From 5cecf68669aaab04f293d2f1249b50328d342ff7 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 6 Apr 2017 09:36:54 -0700 Subject: -1 --> unlimited --- src/core/ext/filters/message_size/message_size_filter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/ext/filters/message_size/message_size_filter.c b/src/core/ext/filters/message_size/message_size_filter.c index 7cb2c346fd..5626f39d7a 100644 --- a/src/core/ext/filters/message_size/message_size_filter.c +++ b/src/core/ext/filters/message_size/message_size_filter.c @@ -208,7 +208,7 @@ static void destroy_call_elem(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, static int default_size(const grpc_channel_args* args, int without_minimal_stack) { if (grpc_channel_args_want_minimal_stack(args)) { - return INT_MAX; + return -1; } return without_minimal_stack; } @@ -294,7 +294,7 @@ static bool maybe_add_message_size_filter(grpc_exec_ctx* exec_ctx, grpc_channel_stack_builder_get_channel_arguments(builder); bool enable = false; message_size_limits lim = get_message_size_limits(channel_args); - if (lim.max_send_size != INT_MAX || lim.max_recv_size != INT_MAX) { + if (lim.max_send_size != -1 || lim.max_recv_size != -1) { enable = true; } const grpc_arg* a = -- cgit v1.2.3 From 2024dbd6813648f6cc522395d126ae995dd2be5d Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 6 Apr 2017 09:40:15 -0700 Subject: cleanup options parsing --- src/core/ext/filters/message_size/message_size_filter.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/core/ext/filters/message_size/message_size_filter.c b/src/core/ext/filters/message_size/message_size_filter.c index 5626f39d7a..94184065cb 100644 --- a/src/core/ext/filters/message_size/message_size_filter.c +++ b/src/core/ext/filters/message_size/message_size_filter.c @@ -223,17 +223,13 @@ message_size_limits get_message_size_limits( for (size_t i = 0; i < channel_args->num_args; ++i) { if (strcmp(channel_args->args[i].key, GRPC_ARG_MAX_SEND_MESSAGE_LENGTH) == 0) { - const grpc_integer_options options = { - default_size(channel_args, GRPC_DEFAULT_MAX_SEND_MESSAGE_LENGTH), 0, - INT_MAX}; + const grpc_integer_options options = {lim.max_send_size, 0, INT_MAX}; lim.max_send_size = grpc_channel_arg_get_integer(&channel_args->args[i], options); } if (strcmp(channel_args->args[i].key, GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH) == 0) { - const grpc_integer_options options = { - default_size(channel_args, GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH), 0, - INT_MAX}; + const grpc_integer_options options = {lim.max_recv_size, 0, INT_MAX}; lim.max_recv_size = grpc_channel_arg_get_integer(&channel_args->args[i], options); } -- cgit v1.2.3 From dcd24e424157c4523f140cebb8618a8fd9e905a0 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 6 Apr 2017 10:47:46 -0700 Subject: BUILD --- BUILD | 1 + 1 file changed, 1 insertion(+) diff --git a/BUILD b/BUILD index 83cf3e651a..4982db9e5e 100644 --- a/BUILD +++ b/BUILD @@ -732,6 +732,7 @@ grpc_cc_library( language = "c", deps = [ "grpc_base", + "grpc_deadline_filter", ], ) -- cgit v1.2.3 From e1bfff0bbedd5c0b973e5a08839a957183e006de Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Thu, 6 Apr 2017 13:17:20 -0700 Subject: Fix test after merge --- test/core/end2end/tests/bad_ping.c | 1 + 1 file changed, 1 insertion(+) diff --git a/test/core/end2end/tests/bad_ping.c b/test/core/end2end/tests/bad_ping.c index 01a6aeaa04..38cd1dfa84 100644 --- a/test/core/end2end/tests/bad_ping.c +++ b/test/core/end2end/tests/bad_ping.c @@ -75,6 +75,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_shutdown(f->cq); drain_cq(f->cq); grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); } static void test_bad_ping(grpc_end2end_test_config config) { -- cgit v1.2.3 From 7b6c7a3927f75704cb3f7f02024f284b6817405a Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 6 Apr 2017 13:27:31 -0700 Subject: Fix include guards --- .../ext/filters/http/message_compress/message_compress_filter.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/ext/filters/http/message_compress/message_compress_filter.h b/src/core/ext/filters/http/message_compress/message_compress_filter.h index d80d3a79ca..75bfa17fba 100644 --- a/src/core/ext/filters/http/message_compress/message_compress_filter.h +++ b/src/core/ext/filters/http/message_compress/message_compress_filter.h @@ -31,8 +31,8 @@ * */ -#ifndef GRPC_CORE_EXT_FILTERS_HTTP_COMPRESS_COMPRESS_FILTER_H -#define GRPC_CORE_EXT_FILTERS_HTTP_COMPRESS_COMPRESS_FILTER_H +#ifndef GRPC_CORE_EXT_FILTERS_HTTP_MESSAGE_COMPRESS_MESSAGE_COMPRESS_FILTER_H +#define GRPC_CORE_EXT_FILTERS_HTTP_MESSAGE_COMPRESS_MESSAGE_COMPRESS_FILTER_H #include @@ -64,4 +64,5 @@ extern int grpc_compression_trace; extern const grpc_channel_filter grpc_message_compress_filter; -#endif /* GRPC_CORE_EXT_FILTERS_HTTP_COMPRESS_COMPRESS_FILTER_H */ +#endif /* GRPC_CORE_EXT_FILTERS_HTTP_MESSAGE_COMPRESS_MESSAGE_COMPRESS_FILTER_H \ + */ -- cgit v1.2.3 From dc0b8a60d3af630518ed1a27699430a2e9364a70 Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Fri, 7 Apr 2017 13:55:46 -0700 Subject: change cq_create to cq_create_for_next --- test/cpp/microbenchmarks/bm_cq_multiple_threads.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc index 967c226ac7..33b77368ad 100644 --- a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc +++ b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc @@ -106,7 +106,7 @@ static void setup() { init_engine_vtable(); grpc_set_event_engine_test_only(&g_vtable); - g_cq = grpc_completion_queue_create(NULL); + g_cq = grpc_completion_queue_create_for_next(NULL); } static void BM_Cq_Throughput(benchmark::State& state) { -- cgit v1.2.3 From 79962f33c71e248276486122097e33b038e537df Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Mon, 10 Apr 2017 14:37:43 -0700 Subject: Refactor tag completion handling into one function --- src/node/ext/call.cc | 32 ++++++++++++++--------------- src/node/ext/call.h | 6 +----- src/node/ext/completion_queue_threadpool.cc | 9 ++------ src/node/ext/completion_queue_uv.cc | 12 ++++------- 4 files changed, 22 insertions(+), 37 deletions(-) diff --git a/src/node/ext/call.cc b/src/node/ext/call.cc index 5d573110da..8d5e2ced6a 100644 --- a/src/node/ext/call.cc +++ b/src/node/ext/call.cc @@ -499,25 +499,23 @@ tag::~tag() { delete ops; } -Local GetTagNodeValue(void *tag) { - EscapableHandleScope scope; +void CompleteTag(void *tag, const char *error_message) { + HandleScope scope; struct tag *tag_struct = reinterpret_cast(tag); - Local tag_obj = Nan::New(); - for (vector >::iterator it = tag_struct->ops->begin(); - it != tag_struct->ops->end(); ++it) { - Op *op_ptr = it->get(); - Nan::Set(tag_obj, op_ptr->GetOpType(), op_ptr->GetNodeValue()); + Callback *callback = tag_struct->callback; + if (error_message == NULL) { + Local tag_obj = Nan::New(); + for (vector >::iterator it = tag_struct->ops->begin(); + it != tag_struct->ops->end(); ++it) { + Op *op_ptr = it->get(); + Nan::Set(tag_obj, op_ptr->GetOpType(), op_ptr->GetNodeValue()); + } + Local argv[] = {Nan::Null(), tag_obj}; + callback->Call(2, argv); + } else { + Local argv[] = {Nan::Error(error_message)}; + callback->Call(1, argv); } - return scope.Escape(tag_obj); -} - -Callback *GetTagCallback(void *tag) { - struct tag *tag_struct = reinterpret_cast(tag); - return tag_struct->callback; -} - -void CompleteTag(void *tag) { - struct tag *tag_struct = reinterpret_cast(tag); bool is_final_op = false; if (tag_struct->call == NULL) { return; diff --git a/src/node/ext/call.h b/src/node/ext/call.h index 53a5e4ab67..4316e9ed88 100644 --- a/src/node/ext/call.h +++ b/src/node/ext/call.h @@ -123,13 +123,9 @@ struct tag { call_persist; }; -v8::Local GetTagNodeValue(void *tag); - -Nan::Callback *GetTagCallback(void *tag); - void DestroyTag(void *tag); -void CompleteTag(void *tag); +void CompleteTag(void *tag, const char *error_message); } // namespace node } // namespace grpc diff --git a/src/node/ext/completion_queue_threadpool.cc b/src/node/ext/completion_queue_threadpool.cc index 1917074dc2..7b1bdda033 100644 --- a/src/node/ext/completion_queue_threadpool.cc +++ b/src/node/ext/completion_queue_threadpool.cc @@ -148,9 +148,7 @@ void CompletionQueueAsyncWorker::HandleOKCallback() { Nan::HandleScope scope; current_threads -= 1; TryAddWorker(); - Nan::Callback *callback = GetTagCallback(result.tag); - Local argv[] = {Nan::Null(), GetTagNodeValue(result.tag)}; - callback->Call(2, argv); + CompleteTag(result.tag, NULL); DestroyTag(result.tag); } @@ -159,10 +157,7 @@ void CompletionQueueAsyncWorker::HandleErrorCallback() { Nan::HandleScope scope; current_threads -= 1; TryAddWorker(); - Nan::Callback *callback = GetTagCallback(result.tag); - Local argv[] = {Nan::Error(ErrorMessage())}; - - callback->Call(1, argv); + CompleteTag(result.tag, ErrorMessage()); DestroyTag(result.tag); } diff --git a/src/node/ext/completion_queue_uv.cc b/src/node/ext/completion_queue_uv.cc index 615973a6c9..0f6f7da460 100644 --- a/src/node/ext/completion_queue_uv.cc +++ b/src/node/ext/completion_queue_uv.cc @@ -61,17 +61,13 @@ void drain_completion_queue(uv_prepare_t *handle) { queue, gpr_inf_past(GPR_CLOCK_MONOTONIC), NULL); if (event.type == GRPC_OP_COMPLETE) { - Nan::Callback *callback = grpc::node::GetTagCallback(event.tag); + const char *error_message; if (event.success) { - Local argv[] = {Nan::Null(), - grpc::node::GetTagNodeValue(event.tag)}; - callback->Call(2, argv); + error_message = NULL; } else { - Local argv[] = {Nan::Error( - "The async function encountered an error")}; - callback->Call(1, argv); + error_message = "The async function encountered an error"; } - grpc::node::CompleteTag(event.tag); + CompleteTag(event.tag, error_message); grpc::node::DestroyTag(event.tag); pending_batches--; if (pending_batches == 0) { -- cgit v1.2.3 From 42cfaa99bd3490bb0849fd66aa56016e763a56a8 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Mon, 10 Apr 2017 15:43:09 -0700 Subject: Add native tag completion callbacks, dispose of server after tryShutdown succeeds --- src/node/ext/call.cc | 23 ++++++++++++++++++++--- src/node/ext/call.h | 1 + src/node/ext/server.cc | 37 +++++++++++++++++++++++++++++++++++++ src/node/ext/server.h | 2 ++ src/node/ext/server_uv.cc | 3 +++ 5 files changed, 63 insertions(+), 3 deletions(-) diff --git a/src/node/ext/call.cc b/src/node/ext/call.cc index 8d5e2ced6a..bb11cfb83a 100644 --- a/src/node/ext/call.cc +++ b/src/node/ext/call.cc @@ -217,6 +217,8 @@ class SendMetadataOp : public Op { bool IsFinalOp() { return false; } + void OnComplete() { + } protected: std::string GetTypeString() const { return "send_metadata"; @@ -260,6 +262,8 @@ class SendMessageOp : public Op { bool IsFinalOp() { return false; } + void OnComplete() { + } protected: std::string GetTypeString() const { return "send_message"; @@ -280,6 +284,8 @@ class SendClientCloseOp : public Op { bool IsFinalOp() { return false; } + void OnComplete() { + } protected: std::string GetTypeString() const { return "client_close"; @@ -349,6 +355,8 @@ class SendServerStatusOp : public Op { bool IsFinalOp() { return true; } + void OnComplete() { + } protected: std::string GetTypeString() const { return "send_status"; @@ -381,6 +389,8 @@ class GetMetadataOp : public Op { bool IsFinalOp() { return false; } + void OnComplete() { + } protected: std::string GetTypeString() const { @@ -413,6 +423,8 @@ class ReadMessageOp : public Op { bool IsFinalOp() { return false; } + void OnComplete() { + } protected: std::string GetTypeString() const { @@ -454,6 +466,8 @@ class ClientStatusOp : public Op { bool IsFinalOp() { return true; } + void OnComplete() { + } protected: std::string GetTypeString() const { return "status"; @@ -478,6 +492,8 @@ class ServerCloseResponseOp : public Op { bool IsFinalOp() { return false; } + void OnComplete() { + } protected: std::string GetTypeString() const { @@ -517,16 +533,17 @@ void CompleteTag(void *tag, const char *error_message) { callback->Call(1, argv); } bool is_final_op = false; - if (tag_struct->call == NULL) { - return; - } for (vector >::iterator it = tag_struct->ops->begin(); it != tag_struct->ops->end(); ++it) { Op *op_ptr = it->get(); + op_ptr->OnComplete(); if (op_ptr->IsFinalOp()) { is_final_op = true; } } + if (tag_struct->call == NULL) { + return; + } tag_struct->call->CompleteBatch(is_final_op); } diff --git a/src/node/ext/call.h b/src/node/ext/call.h index 4316e9ed88..b38f50060c 100644 --- a/src/node/ext/call.h +++ b/src/node/ext/call.h @@ -106,6 +106,7 @@ class Op { virtual ~Op(); v8::Local GetOpType() const; virtual bool IsFinalOp() = 0; + virtual void OnComplete() = 0; protected: virtual std::string GetTypeString() const = 0; diff --git a/src/node/ext/server.cc b/src/node/ext/server.cc index f0920c842a..22c89c5862 100644 --- a/src/node/ext/server.cc +++ b/src/node/ext/server.cc @@ -117,6 +117,8 @@ class NewCallOp : public Op { bool IsFinalOp() { return false; } + void OnComplete() { + } grpc_call *call; grpc_call_details details; @@ -126,6 +128,32 @@ class NewCallOp : public Op { std::string GetTypeString() const { return "new_call"; } }; +class TryShutdownOp: public Op { + public: + TryShutdownOp(Server *server, Local server_value) : server(server) { + server_persist.Reset(server_value); + } + Local GetNodeValue() const { + EscapableHandleScope scope; + return scope.Escape(Nan::New(server_persist)); + } + bool ParseOp(Local value, grpc_op *out) { + return true; + } + bool IsFinalOp() { + return false; + } + void OnComplete() { + server->DestroyWrappedServer(); + } + protected: + std::string GetTypeString() const { return "try_shutdown"; } + private: + Server *server; + Nan::Persistent> + server_persist; +}; + void Server::Init(Local exports) { HandleScope scope; Local tpl = Nan::New(New); @@ -147,6 +175,13 @@ bool Server::HasInstance(Local val) { return Nan::New(fun_tpl)->HasInstance(val); } +void Server::DestroyWrappedServer() { + if (this->wrapped_server != NULL) { + grpc_server_destroy(this->wrapped_server); + this->wrapped_server = NULL; + } +} + NAN_METHOD(Server::New) { /* If this is not a constructor call, make a constructor call and return the result */ @@ -242,7 +277,9 @@ NAN_METHOD(Server::TryShutdown) { return Nan::ThrowTypeError("tryShutdown can only be called on a Server"); } Server *server = ObjectWrap::Unwrap(info.This()); + TryShutdownOp *op = new TryShutdownOp(server, info.This()); unique_ptr ops(new OpVec()); + ops->push_back(unique_ptr(op)); grpc_server_shutdown_and_notify( server->wrapped_server, GetCompletionQueue(), new struct tag(new Nan::Callback(info[0].As()), ops.release(), diff --git a/src/node/ext/server.h b/src/node/ext/server.h index ab5fc210e8..c0f2e86554 100644 --- a/src/node/ext/server.h +++ b/src/node/ext/server.h @@ -53,6 +53,8 @@ class Server : public Nan::ObjectWrap { JavaScript constructor */ static bool HasInstance(v8::Local val); + void DestroyWrappedServer(); + private: explicit Server(grpc_server *server); ~Server(); diff --git a/src/node/ext/server_uv.cc b/src/node/ext/server_uv.cc index 82e7589fc8..bf402e1961 100644 --- a/src/node/ext/server_uv.cc +++ b/src/node/ext/server_uv.cc @@ -76,6 +76,8 @@ class ServerShutdownOp : public Op { bool IsFinalOp() { return false; } + void OnComplete() { + } grpc_server *server; @@ -104,6 +106,7 @@ NAN_METHOD(ServerShutdownCallback) { } void Server::ShutdownServer() { + Nan::HandleScope scope; if (this->wrapped_server != NULL) { if (shutdown_callback == NULL) { Localcallback_tpl = -- cgit v1.2.3 From 95a15a137c67acf8ea2ed9bfd133acbede522714 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 11 Apr 2017 10:13:41 -0700 Subject: Deal with initial_metadata/send_message ordering issues in message_compress_filter --- .../message_compress/message_compress_filter.c | 80 +++++++++++++++++----- 1 file changed, 64 insertions(+), 16 deletions(-) diff --git a/src/core/ext/filters/http/message_compress/message_compress_filter.c b/src/core/ext/filters/http/message_compress/message_compress_filter.c index 1cbc852686..23b100d8ee 100644 --- a/src/core/ext/filters/http/message_compress/message_compress_filter.c +++ b/src/core/ext/filters/http/message_compress/message_compress_filter.c @@ -51,6 +51,10 @@ int grpc_compression_trace = 0; +#define INITIAL_METADATA_UNSEEN 0 +#define HAS_COMPRESSION_ALGORITHM 1 +#define NO_COMPRESSION_ALGORITHM 2 + typedef struct call_data { grpc_slice_buffer slices; /**< Buffers up input slices to be compressed */ grpc_linked_mdelem compression_algorithm_storage; @@ -59,8 +63,16 @@ typedef struct call_data { /** Compression algorithm we'll try to use. It may be given by incoming * metadata, or by the channel's default compression settings. */ grpc_compression_algorithm compression_algorithm; - /** If true, contents of \a compression_algorithm are authoritative */ - int has_compression_algorithm; + + /* Atomic recording the state of initial metadata; allowed values: + INITIAL_METADATA_UNSEEN - initial metadata op not seen + HAS_COMPRESSION_ALGORITHM - initial metadata seen; compression algorithm + set + NO_COMPRESSION_ALGORITHM - initial metadata seen; no compression algorithm + set + pointer - a stalled op containing a send_message that's waiting on initial + metadata */ + gpr_atm send_initial_metadata_state; grpc_transport_stream_op_batch *send_op; uint32_t send_length; @@ -81,14 +93,15 @@ typedef struct channel_data { uint32_t supported_compression_algorithms; } channel_data; -static int skip_compression(grpc_call_element *elem, uint32_t flags) { +static bool skip_compression(grpc_call_element *elem, uint32_t flags, + bool has_compression_algorithm) { call_data *calld = elem->call_data; channel_data *channeld = elem->channel_data; if (flags & (GRPC_WRITE_NO_COMPRESS | GRPC_WRITE_INTERNAL_COMPRESS)) { return 1; } - if (calld->has_compression_algorithm) { + if (has_compression_algorithm) { if (calld->compression_algorithm == GRPC_COMPRESS_NONE) { return 1; } @@ -101,12 +114,14 @@ static int skip_compression(grpc_call_element *elem, uint32_t flags) { /** Filter initial metadata */ static grpc_error *process_send_initial_metadata( grpc_exec_ctx *exec_ctx, grpc_call_element *elem, - grpc_metadata_batch *initial_metadata) GRPC_MUST_USE_RESULT; + grpc_metadata_batch *initial_metadata, + bool *has_compression_algorithm) GRPC_MUST_USE_RESULT; static grpc_error *process_send_initial_metadata( grpc_exec_ctx *exec_ctx, grpc_call_element *elem, - grpc_metadata_batch *initial_metadata) { + grpc_metadata_batch *initial_metadata, bool *has_compression_algorithm) { call_data *calld = elem->call_data; channel_data *channeld = elem->channel_data; + *has_compression_algorithm = false; /* Parse incoming request for compression. If any, it'll be available * at calld->compression_algorithm */ if (initial_metadata->idx.named.grpc_internal_encoding_request != NULL) { @@ -130,7 +145,7 @@ static grpc_error *process_send_initial_metadata( gpr_free(val); calld->compression_algorithm = GRPC_COMPRESS_NONE; } - calld->has_compression_algorithm = 1; + *has_compression_algorithm = true; grpc_metadata_batch_remove( exec_ctx, initial_metadata, @@ -140,7 +155,7 @@ static grpc_error *process_send_initial_metadata( * exceptionally skipping compression, fall back to the channel * default */ calld->compression_algorithm = channeld->default_compression_algorithm; - calld->has_compression_algorithm = 1; /* GPR_TRUE */ + *has_compression_algorithm = true; } grpc_error *error = GRPC_ERROR_NONE; @@ -251,20 +266,54 @@ static void compress_start_transport_stream_op_batch( GPR_TIMER_BEGIN("compress_start_transport_stream_op_batch", 0); if (op->send_initial_metadata) { + bool has_compression_algorithm; grpc_error *error = process_send_initial_metadata( exec_ctx, elem, - op->payload->send_initial_metadata.send_initial_metadata); + op->payload->send_initial_metadata.send_initial_metadata, + &has_compression_algorithm); if (error != GRPC_ERROR_NONE) { grpc_transport_stream_op_batch_finish_with_failure(exec_ctx, op, error); return; } + gpr_atm cur = gpr_atm_acq_load(&calld->send_initial_metadata_state); + GPR_ASSERT(cur != HAS_COMPRESSION_ALGORITHM && + cur != NO_COMPRESSION_ALGORITHM); + gpr_atm_rel_store(&calld->send_initial_metadata_state, + has_compression_algorithm ? HAS_COMPRESSION_ALGORITHM + : NO_COMPRESSION_ALGORITHM); + if (cur != INITIAL_METADATA_UNSEEN) { + grpc_call_next_op(exec_ctx, elem, (grpc_transport_stream_op_batch *)op); + } } - if (op->send_message && - !skip_compression(elem, op->payload->send_message.send_message->flags)) { - calld->send_op = op; - calld->send_length = op->payload->send_message.send_message->length; - calld->send_flags = op->payload->send_message.send_message->flags; - continue_send_message(exec_ctx, elem); + if (op->send_message) { + gpr_atm cur; + retry_send: + cur = gpr_atm_acq_load(&calld->send_initial_metadata_state); + switch (cur) { + case INITIAL_METADATA_UNSEEN: + if (!gpr_atm_rel_cas(&calld->send_initial_metadata_state, cur, + (gpr_atm)op)) { + goto retry_send; + } + break; + case HAS_COMPRESSION_ALGORITHM: + case NO_COMPRESSION_ALGORITHM: + if (!skip_compression(elem, + op->payload->send_message.send_message->flags, + cur == HAS_COMPRESSION_ALGORITHM)) { + calld->send_op = op; + calld->send_length = op->payload->send_message.send_message->length; + calld->send_flags = op->payload->send_message.send_message->flags; + continue_send_message(exec_ctx, elem); + } else { + /* pass control down the stack */ + grpc_call_next_op(exec_ctx, elem, op); + } + break; + default: + /* >1 send_message concurrently */ + GPR_UNREACHABLE_CODE(break); + } } else { /* pass control down the stack */ grpc_call_next_op(exec_ctx, elem, op); @@ -282,7 +331,6 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx, /* initialize members */ grpc_slice_buffer_init(&calld->slices); - calld->has_compression_algorithm = 0; grpc_closure_init(&calld->got_slice, got_slice, elem, grpc_schedule_on_exec_ctx); grpc_closure_init(&calld->send_done, send_done, elem, -- cgit v1.2.3 From 19b1f5edc98cd2d86629c1af226e2d1ccddf4752 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 11 Apr 2017 10:17:10 -0700 Subject: Allow unlimited size messages --- src/core/ext/filters/message_size/message_size_filter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/ext/filters/message_size/message_size_filter.c b/src/core/ext/filters/message_size/message_size_filter.c index 94184065cb..455958d575 100644 --- a/src/core/ext/filters/message_size/message_size_filter.c +++ b/src/core/ext/filters/message_size/message_size_filter.c @@ -223,13 +223,13 @@ message_size_limits get_message_size_limits( for (size_t i = 0; i < channel_args->num_args; ++i) { if (strcmp(channel_args->args[i].key, GRPC_ARG_MAX_SEND_MESSAGE_LENGTH) == 0) { - const grpc_integer_options options = {lim.max_send_size, 0, INT_MAX}; + const grpc_integer_options options = {lim.max_send_size, -1, INT_MAX}; lim.max_send_size = grpc_channel_arg_get_integer(&channel_args->args[i], options); } if (strcmp(channel_args->args[i].key, GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH) == 0) { - const grpc_integer_options options = {lim.max_recv_size, 0, INT_MAX}; + const grpc_integer_options options = {lim.max_recv_size, -1, INT_MAX}; lim.max_recv_size = grpc_channel_arg_get_integer(&channel_args->args[i], options); } -- cgit v1.2.3 From c22d62f54e342b40d5352ed565c1629943a667db Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Tue, 11 Apr 2017 11:39:32 -0700 Subject: Move ForceShutdown completion handling to new OnComplete method --- src/node/ext/server_uv.cc | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/node/ext/server_uv.cc b/src/node/ext/server_uv.cc index bf402e1961..6a31b89249 100644 --- a/src/node/ext/server_uv.cc +++ b/src/node/ext/server_uv.cc @@ -67,7 +67,7 @@ class ServerShutdownOp : public Op { } Local GetNodeValue() const { - return Nan::New(reinterpret_cast(server)); + return Nan::Null(); } bool ParseOp(Local value, grpc_op *out) { @@ -77,6 +77,7 @@ class ServerShutdownOp : public Op { return false; } void OnComplete() { + grpc_server_destroy(server); } grpc_server *server; @@ -96,13 +97,6 @@ NAN_METHOD(ServerShutdownCallback) { if (!info[0]->IsNull()) { return Nan::ThrowError("forceShutdown failed somehow"); } - MaybeLocal maybe_result = Nan::To(info[1]); - Local result = maybe_result.ToLocalChecked(); - Local server_val = Nan::Get( - result, Nan::New("shutdown").ToLocalChecked()).ToLocalChecked(); - Local server_extern = server_val.As(); - grpc_server *server = reinterpret_cast(server_extern->Value()); - grpc_server_destroy(server); } void Server::ShutdownServer() { -- cgit v1.2.3 From 803392e9f14baeedfe37308cf0ff47978bf3f5e6 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Tue, 11 Apr 2017 12:13:08 -0700 Subject: Node server: add NULL check to tryShutdown --- src/node/ext/server.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/node/ext/server.cc b/src/node/ext/server.cc index 22c89c5862..2d017dd048 100644 --- a/src/node/ext/server.cc +++ b/src/node/ext/server.cc @@ -277,6 +277,12 @@ NAN_METHOD(Server::TryShutdown) { return Nan::ThrowTypeError("tryShutdown can only be called on a Server"); } Server *server = ObjectWrap::Unwrap(info.This()); + if (server->wrapped_server == NULL) { + // Server is already shut down. Call callback immediately. + Nan::Callback callback(info[0].As()); + callback.Call(0, {}); + return; + } TryShutdownOp *op = new TryShutdownOp(server, info.This()); unique_ptr ops(new OpVec()); ops->push_back(unique_ptr(op)); -- cgit v1.2.3 From 9d9313cfc650e79b44f95d9b7fd9e75e2dc38111 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 11 Apr 2017 15:05:46 -0700 Subject: Threading robustness Move server startup to a separate thread. Where there is no opportunity for failure, do not return bool. --- include/grpc++/impl/codegen/server_interface.h | 2 +- include/grpc++/server.h | 2 +- src/core/lib/surface/server.c | 19 ++++++++++++++----- src/cpp/server/server_builder.cc | 5 +---- src/cpp/server/server_cc.cc | 4 +--- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/include/grpc++/impl/codegen/server_interface.h b/include/grpc++/impl/codegen/server_interface.h index bd1b36e883..7975011704 100644 --- a/include/grpc++/impl/codegen/server_interface.h +++ b/include/grpc++/impl/codegen/server_interface.h @@ -124,7 +124,7 @@ class ServerInterface : public CallHook { /// \param num_cqs How many completion queues does \a cqs hold. /// /// \return true on a successful shutdown. - virtual bool Start(ServerCompletionQueue** cqs, size_t num_cqs) = 0; + virtual void Start(ServerCompletionQueue** cqs, size_t num_cqs) = 0; virtual void ShutdownInternal(gpr_timespec deadline) = 0; diff --git a/include/grpc++/server.h b/include/grpc++/server.h index 489937712e..af90a5c70b 100644 --- a/include/grpc++/server.h +++ b/include/grpc++/server.h @@ -179,7 +179,7 @@ class Server final : public ServerInterface, private GrpcLibraryCodegen { /// \param num_cqs How many completion queues does \a cqs hold. /// /// \return true on a successful shutdown. - bool Start(ServerCompletionQueue** cqs, size_t num_cqs) override; + void Start(ServerCompletionQueue** cqs, size_t num_cqs) override; void PerformOpsOnCall(CallOpSetInterface* ops, Call* call) override; diff --git a/src/core/lib/surface/server.c b/src/core/lib/surface/server.c index 191ee75252..6ac3181482 100644 --- a/src/core/lib/surface/server.c +++ b/src/core/lib/surface/server.c @@ -44,6 +44,7 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/iomgr/executor.h" #include "src/core/lib/iomgr/iomgr.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/support/stack_lockfree.h" @@ -1077,8 +1078,16 @@ void *grpc_server_register_method( return m; } +static void start_listeners(grpc_exec_ctx *exec_ctx, void *s, + grpc_error *error) { + grpc_server *server = s; + for (listener *l = server->listeners; l; l = l->next) { + l->start(exec_ctx, server, l->arg, server->pollsets, server->pollset_count); + } + server_unref(exec_ctx, server); +} + void grpc_server_start(grpc_server *server) { - listener *l; size_t i; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -1112,10 +1121,10 @@ void grpc_server_start(grpc_server *server) { (size_t)server->max_requested_calls_per_cq, server); } - for (l = server->listeners; l; l = l->next) { - l->start(&exec_ctx, server, l->arg, server->pollsets, - server->pollset_count); - } + server_ref(server); + grpc_closure_sched(&exec_ctx, grpc_closure_create(start_listeners, server, + grpc_executor_scheduler), + GRPC_ERROR_NONE); grpc_exec_ctx_finish(&exec_ctx); } diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc index 4eb4b5a1b2..3a15afc49e 100644 --- a/src/cpp/server/server_builder.cc +++ b/src/cpp/server/server_builder.cc @@ -337,10 +337,7 @@ std::unique_ptr ServerBuilder::BuildAndStart() { } auto cqs_data = cqs_.empty() ? nullptr : &cqs_[0]; - if (!server->Start(cqs_data, cqs_.size())) { - if (added_port) server->Shutdown(); - return nullptr; - } + server->Start(cqs_data, cqs_.size()); for (auto plugin = plugins_.begin(); plugin != plugins_.end(); plugin++) { (*plugin)->Finish(initializer); diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc index ce173a1ee2..43e9531f17 100644 --- a/src/cpp/server/server_cc.cc +++ b/src/cpp/server/server_cc.cc @@ -494,7 +494,7 @@ int Server::AddListeningPort(const grpc::string& addr, return port; } -bool Server::Start(ServerCompletionQueue** cqs, size_t num_cqs) { +void Server::Start(ServerCompletionQueue** cqs, size_t num_cqs) { GPR_ASSERT(!started_); global_callbacks_->PreServerStart(this); started_ = true; @@ -530,8 +530,6 @@ bool Server::Start(ServerCompletionQueue** cqs, size_t num_cqs) { for (auto it = sync_req_mgrs_.begin(); it != sync_req_mgrs_.end(); it++) { (*it)->Start(); } - - return true; } void Server::ShutdownInternal(gpr_timespec deadline) { -- cgit v1.2.3 From 017a335d2b1170dafe4731c69c4fec9fad42a4ba Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Tue, 11 Apr 2017 14:34:04 -0700 Subject: Only delete core-level server if shutdown was successful --- src/node/ext/call.cc | 19 ++++++++++--------- src/node/ext/call.h | 2 +- src/node/ext/server.cc | 8 +++++--- src/node/ext/server_uv.cc | 4 +++- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/node/ext/call.cc b/src/node/ext/call.cc index bb11cfb83a..bd60775aad 100644 --- a/src/node/ext/call.cc +++ b/src/node/ext/call.cc @@ -217,7 +217,7 @@ class SendMetadataOp : public Op { bool IsFinalOp() { return false; } - void OnComplete() { + void OnComplete(bool success) { } protected: std::string GetTypeString() const { @@ -262,7 +262,7 @@ class SendMessageOp : public Op { bool IsFinalOp() { return false; } - void OnComplete() { + void OnComplete(bool success) { } protected: std::string GetTypeString() const { @@ -284,7 +284,7 @@ class SendClientCloseOp : public Op { bool IsFinalOp() { return false; } - void OnComplete() { + void OnComplete(bool success) { } protected: std::string GetTypeString() const { @@ -355,7 +355,7 @@ class SendServerStatusOp : public Op { bool IsFinalOp() { return true; } - void OnComplete() { + void OnComplete(bool success) { } protected: std::string GetTypeString() const { @@ -389,7 +389,7 @@ class GetMetadataOp : public Op { bool IsFinalOp() { return false; } - void OnComplete() { + void OnComplete(bool success) { } protected: @@ -423,7 +423,7 @@ class ReadMessageOp : public Op { bool IsFinalOp() { return false; } - void OnComplete() { + void OnComplete(bool success) { } protected: @@ -466,7 +466,7 @@ class ClientStatusOp : public Op { bool IsFinalOp() { return true; } - void OnComplete() { + void OnComplete(bool success) { } protected: std::string GetTypeString() const { @@ -492,7 +492,7 @@ class ServerCloseResponseOp : public Op { bool IsFinalOp() { return false; } - void OnComplete() { + void OnComplete(bool success) { } protected: @@ -532,11 +532,12 @@ void CompleteTag(void *tag, const char *error_message) { Local argv[] = {Nan::Error(error_message)}; callback->Call(1, argv); } + bool success = (error_message == NULL); bool is_final_op = false; for (vector >::iterator it = tag_struct->ops->begin(); it != tag_struct->ops->end(); ++it) { Op *op_ptr = it->get(); - op_ptr->OnComplete(); + op_ptr->OnComplete(success); if (op_ptr->IsFinalOp()) { is_final_op = true; } diff --git a/src/node/ext/call.h b/src/node/ext/call.h index b38f50060c..340e32682b 100644 --- a/src/node/ext/call.h +++ b/src/node/ext/call.h @@ -106,7 +106,7 @@ class Op { virtual ~Op(); v8::Local GetOpType() const; virtual bool IsFinalOp() = 0; - virtual void OnComplete() = 0; + virtual void OnComplete(bool success) = 0; protected: virtual std::string GetTypeString() const = 0; diff --git a/src/node/ext/server.cc b/src/node/ext/server.cc index 2d017dd048..5384305631 100644 --- a/src/node/ext/server.cc +++ b/src/node/ext/server.cc @@ -117,7 +117,7 @@ class NewCallOp : public Op { bool IsFinalOp() { return false; } - void OnComplete() { + void OnComplete(bool success) { } grpc_call *call; @@ -143,8 +143,10 @@ class TryShutdownOp: public Op { bool IsFinalOp() { return false; } - void OnComplete() { - server->DestroyWrappedServer(); + void OnComplete(bool success) { + if (success) { + server->DestroyWrappedServer(); + } } protected: std::string GetTypeString() const { return "try_shutdown"; } diff --git a/src/node/ext/server_uv.cc b/src/node/ext/server_uv.cc index 6a31b89249..789938318e 100644 --- a/src/node/ext/server_uv.cc +++ b/src/node/ext/server_uv.cc @@ -76,7 +76,9 @@ class ServerShutdownOp : public Op { bool IsFinalOp() { return false; } - void OnComplete() { + void OnComplete(bool success) { + /* Because cancel_all_calls was called, we assume that shutdown_and_notify + completes successfully */ grpc_server_destroy(server); } -- cgit v1.2.3 From e1b238458feb5ca7fabfa8f1a06bde8e6d1d0294 Mon Sep 17 00:00:00 2001 From: Makarand Dharmapurikar Date: Tue, 11 Apr 2017 16:18:40 -0700 Subject: modified caching test added logic to test that cached response is specific to request payload. Removed trailing '\0' from query parameter --- src/core/lib/channel/http_client_filter.c | 4 +--- test/cpp/interop/interop_client.cc | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/core/lib/channel/http_client_filter.c b/src/core/lib/channel/http_client_filter.c index 4e47c5c658..917a769f8a 100644 --- a/src/core/lib/channel/http_client_filter.c +++ b/src/core/lib/channel/http_client_filter.c @@ -332,10 +332,8 @@ static grpc_error *hc_mutate_op(grpc_exec_ctx *exec_ctx, */ char *t = (char *)GRPC_SLICE_START_PTR(path_with_query_slice); /* safe to use strlen since base64_encode will always add '\0' */ - size_t path_length = strlen(t) + 1; - *(t + path_length) = '\0'; path_with_query_slice = - grpc_slice_sub(path_with_query_slice, 0, path_length); + grpc_slice_sub(path_with_query_slice, 0, strlen(t)); /* substitute previous path with the new path+query */ grpc_mdelem mdelem_path_and_query = grpc_mdelem_from_slices( diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc index 55ba324cc7..0e79c5e4b4 100644 --- a/test/cpp/interop/interop_client.cc +++ b/test/cpp/interop/interop_client.cc @@ -918,6 +918,26 @@ bool InteropClient::DoCacheableUnary() { // second response is a cached copy of the first response GPR_ASSERT(response2.payload().body() == response1.payload().body()); + // Request 3 + // Modify the request body so it will not get a cache hit + ts = gpr_now(GPR_CLOCK_PRECISE); + timestamp = std::to_string((long long unsigned)ts.tv_nsec); + SimpleRequest request1; + request1.mutable_payload()->set_body(timestamp.c_str(), timestamp.size()); + ClientContext context3; + SimpleResponse response3; + context3.set_cacheable(true); + context3.AddMetadata("x-user-ip", "1.2.3.4"); + Status s3 = + serviceStub_.Get()->CacheableUnaryCall(&context3, request1, &response3); + if (!AssertStatusOk(s3)) { + return false; + } + gpr_log(GPR_DEBUG, "response 3 payload: %s", + response3.payload().body().c_str()); + + // Check that the response is different from the previous response. + GPR_ASSERT(response3.payload().body() != response1.payload().body()); return true; } -- cgit v1.2.3 From 220bc643f9b4bd8c87f080fd618c9460e55566be Mon Sep 17 00:00:00 2001 From: Makarand Dharmapurikar Date: Tue, 11 Apr 2017 16:24:17 -0700 Subject: enable cacheable_unary test --- test/cpp/interop/client.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc index 369413e6a1..ea27f2827d 100644 --- a/test/cpp/interop/client.cc +++ b/test/cpp/interop/client.cc @@ -163,8 +163,8 @@ int main(int argc, char** argv) { std::bind(&grpc::testing::InteropClient::DoUnimplementedMethod, &client); actions["unimplemented_service"] = std::bind(&grpc::testing::InteropClient::DoUnimplementedService, &client); - // actions["cacheable_unary"] = - // std::bind(&grpc::testing::InteropClient::DoCacheableUnary, &client); + actions["cacheable_unary"] = + std::bind(&grpc::testing::InteropClient::DoCacheableUnary, &client); UpdateActions(&actions); -- cgit v1.2.3 From 2ad8a9b654606488b8c1d8453a5a855e1b5555b9 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 11 Apr 2017 20:59:14 -0700 Subject: Handle cancellation --- .../message_compress/message_compress_filter.c | 39 +++++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/src/core/ext/filters/http/message_compress/message_compress_filter.c b/src/core/ext/filters/http/message_compress/message_compress_filter.c index 23b100d8ee..61ab3d26d8 100644 --- a/src/core/ext/filters/http/message_compress/message_compress_filter.c +++ b/src/core/ext/filters/http/message_compress/message_compress_filter.c @@ -54,6 +54,7 @@ int grpc_compression_trace = 0; #define INITIAL_METADATA_UNSEEN 0 #define HAS_COMPRESSION_ALGORITHM 1 #define NO_COMPRESSION_ALGORITHM 2 +#define CANCELLED 3 typedef struct call_data { grpc_slice_buffer slices; /**< Buffers up input slices to be compressed */ @@ -70,6 +71,7 @@ typedef struct call_data { set NO_COMPRESSION_ALGORITHM - initial metadata seen; no compression algorithm set + CANCELLED - request was cancelled pointer - a stalled op containing a send_message that's waiting on initial metadata */ gpr_atm send_initial_metadata_state; @@ -265,6 +267,26 @@ static void compress_start_transport_stream_op_batch( GPR_TIMER_BEGIN("compress_start_transport_stream_op_batch", 0); + if (op->cancel_stream) { + gpr_atm cur; + do { + cur = gpr_atm_acq_load(&calld->send_initial_metadata_state); + } while ( + !gpr_atm_rel_cas(&calld->send_initial_metadata_state, cur, CANCELLED)); + switch (cur) { + case HAS_COMPRESSION_ALGORITHM: + case NO_COMPRESSION_ALGORITHM: + case INITIAL_METADATA_UNSEEN: + case CANCELLED: + break; + default: + grpc_transport_stream_op_batch_finish_with_failure( + exec_ctx, (grpc_transport_stream_op_batch *)cur, + GRPC_ERROR_CANCELLED); + break; + } + } + if (op->send_initial_metadata) { bool has_compression_algorithm; grpc_error *error = process_send_initial_metadata( @@ -278,11 +300,14 @@ static void compress_start_transport_stream_op_batch( gpr_atm cur = gpr_atm_acq_load(&calld->send_initial_metadata_state); GPR_ASSERT(cur != HAS_COMPRESSION_ALGORITHM && cur != NO_COMPRESSION_ALGORITHM); - gpr_atm_rel_store(&calld->send_initial_metadata_state, - has_compression_algorithm ? HAS_COMPRESSION_ALGORITHM - : NO_COMPRESSION_ALGORITHM); - if (cur != INITIAL_METADATA_UNSEEN) { - grpc_call_next_op(exec_ctx, elem, (grpc_transport_stream_op_batch *)op); + if (cur != CANCELLED) { + gpr_atm_rel_store(&calld->send_initial_metadata_state, + has_compression_algorithm ? HAS_COMPRESSION_ALGORITHM + : NO_COMPRESSION_ALGORITHM); + if (cur != INITIAL_METADATA_UNSEEN) { + grpc_call_next_op(exec_ctx, elem, + (grpc_transport_stream_op_batch *)cur); + } } } if (op->send_message) { @@ -296,6 +321,10 @@ static void compress_start_transport_stream_op_batch( goto retry_send; } break; + case CANCELLED: + grpc_transport_stream_op_batch_finish_with_failure( + exec_ctx, op, GRPC_ERROR_CANCELLED); + break; case HAS_COMPRESSION_ALGORITHM: case NO_COMPRESSION_ALGORITHM: if (!skip_compression(elem, -- cgit v1.2.3 From feb77ef996b946371c4abb77fdf86f53ee968809 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 12 Apr 2017 07:10:22 -0700 Subject: Get cancel error right --- .../message_compress/message_compress_filter.c | 46 +++++++++++++--------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/src/core/ext/filters/http/message_compress/message_compress_filter.c b/src/core/ext/filters/http/message_compress/message_compress_filter.c index 61ab3d26d8..978dbd61d4 100644 --- a/src/core/ext/filters/http/message_compress/message_compress_filter.c +++ b/src/core/ext/filters/http/message_compress/message_compress_filter.c @@ -52,9 +52,10 @@ int grpc_compression_trace = 0; #define INITIAL_METADATA_UNSEEN 0 -#define HAS_COMPRESSION_ALGORITHM 1 -#define NO_COMPRESSION_ALGORITHM 2 -#define CANCELLED 3 +#define HAS_COMPRESSION_ALGORITHM 2 +#define NO_COMPRESSION_ALGORITHM 4 + +#define CANCELLED_BIT ((gpr_atm)1) typedef struct call_data { grpc_slice_buffer slices; /**< Buffers up input slices to be compressed */ @@ -71,9 +72,9 @@ typedef struct call_data { set NO_COMPRESSION_ALGORITHM - initial metadata seen; no compression algorithm set - CANCELLED - request was cancelled pointer - a stalled op containing a send_message that's waiting on initial - metadata */ + metadata + pointer | CANCELLED_BIT - request was cancelled with error pointed to */ gpr_atm send_initial_metadata_state; grpc_transport_stream_op_batch *send_op; @@ -269,20 +270,23 @@ static void compress_start_transport_stream_op_batch( if (op->cancel_stream) { gpr_atm cur; + GRPC_ERROR_REF(op->payload->cancel_stream.cancel_error); do { cur = gpr_atm_acq_load(&calld->send_initial_metadata_state); - } while ( - !gpr_atm_rel_cas(&calld->send_initial_metadata_state, cur, CANCELLED)); + } while (!gpr_atm_rel_cas( + &calld->send_initial_metadata_state, cur, + CANCELLED_BIT | (gpr_atm)op->payload->cancel_stream.cancel_error)); switch (cur) { case HAS_COMPRESSION_ALGORITHM: case NO_COMPRESSION_ALGORITHM: case INITIAL_METADATA_UNSEEN: - case CANCELLED: break; default: - grpc_transport_stream_op_batch_finish_with_failure( - exec_ctx, (grpc_transport_stream_op_batch *)cur, - GRPC_ERROR_CANCELLED); + if ((cur & CANCELLED_BIT) == 0) { + grpc_transport_stream_op_batch_finish_with_failure( + exec_ctx, (grpc_transport_stream_op_batch *)cur, + op->payload->cancel_stream.cancel_error); + } break; } } @@ -300,7 +304,7 @@ static void compress_start_transport_stream_op_batch( gpr_atm cur = gpr_atm_acq_load(&calld->send_initial_metadata_state); GPR_ASSERT(cur != HAS_COMPRESSION_ALGORITHM && cur != NO_COMPRESSION_ALGORITHM); - if (cur != CANCELLED) { + if ((cur & CANCELLED_BIT) == 0) { gpr_atm_rel_store(&calld->send_initial_metadata_state, has_compression_algorithm ? HAS_COMPRESSION_ALGORITHM : NO_COMPRESSION_ALGORITHM); @@ -321,10 +325,6 @@ static void compress_start_transport_stream_op_batch( goto retry_send; } break; - case CANCELLED: - grpc_transport_stream_op_batch_finish_with_failure( - exec_ctx, op, GRPC_ERROR_CANCELLED); - break; case HAS_COMPRESSION_ALGORITHM: case NO_COMPRESSION_ALGORITHM: if (!skip_compression(elem, @@ -340,8 +340,13 @@ static void compress_start_transport_stream_op_batch( } break; default: - /* >1 send_message concurrently */ - GPR_UNREACHABLE_CODE(break); + if (cur & CANCELLED_BIT) { + grpc_transport_stream_op_batch_finish_with_failure( + exec_ctx, op, (grpc_error *)(cur & ~CANCELLED_BIT)); + } else { + /* >1 send_message concurrently */ + GPR_UNREACHABLE_CODE(break); + } } } else { /* pass control down the stack */ @@ -375,6 +380,11 @@ static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, /* grab pointers to our data from the call element */ call_data *calld = elem->call_data; grpc_slice_buffer_destroy_internal(exec_ctx, &calld->slices); + gpr_atm imstate = + gpr_atm_no_barrier_load(&calld->send_initial_metadata_state); + if (imstate & CANCELLED_BIT) { + GRPC_ERROR_UNREF((grpc_error *)(imstate & ~CANCELLED_BIT)); + } } /* Constructor for channel_data */ -- cgit v1.2.3 From bd3cc405290c8f4d4e1ea42b15652e172b34410f Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 12 Apr 2017 08:06:44 -0700 Subject: Add synchronization so startup completes before shutdown begins --- src/core/lib/surface/server.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/core/lib/surface/server.c b/src/core/lib/surface/server.c index 6ac3181482..da4dd703d5 100644 --- a/src/core/lib/surface/server.c +++ b/src/core/lib/surface/server.c @@ -212,6 +212,11 @@ struct grpc_server { gpr_mu mu_global; /* mutex for server and channel state */ gpr_mu mu_call; /* mutex for call-specific state */ + /* startup synchronization: flag is protected by mu_global, signals whether + we are doing the listener start routine or not */ + bool starting; + gpr_cv starting_cv; + registered_method *registered_methods; /** one request matcher for unregistered methods */ request_matcher unregistered_request_matcher; @@ -389,6 +394,7 @@ static void server_delete(grpc_exec_ctx *exec_ctx, grpc_server *server) { grpc_channel_args_destroy(exec_ctx, server->channel_args); gpr_mu_destroy(&server->mu_global); gpr_mu_destroy(&server->mu_call); + gpr_cv_destroy(&server->starting_cv); while ((rm = server->registered_methods) != NULL) { server->registered_methods = rm->next; if (server->started) { @@ -1022,6 +1028,7 @@ grpc_server *grpc_server_create(const grpc_channel_args *args, void *reserved) { gpr_mu_init(&server->mu_global); gpr_mu_init(&server->mu_call); + gpr_cv_init(&server->starting_cv); /* decremented by grpc_server_destroy */ gpr_ref_init(&server->internal_refcount, 1); @@ -1084,6 +1091,12 @@ static void start_listeners(grpc_exec_ctx *exec_ctx, void *s, for (listener *l = server->listeners; l; l = l->next) { l->start(exec_ctx, server, l->arg, server->pollsets, server->pollset_count); } + + gpr_mu_lock(&server->mu_global); + server->starting = false; + gpr_cv_signal(&server->starting_cv); + gpr_mu_unlock(&server->mu_global); + server_unref(exec_ctx, server); } @@ -1122,6 +1135,7 @@ void grpc_server_start(grpc_server *server) { } server_ref(server); + server->starting = true; grpc_closure_sched(&exec_ctx, grpc_closure_create(start_listeners, server, grpc_executor_scheduler), GRPC_ERROR_NONE); @@ -1258,8 +1272,14 @@ void grpc_server_shutdown_and_notify(grpc_server *server, GRPC_API_TRACE("grpc_server_shutdown_and_notify(server=%p, cq=%p, tag=%p)", 3, (server, cq, tag)); - /* lock, and gather up some stuff to do */ + /* wait for startup to be finished: locks mu_global */ gpr_mu_lock(&server->mu_global); + while (server->starting) { + gpr_cv_wait(&server->starting_cv, &server->mu_global, + gpr_inf_future(GPR_CLOCK_REALTIME)); + } + + /* stay locked, and gather up some stuff to do */ grpc_cq_begin_op(cq, tag); if (server->shutdown_published) { grpc_cq_end_op(&exec_ctx, cq, tag, GRPC_ERROR_NONE, done_published_shutdown, -- cgit v1.2.3 From 161e4baf74eaf760cd028a833a5a05d3e51796ae Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 12 Apr 2017 09:14:26 -0700 Subject: Fix memory leak --- src/core/ext/filters/http/message_compress/message_compress_filter.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/ext/filters/http/message_compress/message_compress_filter.c b/src/core/ext/filters/http/message_compress/message_compress_filter.c index 978dbd61d4..00bd271dd5 100644 --- a/src/core/ext/filters/http/message_compress/message_compress_filter.c +++ b/src/core/ext/filters/http/message_compress/message_compress_filter.c @@ -286,6 +286,8 @@ static void compress_start_transport_stream_op_batch( grpc_transport_stream_op_batch_finish_with_failure( exec_ctx, (grpc_transport_stream_op_batch *)cur, op->payload->cancel_stream.cancel_error); + } else { + GRPC_ERROR_UNREF((grpc_error*)(cur & ~CANCELLED_BIT)); } break; } -- cgit v1.2.3 From 70a2a4b01ae451d746d314cb18dcc372d094cf3e Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Wed, 12 Apr 2017 10:23:35 -0700 Subject: Bump version to 1.2.4 --- BUILD | 2 +- CMakeLists.txt | 2 +- Makefile | 4 ++-- build.yaml | 2 +- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.json | 2 +- package.xml | 4 ++-- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Auth/project.json | 4 ++-- src/csharp/Grpc.Core.Testing/project.json | 4 ++-- src/csharp/Grpc.Core/VersionInfo.cs | 4 ++-- src/csharp/Grpc.Core/project.json | 2 +- src/csharp/Grpc.HealthCheck/project.json | 4 ++-- src/csharp/Grpc.Reflection/project.json | 4 ++-- src/csharp/build_packages_dotnetcli.bat | 2 +- src/csharp/build_packages_dotnetcli.sh | 4 ++-- src/node/health_check/package.json | 4 ++-- src/node/tools/package.json | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/private/version.h | 2 +- src/php/composer.json | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 33 files changed, 42 insertions(+), 42 deletions(-) diff --git a/BUILD b/BUILD index 680722ac66..0893b81c9b 100644 --- a/BUILD +++ b/BUILD @@ -41,7 +41,7 @@ g_stands_for = "green" core_version = "3.0.0-dev" -version = "1.2.3" +version = "1.2.4" grpc_cc_library( name = "gpr", diff --git a/CMakeLists.txt b/CMakeLists.txt index e09f729733..725c2db0e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,7 @@ cmake_minimum_required(VERSION 2.8) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.2.3") +set(PACKAGE_VERSION "1.2.4") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index 7f9e203c95..41b803fe0b 100644 --- a/Makefile +++ b/Makefile @@ -412,8 +412,8 @@ Q = @ endif CORE_VERSION = 3.0.0-dev -CPP_VERSION = 1.2.3 -CSHARP_VERSION = 1.2.3 +CPP_VERSION = 1.2.4 +CSHARP_VERSION = 1.2.4 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/build.yaml b/build.yaml index ac183a91b5..1a9c07e1ad 100644 --- a/build.yaml +++ b/build.yaml @@ -14,7 +14,7 @@ settings: '#10': See the expand_version.py for all the quirks here core_version: 3.0.0-dev g_stands_for: green - version: 1.2.3 + version: 1.2.4 filegroups: - name: census public_headers: diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 9e6218d031..3f75650c99 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -37,7 +37,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.2.3' + version = '1.2.4' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'http://www.grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index a4b56fe105..c1eaa721bd 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -36,7 +36,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.2.3' + version = '1.2.4' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'http://www.grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index a567e6aa0f..15234ea8cc 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -36,7 +36,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.2.3' + version = '1.2.4' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'http://www.grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index 891f9a5aeb..a79c28ea5a 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -35,7 +35,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.2.3' + version = '1.2.4' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'http://www.grpc.io' diff --git a/package.json b/package.json index f2646c0d6d..bc29b84cfe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "grpc", - "version": "1.2.3", + "version": "1.2.4", "author": "Google Inc.", "description": "gRPC Library for Node", "homepage": "http://www.grpc.io/", diff --git a/package.xml b/package.xml index f120d57a6d..fdda050447 100644 --- a/package.xml +++ b/package.xml @@ -13,8 +13,8 @@ 2017-03-01 - 1.2.3 - 1.2.3 + 1.2.4 + 1.2.4 beta diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index cda0799924..8f3f8e01f5 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -37,5 +37,5 @@ #include namespace grpc { -grpc::string Version() { return "1.2.3"; } +grpc::string Version() { return "1.2.4"; } } diff --git a/src/csharp/Grpc.Auth/project.json b/src/csharp/Grpc.Auth/project.json index 45ee3a3112..fbfe29e8b7 100644 --- a/src/csharp/Grpc.Auth/project.json +++ b/src/csharp/Grpc.Auth/project.json @@ -1,5 +1,5 @@ { - "version": "1.2.3", + "version": "1.2.4", "title": "gRPC C# Auth", "authors": [ "Google Inc." ], "copyright": "Copyright 2015, Google Inc.", @@ -21,7 +21,7 @@ } }, "dependencies": { - "Grpc.Core": "1.2.3", + "Grpc.Core": "1.2.4", "Google.Apis.Auth": "1.21.0" }, "frameworks": { diff --git a/src/csharp/Grpc.Core.Testing/project.json b/src/csharp/Grpc.Core.Testing/project.json index 40dc57ac76..c174e8bf53 100644 --- a/src/csharp/Grpc.Core.Testing/project.json +++ b/src/csharp/Grpc.Core.Testing/project.json @@ -1,5 +1,5 @@ { - "version": "1.2.3", + "version": "1.2.4", "title": "gRPC C# Core Testing", "authors": [ "Google Inc." ], "copyright": "Copyright 2017, Google Inc.", @@ -21,7 +21,7 @@ } }, "dependencies": { - "Grpc.Core": "1.2.3" + "Grpc.Core": "1.2.4" }, "frameworks": { "net45": { diff --git a/src/csharp/Grpc.Core/VersionInfo.cs b/src/csharp/Grpc.Core/VersionInfo.cs index c3339ce1a4..d324963d1a 100644 --- a/src/csharp/Grpc.Core/VersionInfo.cs +++ b/src/csharp/Grpc.Core/VersionInfo.cs @@ -48,11 +48,11 @@ namespace Grpc.Core /// /// Current AssemblyFileVersion of gRPC C# assemblies /// - public const string CurrentAssemblyFileVersion = "1.2.3.0"; + public const string CurrentAssemblyFileVersion = "1.2.4.0"; /// /// Current version of gRPC C# /// - public const string CurrentVersion = "1.2.3"; + public const string CurrentVersion = "1.2.4"; } } diff --git a/src/csharp/Grpc.Core/project.json b/src/csharp/Grpc.Core/project.json index 0381b04cf5..793258da70 100644 --- a/src/csharp/Grpc.Core/project.json +++ b/src/csharp/Grpc.Core/project.json @@ -1,5 +1,5 @@ { - "version": "1.2.3", + "version": "1.2.4", "title": "gRPC C# Core", "authors": [ "Google Inc." ], "copyright": "Copyright 2015, Google Inc.", diff --git a/src/csharp/Grpc.HealthCheck/project.json b/src/csharp/Grpc.HealthCheck/project.json index 4010d5566a..50d6f202b1 100644 --- a/src/csharp/Grpc.HealthCheck/project.json +++ b/src/csharp/Grpc.HealthCheck/project.json @@ -1,5 +1,5 @@ { - "version": "1.2.3", + "version": "1.2.4", "title": "gRPC C# Healthchecking", "authors": [ "Google Inc." ], "copyright": "Copyright 2015, Google Inc.", @@ -21,7 +21,7 @@ } }, "dependencies": { - "Grpc.Core": "1.2.3", + "Grpc.Core": "1.2.4", "Google.Protobuf": "3.2.0" }, "frameworks": { diff --git a/src/csharp/Grpc.Reflection/project.json b/src/csharp/Grpc.Reflection/project.json index 996aa51512..6f48fa5aa4 100644 --- a/src/csharp/Grpc.Reflection/project.json +++ b/src/csharp/Grpc.Reflection/project.json @@ -1,5 +1,5 @@ { - "version": "1.2.3", + "version": "1.2.4", "title": "gRPC C# Reflection", "authors": [ "Google Inc." ], "copyright": "Copyright 2016, Google Inc.", @@ -21,7 +21,7 @@ } }, "dependencies": { - "Grpc.Core": "1.2.3", + "Grpc.Core": "1.2.4", "Google.Protobuf": "3.2.0" }, "frameworks": { diff --git a/src/csharp/build_packages_dotnetcli.bat b/src/csharp/build_packages_dotnetcli.bat index aa47067d74..f1e44dac8c 100755 --- a/src/csharp/build_packages_dotnetcli.bat +++ b/src/csharp/build_packages_dotnetcli.bat @@ -28,7 +28,7 @@ @rem OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. @rem Current package versions -set VERSION=1.2.3 +set VERSION=1.2.4 set PROTOBUF_VERSION=3.0.0 @rem Adjust the location of nuget.exe diff --git a/src/csharp/build_packages_dotnetcli.sh b/src/csharp/build_packages_dotnetcli.sh index b0432f4b18..b703d879d4 100755 --- a/src/csharp/build_packages_dotnetcli.sh +++ b/src/csharp/build_packages_dotnetcli.sh @@ -66,7 +66,7 @@ dotnet pack --configuration Release Grpc.Auth/project.json --output ../../artifa dotnet pack --configuration Release Grpc.HealthCheck/project.json --output ../../artifacts dotnet pack --configuration Release Grpc.Reflection/project.json --output ../../artifacts -nuget pack Grpc.nuspec -Version "1.2.3" -OutputDirectory ../../artifacts -nuget pack Grpc.Tools.nuspec -Version "1.2.3" -OutputDirectory ../../artifacts +nuget pack Grpc.nuspec -Version "1.2.4" -OutputDirectory ../../artifacts +nuget pack Grpc.Tools.nuspec -Version "1.2.4" -OutputDirectory ../../artifacts (cd ../../artifacts && zip csharp_nugets_dotnetcli.zip *.nupkg) diff --git a/src/node/health_check/package.json b/src/node/health_check/package.json index 5ad59e27e6..fb1ad77704 100644 --- a/src/node/health_check/package.json +++ b/src/node/health_check/package.json @@ -1,6 +1,6 @@ { "name": "grpc-health-check", - "version": "1.2.3", + "version": "1.2.4", "author": "Google Inc.", "description": "Health check service for use with gRPC", "repository": { @@ -15,7 +15,7 @@ } ], "dependencies": { - "grpc": "^1.2.3", + "grpc": "^1.2.4", "lodash": "^3.9.3", "google-protobuf": "^3.0.0" }, diff --git a/src/node/tools/package.json b/src/node/tools/package.json index e06775b5bb..b552c4297a 100644 --- a/src/node/tools/package.json +++ b/src/node/tools/package.json @@ -1,6 +1,6 @@ { "name": "grpc-tools", - "version": "1.2.3", + "version": "1.2.4", "author": "Google Inc.", "description": "Tools for developing with gRPC on Node.js", "homepage": "http://www.grpc.io/", diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index f314d48c88..876fa1ce05 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.2.3' + v = '1.2.4' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index 69035cf8ad..f02b2693ad 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -38,4 +38,4 @@ // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.2.3" +#define GRPC_OBJC_VERSION_STRING @"1.2.4" diff --git a/src/php/composer.json b/src/php/composer.json index a2f83ec1e0..7061f417bc 100644 --- a/src/php/composer.json +++ b/src/php/composer.json @@ -2,7 +2,7 @@ "name": "grpc/grpc-dev", "description": "gRPC library for PHP - for Developement use only", "license": "BSD-3-Clause", - "version": "1.2.3", + "version": "1.2.4", "require": { "php": ">=5.5.0", "google/protobuf": "^v3.1.0" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index 0fdb76072b..c1f101f08b 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION='1.2.3' +VERSION='1.2.4' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index d3ac3aa3ef..99b9f80c67 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION='1.2.3' +VERSION='1.2.4' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index 416910c6ab..bd25f0466b 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION='1.2.3' +VERSION='1.2.4' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index 71495a1075..b46ba3c9be 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION='1.2.3' +VERSION='1.2.4' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index 51f9ccace9..6a31b12567 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -29,5 +29,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.2.3' + VERSION = '1.2.4' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index dd07b264d4..641ffdc79a 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -29,6 +29,6 @@ module GRPC module Tools - VERSION = '1.2.3' + VERSION = '1.2.4' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index 32fad56ca4..ce560e156b 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION='1.2.3' +VERSION='1.2.4' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 4bb1414e86..9fc757eb5d 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.2.3 +PROJECT_NUMBER = 1.2.4 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index db987191b6..1cf44358a2 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.2.3 +PROJECT_NUMBER = 1.2.4 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a -- cgit v1.2.3 From 9ee816e6ef4f98afd076a22ecc631e2d0266ba7b Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Wed, 12 Apr 2017 12:52:20 -0700 Subject: Fix message_size_filter to use RESOURCE_EXHAUSTED status code. --- src/core/lib/channel/message_size_filter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/lib/channel/message_size_filter.c b/src/core/lib/channel/message_size_filter.c index 57726c8476..28a4f6eb18 100644 --- a/src/core/lib/channel/message_size_filter.c +++ b/src/core/lib/channel/message_size_filter.c @@ -122,7 +122,7 @@ static void recv_message_ready(grpc_exec_ctx* exec_ctx, void* user_data, (*calld->recv_message)->length, calld->max_recv_size); grpc_error* new_error = grpc_error_set_int( GRPC_ERROR_CREATE_FROM_COPIED_STRING(message_string), - GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_INVALID_ARGUMENT); + GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_RESOURCE_EXHAUSTED); if (error == GRPC_ERROR_NONE) { error = new_error; } else { @@ -152,7 +152,7 @@ static void start_transport_stream_op_batch( exec_ctx, op, grpc_error_set_int(GRPC_ERROR_CREATE_FROM_COPIED_STRING(message_string), GRPC_ERROR_INT_GRPC_STATUS, - GRPC_STATUS_INVALID_ARGUMENT)); + GRPC_STATUS_RESOURCE_EXHAUSTED)); gpr_free(message_string); return; } -- cgit v1.2.3 From 2a86d3f39902f9256260b4452f22e75cc79bc8ff Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Wed, 12 Apr 2017 12:52:47 -0700 Subject: Update status codes doc. --- doc/statuscodes.md | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/doc/statuscodes.md b/doc/statuscodes.md index 1cd72df30a..f2df9e00de 100644 --- a/doc/statuscodes.md +++ b/doc/statuscodes.md @@ -1,9 +1,20 @@ # Status codes and their use in gRPC -gRPC uses a set of well defined status codes as part of the RPC API. All RPCs started at a client return a `status` object composed of an integer `code` and a string `message`. The server-side can choose the status it returns for a given RPC. +gRPC uses a set of well defined status codes as part of the RPC API. All +RPCs started at a client return a `status` object composed of an integer +`code` and a string `message`. The server-side can choose the status it +returns for a given RPC. -The gRPC client and server-side implementations may also generate and return `status` on their own when errors happen. -Only a subset of the pre-defined status codes are generated by the gRPC libraries. The following table lists these codes and summarizes the situations in which they are generated, either by the client or the server-side library implementation. +The gRPC client and server-side implementations may also generate and +return `status` on their own when errors happen. Only a subset of +the pre-defined status codes are generated by the gRPC libraries. This +allows applications to be sure that any other code it sees was actually +returned by the application (although it is also possible for the +server-side to return one of the codes generated by the gRPC libraries). + +The following table lists the codes that may be returned by the gRPC +libraries (on either the client-side or server-side) and summarizes the +situations in which they are generated. | Case | Code | Generated at Client or Server | | ------------- |:-------------| :-----:| @@ -26,7 +37,7 @@ Only a subset of the pre-defined status codes are generated by the gRPC librarie | Response cardinality violation (method requires exactly one response but server sent some other number of responses) | UNIMPLEMENTED | Client| | Error parsing response proto | INTERNAL | Client| | Error parsing request proto | INTERNAL | Server| - +| Sent or received message was larger than configured limit | RESOURCE_EXHAUSTED | Both | The following status codes are never generated by the library: - INVALID_ARGUMENT -- cgit v1.2.3 From dd1ec7f9cdf7598ed874bfe942ad837686a03ac7 Mon Sep 17 00:00:00 2001 From: Makarand Dharmapurikar Date: Wed, 12 Apr 2017 13:52:18 -0700 Subject: fixed asan buffer overflow --- src/core/lib/channel/http_server_filter.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/lib/channel/http_server_filter.c b/src/core/lib/channel/http_server_filter.c index c1e49ffacc..45dcc26f9a 100644 --- a/src/core/lib/channel/http_server_filter.c +++ b/src/core/lib/channel/http_server_filter.c @@ -228,6 +228,8 @@ static grpc_error *server_filter_incoming_metadata(grpc_exec_ctx *exec_ctx, if (offset < path_length) { grpc_slice query_slice = grpc_slice_sub(path_slice, offset + 1, path_length); + /* add a trailing '\0' before decoding */ + const char *b64_data = grpc_slice_to_c_string(query_slice); /* substitute path metadata with just the path (not query) */ grpc_mdelem mdelem_path_without_query = grpc_mdelem_from_slices( @@ -238,14 +240,12 @@ static grpc_error *server_filter_incoming_metadata(grpc_exec_ctx *exec_ctx, /* decode payload from query and add to the slice buffer to be returned */ const int k_url_safe = 1; - grpc_slice_buffer_add( - &calld->read_slice_buffer, - grpc_base64_decode(exec_ctx, - (const char *)GRPC_SLICE_START_PTR(query_slice), - k_url_safe)); + grpc_slice_buffer_add(&calld->read_slice_buffer, + grpc_base64_decode(exec_ctx, b64_data, k_url_safe)); grpc_slice_buffer_stream_init(&calld->read_stream, &calld->read_slice_buffer, 0); calld->seen_path_with_query = true; + gpr_free((void *)b64_data); grpc_slice_unref_internal(exec_ctx, query_slice); } else { gpr_log(GPR_ERROR, "GET request without QUERY"); -- cgit v1.2.3 From e7a8f41fd01007b9990f908d9697a7e8a73b9f53 Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Wed, 12 Apr 2017 14:04:44 -0700 Subject: Create f->shutdown_cq in the fixture --- src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m | 1 + 1 file changed, 1 insertion(+) diff --git a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m index 8a7c4a70d6..3dd264718c 100644 --- a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m +++ b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m @@ -80,6 +80,7 @@ static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( f.fixture_data = ffd; f.cq = grpc_completion_queue_create_for_next(NULL); + f.shutdown_cq = grpc_completion_queue_create_for_pluck(NULL); return f; } -- cgit v1.2.3 From 37daca3feb5bcbac48e33a03c8a934cec1599e55 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 12 Apr 2017 14:58:54 -0700 Subject: add missing refs --- .../ext/filters/http/message_compress/message_compress_filter.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/ext/filters/http/message_compress/message_compress_filter.c b/src/core/ext/filters/http/message_compress/message_compress_filter.c index e1267294ec..f414a60eee 100644 --- a/src/core/ext/filters/http/message_compress/message_compress_filter.c +++ b/src/core/ext/filters/http/message_compress/message_compress_filter.c @@ -295,9 +295,9 @@ static void compress_start_transport_stream_op_batch( if ((cur & CANCELLED_BIT) == 0) { grpc_transport_stream_op_batch_finish_with_failure( exec_ctx, (grpc_transport_stream_op_batch *)cur, - op->payload->cancel_stream.cancel_error); + GRPC_ERROR_REF(op->payload->cancel_stream.cancel_error)); } else { - GRPC_ERROR_UNREF((grpc_error*)(cur & ~CANCELLED_BIT)); + GRPC_ERROR_UNREF((grpc_error *)(cur & ~CANCELLED_BIT)); } break; } @@ -354,7 +354,8 @@ static void compress_start_transport_stream_op_batch( default: if (cur & CANCELLED_BIT) { grpc_transport_stream_op_batch_finish_with_failure( - exec_ctx, op, (grpc_error *)(cur & ~CANCELLED_BIT)); + exec_ctx, op, + GRPC_ERROR_REF((grpc_error *)(cur & ~CANCELLED_BIT))); } else { /* >1 send_message concurrently */ GPR_UNREACHABLE_CODE(break); -- cgit v1.2.3 From f3d9b4808a5645ad2ff5d0fee4085bb06cb83419 Mon Sep 17 00:00:00 2001 From: yang-g Date: Wed, 12 Apr 2017 15:21:56 -0700 Subject: Fix buffer overflow https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=973 --- src/core/lib/channel/http_server_filter.c | 6 +++--- .../clusterfuzz-testcase-5595941564317696 | Bin 0 -> 92 bytes tools/run_tests/generated/tests.json | 23 +++++++++++++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 test/core/end2end/fuzzers/server_fuzzer_corpus/clusterfuzz-testcase-5595941564317696 diff --git a/src/core/lib/channel/http_server_filter.c b/src/core/lib/channel/http_server_filter.c index c1e49ffacc..ebcde5315f 100644 --- a/src/core/lib/channel/http_server_filter.c +++ b/src/core/lib/channel/http_server_filter.c @@ -240,9 +240,9 @@ static grpc_error *server_filter_incoming_metadata(grpc_exec_ctx *exec_ctx, const int k_url_safe = 1; grpc_slice_buffer_add( &calld->read_slice_buffer, - grpc_base64_decode(exec_ctx, - (const char *)GRPC_SLICE_START_PTR(query_slice), - k_url_safe)); + grpc_base64_decode_with_len( + exec_ctx, (const char *)GRPC_SLICE_START_PTR(query_slice), + GRPC_SLICE_LENGTH(query_slice), k_url_safe)); grpc_slice_buffer_stream_init(&calld->read_stream, &calld->read_slice_buffer, 0); calld->seen_path_with_query = true; diff --git a/test/core/end2end/fuzzers/server_fuzzer_corpus/clusterfuzz-testcase-5595941564317696 b/test/core/end2end/fuzzers/server_fuzzer_corpus/clusterfuzz-testcase-5595941564317696 new file mode 100644 index 0000000000..335ce87196 Binary files /dev/null and b/test/core/end2end/fuzzers/server_fuzzer_corpus/clusterfuzz-testcase-5595941564317696 differ diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 12d48f219d..188b77586e 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -150787,6 +150787,29 @@ ], "uses_polling": false }, + { + "args": [ + "test/core/end2end/fuzzers/server_fuzzer_corpus/clusterfuzz-testcase-5595941564317696" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "tsan" + ], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "server_fuzzer_one_entry", + "platforms": [ + "mac", + "linux" + ], + "uses_polling": false + }, { "args": [ "test/core/end2end/fuzzers/server_fuzzer_corpus/clusterfuzz-testcase-6312731374256128" -- cgit v1.2.3 From db32770412f32ab35f82f52272309cc9f0996be8 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 12 Apr 2017 18:23:47 -0700 Subject: Fix modulemap redefinition --- src/objective-c/BoringSSL.podspec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/objective-c/BoringSSL.podspec b/src/objective-c/BoringSSL.podspec index 908bb0b5e5..55cc6f677e 100644 --- a/src/objective-c/BoringSSL.podspec +++ b/src/objective-c/BoringSSL.podspec @@ -31,7 +31,7 @@ Pod::Spec.new do |s| s.name = 'BoringSSL' - version = '8.0' + version = '8.1' s.version = version s.summary = 'BoringSSL is a fork of OpenSSL that is designed to meet Google’s needs.' # Adapted from the homepage: @@ -95,7 +95,7 @@ Pod::Spec.new do |s| # The module map and umbrella header created automatically by Cocoapods don't work for C libraries # like this one. The following file, and a correct umbrella header, are created on the fly by the # `prepare_command` of this pod. - s.module_map = 'include/openssl/module.modulemap' + s.module_map = 'include/openssl/BoringSSL.modulemap' # We don't need to inhibit all warnings; only -Wno-shorten-64-to-32. But Cocoapods' linter doesn't # want that for some reason. @@ -186,7 +186,7 @@ Pod::Spec.new do |s| #include "x509.h" #include "x509v3.h" EOF - cat > include/openssl/module.modulemap < include/openssl/BoringSSL.modulemap < Date: Wed, 12 Apr 2017 18:06:36 -0700 Subject: Add GRPC_CHTTP2_KEEPALIVE_STATE_DISABLED --- .../transport/chttp2/transport/chttp2_transport.c | 23 +++++++++++----------- src/core/ext/transport/chttp2/transport/internal.h | 1 + 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 5ad31c7d2c..ecf278329e 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -544,9 +544,9 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), t->keepalive_time), &t->init_keepalive_ping_locked, gpr_now(GPR_CLOCK_MONOTONIC)); } else { - /* Use GRPC_CHTTP2_KEEPALIVE_STATE_DYING to indicate there are no inflight - keeaplive timers */ - t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_DYING; + /* Use GRPC_CHTTP2_KEEPALIVE_STATE_DISABLED to indicate there are no + inflight keeaplive timers */ + t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_DISABLED; } grpc_chttp2_initiate_write(exec_ctx, t, false, "init"); @@ -596,18 +596,17 @@ static void close_transport_locked(grpc_exec_ctx *exec_ctx, GRPC_ERROR_REF(error), "close_transport"); grpc_endpoint_shutdown(exec_ctx, t->ep, GRPC_ERROR_REF(error)); switch (t->keepalive_state) { - case GRPC_CHTTP2_KEEPALIVE_STATE_WAITING: { + case GRPC_CHTTP2_KEEPALIVE_STATE_WAITING: grpc_timer_cancel(exec_ctx, &t->keepalive_ping_timer); break; - } - case GRPC_CHTTP2_KEEPALIVE_STATE_PINGING: { + case GRPC_CHTTP2_KEEPALIVE_STATE_PINGING: grpc_timer_cancel(exec_ctx, &t->keepalive_ping_timer); grpc_timer_cancel(exec_ctx, &t->keepalive_watchdog_timer); break; - } - case GRPC_CHTTP2_KEEPALIVE_STATE_DYING: { + case GRPC_CHTTP2_KEEPALIVE_STATE_DYING: + case GRPC_CHTTP2_KEEPALIVE_STATE_DISABLED: + /* keepalive timers are not set in these two states */ break; - } } /* flush writable stream list to avoid dangling references */ @@ -2269,7 +2268,9 @@ static void init_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { grpc_chttp2_transport *t = arg; GPR_ASSERT(t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_WAITING); - if (error == GRPC_ERROR_NONE && !(t->destroying || t->closed)) { + if (t->destroying || t->closed) { + t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_DYING; + } else if (error == GRPC_ERROR_NONE) { if (t->keepalive_permit_without_calls || grpc_chttp2_stream_map_size(&t->stream_map) > 0) { t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_PINGING; @@ -2284,7 +2285,7 @@ static void init_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg, gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), t->keepalive_time), &t->init_keepalive_ping_locked, gpr_now(GPR_CLOCK_MONOTONIC)); } - } else if (error == GRPC_ERROR_CANCELLED && !(t->destroying || t->closed)) { + } else if (error == GRPC_ERROR_CANCELLED) { /* The keepalive ping timer may be cancelled by bdp */ GRPC_CHTTP2_REF_TRANSPORT(t, "init keepalive ping"); grpc_timer_init( diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 6eb848b8d7..0452081dd5 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -222,6 +222,7 @@ typedef enum { GRPC_CHTTP2_KEEPALIVE_STATE_WAITING, GRPC_CHTTP2_KEEPALIVE_STATE_PINGING, GRPC_CHTTP2_KEEPALIVE_STATE_DYING, + GRPC_CHTTP2_KEEPALIVE_STATE_DISABLED, } grpc_chttp2_keepalive_state; struct grpc_chttp2_transport { -- cgit v1.2.3 From 840a1352150b5e52068dbfc2e02f43d91ecb9c1c Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Thu, 13 Apr 2017 03:12:52 -0700 Subject: Add shutdown_cq as a server cq so that progress can be made when calling cq_pluck on f->shutdown_cq --- src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m | 1 + 1 file changed, 1 insertion(+) diff --git a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m index 3dd264718c..d9aec7ae68 100644 --- a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m +++ b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m @@ -111,6 +111,7 @@ static void chttp2_init_server_secure_fullstack( } f->server = grpc_server_create(server_args, NULL); grpc_server_register_completion_queue(f->server, f->cq, NULL); + grpc_server_register_completion_queue(f->server, f->shutdown_cq, NULL); GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, server_creds)); grpc_server_credentials_release(server_creds); -- cgit v1.2.3 From c1b86a1c33e03ce2965a1548616a09c546d07113 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 13 Apr 2017 06:51:13 -0700 Subject: Fix duplicated dep --- BUILD | 2 -- 1 file changed, 2 deletions(-) diff --git a/BUILD b/BUILD index a48d4073f3..16c96c8ca2 100644 --- a/BUILD +++ b/BUILD @@ -76,7 +76,6 @@ grpc_cc_library( "grpc_transport_chttp2_client_secure", "grpc_transport_chttp2_server_insecure", "grpc_transport_chttp2_server_secure", - "grpc_max_age_filter", "grpc_message_size_filter", "grpc_deadline_filter", ], @@ -118,7 +117,6 @@ grpc_cc_library( "grpc_resolver_sockaddr", "grpc_transport_chttp2_client_insecure", "grpc_transport_chttp2_server_insecure", - "grpc_max_age_filter", "grpc_message_size_filter", "grpc_deadline_filter", ], -- cgit v1.2.3 From 17a93b33e07636c8fb012ee1375498a10b956e31 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 13 Apr 2017 07:14:47 -0700 Subject: Fix test. --- test/core/end2end/tests/max_message_length.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.c index ab58d9f9a6..a8b6f1f79a 100644 --- a/test/core/end2end/tests/max_message_length.c +++ b/test/core/end2end/tests/max_message_length.c @@ -272,7 +272,7 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config, GPR_ASSERT(was_cancelled == 1); done: - GPR_ASSERT(status == GRPC_STATUS_INVALID_ARGUMENT); + GPR_ASSERT(status == GRPC_STATUS_RESOURCE_EXHAUSTED); GPR_ASSERT( grpc_slice_str_cmp( details, send_limit @@ -466,7 +466,7 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config, GPR_ASSERT(0 == grpc_slice_str_cmp(call_details.host, "foo.test.google.fr:1234")); - GPR_ASSERT(status == GRPC_STATUS_INVALID_ARGUMENT); + GPR_ASSERT(status == GRPC_STATUS_RESOURCE_EXHAUSTED); GPR_ASSERT( grpc_slice_str_cmp( details, send_limit -- cgit v1.2.3 From 0362d6b374e4b10e324e09e750b88d6c6bc834d1 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 13 Apr 2017 07:59:08 -0700 Subject: ubsan fixes --- src/core/ext/census/context.c | 2 +- src/core/ext/census/resource.c | 4 +++- src/core/lib/channel/http_client_filter.c | 6 ++++-- test/core/end2end/fuzzers/api_fuzzer.c | 2 +- test/core/support/spinlock_test.c | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/core/ext/census/context.c b/src/core/ext/census/context.c index 0dfc4ecbf1..4195cb1c9b 100644 --- a/src/core/ext/census/context.c +++ b/src/core/ext/census/context.c @@ -200,7 +200,7 @@ static bool tag_set_add_tag(struct tag_set *tags, const census_tag *tag, // allocate new memory if needed tags->kvm_size += 2 * CENSUS_MAX_TAG_KV_LEN + TAG_HEADER_SIZE; char *new_kvm = gpr_malloc(tags->kvm_size); - memcpy(new_kvm, tags->kvm, tags->kvm_used); + if (tags->kvm_used > 0) memcpy(new_kvm, tags->kvm, tags->kvm_used); gpr_free(tags->kvm); tags->kvm = new_kvm; } diff --git a/src/core/ext/census/resource.c b/src/core/ext/census/resource.c index ed44f004f9..26ea1a8672 100644 --- a/src/core/ext/census/resource.c +++ b/src/core/ext/census/resource.c @@ -223,7 +223,9 @@ size_t allocate_resource(void) { if (n_resources == n_defined_resources) { size_t new_n_resources = n_resources ? n_resources * 2 : 2; resource **new_resources = gpr_malloc(new_n_resources * sizeof(resource *)); - memcpy(new_resources, resources, n_resources * sizeof(resource *)); + if (n_resources != 0) { + memcpy(new_resources, resources, n_resources * sizeof(resource *)); + } memset(new_resources + n_resources, 0, (new_n_resources - n_resources) * sizeof(resource *)); gpr_free(resources); diff --git a/src/core/lib/channel/http_client_filter.c b/src/core/lib/channel/http_client_filter.c index 4e47c5c658..255f5388aa 100644 --- a/src/core/lib/channel/http_client_filter.c +++ b/src/core/lib/channel/http_client_filter.c @@ -222,8 +222,10 @@ static void continue_send_message(grpc_exec_ctx *exec_ctx, while (grpc_byte_stream_next( exec_ctx, calld->send_op->payload->send_message.send_message, &calld->incoming_slice, ~(size_t)0, &calld->got_slice)) { - memcpy(wrptr, GRPC_SLICE_START_PTR(calld->incoming_slice), - GRPC_SLICE_LENGTH(calld->incoming_slice)); + if (GRPC_SLICE_LENGTH(calld->incoming_slice) > 0) { + memcpy(wrptr, GRPC_SLICE_START_PTR(calld->incoming_slice), + GRPC_SLICE_LENGTH(calld->incoming_slice)); + } wrptr += GRPC_SLICE_LENGTH(calld->incoming_slice); grpc_slice_buffer_add(&calld->slices, calld->incoming_slice); if (calld->send_length == calld->slices.length) { diff --git a/test/core/end2end/fuzzers/api_fuzzer.c b/test/core/end2end/fuzzers/api_fuzzer.c index a0acf5bf60..0ec5a23d5d 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.c +++ b/test/core/end2end/fuzzers/api_fuzzer.c @@ -967,7 +967,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { break; } grpc_op *ops = gpr_malloc(sizeof(grpc_op) * num_ops); - memset(ops, 0, sizeof(grpc_op) * num_ops); + if (num_ops > 0) memset(ops, 0, sizeof(grpc_op) * num_ops); bool ok = true; size_t i; grpc_op *op; diff --git a/test/core/support/spinlock_test.c b/test/core/support/spinlock_test.c index c70e76c7ea..96055e9bd7 100644 --- a/test/core/support/spinlock_test.c +++ b/test/core/support/spinlock_test.c @@ -109,7 +109,7 @@ static void test(const char *name, void (*body)(void *m), int timeout_s, start, gpr_time_from_micros((int64_t)timeout_s * 1000000, GPR_TIMESPAN)); fprintf(stderr, "%s:", name); while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0) { - iterations <<= 1; + if (iterations < INT64_MAX / 2) iterations <<= 1; fprintf(stderr, " %ld", (long)iterations); m = test_new(10, iterations, incr_step); test_create_threads(m, body); -- cgit v1.2.3 From 7fb4036a172f23f6d2bf6b451c1052f9495c880d Mon Sep 17 00:00:00 2001 From: Makarand Dharmapurikar Date: Thu, 13 Apr 2017 09:07:47 -0700 Subject: clang-format fix --- test/cpp/interop/client.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc index ea27f2827d..6f1d910304 100644 --- a/test/cpp/interop/client.cc +++ b/test/cpp/interop/client.cc @@ -164,7 +164,7 @@ int main(int argc, char** argv) { actions["unimplemented_service"] = std::bind(&grpc::testing::InteropClient::DoUnimplementedService, &client); actions["cacheable_unary"] = - std::bind(&grpc::testing::InteropClient::DoCacheableUnary, &client); + std::bind(&grpc::testing::InteropClient::DoCacheableUnary, &client); UpdateActions(&actions); -- cgit v1.2.3 From a103f7bbdfd1d8834d8386644d7f5e2d7b8d1a90 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 13 Apr 2017 09:25:44 -0700 Subject: update comments --- include/grpc++/impl/codegen/server_interface.h | 2 -- include/grpc++/server.h | 2 -- 2 files changed, 4 deletions(-) diff --git a/include/grpc++/impl/codegen/server_interface.h b/include/grpc++/impl/codegen/server_interface.h index 7975011704..31d55529ef 100644 --- a/include/grpc++/impl/codegen/server_interface.h +++ b/include/grpc++/impl/codegen/server_interface.h @@ -122,8 +122,6 @@ class ServerInterface : public CallHook { /// caller is required to keep all completion queues live until the server is /// destroyed. /// \param num_cqs How many completion queues does \a cqs hold. - /// - /// \return true on a successful shutdown. virtual void Start(ServerCompletionQueue** cqs, size_t num_cqs) = 0; virtual void ShutdownInternal(gpr_timespec deadline) = 0; diff --git a/include/grpc++/server.h b/include/grpc++/server.h index af90a5c70b..6d5f89d360 100644 --- a/include/grpc++/server.h +++ b/include/grpc++/server.h @@ -177,8 +177,6 @@ class Server final : public ServerInterface, private GrpcLibraryCodegen { /// caller is required to keep all completion queues live until the server is /// destroyed. /// \param num_cqs How many completion queues does \a cqs hold. - /// - /// \return true on a successful shutdown. void Start(ServerCompletionQueue** cqs, size_t num_cqs) override; void PerformOpsOnCall(CallOpSetInterface* ops, Call* call) override; -- cgit v1.2.3 From c9f4bf9fcd9201a7447dcb351c810ef7200755a8 Mon Sep 17 00:00:00 2001 From: yang-g Date: Thu, 13 Apr 2017 11:21:51 -0700 Subject: get rid of the trailing null in path --- src/core/lib/channel/http_client_filter.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/core/lib/channel/http_client_filter.c b/src/core/lib/channel/http_client_filter.c index 151fb9885d..11b36146d8 100644 --- a/src/core/lib/channel/http_client_filter.c +++ b/src/core/lib/channel/http_client_filter.c @@ -341,11 +341,8 @@ static grpc_error *hc_mutate_op(grpc_exec_ctx *exec_ctx, /* remove trailing unused memory and add trailing 0 to terminate string */ char *t = (char *)GRPC_SLICE_START_PTR(path_with_query_slice); - /* safe to use strlen since base64_encode will always add '\0' */ - size_t path_length = strlen(t) + 1; - *(t + path_length) = '\0'; path_with_query_slice = - grpc_slice_sub(path_with_query_slice, 0, path_length); + grpc_slice_sub(path_with_query_slice, 0, strlen(t)); /* substitute previous path with the new path+query */ grpc_mdelem mdelem_path_and_query = grpc_mdelem_from_slices( -- cgit v1.2.3 From 63ed60f0483523522067d098abb6044ab6b99e27 Mon Sep 17 00:00:00 2001 From: Makarand Dharmapurikar Date: Thu, 13 Apr 2017 12:45:18 -0700 Subject: using grpc_base64_decode_with_len to simplify code --- src/core/lib/channel/http_server_filter.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/lib/channel/http_server_filter.c b/src/core/lib/channel/http_server_filter.c index 45dcc26f9a..ebcde5315f 100644 --- a/src/core/lib/channel/http_server_filter.c +++ b/src/core/lib/channel/http_server_filter.c @@ -228,8 +228,6 @@ static grpc_error *server_filter_incoming_metadata(grpc_exec_ctx *exec_ctx, if (offset < path_length) { grpc_slice query_slice = grpc_slice_sub(path_slice, offset + 1, path_length); - /* add a trailing '\0' before decoding */ - const char *b64_data = grpc_slice_to_c_string(query_slice); /* substitute path metadata with just the path (not query) */ grpc_mdelem mdelem_path_without_query = grpc_mdelem_from_slices( @@ -240,12 +238,14 @@ static grpc_error *server_filter_incoming_metadata(grpc_exec_ctx *exec_ctx, /* decode payload from query and add to the slice buffer to be returned */ const int k_url_safe = 1; - grpc_slice_buffer_add(&calld->read_slice_buffer, - grpc_base64_decode(exec_ctx, b64_data, k_url_safe)); + grpc_slice_buffer_add( + &calld->read_slice_buffer, + grpc_base64_decode_with_len( + exec_ctx, (const char *)GRPC_SLICE_START_PTR(query_slice), + GRPC_SLICE_LENGTH(query_slice), k_url_safe)); grpc_slice_buffer_stream_init(&calld->read_stream, &calld->read_slice_buffer, 0); calld->seen_path_with_query = true; - gpr_free((void *)b64_data); grpc_slice_unref_internal(exec_ctx, query_slice); } else { gpr_log(GPR_ERROR, "GET request without QUERY"); -- cgit v1.2.3 From c2b1f1672d23d2a374205d77f374b54cee66fe61 Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Fri, 31 Mar 2017 09:38:36 -0700 Subject: Change metadata names used by the instrumentation. --- src/core/lib/transport/static_metadata.c | 765 +++++++++++++++-------------- src/core/lib/transport/static_metadata.h | 186 +++---- test/core/end2end/fuzzers/hpack.dictionary | 5 +- tools/codegen/core/gen_static_metadata.py | 343 +++++++------ 4 files changed, 689 insertions(+), 610 deletions(-) diff --git a/src/core/lib/transport/static_metadata.c b/src/core/lib/transport/static_metadata.c index c13ba230b3..599d4ad117 100644 --- a/src/core/lib/transport/static_metadata.c +++ b/src/core/lib/transport/static_metadata.c @@ -51,67 +51,69 @@ static uint8_t g_bytes[] = { 115, 103, 114, 112, 99, 45, 112, 97, 121, 108, 111, 97, 100, 45, 98, 105, 110, 103, 114, 112, 99, 45, 101, 110, 99, 111, 100, 105, 110, 103, 103, 114, 112, 99, 45, 97, 99, 99, 101, 112, 116, 45, 101, 110, 99, - 111, 100, 105, 110, 103, 99, 111, 110, 116, 101, 110, 116, 45, 116, 121, - 112, 101, 103, 114, 112, 99, 45, 105, 110, 116, 101, 114, 110, 97, 108, - 45, 101, 110, 99, 111, 100, 105, 110, 103, 45, 114, 101, 113, 117, 101, - 115, 116, 117, 115, 101, 114, 45, 97, 103, 101, 110, 116, 104, 111, 115, - 116, 108, 98, 45, 116, 111, 107, 101, 110, 103, 114, 112, 99, 45, 116, - 105, 109, 101, 111, 117, 116, 103, 114, 112, 99, 45, 116, 114, 97, 99, - 105, 110, 103, 45, 98, 105, 110, 103, 114, 112, 99, 45, 115, 116, 97, - 116, 115, 45, 98, 105, 110, 103, 114, 112, 99, 46, 119, 97, 105, 116, - 95, 102, 111, 114, 95, 114, 101, 97, 100, 121, 103, 114, 112, 99, 46, - 116, 105, 109, 101, 111, 117, 116, 103, 114, 112, 99, 46, 109, 97, 120, - 95, 114, 101, 113, 117, 101, 115, 116, 95, 109, 101, 115, 115, 97, 103, - 101, 95, 98, 121, 116, 101, 115, 103, 114, 112, 99, 46, 109, 97, 120, - 95, 114, 101, 115, 112, 111, 110, 115, 101, 95, 109, 101, 115, 115, 97, - 103, 101, 95, 98, 121, 116, 101, 115, 47, 103, 114, 112, 99, 46, 108, - 98, 46, 118, 49, 46, 76, 111, 97, 100, 66, 97, 108, 97, 110, 99, - 101, 114, 47, 66, 97, 108, 97, 110, 99, 101, 76, 111, 97, 100, 48, - 49, 50, 105, 100, 101, 110, 116, 105, 116, 121, 103, 122, 105, 112, 100, - 101, 102, 108, 97, 116, 101, 116, 114, 97, 105, 108, 101, 114, 115, 97, - 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 47, 103, 114, 112, 99, - 80, 79, 83, 84, 50, 48, 48, 52, 48, 52, 104, 116, 116, 112, 104, - 116, 116, 112, 115, 103, 114, 112, 99, 71, 69, 84, 80, 85, 84, 47, - 47, 105, 110, 100, 101, 120, 46, 104, 116, 109, 108, 50, 48, 52, 50, - 48, 54, 51, 48, 52, 52, 48, 48, 53, 48, 48, 97, 99, 99, 101, - 112, 116, 45, 99, 104, 97, 114, 115, 101, 116, 97, 99, 99, 101, 112, - 116, 45, 101, 110, 99, 111, 100, 105, 110, 103, 103, 122, 105, 112, 44, - 32, 100, 101, 102, 108, 97, 116, 101, 97, 99, 99, 101, 112, 116, 45, - 108, 97, 110, 103, 117, 97, 103, 101, 97, 99, 99, 101, 112, 116, 45, - 114, 97, 110, 103, 101, 115, 97, 99, 99, 101, 112, 116, 97, 99, 99, - 101, 115, 115, 45, 99, 111, 110, 116, 114, 111, 108, 45, 97, 108, 108, - 111, 119, 45, 111, 114, 105, 103, 105, 110, 97, 103, 101, 97, 108, 108, - 111, 119, 97, 117, 116, 104, 111, 114, 105, 122, 97, 116, 105, 111, 110, - 99, 97, 99, 104, 101, 45, 99, 111, 110, 116, 114, 111, 108, 99, 111, - 110, 116, 101, 110, 116, 45, 100, 105, 115, 112, 111, 115, 105, 116, 105, - 111, 110, 99, 111, 110, 116, 101, 110, 116, 45, 101, 110, 99, 111, 100, - 105, 110, 103, 99, 111, 110, 116, 101, 110, 116, 45, 108, 97, 110, 103, - 117, 97, 103, 101, 99, 111, 110, 116, 101, 110, 116, 45, 108, 101, 110, - 103, 116, 104, 99, 111, 110, 116, 101, 110, 116, 45, 108, 111, 99, 97, - 116, 105, 111, 110, 99, 111, 110, 116, 101, 110, 116, 45, 114, 97, 110, - 103, 101, 99, 111, 111, 107, 105, 101, 100, 97, 116, 101, 101, 116, 97, - 103, 101, 120, 112, 101, 99, 116, 101, 120, 112, 105, 114, 101, 115, 102, - 114, 111, 109, 105, 102, 45, 109, 97, 116, 99, 104, 105, 102, 45, 109, - 111, 100, 105, 102, 105, 101, 100, 45, 115, 105, 110, 99, 101, 105, 102, - 45, 110, 111, 110, 101, 45, 109, 97, 116, 99, 104, 105, 102, 45, 114, - 97, 110, 103, 101, 105, 102, 45, 117, 110, 109, 111, 100, 105, 102, 105, - 101, 100, 45, 115, 105, 110, 99, 101, 108, 97, 115, 116, 45, 109, 111, - 100, 105, 102, 105, 101, 100, 108, 105, 110, 107, 108, 111, 99, 97, 116, - 105, 111, 110, 109, 97, 120, 45, 102, 111, 114, 119, 97, 114, 100, 115, - 112, 114, 111, 120, 121, 45, 97, 117, 116, 104, 101, 110, 116, 105, 99, - 97, 116, 101, 112, 114, 111, 120, 121, 45, 97, 117, 116, 104, 111, 114, - 105, 122, 97, 116, 105, 111, 110, 114, 97, 110, 103, 101, 114, 101, 102, - 101, 114, 101, 114, 114, 101, 102, 114, 101, 115, 104, 114, 101, 116, 114, - 121, 45, 97, 102, 116, 101, 114, 115, 101, 114, 118, 101, 114, 115, 101, - 116, 45, 99, 111, 111, 107, 105, 101, 115, 116, 114, 105, 99, 116, 45, - 116, 114, 97, 110, 115, 112, 111, 114, 116, 45, 115, 101, 99, 117, 114, - 105, 116, 121, 116, 114, 97, 110, 115, 102, 101, 114, 45, 101, 110, 99, - 111, 100, 105, 110, 103, 118, 97, 114, 121, 118, 105, 97, 119, 119, 119, - 45, 97, 117, 116, 104, 101, 110, 116, 105, 99, 97, 116, 101, 105, 100, - 101, 110, 116, 105, 116, 121, 44, 100, 101, 102, 108, 97, 116, 101, 105, - 100, 101, 110, 116, 105, 116, 121, 44, 103, 122, 105, 112, 100, 101, 102, - 108, 97, 116, 101, 44, 103, 122, 105, 112, 105, 100, 101, 110, 116, 105, - 116, 121, 44, 100, 101, 102, 108, 97, 116, 101, 44, 103, 122, 105, 112}; + 111, 100, 105, 110, 103, 103, 114, 112, 99, 45, 115, 101, 114, 118, 101, + 114, 45, 115, 116, 97, 116, 115, 45, 98, 105, 110, 103, 114, 112, 99, + 45, 116, 97, 103, 115, 45, 98, 105, 110, 103, 114, 112, 99, 45, 116, + 114, 97, 99, 101, 45, 98, 105, 110, 99, 111, 110, 116, 101, 110, 116, + 45, 116, 121, 112, 101, 103, 114, 112, 99, 45, 105, 110, 116, 101, 114, + 110, 97, 108, 45, 101, 110, 99, 111, 100, 105, 110, 103, 45, 114, 101, + 113, 117, 101, 115, 116, 117, 115, 101, 114, 45, 97, 103, 101, 110, 116, + 104, 111, 115, 116, 108, 98, 45, 116, 111, 107, 101, 110, 103, 114, 112, + 99, 45, 116, 105, 109, 101, 111, 117, 116, 103, 114, 112, 99, 46, 119, + 97, 105, 116, 95, 102, 111, 114, 95, 114, 101, 97, 100, 121, 103, 114, + 112, 99, 46, 116, 105, 109, 101, 111, 117, 116, 103, 114, 112, 99, 46, + 109, 97, 120, 95, 114, 101, 113, 117, 101, 115, 116, 95, 109, 101, 115, + 115, 97, 103, 101, 95, 98, 121, 116, 101, 115, 103, 114, 112, 99, 46, + 109, 97, 120, 95, 114, 101, 115, 112, 111, 110, 115, 101, 95, 109, 101, + 115, 115, 97, 103, 101, 95, 98, 121, 116, 101, 115, 47, 103, 114, 112, + 99, 46, 108, 98, 46, 118, 49, 46, 76, 111, 97, 100, 66, 97, 108, + 97, 110, 99, 101, 114, 47, 66, 97, 108, 97, 110, 99, 101, 76, 111, + 97, 100, 48, 49, 50, 105, 100, 101, 110, 116, 105, 116, 121, 103, 122, + 105, 112, 100, 101, 102, 108, 97, 116, 101, 116, 114, 97, 105, 108, 101, + 114, 115, 97, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 47, 103, + 114, 112, 99, 80, 79, 83, 84, 50, 48, 48, 52, 48, 52, 104, 116, + 116, 112, 104, 116, 116, 112, 115, 103, 114, 112, 99, 71, 69, 84, 80, + 85, 84, 47, 47, 105, 110, 100, 101, 120, 46, 104, 116, 109, 108, 50, + 48, 52, 50, 48, 54, 51, 48, 52, 52, 48, 48, 53, 48, 48, 97, + 99, 99, 101, 112, 116, 45, 99, 104, 97, 114, 115, 101, 116, 97, 99, + 99, 101, 112, 116, 45, 101, 110, 99, 111, 100, 105, 110, 103, 103, 122, + 105, 112, 44, 32, 100, 101, 102, 108, 97, 116, 101, 97, 99, 99, 101, + 112, 116, 45, 108, 97, 110, 103, 117, 97, 103, 101, 97, 99, 99, 101, + 112, 116, 45, 114, 97, 110, 103, 101, 115, 97, 99, 99, 101, 112, 116, + 97, 99, 99, 101, 115, 115, 45, 99, 111, 110, 116, 114, 111, 108, 45, + 97, 108, 108, 111, 119, 45, 111, 114, 105, 103, 105, 110, 97, 103, 101, + 97, 108, 108, 111, 119, 97, 117, 116, 104, 111, 114, 105, 122, 97, 116, + 105, 111, 110, 99, 97, 99, 104, 101, 45, 99, 111, 110, 116, 114, 111, + 108, 99, 111, 110, 116, 101, 110, 116, 45, 100, 105, 115, 112, 111, 115, + 105, 116, 105, 111, 110, 99, 111, 110, 116, 101, 110, 116, 45, 101, 110, + 99, 111, 100, 105, 110, 103, 99, 111, 110, 116, 101, 110, 116, 45, 108, + 97, 110, 103, 117, 97, 103, 101, 99, 111, 110, 116, 101, 110, 116, 45, + 108, 101, 110, 103, 116, 104, 99, 111, 110, 116, 101, 110, 116, 45, 108, + 111, 99, 97, 116, 105, 111, 110, 99, 111, 110, 116, 101, 110, 116, 45, + 114, 97, 110, 103, 101, 99, 111, 111, 107, 105, 101, 100, 97, 116, 101, + 101, 116, 97, 103, 101, 120, 112, 101, 99, 116, 101, 120, 112, 105, 114, + 101, 115, 102, 114, 111, 109, 105, 102, 45, 109, 97, 116, 99, 104, 105, + 102, 45, 109, 111, 100, 105, 102, 105, 101, 100, 45, 115, 105, 110, 99, + 101, 105, 102, 45, 110, 111, 110, 101, 45, 109, 97, 116, 99, 104, 105, + 102, 45, 114, 97, 110, 103, 101, 105, 102, 45, 117, 110, 109, 111, 100, + 105, 102, 105, 101, 100, 45, 115, 105, 110, 99, 101, 108, 97, 115, 116, + 45, 109, 111, 100, 105, 102, 105, 101, 100, 108, 105, 110, 107, 108, 111, + 99, 97, 116, 105, 111, 110, 109, 97, 120, 45, 102, 111, 114, 119, 97, + 114, 100, 115, 112, 114, 111, 120, 121, 45, 97, 117, 116, 104, 101, 110, + 116, 105, 99, 97, 116, 101, 112, 114, 111, 120, 121, 45, 97, 117, 116, + 104, 111, 114, 105, 122, 97, 116, 105, 111, 110, 114, 97, 110, 103, 101, + 114, 101, 102, 101, 114, 101, 114, 114, 101, 102, 114, 101, 115, 104, 114, + 101, 116, 114, 121, 45, 97, 102, 116, 101, 114, 115, 101, 114, 118, 101, + 114, 115, 101, 116, 45, 99, 111, 111, 107, 105, 101, 115, 116, 114, 105, + 99, 116, 45, 116, 114, 97, 110, 115, 112, 111, 114, 116, 45, 115, 101, + 99, 117, 114, 105, 116, 121, 116, 114, 97, 110, 115, 102, 101, 114, 45, + 101, 110, 99, 111, 100, 105, 110, 103, 118, 97, 114, 121, 118, 105, 97, + 119, 119, 119, 45, 97, 117, 116, 104, 101, 110, 116, 105, 99, 97, 116, + 101, 105, 100, 101, 110, 116, 105, 116, 121, 44, 100, 101, 102, 108, 97, + 116, 101, 105, 100, 101, 110, 116, 105, 116, 121, 44, 103, 122, 105, 112, + 100, 101, 102, 108, 97, 116, 101, 44, 103, 122, 105, 112, 105, 100, 101, + 110, 116, 105, 116, 121, 44, 100, 101, 102, 108, 97, 116, 101, 44, 103, + 122, 105, 112}; static void static_ref(void *unused) {} static void static_unref(grpc_exec_ctx *exec_ctx, void *unused) {} @@ -220,6 +222,7 @@ grpc_slice_refcount grpc_static_metadata_refcounts[GRPC_STATIC_MDSTR_COUNT] = { {&grpc_static_metadata_vtable, &static_sub_refcnt}, {&grpc_static_metadata_vtable, &static_sub_refcnt}, {&grpc_static_metadata_vtable, &static_sub_refcnt}, + {&grpc_static_metadata_vtable, &static_sub_refcnt}, }; const grpc_slice grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT] = { @@ -246,177 +249,179 @@ const grpc_slice grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT] = { {.refcount = &grpc_static_metadata_refcounts[10], .data.refcounted = {g_bytes + 90, 20}}, {.refcount = &grpc_static_metadata_refcounts[11], - .data.refcounted = {g_bytes + 110, 12}}, + .data.refcounted = {g_bytes + 110, 21}}, {.refcount = &grpc_static_metadata_refcounts[12], - .data.refcounted = {g_bytes + 122, 30}}, + .data.refcounted = {g_bytes + 131, 13}}, {.refcount = &grpc_static_metadata_refcounts[13], - .data.refcounted = {g_bytes + 152, 10}}, + .data.refcounted = {g_bytes + 144, 14}}, {.refcount = &grpc_static_metadata_refcounts[14], - .data.refcounted = {g_bytes + 162, 4}}, + .data.refcounted = {g_bytes + 158, 12}}, {.refcount = &grpc_static_metadata_refcounts[15], - .data.refcounted = {g_bytes + 166, 8}}, + .data.refcounted = {g_bytes + 170, 30}}, {.refcount = &grpc_static_metadata_refcounts[16], - .data.refcounted = {g_bytes + 174, 12}}, + .data.refcounted = {g_bytes + 200, 10}}, {.refcount = &grpc_static_metadata_refcounts[17], - .data.refcounted = {g_bytes + 186, 16}}, + .data.refcounted = {g_bytes + 210, 4}}, {.refcount = &grpc_static_metadata_refcounts[18], - .data.refcounted = {g_bytes + 202, 14}}, + .data.refcounted = {g_bytes + 214, 8}}, {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}, + .data.refcounted = {g_bytes + 222, 12}}, {.refcount = &grpc_static_metadata_refcounts[20], - .data.refcounted = {g_bytes + 216, 19}}, + .data.refcounted = {g_bytes + 234, 0}}, {.refcount = &grpc_static_metadata_refcounts[21], - .data.refcounted = {g_bytes + 235, 12}}, + .data.refcounted = {g_bytes + 234, 19}}, {.refcount = &grpc_static_metadata_refcounts[22], - .data.refcounted = {g_bytes + 247, 30}}, + .data.refcounted = {g_bytes + 253, 12}}, {.refcount = &grpc_static_metadata_refcounts[23], - .data.refcounted = {g_bytes + 277, 31}}, + .data.refcounted = {g_bytes + 265, 30}}, {.refcount = &grpc_static_metadata_refcounts[24], - .data.refcounted = {g_bytes + 308, 36}}, + .data.refcounted = {g_bytes + 295, 31}}, {.refcount = &grpc_static_metadata_refcounts[25], - .data.refcounted = {g_bytes + 344, 1}}, + .data.refcounted = {g_bytes + 326, 36}}, {.refcount = &grpc_static_metadata_refcounts[26], - .data.refcounted = {g_bytes + 345, 1}}, + .data.refcounted = {g_bytes + 362, 1}}, {.refcount = &grpc_static_metadata_refcounts[27], - .data.refcounted = {g_bytes + 346, 1}}, + .data.refcounted = {g_bytes + 363, 1}}, {.refcount = &grpc_static_metadata_refcounts[28], - .data.refcounted = {g_bytes + 347, 8}}, + .data.refcounted = {g_bytes + 364, 1}}, {.refcount = &grpc_static_metadata_refcounts[29], - .data.refcounted = {g_bytes + 355, 4}}, + .data.refcounted = {g_bytes + 365, 8}}, {.refcount = &grpc_static_metadata_refcounts[30], - .data.refcounted = {g_bytes + 359, 7}}, + .data.refcounted = {g_bytes + 373, 4}}, {.refcount = &grpc_static_metadata_refcounts[31], - .data.refcounted = {g_bytes + 366, 8}}, + .data.refcounted = {g_bytes + 377, 7}}, {.refcount = &grpc_static_metadata_refcounts[32], - .data.refcounted = {g_bytes + 374, 16}}, + .data.refcounted = {g_bytes + 384, 8}}, {.refcount = &grpc_static_metadata_refcounts[33], - .data.refcounted = {g_bytes + 390, 4}}, + .data.refcounted = {g_bytes + 392, 16}}, {.refcount = &grpc_static_metadata_refcounts[34], - .data.refcounted = {g_bytes + 394, 3}}, + .data.refcounted = {g_bytes + 408, 4}}, {.refcount = &grpc_static_metadata_refcounts[35], - .data.refcounted = {g_bytes + 397, 3}}, + .data.refcounted = {g_bytes + 412, 3}}, {.refcount = &grpc_static_metadata_refcounts[36], - .data.refcounted = {g_bytes + 400, 4}}, + .data.refcounted = {g_bytes + 415, 3}}, {.refcount = &grpc_static_metadata_refcounts[37], - .data.refcounted = {g_bytes + 404, 5}}, + .data.refcounted = {g_bytes + 418, 4}}, {.refcount = &grpc_static_metadata_refcounts[38], - .data.refcounted = {g_bytes + 409, 4}}, + .data.refcounted = {g_bytes + 422, 5}}, {.refcount = &grpc_static_metadata_refcounts[39], - .data.refcounted = {g_bytes + 413, 3}}, + .data.refcounted = {g_bytes + 427, 4}}, {.refcount = &grpc_static_metadata_refcounts[40], - .data.refcounted = {g_bytes + 416, 3}}, + .data.refcounted = {g_bytes + 431, 3}}, {.refcount = &grpc_static_metadata_refcounts[41], - .data.refcounted = {g_bytes + 419, 1}}, + .data.refcounted = {g_bytes + 434, 3}}, {.refcount = &grpc_static_metadata_refcounts[42], - .data.refcounted = {g_bytes + 420, 11}}, + .data.refcounted = {g_bytes + 437, 1}}, {.refcount = &grpc_static_metadata_refcounts[43], - .data.refcounted = {g_bytes + 431, 3}}, + .data.refcounted = {g_bytes + 438, 11}}, {.refcount = &grpc_static_metadata_refcounts[44], - .data.refcounted = {g_bytes + 434, 3}}, + .data.refcounted = {g_bytes + 449, 3}}, {.refcount = &grpc_static_metadata_refcounts[45], - .data.refcounted = {g_bytes + 437, 3}}, + .data.refcounted = {g_bytes + 452, 3}}, {.refcount = &grpc_static_metadata_refcounts[46], - .data.refcounted = {g_bytes + 440, 3}}, + .data.refcounted = {g_bytes + 455, 3}}, {.refcount = &grpc_static_metadata_refcounts[47], - .data.refcounted = {g_bytes + 443, 3}}, + .data.refcounted = {g_bytes + 458, 3}}, {.refcount = &grpc_static_metadata_refcounts[48], - .data.refcounted = {g_bytes + 446, 14}}, + .data.refcounted = {g_bytes + 461, 3}}, {.refcount = &grpc_static_metadata_refcounts[49], - .data.refcounted = {g_bytes + 460, 15}}, + .data.refcounted = {g_bytes + 464, 14}}, {.refcount = &grpc_static_metadata_refcounts[50], - .data.refcounted = {g_bytes + 475, 13}}, + .data.refcounted = {g_bytes + 478, 15}}, {.refcount = &grpc_static_metadata_refcounts[51], - .data.refcounted = {g_bytes + 488, 15}}, + .data.refcounted = {g_bytes + 493, 13}}, {.refcount = &grpc_static_metadata_refcounts[52], - .data.refcounted = {g_bytes + 503, 13}}, + .data.refcounted = {g_bytes + 506, 15}}, {.refcount = &grpc_static_metadata_refcounts[53], - .data.refcounted = {g_bytes + 516, 6}}, + .data.refcounted = {g_bytes + 521, 13}}, {.refcount = &grpc_static_metadata_refcounts[54], - .data.refcounted = {g_bytes + 522, 27}}, + .data.refcounted = {g_bytes + 534, 6}}, {.refcount = &grpc_static_metadata_refcounts[55], - .data.refcounted = {g_bytes + 549, 3}}, + .data.refcounted = {g_bytes + 540, 27}}, {.refcount = &grpc_static_metadata_refcounts[56], - .data.refcounted = {g_bytes + 552, 5}}, + .data.refcounted = {g_bytes + 567, 3}}, {.refcount = &grpc_static_metadata_refcounts[57], - .data.refcounted = {g_bytes + 557, 13}}, + .data.refcounted = {g_bytes + 570, 5}}, {.refcount = &grpc_static_metadata_refcounts[58], - .data.refcounted = {g_bytes + 570, 13}}, + .data.refcounted = {g_bytes + 575, 13}}, {.refcount = &grpc_static_metadata_refcounts[59], - .data.refcounted = {g_bytes + 583, 19}}, + .data.refcounted = {g_bytes + 588, 13}}, {.refcount = &grpc_static_metadata_refcounts[60], - .data.refcounted = {g_bytes + 602, 16}}, + .data.refcounted = {g_bytes + 601, 19}}, {.refcount = &grpc_static_metadata_refcounts[61], - .data.refcounted = {g_bytes + 618, 16}}, + .data.refcounted = {g_bytes + 620, 16}}, {.refcount = &grpc_static_metadata_refcounts[62], - .data.refcounted = {g_bytes + 634, 14}}, + .data.refcounted = {g_bytes + 636, 16}}, {.refcount = &grpc_static_metadata_refcounts[63], - .data.refcounted = {g_bytes + 648, 16}}, + .data.refcounted = {g_bytes + 652, 14}}, {.refcount = &grpc_static_metadata_refcounts[64], - .data.refcounted = {g_bytes + 664, 13}}, + .data.refcounted = {g_bytes + 666, 16}}, {.refcount = &grpc_static_metadata_refcounts[65], - .data.refcounted = {g_bytes + 677, 6}}, + .data.refcounted = {g_bytes + 682, 13}}, {.refcount = &grpc_static_metadata_refcounts[66], - .data.refcounted = {g_bytes + 683, 4}}, + .data.refcounted = {g_bytes + 695, 6}}, {.refcount = &grpc_static_metadata_refcounts[67], - .data.refcounted = {g_bytes + 687, 4}}, + .data.refcounted = {g_bytes + 701, 4}}, {.refcount = &grpc_static_metadata_refcounts[68], - .data.refcounted = {g_bytes + 691, 6}}, + .data.refcounted = {g_bytes + 705, 4}}, {.refcount = &grpc_static_metadata_refcounts[69], - .data.refcounted = {g_bytes + 697, 7}}, + .data.refcounted = {g_bytes + 709, 6}}, {.refcount = &grpc_static_metadata_refcounts[70], - .data.refcounted = {g_bytes + 704, 4}}, + .data.refcounted = {g_bytes + 715, 7}}, {.refcount = &grpc_static_metadata_refcounts[71], - .data.refcounted = {g_bytes + 708, 8}}, + .data.refcounted = {g_bytes + 722, 4}}, {.refcount = &grpc_static_metadata_refcounts[72], - .data.refcounted = {g_bytes + 716, 17}}, + .data.refcounted = {g_bytes + 726, 8}}, {.refcount = &grpc_static_metadata_refcounts[73], - .data.refcounted = {g_bytes + 733, 13}}, + .data.refcounted = {g_bytes + 734, 17}}, {.refcount = &grpc_static_metadata_refcounts[74], - .data.refcounted = {g_bytes + 746, 8}}, + .data.refcounted = {g_bytes + 751, 13}}, {.refcount = &grpc_static_metadata_refcounts[75], - .data.refcounted = {g_bytes + 754, 19}}, + .data.refcounted = {g_bytes + 764, 8}}, {.refcount = &grpc_static_metadata_refcounts[76], - .data.refcounted = {g_bytes + 773, 13}}, + .data.refcounted = {g_bytes + 772, 19}}, {.refcount = &grpc_static_metadata_refcounts[77], - .data.refcounted = {g_bytes + 786, 4}}, + .data.refcounted = {g_bytes + 791, 13}}, {.refcount = &grpc_static_metadata_refcounts[78], - .data.refcounted = {g_bytes + 790, 8}}, + .data.refcounted = {g_bytes + 804, 4}}, {.refcount = &grpc_static_metadata_refcounts[79], - .data.refcounted = {g_bytes + 798, 12}}, + .data.refcounted = {g_bytes + 808, 8}}, {.refcount = &grpc_static_metadata_refcounts[80], - .data.refcounted = {g_bytes + 810, 18}}, + .data.refcounted = {g_bytes + 816, 12}}, {.refcount = &grpc_static_metadata_refcounts[81], - .data.refcounted = {g_bytes + 828, 19}}, + .data.refcounted = {g_bytes + 828, 18}}, {.refcount = &grpc_static_metadata_refcounts[82], - .data.refcounted = {g_bytes + 847, 5}}, + .data.refcounted = {g_bytes + 846, 19}}, {.refcount = &grpc_static_metadata_refcounts[83], - .data.refcounted = {g_bytes + 852, 7}}, + .data.refcounted = {g_bytes + 865, 5}}, {.refcount = &grpc_static_metadata_refcounts[84], - .data.refcounted = {g_bytes + 859, 7}}, + .data.refcounted = {g_bytes + 870, 7}}, {.refcount = &grpc_static_metadata_refcounts[85], - .data.refcounted = {g_bytes + 866, 11}}, + .data.refcounted = {g_bytes + 877, 7}}, {.refcount = &grpc_static_metadata_refcounts[86], - .data.refcounted = {g_bytes + 877, 6}}, + .data.refcounted = {g_bytes + 884, 11}}, {.refcount = &grpc_static_metadata_refcounts[87], - .data.refcounted = {g_bytes + 883, 10}}, + .data.refcounted = {g_bytes + 895, 6}}, {.refcount = &grpc_static_metadata_refcounts[88], - .data.refcounted = {g_bytes + 893, 25}}, + .data.refcounted = {g_bytes + 901, 10}}, {.refcount = &grpc_static_metadata_refcounts[89], - .data.refcounted = {g_bytes + 918, 17}}, + .data.refcounted = {g_bytes + 911, 25}}, {.refcount = &grpc_static_metadata_refcounts[90], - .data.refcounted = {g_bytes + 935, 4}}, + .data.refcounted = {g_bytes + 936, 17}}, {.refcount = &grpc_static_metadata_refcounts[91], - .data.refcounted = {g_bytes + 939, 3}}, + .data.refcounted = {g_bytes + 953, 4}}, {.refcount = &grpc_static_metadata_refcounts[92], - .data.refcounted = {g_bytes + 942, 16}}, + .data.refcounted = {g_bytes + 957, 3}}, {.refcount = &grpc_static_metadata_refcounts[93], - .data.refcounted = {g_bytes + 958, 16}}, + .data.refcounted = {g_bytes + 960, 16}}, {.refcount = &grpc_static_metadata_refcounts[94], - .data.refcounted = {g_bytes + 974, 13}}, + .data.refcounted = {g_bytes + 976, 16}}, {.refcount = &grpc_static_metadata_refcounts[95], - .data.refcounted = {g_bytes + 987, 12}}, + .data.refcounted = {g_bytes + 992, 13}}, {.refcount = &grpc_static_metadata_refcounts[96], - .data.refcounted = {g_bytes + 999, 21}}, + .data.refcounted = {g_bytes + 1005, 12}}, + {.refcount = &grpc_static_metadata_refcounts[97], + .data.refcounted = {g_bytes + 1017, 21}}, }; uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] = { @@ -426,16 +431,16 @@ uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 4, 6, 6, 8, 8}; static const int8_t elems_r[] = { - 10, 8, -3, 0, 9, 21, -75, 22, 0, 10, -7, 20, 0, 19, 18, 17, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - -48, -49, 16, -51, -52, -53, -54, -54, -55, -56, -57, 0, 37, 36, 35, 34, - 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, - 17, 16, 15, 14, 13, 12, 11, 14, 13, 12, 11, 10, 9, 8, 0}; + 10, 8, -3, 0, 9, 21, -76, 22, 0, 10, -7, 0, 0, 0, 14, 0, + 13, 12, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, -50, -51, 15, -53, -54, -55, -56, -56, -57, -58, 0, 37, 36, 35, 34, + 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, + 17, 16, 15, 14, 13, 12, 11, 10, 13, 12, 11, 10, 9, 8, 7, 0}; static uint32_t elems_phash(uint32_t i) { - i -= 41; - uint32_t x = i % 95; - uint32_t y = i / 95; + i -= 42; + uint32_t x = i % 96; + uint32_t y = i / 96; uint32_t h = x; if (y < GPR_ARRAY_SIZE(elems_r)) { uint32_t delta = (uint32_t)elems_r[y]; @@ -445,29 +450,29 @@ static uint32_t elems_phash(uint32_t i) { } static const uint16_t elem_keys[] = { - 998, 999, 1000, 237, 238, 239, 240, 241, 136, 137, 41, 42, - 424, 425, 426, 901, 902, 903, 704, 705, 1086, 516, 706, 1280, - 1377, 1474, 4675, 4772, 4803, 4966, 5063, 5160, 5257, 1099, 5354, 5451, - 5548, 5645, 5742, 5839, 5936, 6033, 6130, 6227, 6324, 6421, 6518, 6615, - 6712, 6809, 6906, 7003, 7100, 7197, 7294, 7391, 7488, 7585, 7682, 7779, - 7876, 7973, 8070, 8167, 8264, 1063, 1064, 1065, 1066, 8361, 8458, 8555, - 8652, 8749, 8846, 8943, 310, 0, 0, 0, 0, 0, 0, 0, + 1009, 1010, 1011, 240, 241, 242, 243, 244, 138, 139, 42, 43, + 429, 430, 431, 911, 912, 913, 712, 713, 1392, 522, 714, 1588, + 1686, 1784, 4822, 4920, 4951, 5116, 5214, 5312, 5410, 1405, 5508, 5606, + 5704, 5802, 5900, 5998, 6096, 6194, 6292, 6390, 6488, 6586, 6684, 6782, + 6880, 6978, 7076, 7174, 7272, 7370, 7468, 7566, 7664, 7762, 7860, 7958, + 8056, 8154, 8252, 8350, 8448, 1074, 1075, 1076, 1077, 8546, 8644, 8742, + 8840, 8938, 9036, 9134, 0, 314, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 130, 228, 229, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 132, 231, 232, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; static const uint8_t elem_idxs[] = { 73, 76, 74, 19, 20, 21, 22, 23, 15, 16, 17, 18, 11, 12, 13, 3, 4, 5, 0, 1, 41, 6, 2, 69, 48, 55, 24, 25, 26, 27, 28, 29, 30, 7, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 56, 57, 58, 59, 60, 61, 62, 63, 64, 75, 77, 78, 79, 65, 66, 67, 68, 70, 71, - 72, 14, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 8, 9, 10}; + 72, 255, 14, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 8, 9, 10}; grpc_mdelem grpc_static_mdelem_for_static_strings(int a, int b) { if (a == -1 || b == -1) return GRPC_MDNULL; - uint32_t k = (uint32_t)(a * 97 + b); + uint32_t k = (uint32_t)(a * 98 + b); uint32_t h = elems_phash(k); return h < GPR_ARRAY_SIZE(elem_keys) && elem_keys[h] == k ? GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[elem_idxs[h]], @@ -476,326 +481,326 @@ grpc_mdelem grpc_static_mdelem_for_static_strings(int a, int b) { } grpc_mdelem_data grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = { - {{.refcount = &grpc_static_metadata_refcounts[7], - .data.refcounted = {g_bytes + 50, 11}}, - {.refcount = &grpc_static_metadata_refcounts[25], - .data.refcounted = {g_bytes + 344, 1}}}, {{.refcount = &grpc_static_metadata_refcounts[7], .data.refcounted = {g_bytes + 50, 11}}, {.refcount = &grpc_static_metadata_refcounts[26], - .data.refcounted = {g_bytes + 345, 1}}}, + .data.refcounted = {g_bytes + 362, 1}}}, {{.refcount = &grpc_static_metadata_refcounts[7], .data.refcounted = {g_bytes + 50, 11}}, {.refcount = &grpc_static_metadata_refcounts[27], - .data.refcounted = {g_bytes + 346, 1}}}, - {{.refcount = &grpc_static_metadata_refcounts[9], - .data.refcounted = {g_bytes + 77, 13}}, + .data.refcounted = {g_bytes + 363, 1}}}, + {{.refcount = &grpc_static_metadata_refcounts[7], + .data.refcounted = {g_bytes + 50, 11}}, {.refcount = &grpc_static_metadata_refcounts[28], - .data.refcounted = {g_bytes + 347, 8}}}, + .data.refcounted = {g_bytes + 364, 1}}}, {{.refcount = &grpc_static_metadata_refcounts[9], .data.refcounted = {g_bytes + 77, 13}}, {.refcount = &grpc_static_metadata_refcounts[29], - .data.refcounted = {g_bytes + 355, 4}}}, + .data.refcounted = {g_bytes + 365, 8}}}, {{.refcount = &grpc_static_metadata_refcounts[9], .data.refcounted = {g_bytes + 77, 13}}, {.refcount = &grpc_static_metadata_refcounts[30], - .data.refcounted = {g_bytes + 359, 7}}}, + .data.refcounted = {g_bytes + 373, 4}}}, + {{.refcount = &grpc_static_metadata_refcounts[9], + .data.refcounted = {g_bytes + 77, 13}}, + {.refcount = &grpc_static_metadata_refcounts[31], + .data.refcounted = {g_bytes + 377, 7}}}, {{.refcount = &grpc_static_metadata_refcounts[5], .data.refcounted = {g_bytes + 36, 2}}, - {.refcount = &grpc_static_metadata_refcounts[31], - .data.refcounted = {g_bytes + 366, 8}}}, - {{.refcount = &grpc_static_metadata_refcounts[11], - .data.refcounted = {g_bytes + 110, 12}}, {.refcount = &grpc_static_metadata_refcounts[32], - .data.refcounted = {g_bytes + 374, 16}}}, + .data.refcounted = {g_bytes + 384, 8}}}, + {{.refcount = &grpc_static_metadata_refcounts[14], + .data.refcounted = {g_bytes + 158, 12}}, + {.refcount = &grpc_static_metadata_refcounts[33], + .data.refcounted = {g_bytes + 392, 16}}}, {{.refcount = &grpc_static_metadata_refcounts[1], .data.refcounted = {g_bytes + 5, 7}}, - {.refcount = &grpc_static_metadata_refcounts[33], - .data.refcounted = {g_bytes + 390, 4}}}, - {{.refcount = &grpc_static_metadata_refcounts[2], - .data.refcounted = {g_bytes + 12, 7}}, {.refcount = &grpc_static_metadata_refcounts[34], - .data.refcounted = {g_bytes + 394, 3}}}, + .data.refcounted = {g_bytes + 408, 4}}}, {{.refcount = &grpc_static_metadata_refcounts[2], .data.refcounted = {g_bytes + 12, 7}}, {.refcount = &grpc_static_metadata_refcounts[35], - .data.refcounted = {g_bytes + 397, 3}}}, - {{.refcount = &grpc_static_metadata_refcounts[4], - .data.refcounted = {g_bytes + 29, 7}}, + .data.refcounted = {g_bytes + 412, 3}}}, + {{.refcount = &grpc_static_metadata_refcounts[2], + .data.refcounted = {g_bytes + 12, 7}}, {.refcount = &grpc_static_metadata_refcounts[36], - .data.refcounted = {g_bytes + 400, 4}}}, + .data.refcounted = {g_bytes + 415, 3}}}, {{.refcount = &grpc_static_metadata_refcounts[4], .data.refcounted = {g_bytes + 29, 7}}, {.refcount = &grpc_static_metadata_refcounts[37], - .data.refcounted = {g_bytes + 404, 5}}}, + .data.refcounted = {g_bytes + 418, 4}}}, {{.refcount = &grpc_static_metadata_refcounts[4], .data.refcounted = {g_bytes + 29, 7}}, {.refcount = &grpc_static_metadata_refcounts[38], - .data.refcounted = {g_bytes + 409, 4}}}, + .data.refcounted = {g_bytes + 422, 5}}}, + {{.refcount = &grpc_static_metadata_refcounts[4], + .data.refcounted = {g_bytes + 29, 7}}, + {.refcount = &grpc_static_metadata_refcounts[39], + .data.refcounted = {g_bytes + 427, 4}}}, {{.refcount = &grpc_static_metadata_refcounts[3], .data.refcounted = {g_bytes + 19, 10}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[1], .data.refcounted = {g_bytes + 5, 7}}, - {.refcount = &grpc_static_metadata_refcounts[39], - .data.refcounted = {g_bytes + 413, 3}}}, + {.refcount = &grpc_static_metadata_refcounts[40], + .data.refcounted = {g_bytes + 431, 3}}}, {{.refcount = &grpc_static_metadata_refcounts[1], .data.refcounted = {g_bytes + 5, 7}}, - {.refcount = &grpc_static_metadata_refcounts[40], - .data.refcounted = {g_bytes + 416, 3}}}, - {{.refcount = &grpc_static_metadata_refcounts[0], - .data.refcounted = {g_bytes + 0, 5}}, {.refcount = &grpc_static_metadata_refcounts[41], - .data.refcounted = {g_bytes + 419, 1}}}, + .data.refcounted = {g_bytes + 434, 3}}}, {{.refcount = &grpc_static_metadata_refcounts[0], .data.refcounted = {g_bytes + 0, 5}}, {.refcount = &grpc_static_metadata_refcounts[42], - .data.refcounted = {g_bytes + 420, 11}}}, - {{.refcount = &grpc_static_metadata_refcounts[2], - .data.refcounted = {g_bytes + 12, 7}}, + .data.refcounted = {g_bytes + 437, 1}}}, + {{.refcount = &grpc_static_metadata_refcounts[0], + .data.refcounted = {g_bytes + 0, 5}}, {.refcount = &grpc_static_metadata_refcounts[43], - .data.refcounted = {g_bytes + 431, 3}}}, + .data.refcounted = {g_bytes + 438, 11}}}, {{.refcount = &grpc_static_metadata_refcounts[2], .data.refcounted = {g_bytes + 12, 7}}, {.refcount = &grpc_static_metadata_refcounts[44], - .data.refcounted = {g_bytes + 434, 3}}}, + .data.refcounted = {g_bytes + 449, 3}}}, {{.refcount = &grpc_static_metadata_refcounts[2], .data.refcounted = {g_bytes + 12, 7}}, {.refcount = &grpc_static_metadata_refcounts[45], - .data.refcounted = {g_bytes + 437, 3}}}, + .data.refcounted = {g_bytes + 452, 3}}}, {{.refcount = &grpc_static_metadata_refcounts[2], .data.refcounted = {g_bytes + 12, 7}}, {.refcount = &grpc_static_metadata_refcounts[46], - .data.refcounted = {g_bytes + 440, 3}}}, + .data.refcounted = {g_bytes + 455, 3}}}, {{.refcount = &grpc_static_metadata_refcounts[2], .data.refcounted = {g_bytes + 12, 7}}, {.refcount = &grpc_static_metadata_refcounts[47], - .data.refcounted = {g_bytes + 443, 3}}}, - {{.refcount = &grpc_static_metadata_refcounts[48], - .data.refcounted = {g_bytes + 446, 14}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, - {{.refcount = &grpc_static_metadata_refcounts[49], - .data.refcounted = {g_bytes + 460, 15}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 458, 3}}}, + {{.refcount = &grpc_static_metadata_refcounts[2], + .data.refcounted = {g_bytes + 12, 7}}, + {.refcount = &grpc_static_metadata_refcounts[48], + .data.refcounted = {g_bytes + 461, 3}}}, {{.refcount = &grpc_static_metadata_refcounts[49], - .data.refcounted = {g_bytes + 460, 15}}, - {.refcount = &grpc_static_metadata_refcounts[50], - .data.refcounted = {g_bytes + 475, 13}}}, - {{.refcount = &grpc_static_metadata_refcounts[51], - .data.refcounted = {g_bytes + 488, 15}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 464, 14}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, + {{.refcount = &grpc_static_metadata_refcounts[50], + .data.refcounted = {g_bytes + 478, 15}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, + {{.refcount = &grpc_static_metadata_refcounts[50], + .data.refcounted = {g_bytes + 478, 15}}, + {.refcount = &grpc_static_metadata_refcounts[51], + .data.refcounted = {g_bytes + 493, 13}}}, {{.refcount = &grpc_static_metadata_refcounts[52], - .data.refcounted = {g_bytes + 503, 13}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 506, 15}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[53], - .data.refcounted = {g_bytes + 516, 6}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 521, 13}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[54], - .data.refcounted = {g_bytes + 522, 27}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 534, 6}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[55], - .data.refcounted = {g_bytes + 549, 3}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 540, 27}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[56], - .data.refcounted = {g_bytes + 552, 5}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 567, 3}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[57], - .data.refcounted = {g_bytes + 557, 13}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 570, 5}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[58], - .data.refcounted = {g_bytes + 570, 13}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 575, 13}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[59], - .data.refcounted = {g_bytes + 583, 19}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 588, 13}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[60], - .data.refcounted = {g_bytes + 602, 16}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 601, 19}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[61], - .data.refcounted = {g_bytes + 618, 16}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 620, 16}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[62], - .data.refcounted = {g_bytes + 634, 14}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 636, 16}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[63], - .data.refcounted = {g_bytes + 648, 16}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 652, 14}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[64], - .data.refcounted = {g_bytes + 664, 13}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, - {{.refcount = &grpc_static_metadata_refcounts[11], - .data.refcounted = {g_bytes + 110, 12}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 666, 16}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[65], - .data.refcounted = {g_bytes + 677, 6}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 682, 13}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, + {{.refcount = &grpc_static_metadata_refcounts[14], + .data.refcounted = {g_bytes + 158, 12}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[66], - .data.refcounted = {g_bytes + 683, 4}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 695, 6}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[67], - .data.refcounted = {g_bytes + 687, 4}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 701, 4}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[68], - .data.refcounted = {g_bytes + 691, 6}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 705, 4}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[69], - .data.refcounted = {g_bytes + 697, 7}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 709, 6}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[70], - .data.refcounted = {g_bytes + 704, 4}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, - {{.refcount = &grpc_static_metadata_refcounts[14], - .data.refcounted = {g_bytes + 162, 4}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 715, 7}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[71], - .data.refcounted = {g_bytes + 708, 8}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 722, 4}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, + {{.refcount = &grpc_static_metadata_refcounts[17], + .data.refcounted = {g_bytes + 210, 4}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[72], - .data.refcounted = {g_bytes + 716, 17}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 726, 8}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[73], - .data.refcounted = {g_bytes + 733, 13}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 734, 17}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[74], - .data.refcounted = {g_bytes + 746, 8}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 751, 13}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[75], - .data.refcounted = {g_bytes + 754, 19}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 764, 8}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[76], - .data.refcounted = {g_bytes + 773, 13}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, - {{.refcount = &grpc_static_metadata_refcounts[15], - .data.refcounted = {g_bytes + 166, 8}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 772, 19}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[77], - .data.refcounted = {g_bytes + 786, 4}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 791, 13}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, + {{.refcount = &grpc_static_metadata_refcounts[18], + .data.refcounted = {g_bytes + 214, 8}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[78], - .data.refcounted = {g_bytes + 790, 8}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 804, 4}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[79], - .data.refcounted = {g_bytes + 798, 12}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 808, 8}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[80], - .data.refcounted = {g_bytes + 810, 18}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 816, 12}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[81], - .data.refcounted = {g_bytes + 828, 19}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 828, 18}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[82], - .data.refcounted = {g_bytes + 847, 5}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 846, 19}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[83], - .data.refcounted = {g_bytes + 852, 7}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 865, 5}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[84], - .data.refcounted = {g_bytes + 859, 7}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 870, 7}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[85], - .data.refcounted = {g_bytes + 866, 11}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 877, 7}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[86], - .data.refcounted = {g_bytes + 877, 6}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 884, 11}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[87], - .data.refcounted = {g_bytes + 883, 10}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 895, 6}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[88], - .data.refcounted = {g_bytes + 893, 25}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 901, 10}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[89], - .data.refcounted = {g_bytes + 918, 17}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, - {{.refcount = &grpc_static_metadata_refcounts[13], - .data.refcounted = {g_bytes + 152, 10}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 911, 25}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[90], - .data.refcounted = {g_bytes + 935, 4}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 936, 17}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, + {{.refcount = &grpc_static_metadata_refcounts[16], + .data.refcounted = {g_bytes + 200, 10}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[91], - .data.refcounted = {g_bytes + 939, 3}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 953, 4}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[92], - .data.refcounted = {g_bytes + 942, 16}}, - {.refcount = &grpc_static_metadata_refcounts[19], - .data.refcounted = {g_bytes + 216, 0}}}, + .data.refcounted = {g_bytes + 957, 3}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, + {{.refcount = &grpc_static_metadata_refcounts[93], + .data.refcounted = {g_bytes + 960, 16}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[10], .data.refcounted = {g_bytes + 90, 20}}, - {.refcount = &grpc_static_metadata_refcounts[28], - .data.refcounted = {g_bytes + 347, 8}}}, - {{.refcount = &grpc_static_metadata_refcounts[10], - .data.refcounted = {g_bytes + 90, 20}}, - {.refcount = &grpc_static_metadata_refcounts[30], - .data.refcounted = {g_bytes + 359, 7}}}, + {.refcount = &grpc_static_metadata_refcounts[29], + .data.refcounted = {g_bytes + 365, 8}}}, {{.refcount = &grpc_static_metadata_refcounts[10], .data.refcounted = {g_bytes + 90, 20}}, - {.refcount = &grpc_static_metadata_refcounts[93], - .data.refcounted = {g_bytes + 958, 16}}}, + {.refcount = &grpc_static_metadata_refcounts[31], + .data.refcounted = {g_bytes + 377, 7}}}, {{.refcount = &grpc_static_metadata_refcounts[10], .data.refcounted = {g_bytes + 90, 20}}, - {.refcount = &grpc_static_metadata_refcounts[29], - .data.refcounted = {g_bytes + 355, 4}}}, + {.refcount = &grpc_static_metadata_refcounts[94], + .data.refcounted = {g_bytes + 976, 16}}}, {{.refcount = &grpc_static_metadata_refcounts[10], .data.refcounted = {g_bytes + 90, 20}}, - {.refcount = &grpc_static_metadata_refcounts[94], - .data.refcounted = {g_bytes + 974, 13}}}, + {.refcount = &grpc_static_metadata_refcounts[30], + .data.refcounted = {g_bytes + 373, 4}}}, {{.refcount = &grpc_static_metadata_refcounts[10], .data.refcounted = {g_bytes + 90, 20}}, {.refcount = &grpc_static_metadata_refcounts[95], - .data.refcounted = {g_bytes + 987, 12}}}, + .data.refcounted = {g_bytes + 992, 13}}}, {{.refcount = &grpc_static_metadata_refcounts[10], .data.refcounted = {g_bytes + 90, 20}}, {.refcount = &grpc_static_metadata_refcounts[96], - .data.refcounted = {g_bytes + 999, 21}}}, + .data.refcounted = {g_bytes + 1005, 12}}}, + {{.refcount = &grpc_static_metadata_refcounts[10], + .data.refcounted = {g_bytes + 90, 20}}, + {.refcount = &grpc_static_metadata_refcounts[97], + .data.refcounted = {g_bytes + 1017, 21}}}, }; const uint8_t grpc_static_accept_encoding_metadata[8] = {0, 73, 74, 75, 76, 77, 78, 79}; diff --git a/src/core/lib/transport/static_metadata.h b/src/core/lib/transport/static_metadata.h index f9600ee2e4..dcbe418edc 100644 --- a/src/core/lib/transport/static_metadata.h +++ b/src/core/lib/transport/static_metadata.h @@ -44,7 +44,7 @@ #include "src/core/lib/transport/metadata.h" -#define GRPC_STATIC_MDSTR_COUNT 97 +#define GRPC_STATIC_MDSTR_COUNT 98 extern const grpc_slice grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT]; /* ":path" */ #define GRPC_MDSTR_PATH (grpc_static_slice_table[0]) @@ -68,182 +68,184 @@ extern const grpc_slice grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT]; #define GRPC_MDSTR_GRPC_ENCODING (grpc_static_slice_table[9]) /* "grpc-accept-encoding" */ #define GRPC_MDSTR_GRPC_ACCEPT_ENCODING (grpc_static_slice_table[10]) +/* "grpc-server-stats-bin" */ +#define GRPC_MDSTR_GRPC_SERVER_STATS_BIN (grpc_static_slice_table[11]) +/* "grpc-tags-bin" */ +#define GRPC_MDSTR_GRPC_TAGS_BIN (grpc_static_slice_table[12]) +/* "grpc-trace-bin" */ +#define GRPC_MDSTR_GRPC_TRACE_BIN (grpc_static_slice_table[13]) /* "content-type" */ -#define GRPC_MDSTR_CONTENT_TYPE (grpc_static_slice_table[11]) +#define GRPC_MDSTR_CONTENT_TYPE (grpc_static_slice_table[14]) /* "grpc-internal-encoding-request" */ -#define GRPC_MDSTR_GRPC_INTERNAL_ENCODING_REQUEST (grpc_static_slice_table[12]) +#define GRPC_MDSTR_GRPC_INTERNAL_ENCODING_REQUEST (grpc_static_slice_table[15]) /* "user-agent" */ -#define GRPC_MDSTR_USER_AGENT (grpc_static_slice_table[13]) +#define GRPC_MDSTR_USER_AGENT (grpc_static_slice_table[16]) /* "host" */ -#define GRPC_MDSTR_HOST (grpc_static_slice_table[14]) +#define GRPC_MDSTR_HOST (grpc_static_slice_table[17]) /* "lb-token" */ -#define GRPC_MDSTR_LB_TOKEN (grpc_static_slice_table[15]) +#define GRPC_MDSTR_LB_TOKEN (grpc_static_slice_table[18]) /* "grpc-timeout" */ -#define GRPC_MDSTR_GRPC_TIMEOUT (grpc_static_slice_table[16]) -/* "grpc-tracing-bin" */ -#define GRPC_MDSTR_GRPC_TRACING_BIN (grpc_static_slice_table[17]) -/* "grpc-stats-bin" */ -#define GRPC_MDSTR_GRPC_STATS_BIN (grpc_static_slice_table[18]) +#define GRPC_MDSTR_GRPC_TIMEOUT (grpc_static_slice_table[19]) /* "" */ -#define GRPC_MDSTR_EMPTY (grpc_static_slice_table[19]) +#define GRPC_MDSTR_EMPTY (grpc_static_slice_table[20]) /* "grpc.wait_for_ready" */ -#define GRPC_MDSTR_GRPC_DOT_WAIT_FOR_READY (grpc_static_slice_table[20]) +#define GRPC_MDSTR_GRPC_DOT_WAIT_FOR_READY (grpc_static_slice_table[21]) /* "grpc.timeout" */ -#define GRPC_MDSTR_GRPC_DOT_TIMEOUT (grpc_static_slice_table[21]) +#define GRPC_MDSTR_GRPC_DOT_TIMEOUT (grpc_static_slice_table[22]) /* "grpc.max_request_message_bytes" */ #define GRPC_MDSTR_GRPC_DOT_MAX_REQUEST_MESSAGE_BYTES \ - (grpc_static_slice_table[22]) + (grpc_static_slice_table[23]) /* "grpc.max_response_message_bytes" */ #define GRPC_MDSTR_GRPC_DOT_MAX_RESPONSE_MESSAGE_BYTES \ - (grpc_static_slice_table[23]) + (grpc_static_slice_table[24]) /* "/grpc.lb.v1.LoadBalancer/BalanceLoad" */ #define GRPC_MDSTR_SLASH_GRPC_DOT_LB_DOT_V1_DOT_LOADBALANCER_SLASH_BALANCELOAD \ - (grpc_static_slice_table[24]) + (grpc_static_slice_table[25]) /* "0" */ -#define GRPC_MDSTR_0 (grpc_static_slice_table[25]) +#define GRPC_MDSTR_0 (grpc_static_slice_table[26]) /* "1" */ -#define GRPC_MDSTR_1 (grpc_static_slice_table[26]) +#define GRPC_MDSTR_1 (grpc_static_slice_table[27]) /* "2" */ -#define GRPC_MDSTR_2 (grpc_static_slice_table[27]) +#define GRPC_MDSTR_2 (grpc_static_slice_table[28]) /* "identity" */ -#define GRPC_MDSTR_IDENTITY (grpc_static_slice_table[28]) +#define GRPC_MDSTR_IDENTITY (grpc_static_slice_table[29]) /* "gzip" */ -#define GRPC_MDSTR_GZIP (grpc_static_slice_table[29]) +#define GRPC_MDSTR_GZIP (grpc_static_slice_table[30]) /* "deflate" */ -#define GRPC_MDSTR_DEFLATE (grpc_static_slice_table[30]) +#define GRPC_MDSTR_DEFLATE (grpc_static_slice_table[31]) /* "trailers" */ -#define GRPC_MDSTR_TRAILERS (grpc_static_slice_table[31]) +#define GRPC_MDSTR_TRAILERS (grpc_static_slice_table[32]) /* "application/grpc" */ -#define GRPC_MDSTR_APPLICATION_SLASH_GRPC (grpc_static_slice_table[32]) +#define GRPC_MDSTR_APPLICATION_SLASH_GRPC (grpc_static_slice_table[33]) /* "POST" */ -#define GRPC_MDSTR_POST (grpc_static_slice_table[33]) +#define GRPC_MDSTR_POST (grpc_static_slice_table[34]) /* "200" */ -#define GRPC_MDSTR_200 (grpc_static_slice_table[34]) +#define GRPC_MDSTR_200 (grpc_static_slice_table[35]) /* "404" */ -#define GRPC_MDSTR_404 (grpc_static_slice_table[35]) +#define GRPC_MDSTR_404 (grpc_static_slice_table[36]) /* "http" */ -#define GRPC_MDSTR_HTTP (grpc_static_slice_table[36]) +#define GRPC_MDSTR_HTTP (grpc_static_slice_table[37]) /* "https" */ -#define GRPC_MDSTR_HTTPS (grpc_static_slice_table[37]) +#define GRPC_MDSTR_HTTPS (grpc_static_slice_table[38]) /* "grpc" */ -#define GRPC_MDSTR_GRPC (grpc_static_slice_table[38]) +#define GRPC_MDSTR_GRPC (grpc_static_slice_table[39]) /* "GET" */ -#define GRPC_MDSTR_GET (grpc_static_slice_table[39]) +#define GRPC_MDSTR_GET (grpc_static_slice_table[40]) /* "PUT" */ -#define GRPC_MDSTR_PUT (grpc_static_slice_table[40]) +#define GRPC_MDSTR_PUT (grpc_static_slice_table[41]) /* "/" */ -#define GRPC_MDSTR_SLASH (grpc_static_slice_table[41]) +#define GRPC_MDSTR_SLASH (grpc_static_slice_table[42]) /* "/index.html" */ -#define GRPC_MDSTR_SLASH_INDEX_DOT_HTML (grpc_static_slice_table[42]) +#define GRPC_MDSTR_SLASH_INDEX_DOT_HTML (grpc_static_slice_table[43]) /* "204" */ -#define GRPC_MDSTR_204 (grpc_static_slice_table[43]) +#define GRPC_MDSTR_204 (grpc_static_slice_table[44]) /* "206" */ -#define GRPC_MDSTR_206 (grpc_static_slice_table[44]) +#define GRPC_MDSTR_206 (grpc_static_slice_table[45]) /* "304" */ -#define GRPC_MDSTR_304 (grpc_static_slice_table[45]) +#define GRPC_MDSTR_304 (grpc_static_slice_table[46]) /* "400" */ -#define GRPC_MDSTR_400 (grpc_static_slice_table[46]) +#define GRPC_MDSTR_400 (grpc_static_slice_table[47]) /* "500" */ -#define GRPC_MDSTR_500 (grpc_static_slice_table[47]) +#define GRPC_MDSTR_500 (grpc_static_slice_table[48]) /* "accept-charset" */ -#define GRPC_MDSTR_ACCEPT_CHARSET (grpc_static_slice_table[48]) +#define GRPC_MDSTR_ACCEPT_CHARSET (grpc_static_slice_table[49]) /* "accept-encoding" */ -#define GRPC_MDSTR_ACCEPT_ENCODING (grpc_static_slice_table[49]) +#define GRPC_MDSTR_ACCEPT_ENCODING (grpc_static_slice_table[50]) /* "gzip, deflate" */ -#define GRPC_MDSTR_GZIP_COMMA_DEFLATE (grpc_static_slice_table[50]) +#define GRPC_MDSTR_GZIP_COMMA_DEFLATE (grpc_static_slice_table[51]) /* "accept-language" */ -#define GRPC_MDSTR_ACCEPT_LANGUAGE (grpc_static_slice_table[51]) +#define GRPC_MDSTR_ACCEPT_LANGUAGE (grpc_static_slice_table[52]) /* "accept-ranges" */ -#define GRPC_MDSTR_ACCEPT_RANGES (grpc_static_slice_table[52]) +#define GRPC_MDSTR_ACCEPT_RANGES (grpc_static_slice_table[53]) /* "accept" */ -#define GRPC_MDSTR_ACCEPT (grpc_static_slice_table[53]) +#define GRPC_MDSTR_ACCEPT (grpc_static_slice_table[54]) /* "access-control-allow-origin" */ -#define GRPC_MDSTR_ACCESS_CONTROL_ALLOW_ORIGIN (grpc_static_slice_table[54]) +#define GRPC_MDSTR_ACCESS_CONTROL_ALLOW_ORIGIN (grpc_static_slice_table[55]) /* "age" */ -#define GRPC_MDSTR_AGE (grpc_static_slice_table[55]) +#define GRPC_MDSTR_AGE (grpc_static_slice_table[56]) /* "allow" */ -#define GRPC_MDSTR_ALLOW (grpc_static_slice_table[56]) +#define GRPC_MDSTR_ALLOW (grpc_static_slice_table[57]) /* "authorization" */ -#define GRPC_MDSTR_AUTHORIZATION (grpc_static_slice_table[57]) +#define GRPC_MDSTR_AUTHORIZATION (grpc_static_slice_table[58]) /* "cache-control" */ -#define GRPC_MDSTR_CACHE_CONTROL (grpc_static_slice_table[58]) +#define GRPC_MDSTR_CACHE_CONTROL (grpc_static_slice_table[59]) /* "content-disposition" */ -#define GRPC_MDSTR_CONTENT_DISPOSITION (grpc_static_slice_table[59]) +#define GRPC_MDSTR_CONTENT_DISPOSITION (grpc_static_slice_table[60]) /* "content-encoding" */ -#define GRPC_MDSTR_CONTENT_ENCODING (grpc_static_slice_table[60]) +#define GRPC_MDSTR_CONTENT_ENCODING (grpc_static_slice_table[61]) /* "content-language" */ -#define GRPC_MDSTR_CONTENT_LANGUAGE (grpc_static_slice_table[61]) +#define GRPC_MDSTR_CONTENT_LANGUAGE (grpc_static_slice_table[62]) /* "content-length" */ -#define GRPC_MDSTR_CONTENT_LENGTH (grpc_static_slice_table[62]) +#define GRPC_MDSTR_CONTENT_LENGTH (grpc_static_slice_table[63]) /* "content-location" */ -#define GRPC_MDSTR_CONTENT_LOCATION (grpc_static_slice_table[63]) +#define GRPC_MDSTR_CONTENT_LOCATION (grpc_static_slice_table[64]) /* "content-range" */ -#define GRPC_MDSTR_CONTENT_RANGE (grpc_static_slice_table[64]) +#define GRPC_MDSTR_CONTENT_RANGE (grpc_static_slice_table[65]) /* "cookie" */ -#define GRPC_MDSTR_COOKIE (grpc_static_slice_table[65]) +#define GRPC_MDSTR_COOKIE (grpc_static_slice_table[66]) /* "date" */ -#define GRPC_MDSTR_DATE (grpc_static_slice_table[66]) +#define GRPC_MDSTR_DATE (grpc_static_slice_table[67]) /* "etag" */ -#define GRPC_MDSTR_ETAG (grpc_static_slice_table[67]) +#define GRPC_MDSTR_ETAG (grpc_static_slice_table[68]) /* "expect" */ -#define GRPC_MDSTR_EXPECT (grpc_static_slice_table[68]) +#define GRPC_MDSTR_EXPECT (grpc_static_slice_table[69]) /* "expires" */ -#define GRPC_MDSTR_EXPIRES (grpc_static_slice_table[69]) +#define GRPC_MDSTR_EXPIRES (grpc_static_slice_table[70]) /* "from" */ -#define GRPC_MDSTR_FROM (grpc_static_slice_table[70]) +#define GRPC_MDSTR_FROM (grpc_static_slice_table[71]) /* "if-match" */ -#define GRPC_MDSTR_IF_MATCH (grpc_static_slice_table[71]) +#define GRPC_MDSTR_IF_MATCH (grpc_static_slice_table[72]) /* "if-modified-since" */ -#define GRPC_MDSTR_IF_MODIFIED_SINCE (grpc_static_slice_table[72]) +#define GRPC_MDSTR_IF_MODIFIED_SINCE (grpc_static_slice_table[73]) /* "if-none-match" */ -#define GRPC_MDSTR_IF_NONE_MATCH (grpc_static_slice_table[73]) +#define GRPC_MDSTR_IF_NONE_MATCH (grpc_static_slice_table[74]) /* "if-range" */ -#define GRPC_MDSTR_IF_RANGE (grpc_static_slice_table[74]) +#define GRPC_MDSTR_IF_RANGE (grpc_static_slice_table[75]) /* "if-unmodified-since" */ -#define GRPC_MDSTR_IF_UNMODIFIED_SINCE (grpc_static_slice_table[75]) +#define GRPC_MDSTR_IF_UNMODIFIED_SINCE (grpc_static_slice_table[76]) /* "last-modified" */ -#define GRPC_MDSTR_LAST_MODIFIED (grpc_static_slice_table[76]) +#define GRPC_MDSTR_LAST_MODIFIED (grpc_static_slice_table[77]) /* "link" */ -#define GRPC_MDSTR_LINK (grpc_static_slice_table[77]) +#define GRPC_MDSTR_LINK (grpc_static_slice_table[78]) /* "location" */ -#define GRPC_MDSTR_LOCATION (grpc_static_slice_table[78]) +#define GRPC_MDSTR_LOCATION (grpc_static_slice_table[79]) /* "max-forwards" */ -#define GRPC_MDSTR_MAX_FORWARDS (grpc_static_slice_table[79]) +#define GRPC_MDSTR_MAX_FORWARDS (grpc_static_slice_table[80]) /* "proxy-authenticate" */ -#define GRPC_MDSTR_PROXY_AUTHENTICATE (grpc_static_slice_table[80]) +#define GRPC_MDSTR_PROXY_AUTHENTICATE (grpc_static_slice_table[81]) /* "proxy-authorization" */ -#define GRPC_MDSTR_PROXY_AUTHORIZATION (grpc_static_slice_table[81]) +#define GRPC_MDSTR_PROXY_AUTHORIZATION (grpc_static_slice_table[82]) /* "range" */ -#define GRPC_MDSTR_RANGE (grpc_static_slice_table[82]) +#define GRPC_MDSTR_RANGE (grpc_static_slice_table[83]) /* "referer" */ -#define GRPC_MDSTR_REFERER (grpc_static_slice_table[83]) +#define GRPC_MDSTR_REFERER (grpc_static_slice_table[84]) /* "refresh" */ -#define GRPC_MDSTR_REFRESH (grpc_static_slice_table[84]) +#define GRPC_MDSTR_REFRESH (grpc_static_slice_table[85]) /* "retry-after" */ -#define GRPC_MDSTR_RETRY_AFTER (grpc_static_slice_table[85]) +#define GRPC_MDSTR_RETRY_AFTER (grpc_static_slice_table[86]) /* "server" */ -#define GRPC_MDSTR_SERVER (grpc_static_slice_table[86]) +#define GRPC_MDSTR_SERVER (grpc_static_slice_table[87]) /* "set-cookie" */ -#define GRPC_MDSTR_SET_COOKIE (grpc_static_slice_table[87]) +#define GRPC_MDSTR_SET_COOKIE (grpc_static_slice_table[88]) /* "strict-transport-security" */ -#define GRPC_MDSTR_STRICT_TRANSPORT_SECURITY (grpc_static_slice_table[88]) +#define GRPC_MDSTR_STRICT_TRANSPORT_SECURITY (grpc_static_slice_table[89]) /* "transfer-encoding" */ -#define GRPC_MDSTR_TRANSFER_ENCODING (grpc_static_slice_table[89]) +#define GRPC_MDSTR_TRANSFER_ENCODING (grpc_static_slice_table[90]) /* "vary" */ -#define GRPC_MDSTR_VARY (grpc_static_slice_table[90]) +#define GRPC_MDSTR_VARY (grpc_static_slice_table[91]) /* "via" */ -#define GRPC_MDSTR_VIA (grpc_static_slice_table[91]) +#define GRPC_MDSTR_VIA (grpc_static_slice_table[92]) /* "www-authenticate" */ -#define GRPC_MDSTR_WWW_AUTHENTICATE (grpc_static_slice_table[92]) +#define GRPC_MDSTR_WWW_AUTHENTICATE (grpc_static_slice_table[93]) /* "identity,deflate" */ -#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE (grpc_static_slice_table[93]) +#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE (grpc_static_slice_table[94]) /* "identity,gzip" */ -#define GRPC_MDSTR_IDENTITY_COMMA_GZIP (grpc_static_slice_table[94]) +#define GRPC_MDSTR_IDENTITY_COMMA_GZIP (grpc_static_slice_table[95]) /* "deflate,gzip" */ -#define GRPC_MDSTR_DEFLATE_COMMA_GZIP (grpc_static_slice_table[95]) +#define GRPC_MDSTR_DEFLATE_COMMA_GZIP (grpc_static_slice_table[96]) /* "identity,deflate,gzip" */ #define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE_COMMA_GZIP \ - (grpc_static_slice_table[96]) + (grpc_static_slice_table[97]) extern const grpc_slice_refcount_vtable grpc_static_metadata_vtable; extern grpc_slice_refcount @@ -512,6 +514,9 @@ typedef enum { GRPC_BATCH_GRPC_PAYLOAD_BIN, GRPC_BATCH_GRPC_ENCODING, GRPC_BATCH_GRPC_ACCEPT_ENCODING, + GRPC_BATCH_GRPC_SERVER_STATS_BIN, + GRPC_BATCH_GRPC_TAGS_BIN, + GRPC_BATCH_GRPC_TRACE_BIN, GRPC_BATCH_CONTENT_TYPE, GRPC_BATCH_GRPC_INTERNAL_ENCODING_REQUEST, GRPC_BATCH_USER_AGENT, @@ -534,6 +539,9 @@ typedef union { struct grpc_linked_mdelem *grpc_payload_bin; struct grpc_linked_mdelem *grpc_encoding; struct grpc_linked_mdelem *grpc_accept_encoding; + struct grpc_linked_mdelem *grpc_server_stats_bin; + struct grpc_linked_mdelem *grpc_tags_bin; + struct grpc_linked_mdelem *grpc_trace_bin; struct grpc_linked_mdelem *content_type; struct grpc_linked_mdelem *grpc_internal_encoding_request; struct grpc_linked_mdelem *user_agent; diff --git a/test/core/end2end/fuzzers/hpack.dictionary b/test/core/end2end/fuzzers/hpack.dictionary index 6b96785419..4282c61214 100644 --- a/test/core/end2end/fuzzers/hpack.dictionary +++ b/test/core/end2end/fuzzers/hpack.dictionary @@ -10,14 +10,15 @@ "\x10grpc-payload-bin" "\x0Dgrpc-encoding" "\x14grpc-accept-encoding" +"\x15grpc-server-stats-bin" +"\x0Dgrpc-tags-bin" +"\x0Egrpc-trace-bin" "\x0Ccontent-type" "\x1Egrpc-internal-encoding-request" "\x0Auser-agent" "\x04host" "\x08lb-token" "\x0Cgrpc-timeout" -"\x10grpc-tracing-bin" -"\x0Egrpc-stats-bin" "\x00" "\x13grpc.wait_for_ready" "\x0Cgrpc.timeout" diff --git a/tools/codegen/core/gen_static_metadata.py b/tools/codegen/core/gen_static_metadata.py index 109701f740..ead57b2bf6 100755 --- a/tools/codegen/core/gen_static_metadata.py +++ b/tools/codegen/core/gen_static_metadata.py @@ -56,8 +56,9 @@ CONFIG = [ ':authority', 'grpc-message', 'grpc-status', - 'grpc-tracing-bin', - 'grpc-stats-bin', + 'grpc-server-stats-bin', + 'grpc-tags-bin', + 'grpc-trace-bin', '', # channel arg keys 'grpc.wait_for_ready', @@ -154,6 +155,9 @@ METADATA_BATCH_CALLOUTS = [ 'grpc-payload-bin', 'grpc-encoding', 'grpc-accept-encoding', + 'grpc-server-stats-bin', + 'grpc-tags-bin', + 'grpc-trace-bin', 'content-type', 'grpc-internal-encoding-request', 'user-agent', @@ -167,6 +171,7 @@ COMPRESSION_ALGORITHMS = [ 'gzip', ] + # utility: mangle the name of a config def mangle(elem, name=None): xl = { @@ -177,43 +182,56 @@ def mangle(elem, name=None): ',': 'comma', ' ': '_', } + def m0(x): - if not x: return 'empty' + if not x: + return 'empty' r = '' for c in x: put = xl.get(c, c.lower()) - if not put: continue + if not put: + continue last_is_underscore = r[-1] == '_' if r else True - if last_is_underscore and put == '_': continue + if last_is_underscore and put == '_': + continue elif len(put) > 1: - if not last_is_underscore: r += '_' + if not last_is_underscore: + r += '_' r += put r += '_' else: r += put - if r[-1] == '_': r = r[:-1] + if r[-1] == '_': + r = r[:-1] return r + def n(default, name=name): - if name is None: return 'grpc_%s_' % default - if name == '': return '' + if name is None: + return 'grpc_%s_' % default + if name == '': + return '' return 'grpc_%s_' % name + if isinstance(elem, tuple): return '%s%s_%s' % (n('mdelem'), m0(elem[0]), m0(elem[1])) else: return '%s%s' % (n('mdstr'), m0(elem)) + # utility: generate some hash value for a string def fake_hash(elem): return hashlib.md5(elem).hexdigest()[0:8] + # utility: print a big comment block into a set of files def put_banner(files, banner): for f in files: - print >>f, '/*' + print >> f, '/*' for line in banner: - print >>f, ' * %s' % line - print >>f, ' */' - print >>f + print >> f, ' * %s' % line + print >> f, ' */' + print >> f + # build a list of all the strings we need all_strs = list() @@ -236,7 +254,7 @@ for elem in CONFIG: if elem not in all_strs: all_strs.append(elem) compression_elems = [] -for mask in range(1, 1<>H, '#ifndef GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H' -print >>H, '#define GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H' -print >>H -print >>H, '#include "src/core/lib/transport/metadata.h"' -print >>H +print >> H, '#ifndef GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H' +print >> H, '#define GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H' +print >> H +print >> H, '#include "src/core/lib/transport/metadata.h"' +print >> H -print >>C, '#include "src/core/lib/transport/static_metadata.h"' -print >>C -print >>C, '#include "src/core/lib/slice/slice_internal.h"' -print >>C +print >> C, '#include "src/core/lib/transport/static_metadata.h"' +print >> C +print >> C, '#include "src/core/lib/slice/slice_internal.h"' +print >> C str_ofs = 0 id2strofs = {} for i, elem in enumerate(all_strs): id2strofs[i] = str_ofs - str_ofs += len(elem); + str_ofs += len(elem) + + def slice_def(i): - return '{.refcount = &grpc_static_metadata_refcounts[%d], .data.refcounted = {g_bytes+%d, %d}}' % (i, id2strofs[i], len(all_strs[i])) + return ('{.refcount = &grpc_static_metadata_refcounts[%d], .data.refcounted =' + ' {g_bytes+%d, %d}}') % ( + i, id2strofs[i], len(all_strs[i])) + # validate configuration for elem in METADATA_BATCH_CALLOUTS: assert elem in all_strs -print >>H, '#define GRPC_STATIC_MDSTR_COUNT %d' % len(all_strs) -print >>H, 'extern const grpc_slice grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT];' +print >> H, '#define GRPC_STATIC_MDSTR_COUNT %d' % len(all_strs) +print >> H, ('extern const grpc_slice ' + 'grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT];') for i, elem in enumerate(all_strs): - print >>H, '/* "%s" */' % elem - print >>H, '#define %s (grpc_static_slice_table[%d])' % (mangle(elem).upper(), i) -print >>H -print >>C, 'static uint8_t g_bytes[] = {%s};' % (','.join('%d' % ord(c) for c in ''.join(all_strs))) -print >>C -print >>C, 'static void static_ref(void *unused) {}' -print >>C, 'static void static_unref(grpc_exec_ctx *exec_ctx, void *unused) {}' -print >>C, 'static const grpc_slice_refcount_vtable static_sub_vtable = {static_ref, static_unref, grpc_slice_default_eq_impl, grpc_slice_default_hash_impl};'; -print >>H, 'extern const grpc_slice_refcount_vtable grpc_static_metadata_vtable;'; -print >>C, 'const grpc_slice_refcount_vtable grpc_static_metadata_vtable = {static_ref, static_unref, grpc_static_slice_eq, grpc_static_slice_hash};'; -print >>C, 'static grpc_slice_refcount static_sub_refcnt = {&static_sub_vtable, &static_sub_refcnt};'; -print >>H, 'extern grpc_slice_refcount grpc_static_metadata_refcounts[GRPC_STATIC_MDSTR_COUNT];' -print >>C, 'grpc_slice_refcount grpc_static_metadata_refcounts[GRPC_STATIC_MDSTR_COUNT] = {' + print >> H, '/* "%s" */' % elem + print >> H, '#define %s (grpc_static_slice_table[%d])' % ( + mangle(elem).upper(), i) +print >> H +print >> C, 'static uint8_t g_bytes[] = {%s};' % ( + ','.join('%d' % ord(c) for c in ''.join(all_strs))) +print >> C +print >> C, 'static void static_ref(void *unused) {}' +print >> C, 'static void static_unref(grpc_exec_ctx *exec_ctx, void *unused) {}' +print >> C, ('static const grpc_slice_refcount_vtable static_sub_vtable = ' + '{static_ref, static_unref, grpc_slice_default_eq_impl, ' + 'grpc_slice_default_hash_impl};') +print >> H, ('extern const grpc_slice_refcount_vtable ' + 'grpc_static_metadata_vtable;') +print >> C, ('const grpc_slice_refcount_vtable grpc_static_metadata_vtable = ' + '{static_ref, static_unref, grpc_static_slice_eq, ' + 'grpc_static_slice_hash};') +print >> C, ('static grpc_slice_refcount static_sub_refcnt = ' + '{&static_sub_vtable, &static_sub_refcnt};') +print >> H, ('extern grpc_slice_refcount ' + 'grpc_static_metadata_refcounts[GRPC_STATIC_MDSTR_COUNT];') +print >> C, ('grpc_slice_refcount ' + 'grpc_static_metadata_refcounts[GRPC_STATIC_MDSTR_COUNT] = {') for i, elem in enumerate(all_strs): - print >>C, ' {&grpc_static_metadata_vtable, &static_sub_refcnt},' -print >>C, '};' -print >>C -print >>H, '#define GRPC_IS_STATIC_METADATA_STRING(slice) \\' -print >>H, ' ((slice).refcount != NULL && (slice).refcount->vtable == &grpc_static_metadata_vtable)' -print >>H -print >>C, 'const grpc_slice grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT] = {' + print >> C, ' {&grpc_static_metadata_vtable, &static_sub_refcnt},' +print >> C, '};' +print >> C +print >> H, '#define GRPC_IS_STATIC_METADATA_STRING(slice) \\' +print >> H, (' ((slice).refcount != NULL && (slice).refcount->vtable == ' + '&grpc_static_metadata_vtable)') +print >> H +print >> C, ('const grpc_slice grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT]' + ' = {') for i, elem in enumerate(all_strs): - print >>C, slice_def(i) + ',' -print >>C, '};' -print >>C -print >>H, '#define GRPC_STATIC_METADATA_INDEX(static_slice) \\' -print >>H, ' ((int)((static_slice).refcount - grpc_static_metadata_refcounts))' -print >>H - -print >>D, '# hpack fuzzing dictionary' + print >> C, slice_def(i) + ',' +print >> C, '};' +print >> C +print >> H, '#define GRPC_STATIC_METADATA_INDEX(static_slice) \\' +print >> H, (' ((int)((static_slice).refcount - ' + 'grpc_static_metadata_refcounts))') +print >> H + +print >> D, '# hpack fuzzing dictionary' for i, elem in enumerate(all_strs): - print >>D, '%s' % (esc_dict([len(elem)] + [ord(c) for c in elem])) + print >> D, '%s' % (esc_dict([len(elem)] + [ord(c) for c in elem])) for i, elem in enumerate(all_elems): - print >>D, '%s' % (esc_dict([0, len(elem[0])] + [ord(c) for c in elem[0]] + - [len(elem[1])] + [ord(c) for c in elem[1]])) - -print >>H, '#define GRPC_STATIC_MDELEM_COUNT %d' % len(all_elems) -print >>H, 'extern grpc_mdelem_data grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT];' -print >>H, 'extern uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT];' + print >> D, '%s' % (esc_dict([0, len(elem[0])] + [ord(c) for c in elem[0]] + + [len(elem[1])] + [ord(c) for c in elem[1]])) + +print >> H, '#define GRPC_STATIC_MDELEM_COUNT %d' % len(all_elems) +print >> H, ('extern grpc_mdelem_data ' + 'grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT];') +print >> H, ('extern uintptr_t ' + 'grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT];') for i, elem in enumerate(all_elems): - print >>H, '/* "%s": "%s" */' % elem - print >>H, '#define %s (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[%d], GRPC_MDELEM_STORAGE_STATIC))' % (mangle(elem).upper(), i) -print >>H -print >>C, 'uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] = {' -print >>C, ' %s' % ','.join('%d' % static_userdata.get(elem, 0) for elem in all_elems) -print >>C, '};' -print >>C + print >> H, '/* "%s": "%s" */' % elem + print >> H, ('#define %s (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[%d], ' + 'GRPC_MDELEM_STORAGE_STATIC))') % ( + mangle(elem).upper(), i) +print >> H +print >> C, ('uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] ' + '= {') +print >> C, ' %s' % ','.join('%d' % static_userdata.get(elem, 0) + for elem in all_elems) +print >> C, '};' +print >> C + def str_idx(s): for i, s2 in enumerate(all_strs): if s == s2: return i + def md_idx(m): for i, m2 in enumerate(all_elems): if m == m2: return i + def offset_trials(mink): yield 0 for i in range(1, 100): for mul in [-1, 1]: yield mul * i + def perfect_hash(keys, name): p = perfection.hash_parameters(keys) + def f(i, p=p): i += p.offset x = i % p.t y = i / p.t return x + p.r[y] + return { - 'PHASHRANGE': p.t - 1 + max(p.r), - 'PHASHNKEYS': len(p.slots), - 'pyfunc': f, - 'code': """ + 'PHASHRANGE': + p.t - 1 + max(p.r), + 'PHASHNKEYS': + len(p.slots), + 'pyfunc': + f, + 'code': + """ static const int8_t %(name)s_r[] = {%(r)s}; static uint32_t %(name)s_phash(uint32_t i) { i %(offset_sign)s= %(offset)d; @@ -430,71 +489,77 @@ static uint32_t %(name)s_phash(uint32_t i) { return h; } """ % { - 'name': name, - 'r': ','.join('%d' % (r if r is not None else 0) for r in p.r), - 't': p.t, - 'offset': abs(p.offset), - 'offset_sign': '+' if p.offset > 0 else '-' + 'name': name, + 'r': ','.join('%d' % (r if r is not None else 0) for r in p.r), + 't': p.t, + 'offset': abs(p.offset), + 'offset_sign': '+' if p.offset > 0 else '-' } } -elem_keys = [str_idx(elem[0]) * len(all_strs) + str_idx(elem[1]) for elem in all_elems] -elem_hash = perfect_hash(elem_keys, "elems") -print >>C, elem_hash['code'] +elem_keys = [ + str_idx(elem[0]) * len(all_strs) + str_idx(elem[1]) for elem in all_elems +] +elem_hash = perfect_hash(elem_keys, 'elems') +print >> C, elem_hash['code'] keys = [0] * int(elem_hash['PHASHRANGE']) idxs = [255] * int(elem_hash['PHASHNKEYS']) for i, k in enumerate(elem_keys): - h = elem_hash['pyfunc'](k) - assert keys[h] == 0 - keys[h] = k - idxs[h] = i -print >>C, 'static const uint16_t elem_keys[] = {%s};' % ','.join('%d' % k for k in keys) -print >>C, 'static const uint8_t elem_idxs[] = {%s};' % ','.join('%d' % i for i in idxs) -print >>C - -print >>H, 'grpc_mdelem grpc_static_mdelem_for_static_strings(int a, int b);' -print >>C, 'grpc_mdelem grpc_static_mdelem_for_static_strings(int a, int b) {' -print >>C, ' if (a == -1 || b == -1) return GRPC_MDNULL;' -print >>C, ' uint32_t k = (uint32_t)(a * %d + b);' % len(all_strs) -print >>C, ' uint32_t h = elems_phash(k);' -print >>C, ' return h < GPR_ARRAY_SIZE(elem_keys) && elem_keys[h] == k ? GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[elem_idxs[h]], GRPC_MDELEM_STORAGE_STATIC) : GRPC_MDNULL;' -print >>C, '}' -print >>C - -print >>C, 'grpc_mdelem_data grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = {' + h = elem_hash['pyfunc'](k) + assert keys[h] == 0 + keys[h] = k + idxs[h] = i +print >> C, 'static const uint16_t elem_keys[] = {%s};' % ','.join( + '%d' % k for k in keys) +print >> C, 'static const uint8_t elem_idxs[] = {%s};' % ','.join( + '%d' % i for i in idxs) +print >> C + +print >> H, 'grpc_mdelem grpc_static_mdelem_for_static_strings(int a, int b);' +print >> C, 'grpc_mdelem grpc_static_mdelem_for_static_strings(int a, int b) {' +print >> C, ' if (a == -1 || b == -1) return GRPC_MDNULL;' +print >> C, ' uint32_t k = (uint32_t)(a * %d + b);' % len(all_strs) +print >> C, ' uint32_t h = elems_phash(k);' +print >> C, ' return h < GPR_ARRAY_SIZE(elem_keys) && elem_keys[h] == k ? GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[elem_idxs[h]], GRPC_MDELEM_STORAGE_STATIC) : GRPC_MDNULL;' +print >> C, '}' +print >> C + +print >> C, 'grpc_mdelem_data grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = {' for a, b in all_elems: - print >>C, '{%s,%s},' % (slice_def(str_idx(a)), slice_def(str_idx(b))) -print >>C, '};' + print >> C, '{%s,%s},' % (slice_def(str_idx(a)), slice_def(str_idx(b))) +print >> C, '};' -print >>H, 'typedef enum {' +print >> H, 'typedef enum {' for elem in METADATA_BATCH_CALLOUTS: - print >>H, ' %s,' % mangle(elem, 'batch').upper() -print >>H, ' GRPC_BATCH_CALLOUTS_COUNT' -print >>H, '} grpc_metadata_batch_callouts_index;' -print >>H -print >>H, 'typedef union {' -print >>H, ' struct grpc_linked_mdelem *array[GRPC_BATCH_CALLOUTS_COUNT];' -print >>H, ' struct {' + print >> H, ' %s,' % mangle(elem, 'batch').upper() +print >> H, ' GRPC_BATCH_CALLOUTS_COUNT' +print >> H, '} grpc_metadata_batch_callouts_index;' +print >> H +print >> H, 'typedef union {' +print >> H, ' struct grpc_linked_mdelem *array[GRPC_BATCH_CALLOUTS_COUNT];' +print >> H, ' struct {' for elem in METADATA_BATCH_CALLOUTS: - print >>H, ' struct grpc_linked_mdelem *%s;' % mangle(elem, '').lower() -print >>H, ' } named;' -print >>H, '} grpc_metadata_batch_callouts;' -print >>H -print >>H, '#define GRPC_BATCH_INDEX_OF(slice) \\' -print >>H, ' (GRPC_IS_STATIC_METADATA_STRING((slice)) ? (grpc_metadata_batch_callouts_index)GPR_CLAMP(GRPC_STATIC_METADATA_INDEX((slice)), 0, GRPC_BATCH_CALLOUTS_COUNT) : GRPC_BATCH_CALLOUTS_COUNT)' -print >>H - -print >>H, 'extern const uint8_t grpc_static_accept_encoding_metadata[%d];' % (1 << len(COMPRESSION_ALGORITHMS)) -print >>C, 'const uint8_t grpc_static_accept_encoding_metadata[%d] = {' % (1 << len(COMPRESSION_ALGORITHMS)) -print >>C, '0,%s' % ','.join('%d' % md_idx(elem) for elem in compression_elems) -print >>C, '};' -print >>C - -print >>H, '#define GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS(algs) (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[grpc_static_accept_encoding_metadata[(algs)]], GRPC_MDELEM_STORAGE_STATIC))' - -print >>H, '#endif /* GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H */' + print >> H, ' struct grpc_linked_mdelem *%s;' % mangle(elem, '').lower() +print >> H, ' } named;' +print >> H, '} grpc_metadata_batch_callouts;' +print >> H +print >> H, '#define GRPC_BATCH_INDEX_OF(slice) \\' +print >> H, ' (GRPC_IS_STATIC_METADATA_STRING((slice)) ? (grpc_metadata_batch_callouts_index)GPR_CLAMP(GRPC_STATIC_METADATA_INDEX((slice)), 0, GRPC_BATCH_CALLOUTS_COUNT) : GRPC_BATCH_CALLOUTS_COUNT)' +print >> H + +print >> H, 'extern const uint8_t grpc_static_accept_encoding_metadata[%d];' % ( + 1 << len(COMPRESSION_ALGORITHMS)) +print >> C, 'const uint8_t grpc_static_accept_encoding_metadata[%d] = {' % ( + 1 << len(COMPRESSION_ALGORITHMS)) +print >> C, '0,%s' % ','.join('%d' % md_idx(elem) for elem in compression_elems) +print >> C, '};' +print >> C + +print >> H, '#define GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS(algs) (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[grpc_static_accept_encoding_metadata[(algs)]], GRPC_MDELEM_STORAGE_STATIC))' + +print >> H, '#endif /* GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H */' H.close() C.close() -- cgit v1.2.3 From 2eeedad744ca186903f3ef62459aed693bb06916 Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Thu, 13 Apr 2017 14:25:05 -0700 Subject: fix mac issues --- .../tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m | 1 - test/core/end2end/tests/cancel_after_invoke.c | 10 +++++----- test/core/end2end/tests/cancel_with_status.c | 10 +++++----- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m index d9aec7ae68..3dd264718c 100644 --- a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m +++ b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m @@ -111,7 +111,6 @@ static void chttp2_init_server_secure_fullstack( } f->server = grpc_server_create(server_args, NULL); grpc_server_register_completion_queue(f->server, f->cq, NULL); - grpc_server_register_completion_queue(f->server, f->shutdown_cq, NULL); GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, server_creds)); grpc_server_credentials_release(server_creds); diff --git a/test/core/end2end/tests/cancel_after_invoke.c b/test/core/end2end/tests/cancel_after_invoke.c index 95951a255e..f29012b86d 100644 --- a/test/core/end2end/tests/cancel_after_invoke.c +++ b/test/core/end2end/tests/cancel_after_invoke.c @@ -77,11 +77,11 @@ 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->shutdown_cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), - grpc_timeout_seconds_to_deadline(5), - NULL) - .type == GRPC_OP_COMPLETE); + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + grpc_event ev = grpc_completion_queue_next( + f->cq, grpc_timeout_seconds_to_deadline(5), NULL); + GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); + GPR_ASSERT(ev.tag == tag(1000)); grpc_server_destroy(f->server); f->server = NULL; } diff --git a/test/core/end2end/tests/cancel_with_status.c b/test/core/end2end/tests/cancel_with_status.c index d10ad42918..180748c2ae 100644 --- a/test/core/end2end/tests/cancel_with_status.c +++ b/test/core/end2end/tests/cancel_with_status.c @@ -76,11 +76,11 @@ 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->shutdown_cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), - grpc_timeout_seconds_to_deadline(5), - NULL) - .type == GRPC_OP_COMPLETE); + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + grpc_event ev = grpc_completion_queue_next( + f->cq, grpc_timeout_seconds_to_deadline(5), NULL); + GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); + GPR_ASSERT(ev.tag == tag(1000)); grpc_server_destroy(f->server); f->server = NULL; } -- cgit v1.2.3 From 6814d0742ca083a9e5a979b7f6c1df48ed0c85b8 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 13 Apr 2017 14:25:19 -0700 Subject: In all cases when writing, respect what the peer has asked for (not what the peer has acknowledged we asked for) --- src/core/ext/transport/chttp2/transport/writing.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/writing.c b/src/core/ext/transport/chttp2/transport/writing.c index ae9df175ff..069780ae5a 100644 --- a/src/core/ext/transport/chttp2/transport/writing.c +++ b/src/core/ext/transport/chttp2/transport/writing.c @@ -224,9 +224,9 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, .is_eof = false, .use_true_binary_metadata = t->settings - [GRPC_ACKED_SETTINGS] + [GRPC_PEER_SETTINGS] [GRPC_CHTTP2_SETTINGS_GRPC_ALLOW_TRUE_BINARY_METADATA] != 0, - .max_frame_size = t->settings[GRPC_ACKED_SETTINGS] + .max_frame_size = t->settings[GRPC_PEER_SETTINGS] [GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE], .stats = &s->stats.outgoing}; grpc_chttp2_encode_header(exec_ctx, &t->hpack_compressor, @@ -267,7 +267,7 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, (int64_t)t->settings[GRPC_PEER_SETTINGS] [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]); uint32_t max_outgoing = (uint32_t)GPR_MIN( - t->settings[GRPC_ACKED_SETTINGS] + t->settings[GRPC_PEER_SETTINGS] [GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE], GPR_MIN(stream_outgoing_window, t->outgoing_window)); if (max_outgoing > 0) { @@ -328,11 +328,11 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, .is_eof = true, .use_true_binary_metadata = t->settings - [GRPC_ACKED_SETTINGS] + [GRPC_PEER_SETTINGS] [GRPC_CHTTP2_SETTINGS_GRPC_ALLOW_TRUE_BINARY_METADATA] != 0, .max_frame_size = - t->settings[GRPC_ACKED_SETTINGS] + t->settings[GRPC_PEER_SETTINGS] [GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE], .stats = &s->stats.outgoing}; grpc_chttp2_encode_header(exec_ctx, &t->hpack_compressor, -- cgit v1.2.3 From d9986c3cf70606dfc2b7aa6933fb5ea180bce05d Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Thu, 13 Apr 2017 16:20:56 -0700 Subject: 1.3.x branch cut --- BUILD | 4 ++-- CMakeLists.txt | 2 +- Makefile | 6 +++--- build.yaml | 4 ++-- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.json | 2 +- package.xml | 4 ++-- src/core/lib/surface/version.c | 2 +- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Core/Version.csproj.include | 2 +- src/csharp/Grpc.Core/VersionInfo.cs | 2 +- src/csharp/build_packages_dotnetcli.bat | 2 +- src/csharp/build_packages_dotnetcli.sh | 4 ++-- src/node/health_check/package.json | 4 ++-- src/node/tools/package.json | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/private/version.h | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- tools/doxygen/Doxyfile.core | 2 +- tools/doxygen/Doxyfile.core.internal | 2 +- 31 files changed, 38 insertions(+), 38 deletions(-) diff --git a/BUILD b/BUILD index 12bd026c95..4087216a5d 100644 --- a/BUILD +++ b/BUILD @@ -40,9 +40,9 @@ load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_proto_plugin") # This should be updated along with build.yaml g_stands_for = "gentle" -core_version = "3.0.0-dev" +core_version = "3.0.0-pre1" -version = "1.3.0-dev" +version = "1.3.0-pre1" grpc_cc_library( name = "gpr", diff --git a/CMakeLists.txt b/CMakeLists.txt index d3db20d420..81dba56b9e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,7 @@ cmake_minimum_required(VERSION 2.8) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.3.0-dev") +set(PACKAGE_VERSION "1.3.0-pre1") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index 8c26b2e910..01e06f1003 100644 --- a/Makefile +++ b/Makefile @@ -419,9 +419,9 @@ E = @echo Q = @ endif -CORE_VERSION = 3.0.0-dev -CPP_VERSION = 1.3.0-dev -CSHARP_VERSION = 1.3.0-dev +CORE_VERSION = 3.0.0-pre1 +CPP_VERSION = 1.3.0-pre1 +CSHARP_VERSION = 1.3.0-pre1 CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/build.yaml b/build.yaml index 7db0150630..7edad7e9db 100644 --- a/build.yaml +++ b/build.yaml @@ -12,9 +12,9 @@ settings: '#08': Use "-preN" suffixes to identify pre-release versions '#09': Per-language overrides are possible with (eg) ruby_version tag here '#10': See the expand_version.py for all the quirks here - core_version: 3.0.0-dev + core_version: 3.0.0-pre1 g_stands_for: gentle - version: 1.3.0-dev + version: 1.3.0-pre1 filegroups: - name: census public_headers: diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index aed17ae9c3..bd129f73b5 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -37,7 +37,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.3.0-dev' + version = '1.3.0-pre1' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'http://www.grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 1940015782..de30032ee6 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -36,7 +36,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.3.0-dev' + version = '1.3.0-pre1' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'http://www.grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index 841a853363..642b4cad42 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -36,7 +36,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.3.0-dev' + version = '1.3.0-pre1' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'http://www.grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index 08ea79118d..ac3057e870 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -35,7 +35,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.3.0-dev' + version = '1.3.0-pre1' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'http://www.grpc.io' diff --git a/package.json b/package.json index 7f242326d7..d4f7b56b6a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "grpc", - "version": "1.3.0-dev", + "version": "1.3.0-pre1", "author": "Google Inc.", "description": "gRPC Library for Node", "homepage": "http://www.grpc.io/", diff --git a/package.xml b/package.xml index 57e50725e8..6ed135e17b 100644 --- a/package.xml +++ b/package.xml @@ -13,8 +13,8 @@ 2017-03-01 - 1.3.0dev - 1.3.0dev + 1.3.0RC1 + 1.3.0RC1 beta diff --git a/src/core/lib/surface/version.c b/src/core/lib/surface/version.c index ba80bd801e..959b45da2b 100644 --- a/src/core/lib/surface/version.c +++ b/src/core/lib/surface/version.c @@ -36,6 +36,6 @@ #include -const char *grpc_version_string(void) { return "3.0.0-dev"; } +const char *grpc_version_string(void) { return "3.0.0-pre1"; } const char *grpc_g_stands_for(void) { return "gentle"; } diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index f5a0e4131d..16a295de2e 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -37,5 +37,5 @@ #include namespace grpc { -grpc::string Version() { return "1.3.0-dev"; } +grpc::string Version() { return "1.3.0-pre1"; } } diff --git a/src/csharp/Grpc.Core/Version.csproj.include b/src/csharp/Grpc.Core/Version.csproj.include index ce9d0d2d5d..5409c98fe7 100755 --- a/src/csharp/Grpc.Core/Version.csproj.include +++ b/src/csharp/Grpc.Core/Version.csproj.include @@ -1,7 +1,7 @@ - 1.3.0-dev + 1.3.0-pre1 3.2.0 diff --git a/src/csharp/Grpc.Core/VersionInfo.cs b/src/csharp/Grpc.Core/VersionInfo.cs index 6012d904b6..03d4a96f05 100644 --- a/src/csharp/Grpc.Core/VersionInfo.cs +++ b/src/csharp/Grpc.Core/VersionInfo.cs @@ -53,6 +53,6 @@ namespace Grpc.Core /// /// Current version of gRPC C# /// - public const string CurrentVersion = "1.3.0-dev"; + public const string CurrentVersion = "1.3.0-pre1"; } } diff --git a/src/csharp/build_packages_dotnetcli.bat b/src/csharp/build_packages_dotnetcli.bat index 7558ca60c7..2f8d5b8157 100755 --- a/src/csharp/build_packages_dotnetcli.bat +++ b/src/csharp/build_packages_dotnetcli.bat @@ -28,7 +28,7 @@ @rem OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. @rem Current package versions -set VERSION=1.3.0-dev +set VERSION=1.3.0-pre1 @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe diff --git a/src/csharp/build_packages_dotnetcli.sh b/src/csharp/build_packages_dotnetcli.sh index 2186bd3c56..3096b3e45b 100755 --- a/src/csharp/build_packages_dotnetcli.sh +++ b/src/csharp/build_packages_dotnetcli.sh @@ -70,7 +70,7 @@ dotnet pack --configuration Release Grpc.Auth --output ../../../artifacts dotnet pack --configuration Release Grpc.HealthCheck --output ../../../artifacts dotnet pack --configuration Release Grpc.Reflection --output ../../../artifacts -nuget pack Grpc.nuspec -Version "1.3.0-dev" -OutputDirectory ../../artifacts -nuget pack Grpc.Tools.nuspec -Version "1.3.0-dev" -OutputDirectory ../../artifacts +nuget pack Grpc.nuspec -Version "1.3.0-pre1" -OutputDirectory ../../artifacts +nuget pack Grpc.Tools.nuspec -Version "1.3.0-pre1" -OutputDirectory ../../artifacts (cd ../../artifacts && zip csharp_nugets_dotnetcli.zip *.nupkg) diff --git a/src/node/health_check/package.json b/src/node/health_check/package.json index e218f5a406..3d33118298 100644 --- a/src/node/health_check/package.json +++ b/src/node/health_check/package.json @@ -1,6 +1,6 @@ { "name": "grpc-health-check", - "version": "1.3.0-dev", + "version": "1.3.0-pre1", "author": "Google Inc.", "description": "Health check service for use with gRPC", "repository": { @@ -15,7 +15,7 @@ } ], "dependencies": { - "grpc": "^1.3.0-dev", + "grpc": "^1.3.0-pre1", "lodash": "^3.9.3", "google-protobuf": "^3.0.0" }, diff --git a/src/node/tools/package.json b/src/node/tools/package.json index 3096c6e42a..056f28ab3c 100644 --- a/src/node/tools/package.json +++ b/src/node/tools/package.json @@ -1,6 +1,6 @@ { "name": "grpc-tools", - "version": "1.3.0-dev", + "version": "1.3.0-pre1", "author": "Google Inc.", "description": "Tools for developing with gRPC on Node.js", "homepage": "http://www.grpc.io/", diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index 2f41ad196a..e636d9c902 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.3.0-dev' + v = '1.3.0-pre1' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index 09155ee4d4..b53033d524 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -38,4 +38,4 @@ // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.3.0-dev" +#define GRPC_OBJC_VERSION_STRING @"1.3.0-pre1" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index 267d848e74..a37630a185 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION='1.3.0.dev0' +VERSION='1.3.0rc1' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index 4ff5e266a1..c08110ec2c 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION='1.3.0.dev0' +VERSION='1.3.0rc1' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index 8ffc08c04b..4565732621 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION='1.3.0.dev0' +VERSION='1.3.0rc1' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index ba82dce6f6..aadfabfdde 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION='1.3.0.dev0' +VERSION='1.3.0rc1' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index 9901158e73..fa804685b3 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -29,5 +29,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.3.0.dev' + VERSION = '1.3.0.pre1' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index 632c0100bd..fa19aee62b 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -29,6 +29,6 @@ module GRPC module Tools - VERSION = '1.3.0.dev' + VERSION = '1.3.0.pre1' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index ad35b90bad..289c0b13c3 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION='1.3.0.dev0' +VERSION='1.3.0rc1' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 59e619749a..01a2dfb74f 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.3.0-dev +PROJECT_NUMBER = 1.3.0-pre1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index afab2296a0..7734d8ba11 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.3.0-dev +PROJECT_NUMBER = 1.3.0-pre1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.core b/tools/doxygen/Doxyfile.core index e6ca9cb845..d651c9209e 100644 --- a/tools/doxygen/Doxyfile.core +++ b/tools/doxygen/Doxyfile.core @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC Core" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 3.0.0-dev +PROJECT_NUMBER = 3.0.0-pre1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 915648640f..f5ffe97e49 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC Core" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 3.0.0-dev +PROJECT_NUMBER = 3.0.0-pre1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a -- cgit v1.2.3 From 9e1acc0796b80d61d2a4ea8a18018db65ad6a372 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Thu, 13 Apr 2017 16:30:15 -0700 Subject: master to 1.4.0-dev --- BUILD | 2 +- CMakeLists.txt | 2 +- Makefile | 4 ++-- build.yaml | 2 +- gRPC-Core.podspec | 2 +- gRPC-ProtoRPC.podspec | 2 +- gRPC-RxLibrary.podspec | 2 +- gRPC.podspec | 2 +- package.json | 2 +- package.xml | 4 ++-- src/cpp/common/version_cc.cc | 2 +- src/csharp/Grpc.Core/Version.csproj.include | 2 +- src/csharp/Grpc.Core/VersionInfo.cs | 4 ++-- src/csharp/build_packages_dotnetcli.bat | 2 +- src/csharp/build_packages_dotnetcli.sh | 4 ++-- src/node/health_check/package.json | 4 ++-- src/node/tools/package.json | 2 +- src/objective-c/!ProtoCompiler-gRPCPlugin.podspec | 2 +- src/objective-c/GRPCClient/private/version.h | 2 +- src/php/composer.json | 2 +- src/python/grpcio/grpc_version.py | 2 +- src/python/grpcio_health_checking/grpc_version.py | 2 +- src/python/grpcio_reflection/grpc_version.py | 2 +- src/python/grpcio_tests/grpc_version.py | 2 +- src/ruby/lib/grpc/version.rb | 2 +- src/ruby/tools/version.rb | 2 +- tools/distrib/python/grpcio_tools/grpc_version.py | 2 +- tools/doxygen/Doxyfile.c++ | 2 +- tools/doxygen/Doxyfile.c++.internal | 2 +- 29 files changed, 34 insertions(+), 34 deletions(-) diff --git a/BUILD b/BUILD index 12bd026c95..54f50c0783 100644 --- a/BUILD +++ b/BUILD @@ -42,7 +42,7 @@ g_stands_for = "gentle" core_version = "3.0.0-dev" -version = "1.3.0-dev" +version = "1.4.0-dev" grpc_cc_library( name = "gpr", diff --git a/CMakeLists.txt b/CMakeLists.txt index d3db20d420..ef8b45a394 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,7 @@ cmake_minimum_required(VERSION 2.8) set(PACKAGE_NAME "grpc") -set(PACKAGE_VERSION "1.3.0-dev") +set(PACKAGE_VERSION "1.4.0-dev") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") diff --git a/Makefile b/Makefile index 8c26b2e910..223291467b 100644 --- a/Makefile +++ b/Makefile @@ -420,8 +420,8 @@ Q = @ endif CORE_VERSION = 3.0.0-dev -CPP_VERSION = 1.3.0-dev -CSHARP_VERSION = 1.3.0-dev +CPP_VERSION = 1.4.0-dev +CSHARP_VERSION = 1.4.0-dev CPPFLAGS_NO_ARCH += $(addprefix -I, $(INCLUDES)) $(addprefix -D, $(DEFINES)) CPPFLAGS += $(CPPFLAGS_NO_ARCH) $(ARCH_FLAGS) diff --git a/build.yaml b/build.yaml index 7db0150630..63985cda14 100644 --- a/build.yaml +++ b/build.yaml @@ -14,7 +14,7 @@ settings: '#10': See the expand_version.py for all the quirks here core_version: 3.0.0-dev g_stands_for: gentle - version: 1.3.0-dev + version: 1.4.0-dev filegroups: - name: census public_headers: diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index aed17ae9c3..af83638336 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -37,7 +37,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-Core' - version = '1.3.0-dev' + version = '1.4.0-dev' s.version = version s.summary = 'Core cross-platform gRPC library, written in C' s.homepage = 'http://www.grpc.io' diff --git a/gRPC-ProtoRPC.podspec b/gRPC-ProtoRPC.podspec index 1940015782..62cb0d11a1 100644 --- a/gRPC-ProtoRPC.podspec +++ b/gRPC-ProtoRPC.podspec @@ -36,7 +36,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-ProtoRPC' - version = '1.3.0-dev' + version = '1.4.0-dev' s.version = version s.summary = 'RPC library for Protocol Buffers, based on gRPC' s.homepage = 'http://www.grpc.io' diff --git a/gRPC-RxLibrary.podspec b/gRPC-RxLibrary.podspec index 841a853363..77ceb22123 100644 --- a/gRPC-RxLibrary.podspec +++ b/gRPC-RxLibrary.podspec @@ -36,7 +36,7 @@ Pod::Spec.new do |s| s.name = 'gRPC-RxLibrary' - version = '1.3.0-dev' + version = '1.4.0-dev' s.version = version s.summary = 'Reactive Extensions library for iOS/OSX.' s.homepage = 'http://www.grpc.io' diff --git a/gRPC.podspec b/gRPC.podspec index 08ea79118d..10520bd388 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -35,7 +35,7 @@ Pod::Spec.new do |s| s.name = 'gRPC' - version = '1.3.0-dev' + version = '1.4.0-dev' s.version = version s.summary = 'gRPC client library for iOS/OSX' s.homepage = 'http://www.grpc.io' diff --git a/package.json b/package.json index 7f242326d7..6a01ae2324 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "grpc", - "version": "1.3.0-dev", + "version": "1.4.0-dev", "author": "Google Inc.", "description": "gRPC Library for Node", "homepage": "http://www.grpc.io/", diff --git a/package.xml b/package.xml index 57e50725e8..d2eb2512ec 100644 --- a/package.xml +++ b/package.xml @@ -13,8 +13,8 @@ 2017-03-01 - 1.3.0dev - 1.3.0dev + 1.4.0dev + 1.4.0dev beta diff --git a/src/cpp/common/version_cc.cc b/src/cpp/common/version_cc.cc index f5a0e4131d..72a4c4cf94 100644 --- a/src/cpp/common/version_cc.cc +++ b/src/cpp/common/version_cc.cc @@ -37,5 +37,5 @@ #include namespace grpc { -grpc::string Version() { return "1.3.0-dev"; } +grpc::string Version() { return "1.4.0-dev"; } } diff --git a/src/csharp/Grpc.Core/Version.csproj.include b/src/csharp/Grpc.Core/Version.csproj.include index ce9d0d2d5d..6af2af10bd 100755 --- a/src/csharp/Grpc.Core/Version.csproj.include +++ b/src/csharp/Grpc.Core/Version.csproj.include @@ -1,7 +1,7 @@ - 1.3.0-dev + 1.4.0-dev 3.2.0 diff --git a/src/csharp/Grpc.Core/VersionInfo.cs b/src/csharp/Grpc.Core/VersionInfo.cs index 6012d904b6..2e55d9d80e 100644 --- a/src/csharp/Grpc.Core/VersionInfo.cs +++ b/src/csharp/Grpc.Core/VersionInfo.cs @@ -48,11 +48,11 @@ namespace Grpc.Core /// /// Current AssemblyFileVersion of gRPC C# assemblies /// - public const string CurrentAssemblyFileVersion = "1.3.0.0"; + public const string CurrentAssemblyFileVersion = "1.4.0.0"; /// /// Current version of gRPC C# /// - public const string CurrentVersion = "1.3.0-dev"; + public const string CurrentVersion = "1.4.0-dev"; } } diff --git a/src/csharp/build_packages_dotnetcli.bat b/src/csharp/build_packages_dotnetcli.bat index 7558ca60c7..673642e3d8 100755 --- a/src/csharp/build_packages_dotnetcli.bat +++ b/src/csharp/build_packages_dotnetcli.bat @@ -28,7 +28,7 @@ @rem OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. @rem Current package versions -set VERSION=1.3.0-dev +set VERSION=1.4.0-dev @rem Adjust the location of nuget.exe set NUGET=C:\nuget\nuget.exe diff --git a/src/csharp/build_packages_dotnetcli.sh b/src/csharp/build_packages_dotnetcli.sh index 2186bd3c56..ee923e3d87 100755 --- a/src/csharp/build_packages_dotnetcli.sh +++ b/src/csharp/build_packages_dotnetcli.sh @@ -70,7 +70,7 @@ dotnet pack --configuration Release Grpc.Auth --output ../../../artifacts dotnet pack --configuration Release Grpc.HealthCheck --output ../../../artifacts dotnet pack --configuration Release Grpc.Reflection --output ../../../artifacts -nuget pack Grpc.nuspec -Version "1.3.0-dev" -OutputDirectory ../../artifacts -nuget pack Grpc.Tools.nuspec -Version "1.3.0-dev" -OutputDirectory ../../artifacts +nuget pack Grpc.nuspec -Version "1.4.0-dev" -OutputDirectory ../../artifacts +nuget pack Grpc.Tools.nuspec -Version "1.4.0-dev" -OutputDirectory ../../artifacts (cd ../../artifacts && zip csharp_nugets_dotnetcli.zip *.nupkg) diff --git a/src/node/health_check/package.json b/src/node/health_check/package.json index e218f5a406..37c9b7a54f 100644 --- a/src/node/health_check/package.json +++ b/src/node/health_check/package.json @@ -1,6 +1,6 @@ { "name": "grpc-health-check", - "version": "1.3.0-dev", + "version": "1.4.0-dev", "author": "Google Inc.", "description": "Health check service for use with gRPC", "repository": { @@ -15,7 +15,7 @@ } ], "dependencies": { - "grpc": "^1.3.0-dev", + "grpc": "^1.4.0-dev", "lodash": "^3.9.3", "google-protobuf": "^3.0.0" }, diff --git a/src/node/tools/package.json b/src/node/tools/package.json index 3096c6e42a..a81aa87f4b 100644 --- a/src/node/tools/package.json +++ b/src/node/tools/package.json @@ -1,6 +1,6 @@ { "name": "grpc-tools", - "version": "1.3.0-dev", + "version": "1.4.0-dev", "author": "Google Inc.", "description": "Tools for developing with gRPC on Node.js", "homepage": "http://www.grpc.io/", diff --git a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec index 2f41ad196a..2f29058b59 100644 --- a/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec +++ b/src/objective-c/!ProtoCompiler-gRPCPlugin.podspec @@ -42,7 +42,7 @@ Pod::Spec.new do |s| # exclamation mark ensures that other "regular" pods will be able to find it as it'll be installed # before them. s.name = '!ProtoCompiler-gRPCPlugin' - v = '1.3.0-dev' + v = '1.4.0-dev' s.version = v s.summary = 'The gRPC ProtoC plugin generates Objective-C files from .proto services.' s.description = <<-DESC diff --git a/src/objective-c/GRPCClient/private/version.h b/src/objective-c/GRPCClient/private/version.h index 09155ee4d4..c846f4214c 100644 --- a/src/objective-c/GRPCClient/private/version.h +++ b/src/objective-c/GRPCClient/private/version.h @@ -38,4 +38,4 @@ // `tools/buildgen/generate_projects.sh`. -#define GRPC_OBJC_VERSION_STRING @"1.3.0-dev" +#define GRPC_OBJC_VERSION_STRING @"1.4.0-dev" diff --git a/src/php/composer.json b/src/php/composer.json index 2b140077cc..24c17c3b57 100644 --- a/src/php/composer.json +++ b/src/php/composer.json @@ -2,7 +2,7 @@ "name": "grpc/grpc-dev", "description": "gRPC library for PHP - for Developement use only", "license": "BSD-3-Clause", - "version": "1.3.0", + "version": "1.4.0", "require": { "php": ">=5.5.0", "google/protobuf": "^v3.1.0" diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py index 267d848e74..ea4bc7ba20 100644 --- a/src/python/grpcio/grpc_version.py +++ b/src/python/grpcio/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! -VERSION='1.3.0.dev0' +VERSION='1.4.0.dev0' diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py index 4ff5e266a1..26aa555e14 100644 --- a/src/python/grpcio_health_checking/grpc_version.py +++ b/src/python/grpcio_health_checking/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!! -VERSION='1.3.0.dev0' +VERSION='1.4.0.dev0' diff --git a/src/python/grpcio_reflection/grpc_version.py b/src/python/grpcio_reflection/grpc_version.py index 8ffc08c04b..978d6b4011 100644 --- a/src/python/grpcio_reflection/grpc_version.py +++ b/src/python/grpcio_reflection/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_reflection/grpc_version.py.template`!!! -VERSION='1.3.0.dev0' +VERSION='1.4.0.dev0' diff --git a/src/python/grpcio_tests/grpc_version.py b/src/python/grpcio_tests/grpc_version.py index ba82dce6f6..5f0b084884 100644 --- a/src/python/grpcio_tests/grpc_version.py +++ b/src/python/grpcio_tests/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_tests/grpc_version.py.template`!!! -VERSION='1.3.0.dev0' +VERSION='1.4.0.dev0' diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index 9901158e73..f30dff335f 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -29,5 +29,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '1.3.0.dev' + VERSION = '1.4.0.dev' end diff --git a/src/ruby/tools/version.rb b/src/ruby/tools/version.rb index 632c0100bd..1f8d4afb95 100644 --- a/src/ruby/tools/version.rb +++ b/src/ruby/tools/version.rb @@ -29,6 +29,6 @@ module GRPC module Tools - VERSION = '1.3.0.dev' + VERSION = '1.4.0.dev' end end diff --git a/tools/distrib/python/grpcio_tools/grpc_version.py b/tools/distrib/python/grpcio_tools/grpc_version.py index ad35b90bad..1f2aa81c85 100644 --- a/tools/distrib/python/grpcio_tools/grpc_version.py +++ b/tools/distrib/python/grpcio_tools/grpc_version.py @@ -29,4 +29,4 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/tools/distrib/python/grpcio_tools/grpc_version.py.template`!!! -VERSION='1.3.0.dev0' +VERSION='1.4.0.dev0' diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 59e619749a..1864dd9e90 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.3.0-dev +PROJECT_NUMBER = 1.4.0-dev # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index afab2296a0..0ab0804488 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -40,7 +40,7 @@ PROJECT_NAME = "GRPC C++" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 1.3.0-dev +PROJECT_NUMBER = 1.4.0-dev # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a -- cgit v1.2.3 From a3aec5032aeeac00ad85fa1b14a4be74755f4656 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 13 Apr 2017 17:34:17 -0700 Subject: Remove arm_arch and hack version number --- src/objective-c/BoringSSL.podspec | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/objective-c/BoringSSL.podspec b/src/objective-c/BoringSSL.podspec index 55cc6f677e..7880aad10b 100644 --- a/src/objective-c/BoringSSL.podspec +++ b/src/objective-c/BoringSSL.podspec @@ -69,8 +69,9 @@ Pod::Spec.new do |s| s.source = { :git => 'https://boringssl.googlesource.com/boringssl', - :tag => "version_for_cocoapods_#{version}", - # :commit => '4fec04b48406111cb88fdd8d196253adc54f7a31', + # Restore this version name hack in the next version!! + # :tag => "version_for_cocoapods_#{version}", + :tag => "version_for_cocoapods_8.0", } name = 'openssl' @@ -112,6 +113,7 @@ Pod::Spec.new do |s| s.subspec 'Interface' do |ss| ss.header_mappings_dir = 'include/openssl' ss.source_files = 'include/openssl/*.h' + ss.exclude_files = 'include/openssl/arm_arch.h' end s.subspec 'Implementation' do |ss| ss.header_mappings_dir = '.' @@ -148,11 +150,6 @@ Pod::Spec.new do |s| #include "ssl.h" #include "crypto.h" #include "aes.h" - /* The following macros are defined by base.h. The latter is the first file included by the - other headers. */ - #if defined(OPENSSL_ARM) || defined(OPENSSL_AARCH64) - # include "arm_arch.h" - #endif #include "asn1.h" #include "asn1_mac.h" #include "asn1t.h" -- cgit v1.2.3 From b575394351209239b754b99b3839ba4c799fc831 Mon Sep 17 00:00:00 2001 From: Mehrdad Afshari Date: Thu, 13 Apr 2017 16:23:10 -0700 Subject: Use _pb2_grpc module to access gRPC entities --- src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py b/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py index c58cb3ecf1..cd896f32c3 100644 --- a/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py +++ b/src/python/grpcio_reflection/grpc_reflection/v1alpha/reflection.py @@ -56,7 +56,7 @@ def _file_descriptor_response(descriptor): file_descriptor_proto=(serialized_proto,)),) -class ReflectionServicer(reflection_pb2.ServerReflectionServicer): +class ReflectionServicer(reflection_pb2_grpc.ServerReflectionServicer): """Servicer handling RPCs for service statuses.""" def __init__(self, service_names, pool=None): -- cgit v1.2.3 From 6aba1e574a9fc420cfa3e0274a377f5db2571fdc Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 13 Apr 2017 15:40:22 +0000 Subject: Fix broken test --- test/core/end2end/tests/streaming_error_response.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/core/end2end/tests/streaming_error_response.c b/test/core/end2end/tests/streaming_error_response.c index c652d9469d..e032b33988 100644 --- a/test/core/end2end/tests/streaming_error_response.c +++ b/test/core/end2end/tests/streaming_error_response.c @@ -182,6 +182,9 @@ static void test(grpc_end2end_test_config config, bool request_status_early) { GPR_ASSERT(GRPC_CALL_OK == error); CQ_EXPECT_COMPLETION(cqv, tag(102), 1); + if (!request_status_early) { + CQ_EXPECT_COMPLETION(cqv, tag(1), 1); + } cq_verify(cqv); memset(ops, 0, sizeof(ops)); @@ -193,9 +196,6 @@ static void test(grpc_end2end_test_config config, bool request_status_early) { GPR_ASSERT(GRPC_CALL_OK == error); CQ_EXPECT_COMPLETION(cqv, tag(103), 1); - if (!request_status_early) { - CQ_EXPECT_COMPLETION(cqv, tag(1), 1); - } cq_verify(cqv); memset(ops, 0, sizeof(ops)); -- cgit v1.2.3 From a094b1a4c616f481ff7c41d55238e1b496d60ba6 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 13 Apr 2017 15:48:39 +0000 Subject: Fix broken test --- test/core/end2end/tests/keepalive_timeout.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/core/end2end/tests/keepalive_timeout.c b/test/core/end2end/tests/keepalive_timeout.c index bf6ca0d9d9..b53a50d7a1 100644 --- a/test/core/end2end/tests/keepalive_timeout.c +++ b/test/core/end2end/tests/keepalive_timeout.c @@ -188,8 +188,6 @@ static void test_keepalive_timeout(grpc_end2end_test_config config) { GPR_ASSERT(GRPC_CALL_OK == error); CQ_EXPECT_COMPLETION(cqv, tag(102), 1); - cq_verify(cqv); - CQ_EXPECT_COMPLETION(cqv, tag(1), 1); cq_verify(cqv); -- cgit v1.2.3 From 9b3d39184688cf8fcb159714a1c74608facb15ae Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 13 Apr 2017 16:41:14 +0000 Subject: Fix broken test --- test/core/end2end/tests/resource_quota_server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core/end2end/tests/resource_quota_server.c b/test/core/end2end/tests/resource_quota_server.c index 4d3ce1c937..d6d640b8dd 100644 --- a/test/core/end2end/tests/resource_quota_server.c +++ b/test/core/end2end/tests/resource_quota_server.c @@ -203,7 +203,7 @@ void resource_quota_server(grpc_end2end_test_config config) { op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; - op->flags = 0; + op->flags = GRPC_INITIAL_METADATA_WAIT_FOR_READY; op->reserved = NULL; op++; op->op = GRPC_OP_SEND_MESSAGE; -- cgit v1.2.3