diff options
author | 2017-04-27 18:27:39 -0700 | |
---|---|---|
committer | 2017-04-27 18:27:39 -0700 | |
commit | 9dd9178f30e0e21e826afb56f308904bfc6d945b (patch) | |
tree | 33f924113d40a31ab0bbd63ad30d0e938ca2eeec /src/core/ext/filters/workarounds | |
parent | f8d01f3834593dc134168464a4dab25d11d9065a (diff) |
Allow enabling of each filter
Diffstat (limited to 'src/core/ext/filters/workarounds')
3 files changed, 27 insertions, 0 deletions
diff --git a/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c b/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c index 8dbf4c2b0a..7a3b2c77f9 100644 --- a/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c +++ b/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.c @@ -206,6 +206,9 @@ const grpc_channel_filter grpc_workaround_cronet_compression_filter = { static bool register_workaround_cronet_compression( grpc_exec_ctx* exec_ctx, grpc_channel_stack_builder* builder, void* arg) { + if (!grpc_workaround_is_enabled(GRPC_WORKAROUND_ID_CRONET_COMPRESSION)) { + return true; + } grpc_register_workaround(GRPC_WORKAROUND_ID_CRONET_COMPRESSION, parse_user_agent); return grpc_channel_stack_builder_prepend_filter( diff --git a/src/core/ext/filters/workarounds/workaround_utils.c b/src/core/ext/filters/workarounds/workaround_utils.c index 14ed84599c..ef0e8a6cd8 100644 --- a/src/core/ext/filters/workarounds/workaround_utils.c +++ b/src/core/ext/filters/workarounds/workaround_utils.c @@ -36,6 +36,14 @@ static user_agent_parser user_agent_parsers[GRPC_MAX_WORKAROUND_ID]; +/* Workarounds enabled by user */ +static bool workaround_enabled[GRPC_MAX_WORKAROUND_ID]; + +/* Workarounds supported by C core */ +static bool workaround_supported[GRPC_MAX_WORKAROUND_ID] = { + true /* GRPC_WORKAROUND_ID_CRONET_COMPRESSION */ +}; + grpc_user_agent_md *grpc_parse_user_agent(grpc_mdelem md) { grpc_user_agent_md *user_agent_md; @@ -55,3 +63,17 @@ void grpc_register_workaround(uint32_t id, user_agent_parser parser) { GPR_ASSERT(id < GRPC_MAX_WORKAROUND_ID); user_agent_parsers[id] = parser; } + +bool grpc_workaround_is_enabled(uint32_t id) { + GPR_ASSERT(id < GRPC_MAX_WORKAROUND_ID); + return workaround_enabled[id]; +} + +bool grpc_enable_workaround(uint32_t id) { + if (workaround_supported[id]) { + workaround_enabled[id] = true; + return true; + } else { + return false; + } +} diff --git a/src/core/ext/filters/workarounds/workaround_utils.h b/src/core/ext/filters/workarounds/workaround_utils.h index 99363248cb..d9d5669ed6 100644 --- a/src/core/ext/filters/workarounds/workaround_utils.h +++ b/src/core/ext/filters/workarounds/workaround_utils.h @@ -51,4 +51,6 @@ typedef bool (*user_agent_parser)(grpc_mdelem); void grpc_register_workaround(uint32_t id, user_agent_parser parser); +bool grpc_workaround_is_enabled(uint32_t id); + #endif |