diff options
46 files changed, 385 insertions, 261 deletions
diff --git a/PYTHON-MANIFEST.in b/PYTHON-MANIFEST.in index 846530532d..bb76b38f9f 100644 --- a/PYTHON-MANIFEST.in +++ b/PYTHON-MANIFEST.in @@ -7,7 +7,7 @@ graft include/grpc graft third_party/boringssl graft third_party/nanopb graft third_party/zlib -graft third_party/c-ares +graft third_party/cares include src/python/grpcio/_spawn_patch.py include src/python/grpcio/commands.py include src/python/grpcio/grpc_version.py diff --git a/doc/server_side_auth.md b/doc/server_side_auth.md index 288c6e9cb3..d260237928 100644 --- a/doc/server_side_auth.md +++ b/doc/server_side_auth.md @@ -13,7 +13,7 @@ The contents of the *auth properties* are populated by an *auth interceptor*. Th WARNING: AuthContext is the only reliable source of truth when it comes to authenticating RPCs. Using any other call/context properties for authentication purposes is wrong and inherently unsafe. -####Example AuthContext contents +#### Example AuthContext contents For secure channel using mutual TLS authentication with both client and server certificates (test certificates from this repository are used). @@ -45,7 +45,7 @@ gRPC comes with some basic "interceptors" already built-in. WARNING: While there is a public API that allows anyone to write their own custom interceptor, please think twice before using it. There are legitimate uses for custom interceptors but you should keep in mind that as auth interceptors essentially decide which RPCs are authenticated and which are not, their code is very sensitive from the security perspective and getting things wrong might have serious consequences. If unsure, we strongly recommend to rely on official & proven interceptors that come with gRPC. -####Available auth interceptors +#### Available auth interceptors - TLS/SSL certificate authentication (built into gRPC's security layer, automatically used whenever you use a secure connection) - (coming soon) JWT auth token authentication - more will be added over time diff --git a/examples/cpp/README.md b/examples/cpp/README.md index 783935cd53..8e2bb5d13b 100644 --- a/examples/cpp/README.md +++ b/examples/cpp/README.md @@ -1,4 +1,4 @@ -#gRPC in 3 minutes (C++) +# gRPC in 3 minutes (C++) ## Installation diff --git a/examples/cpp/cpptutorial.md b/examples/cpp/cpptutorial.md index ae84aba916..7d98367da4 100644 --- a/examples/cpp/cpptutorial.md +++ b/examples/cpp/cpptutorial.md @@ -1,4 +1,4 @@ -#gRPC Basics: C++ +# gRPC Basics: C++ This tutorial provides a basic C++ programmer's introduction to working with gRPC. By walking through this example you'll learn how to: diff --git a/examples/csharp/route_guide/README.md b/examples/csharp/route_guide/README.md index a9aa87a83d..98073b0296 100644 --- a/examples/csharp/route_guide/README.md +++ b/examples/csharp/route_guide/README.md @@ -1,4 +1,4 @@ -#gRPC Basics: C# sample code +# gRPC Basics: C# sample code The files in this folder are the samples used in [gRPC Basics: C#][], a detailed tutorial for using gRPC in C#. diff --git a/examples/node/dynamic_codegen/route_guide/README.md b/examples/node/dynamic_codegen/route_guide/README.md index 22bcf78986..7ec519c76b 100644 --- a/examples/node/dynamic_codegen/route_guide/README.md +++ b/examples/node/dynamic_codegen/route_guide/README.md @@ -1,4 +1,4 @@ -#gRPC Basics: Node.js sample code +# gRPC Basics: Node.js sample code The files in this folder are the samples used in [gRPC Basics: Node.js][], a detailed tutorial for using gRPC in Node.js. diff --git a/examples/node/static_codegen/route_guide/README.md b/examples/node/static_codegen/route_guide/README.md index 22bcf78986..7ec519c76b 100644 --- a/examples/node/static_codegen/route_guide/README.md +++ b/examples/node/static_codegen/route_guide/README.md @@ -1,4 +1,4 @@ -#gRPC Basics: Node.js sample code +# gRPC Basics: Node.js sample code The files in this folder are the samples used in [gRPC Basics: Node.js][], a detailed tutorial for using gRPC in Node.js. diff --git a/examples/objective-c/auth_sample/README.md b/examples/objective-c/auth_sample/README.md index c560b7af65..b75dcab2de 100644 --- a/examples/objective-c/auth_sample/README.md +++ b/examples/objective-c/auth_sample/README.md @@ -1,3 +1,3 @@ -#OAuth2 on gRPC: Objective-C +# OAuth2 on gRPC: Objective-C This is the supporting code for the tutorial "[OAuth2 on gRPC: Objective-C](http://www.grpc.io/docs/tutorials/auth/oauth2-objective-c.html)." diff --git a/examples/objective-c/helloworld/README.md b/examples/objective-c/helloworld/README.md index fdff938a97..365bea1422 100644 --- a/examples/objective-c/helloworld/README.md +++ b/examples/objective-c/helloworld/README.md @@ -1,4 +1,4 @@ -#gRPC in 3 minutes (Objective-C) +# gRPC in 3 minutes (Objective-C) ## Installation diff --git a/examples/objective-c/route_guide/README.md b/examples/objective-c/route_guide/README.md index 6a6f7c0d33..b99bf546fb 100644 --- a/examples/objective-c/route_guide/README.md +++ b/examples/objective-c/route_guide/README.md @@ -1,4 +1,4 @@ -#gRPC Basics: Objective-C +# gRPC Basics: Objective-C This is the supporting code for the tutorial "[gRPC Basics: Objective-C](http://www.grpc.io/docs/tutorials/basic/objective-c.html)." diff --git a/examples/php/route_guide/README.md b/examples/php/route_guide/README.md index 26f1704f12..5b2cc05efc 100644 --- a/examples/php/route_guide/README.md +++ b/examples/php/route_guide/README.md @@ -1,4 +1,4 @@ -#gRPC Basics: PHP sample code +# gRPC Basics: PHP sample code The files in this folder are the samples used in [gRPC Basics: PHP][], a detailed tutorial for using gRPC in PHP. diff --git a/examples/ruby/errors_and_cancellation/README.md b/examples/ruby/errors_and_cancellation/README.md index 126518c4aa..661bd84792 100644 --- a/examples/ruby/errors_and_cancellation/README.md +++ b/examples/ruby/errors_and_cancellation/README.md @@ -1,4 +1,4 @@ -#Errors and Cancelletion code samples for grpc-ruby +# Errors and Cancelletion code samples for grpc-ruby The examples in this directory show use of grpc errors. diff --git a/examples/ruby/route_guide/README.md b/examples/ruby/route_guide/README.md index 3c353d1d97..b2514630a9 100644 --- a/examples/ruby/route_guide/README.md +++ b/examples/ruby/route_guide/README.md @@ -1,4 +1,4 @@ -#gRPC Basics: Ruby sample code +# gRPC Basics: Ruby sample code The files in this folder are the samples used in [gRPC Basics: Ruby][], a detailed tutorial for using gRPC in Ruby. @@ -72,7 +72,6 @@ EXPORTS grpc_channel_create_registered_call grpc_call_start_batch grpc_call_get_peer - grpc_call_set_load_reporting_cost_context grpc_census_call_set_context grpc_census_call_get_context grpc_channel_get_target diff --git a/include/grpc++/server.h b/include/grpc++/server.h index 6d5f89d360..2f7018e95b 100644 --- a/include/grpc++/server.h +++ b/include/grpc++/server.h @@ -89,7 +89,8 @@ class Server final : public ServerInterface, private GrpcLibraryCodegen { /// Called before server is started. virtual void PreServerStart(Server* server) {} /// Called after a server port is added. - virtual void AddPort(Server* server, int port) {} + virtual void AddPort(Server* server, const grpc::string& addr, + ServerCredentials* creds, int port) {} }; /// Set the global callback object. Can only be called once. Does not take /// ownership of callbacks, and expects the pointed to object to be alive diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index 42cf201da4..9a65d34ce3 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -296,12 +296,6 @@ GRPCAPI grpc_call_error grpc_call_start_batch(grpc_call *call, functionality. Instead, use grpc_auth_context. */ GRPCAPI char *grpc_call_get_peer(grpc_call *call); -struct grpc_load_reporting_cost_context; - -/* Associate costs contained in \a cost_context to \a call. */ -GRPCAPI void grpc_call_set_load_reporting_cost_context( - grpc_call *call, struct grpc_load_reporting_cost_context *context); - struct census_context; /** Set census context for a call; Must be called before first call to diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index 06b67015e3..b5d637ed41 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -248,6 +248,8 @@ typedef struct { /** Secondary user agent: goes at the end of the user-agent metadata sent on each request. A string. */ #define GRPC_ARG_SECONDARY_USER_AGENT_STRING "grpc.secondary_user_agent" +/** The minimum time between subsequent connection attempts, in ms */ +#define GRPC_ARG_MIN_RECONNECT_BACKOFF_MS "grpc.min_reconnect_backoff_ms" /** The maximum time between subsequent connection attempts, in ms */ #define GRPC_ARG_MAX_RECONNECT_BACKOFF_MS "grpc.max_reconnect_backoff_ms" /** The time between the first and second connection attempts, in ms */ diff --git a/include/grpc/load_reporting.h b/include/grpc/load_reporting.h index c833ce5c63..a334a11350 100644 --- a/include/grpc/load_reporting.h +++ b/include/grpc/load_reporting.h @@ -35,7 +35,6 @@ #define GRPC_LOAD_REPORTING_H #include <grpc/impl/codegen/port_platform.h> -#include <grpc/slice.h> #ifdef __cplusplus extern "C" { @@ -50,11 +49,12 @@ extern "C" { * gRPC LB system. */ #define GRPC_LB_TOKEN_MD_KEY "lb-token" -/** A sequence of values for load reporting purposes */ -typedef struct grpc_load_reporting_cost_context { - grpc_slice *values; - size_t values_count; -} grpc_load_reporting_cost_context; +/** Metadata key for gRPC LB cost reporting. + * + * The value corresponding to this key is an opaque binary blob reported by the + * backend as part of its trailing metadata containing cost information for the + * call. */ +#define GRPC_LB_COST_MD_KEY "lb-cost-bin" #ifdef __cplusplus } diff --git a/src/compiler/python_generator.cc b/src/compiler/python_generator.cc index 2649c1688d..50ee54abff 100644 --- a/src/compiler/python_generator.cc +++ b/src/compiler/python_generator.cc @@ -101,6 +101,14 @@ PrivateGenerator::PrivateGenerator(const GeneratorConfiguration& config, void PrivateGenerator::PrintAllComments(StringVector comments, grpc_generator::Printer* out) { if (comments.empty()) { + // Python requires code structures like class and def to have + // a body, even if it is just "pass" or a docstring. We need + // to ensure not to generate empty bodies. We could do something + // smarter and more sophisticated, but at the moment, if there is + // no docstring to print, we simply emit "pass" to ensure validity + // of the generated code. + out->Print("# missing associated documentation comment in .proto file\n"); + out->Print("pass\n"); return; } out->Print("\"\"\""); diff --git a/src/core/ext/filters/client_channel/subchannel.c b/src/core/ext/filters/client_channel/subchannel.c index 362b4a4a28..967e571221 100644 --- a/src/core/ext/filters/client_channel/subchannel.c +++ b/src/core/ext/filters/client_channel/subchannel.c @@ -59,9 +59,9 @@ #define INTERNAL_REF_BITS 16 #define STRONG_REF_MASK (~(gpr_atm)((1 << INTERNAL_REF_BITS) - 1)) -#define GRPC_SUBCHANNEL_MIN_CONNECT_TIMEOUT_SECONDS 20 #define GRPC_SUBCHANNEL_INITIAL_CONNECT_BACKOFF_SECONDS 1 #define GRPC_SUBCHANNEL_RECONNECT_BACKOFF_MULTIPLIER 1.6 +#define GRPC_SUBCHANNEL_RECONNECT_MIN_BACKOFF_SECONDS 20 #define GRPC_SUBCHANNEL_RECONNECT_MAX_BACKOFF_SECONDS 120 #define GRPC_SUBCHANNEL_RECONNECT_JITTER 0.2 @@ -353,8 +353,8 @@ grpc_subchannel *grpc_subchannel_create(grpc_exec_ctx *exec_ctx, "subchannel"); int initial_backoff_ms = GRPC_SUBCHANNEL_INITIAL_CONNECT_BACKOFF_SECONDS * 1000; + int min_backoff_ms = GRPC_SUBCHANNEL_RECONNECT_MIN_BACKOFF_SECONDS * 1000; int max_backoff_ms = GRPC_SUBCHANNEL_RECONNECT_MAX_BACKOFF_SECONDS * 1000; - int min_backoff_ms = GRPC_SUBCHANNEL_MIN_CONNECT_TIMEOUT_SECONDS * 1000; bool fixed_reconnect_backoff = false; if (c->args) { for (size_t i = 0; i < c->args->num_args; i++) { @@ -366,6 +366,12 @@ grpc_subchannel *grpc_subchannel_create(grpc_exec_ctx *exec_ctx, &c->args->args[i], (grpc_integer_options){initial_backoff_ms, 100, INT_MAX}); } else if (0 == strcmp(c->args->args[i].key, + GRPC_ARG_MIN_RECONNECT_BACKOFF_MS)) { + fixed_reconnect_backoff = false; + min_backoff_ms = grpc_channel_arg_get_integer( + &c->args->args[i], + (grpc_integer_options){min_backoff_ms, 100, INT_MAX}); + } else if (0 == strcmp(c->args->args[i].key, GRPC_ARG_MAX_RECONNECT_BACKOFF_MS)) { fixed_reconnect_backoff = false; max_backoff_ms = grpc_channel_arg_get_integer( diff --git a/src/core/ext/filters/load_reporting/load_reporting.c b/src/core/ext/filters/load_reporting/load_reporting.c index 3b5d2103c1..4e9d0937ae 100644 --- a/src/core/ext/filters/load_reporting/load_reporting.c +++ b/src/core/ext/filters/load_reporting/load_reporting.c @@ -47,23 +47,6 @@ #include "src/core/lib/surface/call.h" #include "src/core/lib/surface/channel_init.h" -static void destroy_lr_cost_context(void *c) { - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_load_reporting_cost_context *cost_ctx = c; - for (size_t i = 0; i < cost_ctx->values_count; ++i) { - grpc_slice_unref_internal(&exec_ctx, cost_ctx->values[i]); - } - grpc_exec_ctx_finish(&exec_ctx); - gpr_free(cost_ctx->values); - gpr_free(cost_ctx); -} - -void grpc_call_set_load_reporting_cost_context( - grpc_call *call, grpc_load_reporting_cost_context *ctx) { - grpc_call_context_set(call, GRPC_CONTEXT_LR_COST, ctx, - destroy_lr_cost_context); -} - static bool is_load_reporting_enabled(const grpc_channel_args *a) { return grpc_channel_arg_get_bool( grpc_channel_args_find(a, GRPC_ARG_ENABLE_LOAD_REPORTING), false); diff --git a/src/core/ext/filters/load_reporting/load_reporting_filter.c b/src/core/ext/filters/load_reporting/load_reporting_filter.c index 57b25d0651..75a9a56687 100644 --- a/src/core/ext/filters/load_reporting/load_reporting_filter.c +++ b/src/core/ext/filters/load_reporting/load_reporting_filter.c @@ -48,6 +48,8 @@ typedef struct call_data { intptr_t id; /**< an id unique to the call */ + bool have_trailing_md_string; + grpc_slice trailing_md_string; bool have_initial_md_string; grpc_slice initial_md_string; bool have_service_method; @@ -140,6 +142,9 @@ static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, if (calld->have_initial_md_string) { grpc_slice_unref_internal(exec_ctx, calld->initial_md_string); } + if (calld->have_trailing_md_string) { + grpc_slice_unref_internal(exec_ctx, calld->trailing_md_string); + } if (calld->have_service_method) { grpc_slice_unref_internal(exec_ctx, calld->service_method); } @@ -183,6 +188,18 @@ static void destroy_channel_elem(grpc_exec_ctx *exec_ctx, */ } +static grpc_filtered_mdelem lr_trailing_md_filter(grpc_exec_ctx *exec_ctx, + void *user_data, + grpc_mdelem md) { + grpc_call_element *elem = user_data; + call_data *calld = elem->call_data; + if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_LB_COST_BIN)) { + calld->trailing_md_string = GRPC_MDVALUE(md); + return GRPC_FILTERED_REMOVE(); + } + return GRPC_FILTERED_MDELEM(md); +} + static void lr_start_transport_stream_op_batch( grpc_exec_ctx *exec_ctx, grpc_call_element *elem, grpc_transport_stream_op_batch *op) { @@ -190,13 +207,21 @@ static void lr_start_transport_stream_op_batch( call_data *calld = elem->call_data; if (op->recv_initial_metadata) { + /* substitute our callback for the higher callback */ calld->recv_initial_metadata = op->payload->recv_initial_metadata.recv_initial_metadata; - /* substitute our callback for the higher callback */ calld->ops_recv_initial_metadata_ready = op->payload->recv_initial_metadata.recv_initial_metadata_ready; op->payload->recv_initial_metadata.recv_initial_metadata_ready = &calld->on_initial_md_ready; + } else if (op->send_trailing_metadata) { + GRPC_LOG_IF_ERROR( + "grpc_metadata_batch_filter", + grpc_metadata_batch_filter( + exec_ctx, + op->payload->send_trailing_metadata.send_trailing_metadata, + lr_trailing_md_filter, elem, + "LR trailing metadata filtering error")); } grpc_call_next_op(exec_ctx, elem, op); diff --git a/src/core/lib/channel/context.h b/src/core/lib/channel/context.h index 2c1174ce7a..6c931ad28a 100644 --- a/src/core/lib/channel/context.h +++ b/src/core/lib/channel/context.h @@ -50,9 +50,6 @@ typedef enum { /// Reserved for traffic_class_context. GRPC_CONTEXT_TRAFFIC, - /// Costs for Load Reporting. - GRPC_CONTEXT_LR_COST, - GRPC_CONTEXT_COUNT } grpc_context_index; diff --git a/src/core/lib/transport/static_metadata.c b/src/core/lib/transport/static_metadata.c index 599d4ad117..862cdaa8e0 100644 --- a/src/core/lib/transport/static_metadata.c +++ b/src/core/lib/transport/static_metadata.c @@ -97,23 +97,23 @@ static uint8_t g_bytes[] = { 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}; + 45, 109, 111, 100, 105, 102, 105, 101, 100, 108, 98, 45, 99, 111, 115, + 116, 45, 98, 105, 110, 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) {} @@ -223,6 +223,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] = { @@ -383,64 +384,67 @@ const grpc_slice grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT] = { {.refcount = &grpc_static_metadata_refcounts[77], .data.refcounted = {g_bytes + 791, 13}}, {.refcount = &grpc_static_metadata_refcounts[78], - .data.refcounted = {g_bytes + 804, 4}}, + .data.refcounted = {g_bytes + 804, 11}}, {.refcount = &grpc_static_metadata_refcounts[79], - .data.refcounted = {g_bytes + 808, 8}}, + .data.refcounted = {g_bytes + 815, 4}}, {.refcount = &grpc_static_metadata_refcounts[80], - .data.refcounted = {g_bytes + 816, 12}}, + .data.refcounted = {g_bytes + 819, 8}}, {.refcount = &grpc_static_metadata_refcounts[81], - .data.refcounted = {g_bytes + 828, 18}}, + .data.refcounted = {g_bytes + 827, 12}}, {.refcount = &grpc_static_metadata_refcounts[82], - .data.refcounted = {g_bytes + 846, 19}}, + .data.refcounted = {g_bytes + 839, 18}}, {.refcount = &grpc_static_metadata_refcounts[83], - .data.refcounted = {g_bytes + 865, 5}}, + .data.refcounted = {g_bytes + 857, 19}}, {.refcount = &grpc_static_metadata_refcounts[84], - .data.refcounted = {g_bytes + 870, 7}}, + .data.refcounted = {g_bytes + 876, 5}}, {.refcount = &grpc_static_metadata_refcounts[85], - .data.refcounted = {g_bytes + 877, 7}}, + .data.refcounted = {g_bytes + 881, 7}}, {.refcount = &grpc_static_metadata_refcounts[86], - .data.refcounted = {g_bytes + 884, 11}}, + .data.refcounted = {g_bytes + 888, 7}}, {.refcount = &grpc_static_metadata_refcounts[87], - .data.refcounted = {g_bytes + 895, 6}}, + .data.refcounted = {g_bytes + 895, 11}}, {.refcount = &grpc_static_metadata_refcounts[88], - .data.refcounted = {g_bytes + 901, 10}}, + .data.refcounted = {g_bytes + 906, 6}}, {.refcount = &grpc_static_metadata_refcounts[89], - .data.refcounted = {g_bytes + 911, 25}}, + .data.refcounted = {g_bytes + 912, 10}}, {.refcount = &grpc_static_metadata_refcounts[90], - .data.refcounted = {g_bytes + 936, 17}}, + .data.refcounted = {g_bytes + 922, 25}}, {.refcount = &grpc_static_metadata_refcounts[91], - .data.refcounted = {g_bytes + 953, 4}}, + .data.refcounted = {g_bytes + 947, 17}}, {.refcount = &grpc_static_metadata_refcounts[92], - .data.refcounted = {g_bytes + 957, 3}}, + .data.refcounted = {g_bytes + 964, 4}}, {.refcount = &grpc_static_metadata_refcounts[93], - .data.refcounted = {g_bytes + 960, 16}}, + .data.refcounted = {g_bytes + 968, 3}}, {.refcount = &grpc_static_metadata_refcounts[94], - .data.refcounted = {g_bytes + 976, 16}}, + .data.refcounted = {g_bytes + 971, 16}}, {.refcount = &grpc_static_metadata_refcounts[95], - .data.refcounted = {g_bytes + 992, 13}}, + .data.refcounted = {g_bytes + 987, 16}}, {.refcount = &grpc_static_metadata_refcounts[96], - .data.refcounted = {g_bytes + 1005, 12}}, + .data.refcounted = {g_bytes + 1003, 13}}, {.refcount = &grpc_static_metadata_refcounts[97], - .data.refcounted = {g_bytes + 1017, 21}}, + .data.refcounted = {g_bytes + 1016, 12}}, + {.refcount = &grpc_static_metadata_refcounts[98], + .data.refcounted = {g_bytes + 1028, 21}}, }; uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] = { - 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, - 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, 2, 4, 4, 6, 6, 8, 8}; + 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, 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, 2, 4, 4, 6, 6, 8, 8}; static const int8_t elems_r[] = { - 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}; + 10, 8, -3, 0, 9, 21, -77, 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, 16, -53, -54, -55, -56, + -56, -57, -58, -59, 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 -= 42; - uint32_t x = i % 96; - uint32_t y = i / 96; + uint32_t x = i % 97; + uint32_t y = i / 97; uint32_t h = x; if (y < GPR_ARRAY_SIZE(elems_r)) { uint32_t delta = (uint32_t)elems_r[y]; @@ -450,29 +454,30 @@ static uint32_t elems_phash(uint32_t i) { } static const uint16_t elem_keys[] = { - 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, + 1019, 1020, 1021, 242, 243, 244, 245, 246, 139, 140, 42, 43, + 433, 434, 435, 920, 921, 922, 719, 720, 1406, 527, 721, 1604, + 1703, 1802, 4871, 4970, 5001, 5168, 5267, 5366, 5465, 1419, 5564, 5663, + 5762, 5861, 5960, 6059, 6158, 6257, 6356, 6455, 6554, 6653, 6752, 6851, + 6950, 7049, 7148, 7247, 7346, 7445, 7544, 7643, 7742, 7841, 7940, 8039, + 8138, 8237, 8336, 8435, 8534, 8633, 1085, 1086, 1087, 1088, 8732, 8831, + 8930, 9029, 9128, 9227, 9326, 0, 317, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 133, 233, 234, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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}; 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, + 74, 77, 75, 19, 20, 21, 22, 23, 15, 16, 17, 18, 11, 12, 13, + 3, 4, 5, 0, 1, 41, 6, 2, 70, 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, 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}; + 60, 61, 62, 63, 64, 65, 76, 78, 79, 80, 66, 67, 68, 69, 71, + 72, 73, 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 * 98 + b); + uint32_t k = (uint32_t)(a * 99 + 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]], @@ -706,71 +711,75 @@ grpc_mdelem_data grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = { {.refcount = &grpc_static_metadata_refcounts[20], .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[78], - .data.refcounted = {g_bytes + 804, 4}}, + .data.refcounted = {g_bytes + 804, 11}}, {.refcount = &grpc_static_metadata_refcounts[20], .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[79], - .data.refcounted = {g_bytes + 808, 8}}, + .data.refcounted = {g_bytes + 815, 4}}, {.refcount = &grpc_static_metadata_refcounts[20], .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[80], - .data.refcounted = {g_bytes + 816, 12}}, + .data.refcounted = {g_bytes + 819, 8}}, {.refcount = &grpc_static_metadata_refcounts[20], .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[81], - .data.refcounted = {g_bytes + 828, 18}}, + .data.refcounted = {g_bytes + 827, 12}}, {.refcount = &grpc_static_metadata_refcounts[20], .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[82], - .data.refcounted = {g_bytes + 846, 19}}, + .data.refcounted = {g_bytes + 839, 18}}, {.refcount = &grpc_static_metadata_refcounts[20], .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[83], - .data.refcounted = {g_bytes + 865, 5}}, + .data.refcounted = {g_bytes + 857, 19}}, {.refcount = &grpc_static_metadata_refcounts[20], .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[84], - .data.refcounted = {g_bytes + 870, 7}}, + .data.refcounted = {g_bytes + 876, 5}}, {.refcount = &grpc_static_metadata_refcounts[20], .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[85], - .data.refcounted = {g_bytes + 877, 7}}, + .data.refcounted = {g_bytes + 881, 7}}, {.refcount = &grpc_static_metadata_refcounts[20], .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[86], - .data.refcounted = {g_bytes + 884, 11}}, + .data.refcounted = {g_bytes + 888, 7}}, {.refcount = &grpc_static_metadata_refcounts[20], .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[87], - .data.refcounted = {g_bytes + 895, 6}}, + .data.refcounted = {g_bytes + 895, 11}}, {.refcount = &grpc_static_metadata_refcounts[20], .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[88], - .data.refcounted = {g_bytes + 901, 10}}, + .data.refcounted = {g_bytes + 906, 6}}, {.refcount = &grpc_static_metadata_refcounts[20], .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[89], - .data.refcounted = {g_bytes + 911, 25}}, + .data.refcounted = {g_bytes + 912, 10}}, {.refcount = &grpc_static_metadata_refcounts[20], .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[90], - .data.refcounted = {g_bytes + 936, 17}}, + .data.refcounted = {g_bytes + 922, 25}}, {.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[91], + .data.refcounted = {g_bytes + 947, 17}}, {.refcount = &grpc_static_metadata_refcounts[20], .data.refcounted = {g_bytes + 234, 0}}}, - {{.refcount = &grpc_static_metadata_refcounts[91], - .data.refcounted = {g_bytes + 953, 4}}, + {{.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[92], - .data.refcounted = {g_bytes + 957, 3}}, + .data.refcounted = {g_bytes + 964, 4}}, {.refcount = &grpc_static_metadata_refcounts[20], .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[93], - .data.refcounted = {g_bytes + 960, 16}}, + .data.refcounted = {g_bytes + 968, 3}}, + {.refcount = &grpc_static_metadata_refcounts[20], + .data.refcounted = {g_bytes + 234, 0}}}, + {{.refcount = &grpc_static_metadata_refcounts[94], + .data.refcounted = {g_bytes + 971, 16}}, {.refcount = &grpc_static_metadata_refcounts[20], .data.refcounted = {g_bytes + 234, 0}}}, {{.refcount = &grpc_static_metadata_refcounts[10], @@ -783,24 +792,24 @@ grpc_mdelem_data grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = { .data.refcounted = {g_bytes + 377, 7}}}, {{.refcount = &grpc_static_metadata_refcounts[10], .data.refcounted = {g_bytes + 90, 20}}, - {.refcount = &grpc_static_metadata_refcounts[94], - .data.refcounted = {g_bytes + 976, 16}}}, + {.refcount = &grpc_static_metadata_refcounts[95], + .data.refcounted = {g_bytes + 987, 16}}}, {{.refcount = &grpc_static_metadata_refcounts[10], .data.refcounted = {g_bytes + 90, 20}}, {.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 + 992, 13}}}, - {{.refcount = &grpc_static_metadata_refcounts[10], - .data.refcounted = {g_bytes + 90, 20}}, {.refcount = &grpc_static_metadata_refcounts[96], - .data.refcounted = {g_bytes + 1005, 12}}}, + .data.refcounted = {g_bytes + 1003, 13}}}, {{.refcount = &grpc_static_metadata_refcounts[10], .data.refcounted = {g_bytes + 90, 20}}, {.refcount = &grpc_static_metadata_refcounts[97], - .data.refcounted = {g_bytes + 1017, 21}}}, + .data.refcounted = {g_bytes + 1016, 12}}}, + {{.refcount = &grpc_static_metadata_refcounts[10], + .data.refcounted = {g_bytes + 90, 20}}, + {.refcount = &grpc_static_metadata_refcounts[98], + .data.refcounted = {g_bytes + 1028, 21}}}, }; -const uint8_t grpc_static_accept_encoding_metadata[8] = {0, 73, 74, 75, - 76, 77, 78, 79}; +const uint8_t grpc_static_accept_encoding_metadata[8] = {0, 74, 75, 76, + 77, 78, 79, 80}; diff --git a/src/core/lib/transport/static_metadata.h b/src/core/lib/transport/static_metadata.h index dcbe418edc..84fb316fd6 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 98 +#define GRPC_STATIC_MDSTR_COUNT 99 extern const grpc_slice grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT]; /* ":path" */ #define GRPC_MDSTR_PATH (grpc_static_slice_table[0]) @@ -205,47 +205,49 @@ extern const grpc_slice grpc_static_slice_table[GRPC_STATIC_MDSTR_COUNT]; #define GRPC_MDSTR_IF_UNMODIFIED_SINCE (grpc_static_slice_table[76]) /* "last-modified" */ #define GRPC_MDSTR_LAST_MODIFIED (grpc_static_slice_table[77]) +/* "lb-cost-bin" */ +#define GRPC_MDSTR_LB_COST_BIN (grpc_static_slice_table[78]) /* "link" */ -#define GRPC_MDSTR_LINK (grpc_static_slice_table[78]) +#define GRPC_MDSTR_LINK (grpc_static_slice_table[79]) /* "location" */ -#define GRPC_MDSTR_LOCATION (grpc_static_slice_table[79]) +#define GRPC_MDSTR_LOCATION (grpc_static_slice_table[80]) /* "max-forwards" */ -#define GRPC_MDSTR_MAX_FORWARDS (grpc_static_slice_table[80]) +#define GRPC_MDSTR_MAX_FORWARDS (grpc_static_slice_table[81]) /* "proxy-authenticate" */ -#define GRPC_MDSTR_PROXY_AUTHENTICATE (grpc_static_slice_table[81]) +#define GRPC_MDSTR_PROXY_AUTHENTICATE (grpc_static_slice_table[82]) /* "proxy-authorization" */ -#define GRPC_MDSTR_PROXY_AUTHORIZATION (grpc_static_slice_table[82]) +#define GRPC_MDSTR_PROXY_AUTHORIZATION (grpc_static_slice_table[83]) /* "range" */ -#define GRPC_MDSTR_RANGE (grpc_static_slice_table[83]) +#define GRPC_MDSTR_RANGE (grpc_static_slice_table[84]) /* "referer" */ -#define GRPC_MDSTR_REFERER (grpc_static_slice_table[84]) +#define GRPC_MDSTR_REFERER (grpc_static_slice_table[85]) /* "refresh" */ -#define GRPC_MDSTR_REFRESH (grpc_static_slice_table[85]) +#define GRPC_MDSTR_REFRESH (grpc_static_slice_table[86]) /* "retry-after" */ -#define GRPC_MDSTR_RETRY_AFTER (grpc_static_slice_table[86]) +#define GRPC_MDSTR_RETRY_AFTER (grpc_static_slice_table[87]) /* "server" */ -#define GRPC_MDSTR_SERVER (grpc_static_slice_table[87]) +#define GRPC_MDSTR_SERVER (grpc_static_slice_table[88]) /* "set-cookie" */ -#define GRPC_MDSTR_SET_COOKIE (grpc_static_slice_table[88]) +#define GRPC_MDSTR_SET_COOKIE (grpc_static_slice_table[89]) /* "strict-transport-security" */ -#define GRPC_MDSTR_STRICT_TRANSPORT_SECURITY (grpc_static_slice_table[89]) +#define GRPC_MDSTR_STRICT_TRANSPORT_SECURITY (grpc_static_slice_table[90]) /* "transfer-encoding" */ -#define GRPC_MDSTR_TRANSFER_ENCODING (grpc_static_slice_table[90]) +#define GRPC_MDSTR_TRANSFER_ENCODING (grpc_static_slice_table[91]) /* "vary" */ -#define GRPC_MDSTR_VARY (grpc_static_slice_table[91]) +#define GRPC_MDSTR_VARY (grpc_static_slice_table[92]) /* "via" */ -#define GRPC_MDSTR_VIA (grpc_static_slice_table[92]) +#define GRPC_MDSTR_VIA (grpc_static_slice_table[93]) /* "www-authenticate" */ -#define GRPC_MDSTR_WWW_AUTHENTICATE (grpc_static_slice_table[93]) +#define GRPC_MDSTR_WWW_AUTHENTICATE (grpc_static_slice_table[94]) /* "identity,deflate" */ -#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE (grpc_static_slice_table[94]) +#define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE (grpc_static_slice_table[95]) /* "identity,gzip" */ -#define GRPC_MDSTR_IDENTITY_COMMA_GZIP (grpc_static_slice_table[95]) +#define GRPC_MDSTR_IDENTITY_COMMA_GZIP (grpc_static_slice_table[96]) /* "deflate,gzip" */ -#define GRPC_MDSTR_DEFLATE_COMMA_GZIP (grpc_static_slice_table[96]) +#define GRPC_MDSTR_DEFLATE_COMMA_GZIP (grpc_static_slice_table[97]) /* "identity,deflate,gzip" */ #define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE_COMMA_GZIP \ - (grpc_static_slice_table[97]) + (grpc_static_slice_table[98]) extern const grpc_slice_refcount_vtable grpc_static_metadata_vtable; extern grpc_slice_refcount @@ -257,7 +259,7 @@ extern grpc_slice_refcount #define GRPC_STATIC_METADATA_INDEX(static_slice) \ ((int)((static_slice).refcount - grpc_static_metadata_refcounts)) -#define GRPC_STATIC_MDELEM_COUNT 80 +#define GRPC_STATIC_MDELEM_COUNT 81 extern grpc_mdelem_data grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT]; extern uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT]; /* "grpc-status": "0" */ @@ -428,78 +430,81 @@ extern uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT]; /* "lb-token": "" */ #define GRPC_MDELEM_LB_TOKEN_EMPTY \ (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[55], GRPC_MDELEM_STORAGE_STATIC)) +/* "lb-cost-bin": "" */ +#define GRPC_MDELEM_LB_COST_BIN_EMPTY \ + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[56], GRPC_MDELEM_STORAGE_STATIC)) /* "link": "" */ #define GRPC_MDELEM_LINK_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[56], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[57], GRPC_MDELEM_STORAGE_STATIC)) /* "location": "" */ #define GRPC_MDELEM_LOCATION_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[57], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[58], GRPC_MDELEM_STORAGE_STATIC)) /* "max-forwards": "" */ #define GRPC_MDELEM_MAX_FORWARDS_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[58], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[59], GRPC_MDELEM_STORAGE_STATIC)) /* "proxy-authenticate": "" */ #define GRPC_MDELEM_PROXY_AUTHENTICATE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[59], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[60], GRPC_MDELEM_STORAGE_STATIC)) /* "proxy-authorization": "" */ #define GRPC_MDELEM_PROXY_AUTHORIZATION_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[60], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[61], GRPC_MDELEM_STORAGE_STATIC)) /* "range": "" */ #define GRPC_MDELEM_RANGE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[61], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[62], GRPC_MDELEM_STORAGE_STATIC)) /* "referer": "" */ #define GRPC_MDELEM_REFERER_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[62], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[63], GRPC_MDELEM_STORAGE_STATIC)) /* "refresh": "" */ #define GRPC_MDELEM_REFRESH_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[63], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[64], GRPC_MDELEM_STORAGE_STATIC)) /* "retry-after": "" */ #define GRPC_MDELEM_RETRY_AFTER_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[64], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[65], GRPC_MDELEM_STORAGE_STATIC)) /* "server": "" */ #define GRPC_MDELEM_SERVER_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[65], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[66], GRPC_MDELEM_STORAGE_STATIC)) /* "set-cookie": "" */ #define GRPC_MDELEM_SET_COOKIE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[66], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[67], GRPC_MDELEM_STORAGE_STATIC)) /* "strict-transport-security": "" */ #define GRPC_MDELEM_STRICT_TRANSPORT_SECURITY_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[67], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[68], GRPC_MDELEM_STORAGE_STATIC)) /* "transfer-encoding": "" */ #define GRPC_MDELEM_TRANSFER_ENCODING_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[68], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[69], GRPC_MDELEM_STORAGE_STATIC)) /* "user-agent": "" */ #define GRPC_MDELEM_USER_AGENT_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[69], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[70], GRPC_MDELEM_STORAGE_STATIC)) /* "vary": "" */ #define GRPC_MDELEM_VARY_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[70], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[71], GRPC_MDELEM_STORAGE_STATIC)) /* "via": "" */ #define GRPC_MDELEM_VIA_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[71], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[72], GRPC_MDELEM_STORAGE_STATIC)) /* "www-authenticate": "" */ #define GRPC_MDELEM_WWW_AUTHENTICATE_EMPTY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[72], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[73], GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-accept-encoding": "identity" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[73], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[74], GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-accept-encoding": "deflate" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_DEFLATE \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[74], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[75], GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-accept-encoding": "identity,deflate" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[75], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[76], GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-accept-encoding": "gzip" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_GZIP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[76], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[77], GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-accept-encoding": "identity,gzip" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_GZIP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[77], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[78], GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-accept-encoding": "deflate,gzip" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_DEFLATE_COMMA_GZIP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[78], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[79], GRPC_MDELEM_STORAGE_STATIC)) /* "grpc-accept-encoding": "identity,deflate,gzip" */ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE_COMMA_GZIP \ - (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[79], GRPC_MDELEM_STORAGE_STATIC)) + (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table[80], GRPC_MDELEM_STORAGE_STATIC)) grpc_mdelem grpc_static_mdelem_for_static_strings(int a, int b); typedef enum { diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc index 75610d69cd..62ded0d239 100644 --- a/src/cpp/server/server_cc.cc +++ b/src/cpp/server/server_cc.cc @@ -503,7 +503,7 @@ int Server::AddListeningPort(const grpc::string& addr, ServerCredentials* creds) { GPR_ASSERT(!started_); int port = creds->AddPortToServer(addr, server_); - global_callbacks_->AddPort(this, port); + global_callbacks_->AddPort(this, addr, creds, port); return port; } diff --git a/src/cpp/server/server_context.cc b/src/cpp/server/server_context.cc index afc9873c14..33ad0ae142 100644 --- a/src/cpp/server/server_context.cc +++ b/src/cpp/server/server_context.cc @@ -229,17 +229,9 @@ const struct census_context* ServerContext::census_context() const { void ServerContext::SetLoadReportingCosts( const std::vector<grpc::string>& cost_data) { if (call_ == nullptr) return; - grpc_load_reporting_cost_context* cost_ctx = - static_cast<grpc_load_reporting_cost_context*>( - gpr_malloc(sizeof(*cost_ctx))); - cost_ctx->values_count = cost_data.size(); - cost_ctx->values = static_cast<grpc_slice*>( - gpr_malloc(sizeof(*cost_ctx->values) * cost_ctx->values_count)); - for (size_t i = 0; i < cost_ctx->values_count; ++i) { - cost_ctx->values[i] = - grpc_slice_from_copied_buffer(cost_data[i].data(), cost_data[i].size()); + for (const auto& cost_datum : cost_data) { + AddTrailingMetadata(GRPC_LB_COST_MD_KEY, cost_datum); } - grpc_call_set_load_reporting_cost_context(call_, cost_ctx); } } // namespace grpc diff --git a/src/csharp/Grpc.Core.Tests/AppDomainUnloadTest.cs b/src/csharp/Grpc.Core.Tests/AppDomainUnloadTest.cs index d7ebdb4201..7858e77b27 100644 --- a/src/csharp/Grpc.Core.Tests/AppDomainUnloadTest.cs +++ b/src/csharp/Grpc.Core.Tests/AppDomainUnloadTest.cs @@ -72,10 +72,6 @@ namespace Grpc.Core.Tests public AppDomainTestClass() { var helper = new MockServiceHelper(Host); - var server = helper.GetServer(); - server.Start(); - var channel = helper.GetChannel(); - var readyToShutdown = new TaskCompletionSource<object>(); helper.DuplexStreamingHandler = new DuplexStreamingServerMethod<string, string>(async (requestStream, responseStream, context) => { @@ -83,6 +79,10 @@ namespace Grpc.Core.Tests await requestStream.ToListAsync(); }); + var server = helper.GetServer(); + server.Start(); + var channel = helper.GetChannel(); + var call = Calls.AsyncDuplexStreamingCall(helper.CreateDuplexStreamingCall()); readyToShutdown.Task.Wait(); // make sure handler is running } diff --git a/src/csharp/Grpc.Core.Tests/UserAgentStringTest.cs b/src/csharp/Grpc.Core.Tests/UserAgentStringTest.cs index cc830086a6..74b4997f69 100644 --- a/src/csharp/Grpc.Core.Tests/UserAgentStringTest.cs +++ b/src/csharp/Grpc.Core.Tests/UserAgentStringTest.cs @@ -63,10 +63,6 @@ namespace Grpc.Core.Tests public void DefaultUserAgentString() { helper = new MockServiceHelper(Host); - server = helper.GetServer(); - server.Start(); - channel = helper.GetChannel(); - helper.UnaryHandler = new UnaryServerMethod<string, string>((request, context) => { var userAgentString = context.RequestHeaders.First(m => (m.Key == "user-agent")).Value; @@ -75,6 +71,11 @@ namespace Grpc.Core.Tests Assert.IsTrue(parts[1].StartsWith("grpc-c/")); return Task.FromResult("PASS"); }); + + server = helper.GetServer(); + server.Start(); + channel = helper.GetChannel(); + Assert.AreEqual("PASS", Calls.BlockingUnaryCall(helper.CreateUnaryCall(), "")); } @@ -83,11 +84,6 @@ namespace Grpc.Core.Tests { helper = new MockServiceHelper(Host, channelOptions: new[] { new ChannelOption(ChannelOptions.PrimaryUserAgentString, "XYZ") }); - server = helper.GetServer(); - server.Start(); - channel = helper.GetChannel(); - - channel = helper.GetChannel(); helper.UnaryHandler = new UnaryServerMethod<string, string>((request, context) => { var userAgentString = context.RequestHeaders.First(m => (m.Key == "user-agent")).Value; @@ -95,6 +91,11 @@ namespace Grpc.Core.Tests Assert.AreEqual("XYZ", parts[0]); return Task.FromResult("PASS"); }); + + server = helper.GetServer(); + server.Start(); + channel = helper.GetChannel(); + Assert.AreEqual("PASS", Calls.BlockingUnaryCall(helper.CreateUnaryCall(), "")); } } diff --git a/src/objective-c/tests/InteropTestsLocalCleartext.m b/src/objective-c/tests/InteropTestsLocalCleartext.m index 94cdf85965..cdcdd8a88c 100644 --- a/src/objective-c/tests/InteropTestsLocalCleartext.m +++ b/src/objective-c/tests/InteropTestsLocalCleartext.m @@ -36,7 +36,11 @@ #import "InteropTests.h" -static NSString * const kLocalCleartextHost = @"localhost:5050"; +// The server address is derived from preprocessor macro, which is +// in turn derived from environment variable of the same name. +#define NSStringize_helper(x) #x +#define NSStringize(x) @NSStringize_helper(x) +static NSString * const kLocalCleartextHost = NSStringize(HOST_PORT_LOCAL); // The Protocol Buffers encoding overhead of local interop server. Acquired // by experiment. Adjust this when server's proto file changes. diff --git a/src/objective-c/tests/InteropTestsLocalSSL.m b/src/objective-c/tests/InteropTestsLocalSSL.m index 3c78b65ede..45e62d29b9 100644 --- a/src/objective-c/tests/InteropTestsLocalSSL.m +++ b/src/objective-c/tests/InteropTestsLocalSSL.m @@ -35,8 +35,11 @@ #import <GRPCClient/internal_testing/GRPCCall+InternalTests.h> #import "InteropTests.h" - -static NSString * const kLocalSSLHost = @"localhost:5051"; +// The server address is derived from preprocessor macro, which is +// in turn derived from environment variable of the same name. +#define NSStringize_helper(x) #x +#define NSStringize(x) @NSStringize_helper(x) +static NSString * const kLocalSSLHost = NSStringize(HOST_PORT_LOCALSSL); // The Protocol Buffers encoding overhead of local interop server. Acquired // by experiment. Adjust this when server's proto file changes. diff --git a/src/objective-c/tests/InteropTestsRemote.m b/src/objective-c/tests/InteropTestsRemote.m index ff1193302b..5260fe4570 100644 --- a/src/objective-c/tests/InteropTestsRemote.m +++ b/src/objective-c/tests/InteropTestsRemote.m @@ -36,7 +36,11 @@ #import "InteropTests.h" -static NSString * const kRemoteSSLHost = @"grpc-test.sandbox.googleapis.com"; +// The server address is derived from preprocessor macro, which is +// in turn derived from environment variable of the same name. +#define NSStringize_helper(x) #x +#define NSStringize(x) @NSStringize_helper(x) +static NSString * const kRemoteSSLHost = NSStringize(HOST_PORT_REMOTE); // The Protocol Buffers encoding overhead of remote interop server. Acquired // by experiment. Adjust this when server's proto file changes. diff --git a/src/objective-c/tests/InteropTestsRemoteWithCronet/InteropTestsRemoteWithCronet.m b/src/objective-c/tests/InteropTestsRemoteWithCronet/InteropTestsRemoteWithCronet.m index 9edfbc2639..a7f190d2b4 100644 --- a/src/objective-c/tests/InteropTestsRemoteWithCronet/InteropTestsRemoteWithCronet.m +++ b/src/objective-c/tests/InteropTestsRemoteWithCronet/InteropTestsRemoteWithCronet.m @@ -39,7 +39,12 @@ #import "InteropTests.h" -static NSString * const kRemoteSSLHost = @"grpc-test.sandbox.googleapis.com"; +// The server address is derived from preprocessor macro, which is +// in turn derived from environment variable of the same name. +#define NSStringize_helper(x) #x +#define NSStringize(x) @NSStringize_helper(x) +static NSString * const kRemoteSSLHost = NSStringize(HOST_PORT_REMOTE); + // The Protocol Buffers encoding overhead of remote interop server. Acquired // by experiment. Adjust this when server's proto file changes. diff --git a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj index 97de723a22..b01d5ffcea 100644 --- a/src/objective-c/tests/Tests.xcodeproj/project.pbxproj +++ b/src/objective-c/tests/Tests.xcodeproj/project.pbxproj @@ -1282,6 +1282,9 @@ GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", + "HOST_PORT_LOCALSSL=$(HOST_PORT_LOCALSSL)", + "HOST_PORT_LOCAL=$(HOST_PORT_LOCAL)", + "HOST_PORT_REMOTE=$(HOST_PORT_REMOTE)", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_TREAT_WARNINGS_AS_ERRORS = YES; @@ -1565,6 +1568,7 @@ GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", + "HOST_PORT_REMOTE=$(HOST_PORT_REMOTE)", ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_TREAT_WARNINGS_AS_ERRORS = YES; diff --git a/src/objective-c/tests/run_tests.sh b/src/objective-c/tests/run_tests.sh index 0e82bcaa44..2432209f4f 100755 --- a/src/objective-c/tests/run_tests.sh +++ b/src/objective-c/tests/run_tests.sh @@ -59,6 +59,9 @@ xcodebuild \ -workspace Tests.xcworkspace \ -scheme AllTests \ -destination name="iPhone 6" \ + HOST_PORT_LOCALSSL=localhost:5051 \ + HOST_PORT_LOCAL=localhost:5050 \ + HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com \ test | xcpretty echo "TIME: $(date)" @@ -84,4 +87,5 @@ xcodebuild \ -workspace Tests.xcworkspace \ -scheme InteropTestsRemoteWithCronet \ -destination name="iPhone 6" \ + HOST_PORT_REMOTE=grpc-test.sandbox.googleapis.com \ test | xcpretty diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.c b/src/ruby/ext/grpc/rb_grpc_imports.generated.c index 063f92114c..f189e88198 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.c +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.c @@ -110,7 +110,6 @@ grpc_channel_register_call_type grpc_channel_register_call_import; grpc_channel_create_registered_call_type grpc_channel_create_registered_call_import; grpc_call_start_batch_type grpc_call_start_batch_import; grpc_call_get_peer_type grpc_call_get_peer_import; -grpc_call_set_load_reporting_cost_context_type grpc_call_set_load_reporting_cost_context_import; grpc_census_call_set_context_type grpc_census_call_set_context_import; grpc_census_call_get_context_type grpc_census_call_get_context_import; grpc_channel_get_target_type grpc_channel_get_target_import; @@ -407,7 +406,6 @@ void grpc_rb_load_imports(HMODULE library) { grpc_channel_create_registered_call_import = (grpc_channel_create_registered_call_type) GetProcAddress(library, "grpc_channel_create_registered_call"); grpc_call_start_batch_import = (grpc_call_start_batch_type) GetProcAddress(library, "grpc_call_start_batch"); grpc_call_get_peer_import = (grpc_call_get_peer_type) GetProcAddress(library, "grpc_call_get_peer"); - grpc_call_set_load_reporting_cost_context_import = (grpc_call_set_load_reporting_cost_context_type) GetProcAddress(library, "grpc_call_set_load_reporting_cost_context"); grpc_census_call_set_context_import = (grpc_census_call_set_context_type) GetProcAddress(library, "grpc_census_call_set_context"); grpc_census_call_get_context_import = (grpc_census_call_get_context_type) GetProcAddress(library, "grpc_census_call_get_context"); grpc_channel_get_target_import = (grpc_channel_get_target_type) GetProcAddress(library, "grpc_channel_get_target"); diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h index e036ff7bd6..dcdc8063a2 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h @@ -281,9 +281,6 @@ extern grpc_call_start_batch_type grpc_call_start_batch_import; typedef char *(*grpc_call_get_peer_type)(grpc_call *call); extern grpc_call_get_peer_type grpc_call_get_peer_import; #define grpc_call_get_peer grpc_call_get_peer_import -typedef void(*grpc_call_set_load_reporting_cost_context_type)(grpc_call *call, struct grpc_load_reporting_cost_context *context); -extern grpc_call_set_load_reporting_cost_context_type grpc_call_set_load_reporting_cost_context_import; -#define grpc_call_set_load_reporting_cost_context grpc_call_set_load_reporting_cost_context_import typedef void(*grpc_census_call_set_context_type)(grpc_call *call, struct census_context *context); extern grpc_census_call_set_context_type grpc_census_call_set_context_import; #define grpc_census_call_set_context grpc_census_call_set_context_import diff --git a/test/core/end2end/fuzzers/hpack.dictionary b/test/core/end2end/fuzzers/hpack.dictionary index 4282c61214..2bb9de34c5 100644 --- a/test/core/end2end/fuzzers/hpack.dictionary +++ b/test/core/end2end/fuzzers/hpack.dictionary @@ -77,6 +77,7 @@ "\x08if-range" "\x13if-unmodified-since" "\x0Dlast-modified" +"\x0Blb-cost-bin" "\x04link" "\x08location" "\x0Cmax-forwards" @@ -153,6 +154,7 @@ "\x00\x13if-unmodified-since\x00" "\x00\x0Dlast-modified\x00" "\x00\x08lb-token\x00" +"\x00\x0Blb-cost-bin\x00" "\x00\x04link\x00" "\x00\x08location\x00" "\x00\x0Cmax-forwards\x00" diff --git a/test/core/end2end/tests/load_reporting_hook.c b/test/core/end2end/tests/load_reporting_hook.c index 72e9db6e21..c021bc07ff 100644 --- a/test/core/end2end/tests/load_reporting_hook.c +++ b/test/core/end2end/tests/load_reporting_hook.c @@ -129,8 +129,7 @@ static void end_test(grpc_end2end_test_fixture *f) { static void request_response_with_payload( grpc_end2end_test_config config, grpc_end2end_test_fixture f, const char *method_name, const char *request_msg, const char *response_msg, - grpc_metadata *initial_lr_metadata, - grpc_load_reporting_cost_context *cost_ctx) { + grpc_metadata *initial_lr_metadata, grpc_metadata *trailing_lr_metadata) { grpc_slice request_payload_slice = grpc_slice_from_static_string(request_msg); grpc_slice response_payload_slice = grpc_slice_from_static_string(response_msg); @@ -243,8 +242,9 @@ static void request_response_with_payload( op->reserved = NULL; op++; op->op = GRPC_OP_SEND_STATUS_FROM_SERVER; - GPR_ASSERT(cost_ctx != NULL); - grpc_call_set_load_reporting_cost_context(s, cost_ctx); + GPR_ASSERT(trailing_lr_metadata != NULL); + op->data.send_status_from_server.trailing_metadata_count = 1; + op->data.send_status_from_server.trailing_metadata = trailing_lr_metadata; op->data.send_status_from_server.status = GRPC_STATUS_OK; grpc_slice status_details = grpc_slice_from_static_string("xyz"); op->data.send_status_from_server.status_details = &status_details; @@ -298,21 +298,21 @@ static void test_load_reporting_hook(grpc_end2end_test_config config) { const char *response_msg = "... and the response from the server"; grpc_metadata initial_lr_metadata; + grpc_metadata trailing_lr_metadata; initial_lr_metadata.key = GRPC_MDSTR_LB_TOKEN; initial_lr_metadata.value = grpc_slice_from_static_string("client-token"); memset(&initial_lr_metadata.internal_data, 0, sizeof(initial_lr_metadata.internal_data)); - grpc_load_reporting_cost_context *cost_ctx = gpr_malloc(sizeof(*cost_ctx)); - memset(cost_ctx, 0, sizeof(*cost_ctx)); - cost_ctx->values_count = 1; - cost_ctx->values = - gpr_malloc(sizeof(*cost_ctx->values) * cost_ctx->values_count); - cost_ctx->values[0] = grpc_slice_from_static_string("cost-token"); + trailing_lr_metadata.key = GRPC_MDSTR_LB_COST_BIN; + trailing_lr_metadata.value = grpc_slice_from_static_string("server-token"); + memset(&trailing_lr_metadata.internal_data, 0, + sizeof(trailing_lr_metadata.internal_data)); request_response_with_payload(config, f, method_name, request_msg, - response_msg, &initial_lr_metadata, cost_ctx); + response_msg, &initial_lr_metadata, + &trailing_lr_metadata); end_test(&f); { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; diff --git a/tools/codegen/core/gen_static_metadata.py b/tools/codegen/core/gen_static_metadata.py index ead57b2bf6..360b0f56e9 100755 --- a/tools/codegen/core/gen_static_metadata.py +++ b/tools/codegen/core/gen_static_metadata.py @@ -124,6 +124,7 @@ CONFIG = [ ('if-unmodified-since', ''), ('last-modified', ''), ('lb-token', ''), + ('lb-cost-bin', ''), ('link', ''), ('location', ''), ('max-forwards', ''), diff --git a/tools/grift/README.md b/tools/grift/README.md index 7cbbdc567b..2b5fa5ae14 100644 --- a/tools/grift/README.md +++ b/tools/grift/README.md @@ -1,6 +1,4 @@ -Copyright 2016 Google Inc. - -#Documentation +# Documentation grift is integration of [Apache Thrift](https://github.com/apache/thrift.git) Serializer with gRPC. @@ -8,19 +6,19 @@ This integration allows you to use grpc to send thrift messages in C++ and java. grift uses Compact Protocol to serialize thrift messages. -##generating grpc plugins for thrift services +## generating grpc plugins for thrift services -###CPP +### C++ ```sh $ thrift --gen cpp <thrift-file> ``` -###JAVA +### Java ```sh $ thrift --gen java <thrift-file> ``` -#Installation +# Installation Before Installing thrift make sure to apply this [patch](grpc_plugins_generator.patch) to third_party/thrift. Go to third_party/thrift and follow the [INSTALLATION](https://github.com/apache/thrift.git) instructions to install thrift with commit id bcad91771b7f0bff28a1cac1981d7ef2b9bcef3c.
\ No newline at end of file diff --git a/tools/jenkins/run_interop_objc.sh b/tools/jenkins/run_interop_objc.sh new file mode 100755 index 0000000000..29f9ac989c --- /dev/null +++ b/tools/jenkins/run_interop_objc.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +# 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. +# +# This script is invoked by Jenkins and runs interop test suite. +set -ex + +export LANG=en_US.UTF-8 + +# Enter the gRPC repo root +cd $(dirname $0)/../.. + +tools/run_tests/run_interop_tests.py -l objc -s all --use_docker -t -j 1 $@ || true diff --git a/tools/jenkins/run_performance_profile_hourly.sh b/tools/jenkins/run_performance_profile_hourly.sh index dfcc2bb116..c352a9f4ac 100755 --- a/tools/jenkins/run_performance_profile_hourly.sh +++ b/tools/jenkins/run_performance_profile_hourly.sh @@ -32,6 +32,8 @@ set -ex cd $(dirname $0)/../.. +./tools/run_tests/start_port_server.py || true + CPUS=`python -c 'import multiprocessing; print multiprocessing.cpu_count()'` make CONFIG=opt memory_profile_test memory_profile_client memory_profile_server -j $CPUS diff --git a/tools/run_tests/README.md b/tools/run_tests/README.md index e709ddd2c0..05d33fd6b1 100644 --- a/tools/run_tests/README.md +++ b/tools/run_tests/README.md @@ -1,44 +1,44 @@ -#Overview +# Overview This directory contains scripts that facilitate building and running tests. We are using python scripts as entrypoint for our tests because that gives us the opportunity to run tests using the same commandline regardless of the platform you are using. -#Unit tests (run_tests.py) +# Unit tests (run_tests.py) Builds gRPC in given language and runs unit tests. Use `tools/run_tests/run_tests.py --help` for more help. -######Example +###### Example `tools/run_tests/run_tests.py -l csharp -c dbg` -######Useful options (among many others) +###### Useful options (among many others) - `--use_docker` Builds a docker container containing all the prerequisites for given language and runs the tests under that container. - `--build_only` Only build, do not run the tests. -#Interop tests (run_interop_tests.py) +# Interop tests (run_interop_tests.py) Runs tests for cross-platform/cross-language interoperability. For more details, see [Interop tests descriptions](/doc/interop-test-descriptions.md) The script is also capable of running interop tests for grpc-java and grpc-go, using sources checked out alongside the ones of the grpc repository. -######Example +###### Example `tools/run_tests/run_interop_tests.py -l csharp -s c++ --use_docker` (run interop tests with C# client and C++ server) Note: if you see an error like `no space left on device` when running the interop tests using Docker, make sure that Docker is building the image files in a location with sufficient disk space. -#Performance benchmarks (run_performance_tests.py) +# Performance benchmarks (run_performance_tests.py) Runs predefined benchmark scenarios for given languages. Besides the simple configuration of running all the scenarios locally, the script also supports orchestrating test runs with client and server running on different machines and uploading the results to BigQuery. -######Example +###### Example `tools/run_tests/run_peformance_tests.py -l c++ node` -######Useful options +###### Useful options - `--regex` use regex to select particular scenarios to run. -#Stress tests (run_stress_tests.py) +# Stress tests (run_stress_tests.py) Runs modified interop tests clients and servers under heavy load for an extended period of time to discover potential stability issues. The tests are internally using Kubernetes to run the client and server on GKE and upload statistics to BigQuery. @@ -47,10 +47,10 @@ The tests are internally using Kubernetes to run the client and server on GKE an The directory `tools/run_tests/stress_test/configs/` contains the config files for several scenarios -#Artifacts & Packages (task_runner.py) +# Artifacts & Packages (task_runner.py) A generalized framework for running predefined tasks based on their labels. We use this to building binary artifacts & distrib packages and testing them) -######Example +###### Example `tools/run_tests/task_runner.py -f python artifact linux x64` (build tasks with labels `python`, `artifact`, `linux`, and `x64`) diff --git a/tools/run_tests/run_interop_tests.py b/tools/run_tests/run_interop_tests.py index d2bf529fef..44e93eb9cc 100755 --- a/tools/run_tests/run_interop_tests.py +++ b/tools/run_tests/run_interop_tests.py @@ -371,6 +371,39 @@ class PHP7Language: def __str__(self): return 'php7' +class ObjcLanguage: + + def __init__(self): + self.client_cwd = 'src/objective-c/tests' + self.safename = str(self) + + def client_cmd(self, args): + # from args, extract the server port and craft xcodebuild command out of it + for arg in args: + port = re.search('--server_port=(\d+)', arg) + if port: + portnum = port.group(1) + cmdline = 'pod install && xcodebuild -workspace Tests.xcworkspace -scheme InteropTestsLocalSSL -destination name="iPhone 6" HOST_PORT_LOCALSSL=localhost:%s test'%portnum + return [cmdline] + + def cloud_to_prod_env(self): + return {} + + def global_env(self): + return {} + + def unimplemented_test_cases(self): + # ObjC test runs all cases with the same command. It ignores the testcase + # cmdline argument. Here we return all but one test cases as unimplemented, + # and depend upon ObjC test's behavior that it runs all cases even when + # we tell it to run just one. + return _TEST_CASES[1:] + _SKIP_COMPRESSION + _SKIP_DATA_FRAME_PADDING + + def unimplemented_test_cases_server(self): + return _SKIP_COMPRESSION + + def __str__(self): + return 'objc' class RubyLanguage: @@ -402,7 +435,6 @@ class RubyLanguage: def __str__(self): return 'ruby' - class PythonLanguage: def __init__(self): @@ -460,6 +492,7 @@ _LANGUAGES = { 'node' : NodeLanguage(), 'php' : PHPLanguage(), 'php7' : PHP7Language(), + 'objc' : ObjcLanguage(), 'ruby' : RubyLanguage(), 'python' : PythonLanguage(), } @@ -667,7 +700,8 @@ def cloud_to_cloud_jobspec(language, test_case, server_name, server_host, cwd = language.client_cwd environ = language.global_env() - if docker_image: + if docker_image and language.safename != 'objc': + # we can't run client in docker for objc. container_name = dockerjob.random_name('interop_client_%s' % language.safename) cmdline = docker_run_cmdline(cmdline, image=docker_image, @@ -820,7 +854,7 @@ argp.add_argument('-l', '--language', choices=['all'] + sorted(_LANGUAGES), nargs='+', default=['all'], - help='Clients to run.') + help='Clients to run. Objc client can be only run on OSX.') argp.add_argument('-j', '--jobs', default=multiprocessing.cpu_count(), type=int) argp.add_argument('--cloud_to_prod', default=False, @@ -913,9 +947,13 @@ if not args.use_docker and servers: print('Running interop servers is only supported with --use_docker option enabled.') sys.exit(1) + +# we want to include everything but objc in 'all' +# because objc won't run on non-mac platforms +all_but_objc = set(six.iterkeys(_LANGUAGES)) - set(['objc']) languages = set(_LANGUAGES[l] for l in itertools.chain.from_iterable( - six.iterkeys(_LANGUAGES) if x == 'all' else [x] + all_but_objc if x == 'all' else [x] for x in args.language)) languages_http2_clients_for_http2_server_interop = set() @@ -942,6 +980,9 @@ if args.use_docker: build_jobs = [] for l in languages_to_build: + if str(l) == 'objc': + # we don't need to build a docker image for objc + continue job = build_interop_image_jobspec(l) docker_images[str(l)] = job.tag build_jobs.append(job) diff --git a/vsprojects/README.md b/vsprojects/README.md index f1663d2548..1f0cdc24ba 100644 --- a/vsprojects/README.md +++ b/vsprojects/README.md @@ -1,10 +1,10 @@ -#Pre-generated MS Visual Studio project & solution files +# Pre-generated MS Visual Studio project & solution files Versions 2013 and 2015 are both supported. You can use [their respective community editions](https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx). -#Building +# Building We are using [NuGet](http://www.nuget.org) to pull zlib and openssl dependencies. If you don't have Visual Studio NuGet plugin installed, you'll need to download nuget.exe from the web and manually restore the NuGet packages. @@ -19,7 +19,7 @@ After that, you can build the solution using one of these options: 1. open `grpc.sln` with Visual Studio and hit "Build". 2. build from commandline using `msbuild grpc.sln /p:Configuration=Debug` -#C/C++ Test Dependencies +# C/C++ Test Dependencies * gtest isn't available as a git repo like the other dependencies. download it and add it to `/third_party/gtest/` (the folder will end up with `/build-aux/`, `/cmake/`, `/codegear/`, etc. folders in it). * if using vs2013: open/import the gtest solution in `/msvc/`, and save over the first solution (you will have to change it from read-only). change all projects to use `/MDd` (Property Pages - C/C++ - Code Generation - Runtime Library) and build. This is a "multithreaded debug" setting and it needs to match grpc. * build all |