aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/channel
diff options
context:
space:
mode:
authorGravatar David Garcia Quintas <dgq@google.com>2015-06-30 23:29:03 -0700
committerGravatar David Garcia Quintas <dgq@google.com>2015-06-30 23:29:03 -0700
commitd7d9ce27c523798384051246e18e3f00b29dd8c9 (patch)
tree3bea869080c65f73f1c92ded39c6b7e1434394fe /src/core/channel
parentfc0fa3381c7b7088936ce6f41a8f8c41ef3c38ac (diff)
WIP in *_end2end_test.cc. Tests pass. Fixed leaks and introduced concept of compression request thru MD
Diffstat (limited to 'src/core/channel')
-rw-r--r--src/core/channel/compress_filter.c19
-rw-r--r--src/core/channel/compress_filter.h2
2 files changed, 14 insertions, 7 deletions
diff --git a/src/core/channel/compress_filter.c b/src/core/channel/compress_filter.c
index f5fe87d6b8..6100a90668 100644
--- a/src/core/channel/compress_filter.c
+++ b/src/core/channel/compress_filter.c
@@ -50,7 +50,8 @@ typedef struct call_data {
} call_data;
typedef struct channel_data {
- grpc_mdstr *mdstr_compression_algorithm_key;
+ grpc_mdstr *mdstr_request_compression_algorithm_key;
+ grpc_mdstr *mdstr_outgoing_compression_algorithm_key;
grpc_mdelem *mdelem_compression_algorithms[GRPC_COMPRESS_ALGORITHMS_COUNT];
grpc_compression_algorithm default_compression_algorithm;
} channel_data;
@@ -72,14 +73,14 @@ static int compress_send_sb(grpc_compression_algorithm algorithm,
}
/** For each \a md element from the incoming metadata, filter out the entry for
- * "grpc-compression-algorithm", using its value to populate the call data's
+ * "grpc-encoding", using its value to populate the call data's
* compression_algorithm field. */
static grpc_mdelem* compression_md_filter(void *user_data, grpc_mdelem *md) {
grpc_call_element *elem = user_data;
call_data *calld = elem->call_data;
channel_data *channeld = elem->channel_data;
- if (md->key == channeld->mdstr_compression_algorithm_key) {
+ if (md->key == channeld->mdstr_request_compression_algorithm_key) {
const char *md_c_str = grpc_mdstr_as_c_string(md->value);
if (!grpc_compression_algorithm_parse(md_c_str,
&calld->compression_algorithm)) {
@@ -184,7 +185,6 @@ static void process_send_ops(grpc_call_element *elem,
break;
case GRPC_OP_SLICE:
if (did_compress) {
- gpr_slice_unref(sop->data.slice);
if (j < calld->slices.count) {
sop->data.slice = gpr_slice_ref(calld->slices.slices[j++]);
}
@@ -259,7 +259,10 @@ static void init_channel_elem(grpc_channel_element *elem,
channeld->default_compression_algorithm =
grpc_compression_algorithm_for_level(clevel);
- channeld->mdstr_compression_algorithm_key =
+ channeld->mdstr_request_compression_algorithm_key =
+ grpc_mdstr_from_string(mdctx, GRPC_COMPRESS_REQUEST_ALGORITHM_KEY);
+
+ channeld->mdstr_outgoing_compression_algorithm_key =
grpc_mdstr_from_string(mdctx, "grpc-encoding");
for (algo_idx = 0; algo_idx < GRPC_COMPRESS_ALGORITHMS_COUNT; ++algo_idx) {
@@ -267,7 +270,8 @@ static void init_channel_elem(grpc_channel_element *elem,
GPR_ASSERT(grpc_compression_algorithm_name(algo_idx, &algorith_name) != 0);
channeld->mdelem_compression_algorithms[algo_idx] =
grpc_mdelem_from_metadata_strings(
- mdctx, grpc_mdstr_ref(channeld->mdstr_compression_algorithm_key),
+ mdctx,
+ grpc_mdstr_ref(channeld->mdstr_outgoing_compression_algorithm_key),
grpc_mdstr_from_string(mdctx, algorith_name));
}
@@ -283,7 +287,8 @@ static void destroy_channel_elem(grpc_channel_element *elem) {
channel_data *channeld = elem->channel_data;
grpc_compression_algorithm algo_idx;
- grpc_mdstr_unref(channeld->mdstr_compression_algorithm_key);
+ grpc_mdstr_unref(channeld->mdstr_request_compression_algorithm_key);
+ grpc_mdstr_unref(channeld->mdstr_outgoing_compression_algorithm_key);
for (algo_idx = 0; algo_idx < GRPC_COMPRESS_ALGORITHMS_COUNT;
++algo_idx) {
grpc_mdelem_unref(channeld->mdelem_compression_algorithms[algo_idx]);
diff --git a/src/core/channel/compress_filter.h b/src/core/channel/compress_filter.h
index ea667969e1..3a196eb7bf 100644
--- a/src/core/channel/compress_filter.h
+++ b/src/core/channel/compress_filter.h
@@ -36,6 +36,8 @@
#include "src/core/channel/channel_stack.h"
+#define GRPC_COMPRESS_REQUEST_ALGORITHM_KEY "internal:grpc-encoding-request"
+
/** Message-level compression filter.
*
* See <grpc/compression.h> for the available compression levels.