aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-03-16 13:29:05 -0700
committerGravatar Craig Tiller <ctiller@google.com>2017-03-16 13:29:05 -0700
commitb7f35a658b00ae57d0341261d0944c26066dda04 (patch)
tree8571e6073ad34f835b3b312a77e006e76cf632d1 /src
parentc290bc73f9350e2524f4ffbb0e133953051b07b6 (diff)
Expand benchmark coverage to isolated grpc_call scenarios against a dummy filter stack
Diffstat (limited to 'src')
-rw-r--r--src/core/lib/surface/channel.c37
-rw-r--r--src/core/lib/surface/channel.h5
2 files changed, 28 insertions, 14 deletions
diff --git a/src/core/lib/surface/channel.c b/src/core/lib/surface/channel.c
index d6acd392c1..a00572c007 100644
--- a/src/core/lib/surface/channel.c
+++ b/src/core/lib/surface/channel.c
@@ -83,19 +83,10 @@ struct grpc_channel {
static void destroy_channel(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error);
-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) {
- grpc_channel_stack_builder *builder = grpc_channel_stack_builder_create();
- grpc_channel_stack_builder_set_channel_arguments(exec_ctx, builder,
- input_args);
- grpc_channel_stack_builder_set_target(builder, target);
- grpc_channel_stack_builder_set_transport(builder, optional_transport);
- if (!grpc_channel_init_create_stack(exec_ctx, builder, channel_stack_type)) {
- grpc_channel_stack_builder_destroy(exec_ctx, builder);
- return NULL;
- }
+grpc_channel *grpc_channel_create_with_builder(
+ grpc_exec_ctx *exec_ctx, grpc_channel_stack_builder *builder,
+ grpc_channel_stack_type channel_stack_type) {
+ char *target = gpr_strdup(grpc_channel_stack_builder_get_target(builder));
grpc_channel_args *args = grpc_channel_args_copy(
grpc_channel_stack_builder_get_channel_arguments(builder));
grpc_channel *channel;
@@ -106,11 +97,12 @@ grpc_channel *grpc_channel_create(grpc_exec_ctx *exec_ctx, const char *target,
gpr_log(GPR_ERROR, "channel stack builder failed: %s",
grpc_error_string(error));
GRPC_ERROR_UNREF(error);
+ gpr_free(target);
goto done;
}
memset(channel, 0, sizeof(*channel));
- channel->target = gpr_strdup(target);
+ channel->target = target;
channel->is_client = grpc_channel_stack_type_is_client(channel_stack_type);
gpr_mu_init(&channel->registered_call_mu);
channel->registered_calls = NULL;
@@ -177,6 +169,23 @@ done:
return channel;
}
+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) {
+ grpc_channel_stack_builder *builder = grpc_channel_stack_builder_create();
+ grpc_channel_stack_builder_set_channel_arguments(exec_ctx, builder,
+ input_args);
+ grpc_channel_stack_builder_set_target(builder, target);
+ grpc_channel_stack_builder_set_transport(builder, optional_transport);
+ if (!grpc_channel_init_create_stack(exec_ctx, builder, channel_stack_type)) {
+ grpc_channel_stack_builder_destroy(exec_ctx, builder);
+ return NULL;
+ }
+ return grpc_channel_create_with_builder(exec_ctx, builder,
+ channel_stack_type);
+}
+
char *grpc_channel_get_target(grpc_channel *channel) {
GRPC_API_TRACE("grpc_channel_get_target(channel=%p)", 1, (channel));
return gpr_strdup(channel->target);
diff --git a/src/core/lib/surface/channel.h b/src/core/lib/surface/channel.h
index 3a441d7add..609c9357e0 100644
--- a/src/core/lib/surface/channel.h
+++ b/src/core/lib/surface/channel.h
@@ -35,6 +35,7 @@
#define GRPC_CORE_LIB_SURFACE_CHANNEL_H
#include "src/core/lib/channel/channel_stack.h"
+#include "src/core/lib/channel/channel_stack_builder.h"
#include "src/core/lib/surface/channel_stack_type.h"
grpc_channel *grpc_channel_create(grpc_exec_ctx *exec_ctx, const char *target,
@@ -42,6 +43,10 @@ grpc_channel *grpc_channel_create(grpc_exec_ctx *exec_ctx, const char *target,
grpc_channel_stack_type channel_stack_type,
grpc_transport *optional_transport);
+grpc_channel *grpc_channel_create_with_builder(
+ grpc_exec_ctx *exec_ctx, grpc_channel_stack_builder *builder,
+ grpc_channel_stack_type channel_stack_type);
+
/** Create a call given a grpc_channel, in order to call \a method.
Progress is tied to activity on \a pollset_set. The returned call object is
meant to be used with \a grpc_call_start_batch_and_execute, which relies on