aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/channel
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/channel')
-rw-r--r--src/core/channel/channel_stack.c2
-rw-r--r--src/core/channel/channel_stack.h2
-rw-r--r--src/core/channel/client_channel.c3
-rw-r--r--src/core/channel/client_uchannel.c10
-rw-r--r--src/core/channel/client_uchannel.h3
-rw-r--r--src/core/channel/compress_filter.c11
-rw-r--r--src/core/channel/http_client_filter.c66
-rw-r--r--src/core/channel/http_server_filter.c4
-rw-r--r--src/core/channel/subchannel_call_holder.c15
-rw-r--r--src/core/channel/subchannel_call_holder.h4
10 files changed, 77 insertions, 43 deletions
diff --git a/src/core/channel/channel_stack.c b/src/core/channel/channel_stack.c
index c6a0ada0f1..7f7fbf420f 100644
--- a/src/core/channel/channel_stack.c
+++ b/src/core/channel/channel_stack.c
@@ -157,7 +157,6 @@ void grpc_call_stack_init(grpc_exec_ctx *exec_ctx,
grpc_iomgr_cb_func destroy, void *destroy_arg,
grpc_call_context_element *context,
const void *transport_server_data,
- grpc_mdctx *metadata_context,
grpc_call_stack *call_stack) {
grpc_channel_element *channel_elems = CHANNEL_ELEMS_FROM_STACK(channel_stack);
grpc_call_element_args args;
@@ -178,7 +177,6 @@ void grpc_call_stack_init(grpc_exec_ctx *exec_ctx,
args.refcount = &call_stack->refcount;
args.server_transport_data = transport_server_data;
args.context = context;
- args.metadata_context = metadata_context;
call_elems[i].filter = channel_elems[i].filter;
call_elems[i].channel_data = channel_elems[i].channel_data;
call_elems[i].call_data = user_data;
diff --git a/src/core/channel/channel_stack.h b/src/core/channel/channel_stack.h
index d8940675ac..1db12ead7e 100644
--- a/src/core/channel/channel_stack.h
+++ b/src/core/channel/channel_stack.h
@@ -60,7 +60,6 @@ typedef struct {
typedef struct {
grpc_stream_refcount *refcount;
- grpc_mdctx *metadata_context;
const void *server_transport_data;
grpc_call_context_element *context;
} grpc_call_element_args;
@@ -193,7 +192,6 @@ void grpc_call_stack_init(grpc_exec_ctx *exec_ctx,
grpc_iomgr_cb_func destroy, void *destroy_arg,
grpc_call_context_element *context,
const void *transport_server_data,
- grpc_mdctx *metadata_context,
grpc_call_stack *call_stack);
/* Set a pollset for a call stack: must occur before the first op is started */
void grpc_call_stack_set_pollset(grpc_exec_ctx *exec_ctx,
diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c
index 1abcd3b9cc..020138bf15 100644
--- a/src/core/channel/client_channel.c
+++ b/src/core/channel/client_channel.c
@@ -364,8 +364,7 @@ static int cc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *elemp,
/* Constructor for call_data */
static void init_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
grpc_call_element_args *args) {
- grpc_subchannel_call_holder_init(elem->call_data, cc_pick_subchannel, elem,
- args->metadata_context);
+ grpc_subchannel_call_holder_init(elem->call_data, cc_pick_subchannel, elem);
}
/* Destructor for call_data */
diff --git a/src/core/channel/client_uchannel.c b/src/core/channel/client_uchannel.c
index 3276635625..456ffb7371 100644
--- a/src/core/channel/client_uchannel.c
+++ b/src/core/channel/client_uchannel.c
@@ -140,7 +140,7 @@ static int cuc_pick_subchannel(grpc_exec_ctx *exec_ctx, void *arg,
static void cuc_init_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
grpc_call_element_args *args) {
grpc_subchannel_call_holder_init(elem->call_data, cuc_pick_subchannel,
- elem->channel_data, args->metadata_context);
+ elem->channel_data);
}
/* Destructor for call_data */
@@ -244,8 +244,7 @@ void grpc_client_uchannel_del_interested_party(grpc_exec_ctx *exec_ctx,
}
grpc_channel *grpc_client_uchannel_create(grpc_subchannel *subchannel,
- grpc_channel_args *args,
- grpc_mdctx *mdctx) {
+ grpc_channel_args *args) {
grpc_channel *channel = NULL;
#define MAX_FILTERS 3
const grpc_channel_filter *filters[MAX_FILTERS];
@@ -254,7 +253,6 @@ grpc_channel *grpc_client_uchannel_create(grpc_subchannel *subchannel,
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
size_t n = 0;
- grpc_mdctx_ref(mdctx);
if (grpc_channel_args_is_census_enabled(args)) {
filters[n++] = &grpc_client_census_filter;
}
@@ -262,8 +260,8 @@ grpc_channel *grpc_client_uchannel_create(grpc_subchannel *subchannel,
filters[n++] = &grpc_client_uchannel_filter;
GPR_ASSERT(n <= MAX_FILTERS);
- channel = grpc_channel_create_from_filters(&exec_ctx, target, filters, n,
- args, mdctx, 1);
+ channel =
+ grpc_channel_create_from_filters(&exec_ctx, target, filters, n, args, 1);
gpr_free(target);
return channel;
diff --git a/src/core/channel/client_uchannel.h b/src/core/channel/client_uchannel.h
index 54fbea964c..dfe6695ae3 100644
--- a/src/core/channel/client_uchannel.h
+++ b/src/core/channel/client_uchannel.h
@@ -62,8 +62,7 @@ void grpc_client_uchannel_del_interested_party(grpc_exec_ctx *exec_ctx,
grpc_pollset *pollset);
grpc_channel *grpc_client_uchannel_create(grpc_subchannel *subchannel,
- grpc_channel_args *args,
- grpc_mdctx *mdctx);
+ grpc_channel_args *args);
void grpc_client_uchannel_set_subchannel(grpc_channel *uchannel,
grpc_subchannel *subchannel);
diff --git a/src/core/channel/compress_filter.c b/src/core/channel/compress_filter.c
index 25d6e51281..fc8b425e47 100644
--- a/src/core/channel/compress_filter.c
+++ b/src/core/channel/compress_filter.c
@@ -66,8 +66,6 @@ typedef struct call_data {
grpc_closure *post_send;
grpc_closure send_done;
grpc_closure got_slice;
-
- grpc_mdctx *mdctx;
} call_data;
typedef struct channel_data {
@@ -146,10 +144,10 @@ static void process_send_initial_metadata(
grpc_compression_encoding_mdelem(calld->compression_algorithm));
/* convey supported compression algorithms */
- grpc_metadata_batch_add_tail(
- initial_metadata, &calld->accept_encoding_storage,
- GRPC_MDELEM_REF(grpc_accept_encoding_mdelem_from_compression_algorithms(
- calld->mdctx, channeld->supported_compression_algorithms)));
+ grpc_metadata_batch_add_tail(initial_metadata,
+ &calld->accept_encoding_storage,
+ GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS(
+ channeld->supported_compression_algorithms));
}
static void continue_send_message(grpc_exec_ctx *exec_ctx,
@@ -243,7 +241,6 @@ static void init_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
/* initialize members */
gpr_slice_buffer_init(&calld->slices);
calld->has_compression_algorithm = 0;
- calld->mdctx = args->metadata_context;
grpc_closure_init(&calld->got_slice, got_slice, elem);
grpc_closure_init(&calld->send_done, send_done, elem);
}
diff --git a/src/core/channel/http_client_filter.c b/src/core/channel/http_client_filter.c
index ec7791656f..b9a30cdaf2 100644
--- a/src/core/channel/http_client_filter.c
+++ b/src/core/channel/http_client_filter.c
@@ -55,11 +55,12 @@ typedef struct call_data {
up-call on transport_op, and remember to call our on_done_recv member
after handling it. */
grpc_closure hc_on_recv;
-
- grpc_mdctx *mdctx;
} call_data;
-typedef struct channel_data { grpc_mdelem *static_scheme; } channel_data;
+typedef struct channel_data {
+ grpc_mdelem *static_scheme;
+ grpc_mdelem *user_agent;
+} channel_data;
typedef struct {
grpc_call_element *elem;
@@ -119,10 +120,8 @@ static void hc_mutate_op(grpc_call_element *elem,
grpc_metadata_batch_add_tail(
op->send_initial_metadata, &calld->content_type,
GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC);
- grpc_metadata_batch_add_tail(
- op->send_initial_metadata, &calld->user_agent,
- GRPC_MDELEM_REF(grpc_mdelem_from_cache(calld->mdctx,
- GRPC_MDELEM_CACHED_USER_AGENT)));
+ grpc_metadata_batch_add_tail(op->send_initial_metadata, &calld->user_agent,
+ GRPC_MDELEM_REF(channeld->user_agent));
}
if (op->recv_initial_metadata != NULL) {
@@ -148,7 +147,6 @@ static void init_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
grpc_call_element_args *args) {
call_data *calld = elem->call_data;
calld->on_done_recv = NULL;
- calld->mdctx = args->metadata_context;
grpc_closure_init(&calld->hc_on_recv, hc_on_recv, elem);
}
@@ -177,6 +175,54 @@ static grpc_mdelem *scheme_from_args(const grpc_channel_args *args) {
return GRPC_MDELEM_SCHEME_HTTP;
}
+static grpc_mdstr *user_agent_from_args(const grpc_channel_args *args) {
+ gpr_strvec v;
+ size_t i;
+ int is_first = 1;
+ char *tmp;
+ grpc_mdstr *result;
+
+ gpr_strvec_init(&v);
+
+ for (i = 0; args && i < args->num_args; i++) {
+ if (0 == strcmp(args->args[i].key, GRPC_ARG_PRIMARY_USER_AGENT_STRING)) {
+ if (args->args[i].type != GRPC_ARG_STRING) {
+ gpr_log(GPR_ERROR, "Channel argument '%s' should be a string",
+ GRPC_ARG_PRIMARY_USER_AGENT_STRING);
+ } else {
+ if (!is_first) gpr_strvec_add(&v, gpr_strdup(" "));
+ is_first = 0;
+ gpr_strvec_add(&v, gpr_strdup(args->args[i].value.string));
+ }
+ }
+ }
+
+ gpr_asprintf(&tmp, "%sgrpc-c/%s (%s)", is_first ? "" : " ",
+ grpc_version_string(), GPR_PLATFORM_STRING);
+ is_first = 0;
+ gpr_strvec_add(&v, tmp);
+
+ for (i = 0; args && i < args->num_args; i++) {
+ if (0 == strcmp(args->args[i].key, GRPC_ARG_SECONDARY_USER_AGENT_STRING)) {
+ if (args->args[i].type != GRPC_ARG_STRING) {
+ gpr_log(GPR_ERROR, "Channel argument '%s' should be a string",
+ GRPC_ARG_SECONDARY_USER_AGENT_STRING);
+ } else {
+ if (!is_first) gpr_strvec_add(&v, gpr_strdup(" "));
+ is_first = 0;
+ gpr_strvec_add(&v, gpr_strdup(args->args[i].value.string));
+ }
+ }
+ }
+
+ tmp = gpr_strvec_flatten(&v, NULL);
+ gpr_strvec_destroy(&v);
+ result = grpc_mdstr_from_string(tmp);
+ gpr_free(tmp);
+
+ return result;
+}
+
/* Constructor for channel_data */
static void init_channel_elem(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem,
@@ -184,11 +230,15 @@ static void init_channel_elem(grpc_exec_ctx *exec_ctx,
channel_data *chand = elem->channel_data;
GPR_ASSERT(!args->is_last);
chand->static_scheme = scheme_from_args(args->channel_args);
+ chand->user_agent = grpc_mdelem_from_metadata_strings(
+ GRPC_MDSTR_USER_AGENT, user_agent_from_args(args->channel_args));
}
/* Destructor for channel data */
static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem) {
+ channel_data *chand = elem->channel_data;
+ GRPC_MDELEM_UNREF(chand->user_agent);
}
const grpc_channel_filter grpc_http_client_filter = {
diff --git a/src/core/channel/http_server_filter.c b/src/core/channel/http_server_filter.c
index c9db9470e0..c1645c2ba0 100644
--- a/src/core/channel/http_server_filter.c
+++ b/src/core/channel/http_server_filter.c
@@ -56,7 +56,6 @@ typedef struct call_data {
up-call on transport_op, and remember to call our on_done_recv member
after handling it. */
grpc_closure hs_on_recv;
- grpc_mdctx *mdctx;
} call_data;
typedef struct channel_data { gpr_uint8 unused; } channel_data;
@@ -124,7 +123,7 @@ static grpc_mdelem *server_filter(void *user_data, grpc_mdelem *md) {
/* translate host to :authority since :authority may be
omitted */
grpc_mdelem *authority = grpc_mdelem_from_metadata_strings(
- calld->mdctx, GRPC_MDSTR_AUTHORITY, GRPC_MDSTR_REF(md->value));
+ GRPC_MDSTR_AUTHORITY, GRPC_MDSTR_REF(md->value));
GRPC_MDELEM_UNREF(md);
calld->seen_authority = 1;
return authority;
@@ -211,7 +210,6 @@ static void init_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
/* initialize members */
memset(calld, 0, sizeof(*calld));
grpc_closure_init(&calld->hs_on_recv, hs_on_recv, elem);
- calld->mdctx = args->metadata_context;
}
/* Destructor for call_data */
diff --git a/src/core/channel/subchannel_call_holder.c b/src/core/channel/subchannel_call_holder.c
index c5340e0eaf..7251714519 100644
--- a/src/core/channel/subchannel_call_holder.c
+++ b/src/core/channel/subchannel_call_holder.c
@@ -58,7 +58,7 @@ static void retry_waiting_locked(grpc_exec_ctx *exec_ctx,
void grpc_subchannel_call_holder_init(
grpc_subchannel_call_holder *holder,
grpc_subchannel_call_holder_pick_subchannel pick_subchannel,
- void *pick_subchannel_arg, grpc_mdctx *mdctx) {
+ void *pick_subchannel_arg) {
gpr_atm_rel_store(&holder->subchannel_call, 0);
holder->pick_subchannel = pick_subchannel;
holder->pick_subchannel_arg = pick_subchannel_arg;
@@ -68,7 +68,6 @@ void grpc_subchannel_call_holder_init(
holder->waiting_ops_count = 0;
holder->waiting_ops_capacity = 0;
holder->creation_phase = GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING;
- holder->mdctx = mdctx;
}
void grpc_subchannel_call_holder_destroy(grpc_exec_ctx *exec_ctx,
@@ -157,9 +156,9 @@ retry:
holder->subchannel != NULL) {
holder->creation_phase = GRPC_SUBCHANNEL_CALL_HOLDER_CREATING_CALL;
grpc_closure_init(&holder->next_step, call_ready, holder);
- if (grpc_subchannel_create_call(
- exec_ctx, holder->subchannel, holder->pollset, holder->mdctx,
- &holder->subchannel_call, &holder->next_step)) {
+ if (grpc_subchannel_create_call(exec_ctx, holder->subchannel,
+ holder->pollset, &holder->subchannel_call,
+ &holder->next_step)) {
/* got one immediately - continue the op (and any waiting ops) */
holder->creation_phase = GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING;
retry_waiting_locked(exec_ctx, holder);
@@ -185,9 +184,9 @@ static void subchannel_ready(grpc_exec_ctx *exec_ctx, void *arg, int success) {
fail_locked(exec_ctx, holder);
} else {
grpc_closure_init(&holder->next_step, call_ready, holder);
- if (grpc_subchannel_create_call(
- exec_ctx, holder->subchannel, holder->pollset, holder->mdctx,
- &holder->subchannel_call, &holder->next_step)) {
+ if (grpc_subchannel_create_call(exec_ctx, holder->subchannel,
+ holder->pollset, &holder->subchannel_call,
+ &holder->next_step)) {
holder->creation_phase = GRPC_SUBCHANNEL_CALL_HOLDER_NOT_CREATING;
/* got one immediately - continue the op (and any waiting ops) */
retry_waiting_locked(exec_ctx, holder);
diff --git a/src/core/channel/subchannel_call_holder.h b/src/core/channel/subchannel_call_holder.h
index a770be257c..bda051c566 100644
--- a/src/core/channel/subchannel_call_holder.h
+++ b/src/core/channel/subchannel_call_holder.h
@@ -68,8 +68,6 @@ typedef struct grpc_subchannel_call_holder {
grpc_subchannel_call_holder_pick_subchannel pick_subchannel;
void *pick_subchannel_arg;
- grpc_mdctx *mdctx;
-
gpr_mu mu;
grpc_subchannel_call_holder_creation_phase creation_phase;
@@ -86,7 +84,7 @@ typedef struct grpc_subchannel_call_holder {
void grpc_subchannel_call_holder_init(
grpc_subchannel_call_holder *holder,
grpc_subchannel_call_holder_pick_subchannel pick_subchannel,
- void *pick_subchannel_arg, grpc_mdctx *mdctx);
+ void *pick_subchannel_arg);
void grpc_subchannel_call_holder_destroy(grpc_exec_ctx *exec_ctx,
grpc_subchannel_call_holder *holder);