Skip to content

Commit

Permalink
Merge pull request grpc#4868 from bogdandrutu/bug
Browse files Browse the repository at this point in the history
Fix the census initialization on the server. Remove duplicate initialization logic and also enable census per channel if census is initialized.
  • Loading branch information
a-veitch committed Jan 28, 2016
2 parents fb1ae3a + 441499a commit a569906
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
7 changes: 4 additions & 3 deletions src/core/channel/channel_args.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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(
Expand Down
6 changes: 2 additions & 4 deletions src/core/surface/server.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -779,9 +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;
/* TODO(census): restore this once we finalize census filter etc.
int census_enabled = grpc_channel_args_is_census_enabled(args); */
int census_enabled = 0;
int census_enabled = grpc_channel_args_is_census_enabled(args);

grpc_server *server = gpr_malloc(sizeof(grpc_server));

Expand Down
5 changes: 1 addition & 4 deletions src/core/surface/server_create.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -43,9 +43,6 @@ grpc_server *grpc_server_create(const grpc_channel_args *args, void *reserved) {
const grpc_channel_filter *filters[3];
size_t num_filters = 0;
filters[num_filters++] = &grpc_compress_filter;
if (grpc_channel_args_is_census_enabled(args)) {
filters[num_filters++] = &grpc_server_census_filter;
}
GRPC_API_TRACE("grpc_server_create(%p, %p)", 2, (args, reserved));
return grpc_server_create_from_filters(filters, num_filters, args);
}

0 comments on commit a569906

Please sign in to comment.