aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Bogdan Drutu <bdrutu@google.com>2016-01-26 19:16:04 -0800
committerGravatar Bogdan Drutu <bdrutu@google.com>2016-01-26 19:16:04 -0800
commit441499ac5e5798447e8fdf7a028f84910e9b8c27 (patch)
tree1a5ea58c56b81e663dfea1e96bde562f23211e1b /src
parent33473134d91c445f9107ee90bd61a594190ad897 (diff)
Fix the initialization by modifying the grpc_channel_args_is_census_enabled to by default return census_enabled() instead of always disable
Diffstat (limited to 'src')
-rw-r--r--src/core/channel/channel_args.c7
-rw-r--r--src/core/surface/channel_create.c5
-rw-r--r--src/core/surface/secure_channel_create.c5
-rw-r--r--src/core/surface/server.c10
4 files changed, 12 insertions, 15 deletions
diff --git a/src/core/channel/channel_args.c b/src/core/channel/channel_args.c
index 487db1119a..0427ce0b8d 100644
--- a/src/core/channel/channel_args.c
+++ b/src/core/channel/channel_args.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -35,6 +35,7 @@
#include "src/core/channel/channel_args.h"
#include "src/core/support/string.h"
+#include <grpc/census.h>
#include <grpc/support/alloc.h>
#include <grpc/support/string_util.h>
#include <grpc/support/useful.h>
@@ -119,10 +120,10 @@ int grpc_channel_args_is_census_enabled(const grpc_channel_args *a) {
if (a == NULL) return 0;
for (i = 0; i < a->num_args; i++) {
if (0 == strcmp(a->args[i].key, GRPC_ARG_ENABLE_CENSUS)) {
- return a->args[i].value.integer != 0;
+ return a->args[i].value.integer != 0 && census_enabled();
}
}
- return 0;
+ return census_enabled();
}
grpc_compression_algorithm grpc_channel_args_get_compression_algorithm(
diff --git a/src/core/surface/channel_create.c b/src/core/surface/channel_create.c
index b21f89d00c..49083f0870 100644
--- a/src/core/surface/channel_create.c
+++ b/src/core/surface/channel_create.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015-2016, Google Inc.
+ * Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -36,7 +36,6 @@
#include <stdlib.h>
#include <string.h>
-#include <grpc/census.h>
#include <grpc/support/alloc.h>
#include <grpc/support/slice.h>
#include <grpc/support/slice_buffer.h>
@@ -201,7 +200,7 @@ grpc_channel *grpc_insecure_channel_create(const char *target,
"grpc_insecure_channel_create(target=%p, args=%p, reserved=%p)", 3,
(target, args, reserved));
GPR_ASSERT(!reserved);
- if (grpc_channel_args_is_census_enabled(args) || census_enabled()) {
+ if (grpc_channel_args_is_census_enabled(args)) {
filters[n++] = &grpc_client_census_filter;
}
filters[n++] = &grpc_compress_filter;
diff --git a/src/core/surface/secure_channel_create.c b/src/core/surface/secure_channel_create.c
index 506f5bbe65..552a570713 100644
--- a/src/core/surface/secure_channel_create.c
+++ b/src/core/surface/secure_channel_create.c
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015-2016, Google Inc.
+ * Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -36,7 +36,6 @@
#include <stdlib.h>
#include <string.h>
-#include <grpc/census.h>
#include <grpc/support/alloc.h>
#include <grpc/support/slice.h>
#include <grpc/support/slice_buffer.h>
@@ -296,7 +295,7 @@ grpc_channel *grpc_secure_channel_create(grpc_channel_credentials *creds,
args_copy = grpc_channel_args_copy_and_add(
new_args_from_connector != NULL ? new_args_from_connector : args,
&connector_arg, 1);
- if (grpc_channel_args_is_census_enabled(args) || census_enabled()) {
+ if (grpc_channel_args_is_census_enabled(args)) {
filters[n++] = &grpc_client_census_filter;
}
filters[n++] = &grpc_compress_filter;
diff --git a/src/core/surface/server.c b/src/core/surface/server.c
index 0802965d38..0928f1e045 100644
--- a/src/core/surface/server.c
+++ b/src/core/surface/server.c
@@ -37,7 +37,6 @@
#include <stdlib.h>
#include <string.h>
-#include <grpc/census.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
@@ -780,8 +779,7 @@ grpc_server *grpc_server_create_from_filters(
const grpc_channel_filter **filters, size_t filter_count,
const grpc_channel_args *args) {
size_t i;
- int enable_census =
- grpc_channel_args_is_census_enabled(args) || census_enabled();
+ int census_enabled = grpc_channel_args_is_census_enabled(args);
grpc_server *server = gpr_malloc(sizeof(grpc_server));
@@ -815,15 +813,15 @@ grpc_server *grpc_server_create_from_filters(
grpc_server_census_filter (optional) - for stats collection and tracing
{passed in filter stack}
grpc_connected_channel_filter - for interfacing with transports */
- server->channel_filter_count = filter_count + 1u + (enable_census ? 1u : 0u);
+ server->channel_filter_count = filter_count + 1u + (census_enabled ? 1u : 0u);
server->channel_filters =
gpr_malloc(server->channel_filter_count * sizeof(grpc_channel_filter *));
server->channel_filters[0] = &server_surface_filter;
- if (enable_census) {
+ if (census_enabled) {
server->channel_filters[1] = &grpc_server_census_filter;
}
for (i = 0; i < filter_count; i++) {
- server->channel_filters[i + 1u + (enable_census ? 1u : 0u)] = filters[i];
+ server->channel_filters[i + 1u + (census_enabled ? 1u : 0u)] = filters[i];
}
server->channel_args = grpc_channel_args_copy(args);