diff options
author | 2017-08-24 14:16:37 -0700 | |
---|---|---|
committer | 2017-08-24 14:16:37 -0700 | |
commit | 243fe9d43c6bed0168670255d8208795c8438a79 (patch) | |
tree | 653ca62f529f14f29aab8aee336ae457965e4c93 /src/core/ext | |
parent | cad427b2f79b5e2fcb0ca36a0f9118e6e1294959 (diff) |
Added way to remove filters from channel stack builder
Diffstat (limited to 'src/core/ext')
-rw-r--r-- | src/core/ext/filters/load_reporting/load_reporting.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/core/ext/filters/load_reporting/load_reporting.c b/src/core/ext/filters/load_reporting/load_reporting.c index 9745763c91..b42aa99cdb 100644 --- a/src/core/ext/filters/load_reporting/load_reporting.c +++ b/src/core/ext/filters/load_reporting/load_reporting.c @@ -42,9 +42,15 @@ static bool maybe_add_load_reporting_filter(grpc_exec_ctx *exec_ctx, void *arg) { const grpc_channel_args *args = grpc_channel_stack_builder_get_channel_arguments(builder); - if (is_load_reporting_enabled(args)) { - return grpc_channel_stack_builder_prepend_filter( - builder, (const grpc_channel_filter *)arg, NULL, NULL); + const grpc_channel_filter *filter = arg; + grpc_channel_stack_builder_iterator *it = + grpc_channel_stack_builder_iterator_find(builder, filter->name); + const bool already_has_load_reporting_filter = + !grpc_channel_stack_builder_iterator_is_end(it); + grpc_channel_stack_builder_iterator_destroy(it); + if (is_load_reporting_enabled(args) && !already_has_load_reporting_filter) { + return grpc_channel_stack_builder_prepend_filter(builder, filter, NULL, + NULL); } return true; } |