|
|
|
@ -86,37 +86,36 @@ grpc_channel *grpc_channel_create(grpc_exec_ctx *exec_ctx, const char *target, |
|
|
|
|
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_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; |
|
|
|
|
} |
|
|
|
|
args = grpc_channel_args_copy( |
|
|
|
|
grpc_channel_args *args = grpc_channel_args_copy( |
|
|
|
|
grpc_channel_stack_builder_get_channel_arguments(builder)); |
|
|
|
|
grpc_channel *channel; |
|
|
|
|
grpc_error *error = grpc_channel_stack_builder_finish( |
|
|
|
|
exec_ctx, builder, sizeof(grpc_channel), 1, destroy_channel, NULL, |
|
|
|
|
(void **)&channel); |
|
|
|
|
if (error != GRPC_ERROR_NONE) { |
|
|
|
|
grpc_channel_stack_destroy(exec_ctx, (grpc_channel_stack *)channel); |
|
|
|
|
gpr_free(channel); |
|
|
|
|
return NULL; |
|
|
|
|
const char* msg = grpc_error_string(error); |
|
|
|
|
gpr_log(GPR_ERROR, "channel stack builder failed: %s", msg); |
|
|
|
|
grpc_error_free_string(msg); |
|
|
|
|
GRPC_ERROR_UNREF(error); |
|
|
|
|
goto done; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
memset(channel, 0, sizeof(*channel)); |
|
|
|
|
channel->target = gpr_strdup(target); |
|
|
|
|
channel->is_client = is_client; |
|
|
|
|
channel->is_client = grpc_channel_stack_type_is_client(channel_stack_type); |
|
|
|
|
gpr_mu_init(&channel->registered_call_mu); |
|
|
|
|
channel->registered_calls = NULL; |
|
|
|
|
|
|
|
|
|
grpc_compression_options_init(&channel->compression_options); |
|
|
|
|
if (args) { |
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < args->num_args; i++) { |
|
|
|
|
if (0 == strcmp(args->args[i].key, GRPC_ARG_DEFAULT_AUTHORITY)) { |
|
|
|
|
if (args->args[i].type != GRPC_ARG_STRING) { |
|
|
|
@ -169,9 +168,9 @@ grpc_channel *grpc_channel_create(grpc_exec_ctx *exec_ctx, const char *target, |
|
|
|
|
0x1; /* always support no compression */ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
grpc_channel_args_destroy(args); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
done: |
|
|
|
|
grpc_channel_args_destroy(args); |
|
|
|
|
return channel; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|