diff options
author | Craig Tiller <ctiller@google.com> | 2016-04-06 08:07:11 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2016-04-06 08:07:11 -0700 |
commit | 839bebed9e5e98121369fdb0848d7cafdaca46c6 (patch) | |
tree | ebbb8a53aa6f0fba3914c079d301bcd703d595ad /src/core/lib | |
parent | 8166732d1069e0296baaf211eb219922a22eb6f5 (diff) |
Use channel args from builder
Diffstat (limited to 'src/core/lib')
-rw-r--r-- | src/core/lib/surface/channel.c | 21 | ||||
-rw-r--r-- | src/core/lib/surface/channel_init.c | 17 | ||||
-rw-r--r-- | src/core/lib/surface/channel_init.h | 8 |
3 files changed, 25 insertions, 21 deletions
diff --git a/src/core/lib/surface/channel.c b/src/core/lib/surface/channel.c index b805091b47..b6b760b5d8 100644 --- a/src/core/lib/surface/channel.c +++ b/src/core/lib/surface/channel.c @@ -83,14 +83,26 @@ struct grpc_channel { static void destroy_channel(grpc_exec_ctx *exec_ctx, void *arg, bool success); grpc_channel *grpc_channel_create(grpc_exec_ctx *exec_ctx, const char *target, - const grpc_channel_args *args, + const grpc_channel_args *input_args, grpc_channel_stack_type channel_stack_type, grpc_transport *optional_transport) { bool is_client = grpc_channel_stack_type_is_client(channel_stack_type); - grpc_channel *channel = grpc_channel_init_create_stack( - exec_ctx, channel_stack_type, sizeof(grpc_channel), args, 1, - destroy_channel, NULL, optional_transport, target); + grpc_channel_stack_builder *builder = grpc_channel_stack_builder_create(); + grpc_channel_stack_builder_set_channel_arguments(builder, input_args); + grpc_channel_stack_builder_set_target(builder, target); + grpc_channel_stack_builder_set_transport(builder, optional_transport); + grpc_channel *channel; + grpc_channel_args *args; + if (!grpc_channel_init_create_stack(exec_ctx, builder, channel_stack_type)) { + grpc_channel_stack_builder_destroy(builder); + return NULL; + } else { + args = grpc_channel_args_copy( + grpc_channel_stack_builder_get_channel_arguments(builder)); + channel = grpc_channel_stack_builder_finish( + exec_ctx, builder, sizeof(grpc_channel), 1, destroy_channel, NULL); + } memset(channel, 0, sizeof(*channel)); channel->target = gpr_strdup(target); @@ -141,6 +153,7 @@ grpc_channel *grpc_channel_create(grpc_exec_ctx *exec_ctx, const char *target, } } } + grpc_channel_args_destroy(args); } return channel; diff --git a/src/core/lib/surface/channel_init.c b/src/core/lib/surface/channel_init.c index d0dd722ae0..0627b34479 100644 --- a/src/core/lib/surface/channel_init.c +++ b/src/core/lib/surface/channel_init.c @@ -122,26 +122,19 @@ static const char *name_for_type(grpc_channel_stack_type type) { GPR_UNREACHABLE_CODE(return "UNKNOWN"); } -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, const char *target) { +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 *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]; if (!slot->fn(builder, slot->arg)) { - grpc_channel_stack_builder_destroy(builder); - return NULL; + return false; } } - return grpc_channel_stack_builder_finish(exec_ctx, builder, prefix_bytes, - initial_refs, destroy, destroy_arg); + return true; } diff --git a/src/core/lib/surface/channel_init.h b/src/core/lib/surface/channel_init.h index cb71ae3b7c..3a18a61ddb 100644 --- a/src/core/lib/surface/channel_init.h +++ b/src/core/lib/surface/channel_init.h @@ -80,10 +80,8 @@ void grpc_channel_init_shutdown(void); /// \a optional_transport is either NULL or a constructed transport object /// Returns a pointer to the base of the memory allocated (the actual channel /// stack object will be prefix_bytes past that pointer) -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, - const char *optional_target); +bool grpc_channel_init_create_stack(grpc_exec_ctx *exec_ctx, + grpc_channel_stack_builder *builder, + grpc_channel_stack_type type); #endif /* GRPC_CORE_LIB_SURFACE_CHANNEL_INIT_H */ |