diff options
author | Craig Tiller <ctiller@google.com> | 2016-04-05 17:15:07 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2016-04-05 17:15:07 -0700 |
commit | f82ddc4c78ed602ff2135a45804d8fb3415198a6 (patch) | |
tree | 08d353378e6332f2ebd5499ce830ab90d44d2952 /src/core/lib/surface | |
parent | 859fb06e80d63255ba614ad8c7fc91df50bd101b (diff) |
Nailing down dependencies better
Diffstat (limited to 'src/core/lib/surface')
-rw-r--r-- | src/core/lib/surface/channel.c | 12 | ||||
-rw-r--r-- | src/core/lib/surface/channel_init.c | 3 | ||||
-rw-r--r-- | src/core/lib/surface/channel_init.h | 5 | ||||
-rw-r--r-- | src/core/lib/surface/init.c | 64 |
4 files changed, 37 insertions, 47 deletions
diff --git a/src/core/lib/surface/channel.c b/src/core/lib/surface/channel.c index b05900c356..b805091b47 100644 --- a/src/core/lib/surface/channel.c +++ b/src/core/lib/surface/channel.c @@ -90,7 +90,7 @@ grpc_channel *grpc_channel_create(grpc_exec_ctx *exec_ctx, const char *target, grpc_channel *channel = grpc_channel_init_create_stack( exec_ctx, channel_stack_type, sizeof(grpc_channel), args, 1, - destroy_channel, NULL, optional_transport); + destroy_channel, NULL, optional_transport, target); memset(channel, 0, sizeof(*channel)); channel->target = gpr_strdup(target); @@ -143,16 +143,6 @@ grpc_channel *grpc_channel_create(grpc_exec_ctx *exec_ctx, const char *target, } } - if (channel->is_client && channel->default_authority == NULL && - target != NULL) { - char *default_authority = grpc_get_default_authority(target); - if (default_authority) { - channel->default_authority = - grpc_mdelem_from_strings(":authority", default_authority); - } - gpr_free(default_authority); - } - return channel; } diff --git a/src/core/lib/surface/channel_init.c b/src/core/lib/surface/channel_init.c index fc69f61f77..d0dd722ae0 100644 --- a/src/core/lib/surface/channel_init.c +++ b/src/core/lib/surface/channel_init.c @@ -125,13 +125,14 @@ static const char *name_for_type(grpc_channel_stack_type type) { void *grpc_channel_init_create_stack( grpc_exec_ctx *exec_ctx, grpc_channel_stack_type type, size_t prefix_bytes, const grpc_channel_args *args, int initial_refs, grpc_iomgr_cb_func destroy, - void *destroy_arg, grpc_transport *transport) { + void *destroy_arg, grpc_transport *transport, const char *target) { GPR_ASSERT(g_finalized); grpc_channel_stack_builder *builder = grpc_channel_stack_builder_create(); grpc_channel_stack_builder_set_name(builder, name_for_type(type)); grpc_channel_stack_builder_set_channel_arguments(builder, args); grpc_channel_stack_builder_set_transport(builder, transport); + grpc_channel_stack_builder_set_target(builder, target); 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_init.h b/src/core/lib/surface/channel_init.h index a4d8271ca6..cb71ae3b7c 100644 --- a/src/core/lib/surface/channel_init.h +++ b/src/core/lib/surface/channel_init.h @@ -38,6 +38,8 @@ #include "src/core/lib/surface/channel_stack_type.h" #include "src/core/lib/transport/transport.h" +#define GRPC_CHANNEL_INIT_BUILTIN_PRIORITY 10000 + /// This module provides a way for plugins (and the grpc core library itself) /// to register mutators for channel stacks. /// It also provides a universal entry path to run those mutators to build @@ -81,6 +83,7 @@ void grpc_channel_init_shutdown(void); void *grpc_channel_init_create_stack( grpc_exec_ctx *exec_ctx, grpc_channel_stack_type type, size_t prefix_bytes, const grpc_channel_args *args, int initial_refs, grpc_iomgr_cb_func destroy, - void *destroy_arg, grpc_transport *optional_transport); + void *destroy_arg, grpc_transport *optional_transport, + const char *optional_target); #endif /* GRPC_CORE_LIB_SURFACE_CHANNEL_INIT_H */ diff --git a/src/core/lib/surface/init.c b/src/core/lib/surface/init.c index e3938146ab..9c0448d422 100644 --- a/src/core/lib/surface/init.c +++ b/src/core/lib/surface/init.c @@ -99,34 +99,39 @@ static bool maybe_add_http_filter(grpc_channel_stack_builder *builder, } static void register_builtin_channel_init() { - grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX, prepend_filter, - (void *)&grpc_compress_filter); - grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL, INT_MAX, - prepend_filter, - (void *)&grpc_compress_filter); - grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX, prepend_filter, - (void *)&grpc_compress_filter); - grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, INT_MAX, - maybe_add_http_filter, - (void *)&grpc_http_client_filter); - grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, INT_MAX, + 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, INT_MAX, - maybe_add_http_filter, - (void *)&grpc_http_client_filter); - grpc_channel_init_register_stage(GRPC_CLIENT_DIRECT_CHANNEL, INT_MAX, + 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, INT_MAX, - maybe_add_http_filter, - (void *)&grpc_http_server_filter); - grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX, + 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); - grpc_channel_init_register_stage(GRPC_CLIENT_CHANNEL, INT_MAX, append_filter, - (void *)&grpc_client_channel_filter); - grpc_channel_init_register_stage(GRPC_CLIENT_LAME_CHANNEL, INT_MAX, + grpc_channel_init_register_stage(GRPC_CLIENT_LAME_CHANNEL, + GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, append_filter, (void *)&grpc_lame_filter); - grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX, prepend_filter, - (void *)&grpc_server_top_filter); + grpc_channel_init_register_stage( + GRPC_SERVER_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, prepend_filter, + (void *)&grpc_server_top_filter); } typedef struct grpc_plugin { @@ -155,12 +160,8 @@ void grpc_init(void) { gpr_time_init(); grpc_mdctx_global_init(); grpc_channel_init_init(); - grpc_lb_policy_registry_init(); - grpc_resolver_registry_init(GRPC_DEFAULT_NAME_PREFIX); grpc_register_tracer("api", &grpc_api_trace); grpc_register_tracer("channel", &grpc_trace_channel); - grpc_register_tracer("http", &grpc_http_trace); - grpc_register_tracer("flowctl", &grpc_flowctl_trace); grpc_register_tracer("connectivity_state", &grpc_connectivity_state_trace); grpc_register_tracer("channel_stack_builder", &grpc_trace_channel_stack_builder); @@ -170,7 +171,6 @@ void grpc_init(void) { grpc_tracer_init("GRPC_TRACE"); gpr_timers_global_init(); grpc_cq_global_init(); - grpc_subchannel_index_init(); for (i = 0; i < g_number_of_plugins; i++) { if (g_all_of_the_plugins[i].init != NULL) { g_all_of_the_plugins[i].init(); @@ -195,17 +195,13 @@ void grpc_shutdown(void) { grpc_executor_shutdown(); grpc_cq_global_shutdown(); grpc_iomgr_shutdown(); - grpc_subchannel_index_shutdown(); gpr_timers_global_destroy(); grpc_tracer_shutdown(); - grpc_resolver_registry_shutdown(); - grpc_lb_policy_registry_shutdown(); - for (i = 0; i < g_number_of_plugins; i++) { + for (i = g_number_of_plugins; i >= 0; i--) { if (g_all_of_the_plugins[i].destroy != NULL) { g_all_of_the_plugins[i].destroy(); } } - grpc_channel_init_shutdown(); grpc_mdctx_global_shutdown(); } gpr_mu_unlock(&g_init_mu); |