From 157815d5cd5fc257d568bcfa87baa18325608000 Mon Sep 17 00:00:00 2001 From: ncteisen Date: Wed, 10 Jan 2018 17:58:46 -0800 Subject: Reviewer feedback --- .../ext/transport/chttp2/transport/chttp2_plugin.cc | 10 +++++++++- .../transport/chttp2/transport/chttp2_transport.cc | 19 +++++-------------- .../ext/transport/chttp2/transport/chttp2_transport.h | 2 ++ 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc b/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc index 97c1878f34..3aca61fdac 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc @@ -18,8 +18,16 @@ #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/debug/trace.h" +#include "src/core/lib/support/env.h" #include "src/core/lib/transport/metadata.h" -void grpc_chttp2_plugin_init(void) {} +void grpc_chttp2_plugin_init(void) { + g_flow_control_enabled = true; + char* env_variable = gpr_getenv("GRPC_EXPERIMENTAL_DISABLE_FLOW_CONTROL"); + if (env_variable != nullptr) { + g_flow_control_enabled = false; + gpr_free(env_variable); + } +} void grpc_chttp2_plugin_shutdown(void) {} diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index 97f79d9bdf..835de6aa0f 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -152,6 +152,10 @@ static void keepalive_watchdog_fired_locked(void* arg, grpc_error* error); static void reset_byte_stream(void* arg, grpc_error* error); +// Flow control default enabled. Can be disabled by setting +// GRPC_EXPERIMENTAL_DISABLE_FLOW_CONTROL +bool g_flow_control_enabled = true; + /******************************************************************************* * CONSTRUCTION/DESTRUCTION/REFCOUNTING */ @@ -232,9 +236,6 @@ void grpc_chttp2_ref_transport(grpc_chttp2_transport* t) { gpr_ref(&t->refs); } static const grpc_transport_vtable* get_vtable(void); -// -1 == unset, 0 == disabled, 1 == enabled -static gpr_atm flow_control_enabled = -1; - static void init_transport(grpc_chttp2_transport* t, const grpc_channel_args* channel_args, grpc_endpoint* ep, bool is_client) { @@ -520,17 +521,7 @@ static void init_transport(grpc_chttp2_transport* t, } } - if (gpr_atm_no_barrier_load(&flow_control_enabled) == -1) { - char* env_variable = gpr_getenv("GRPC_EXPERIMENTAL_DISABLE_FLOW_CONTROL"); - if (env_variable != nullptr) { - gpr_atm_no_barrier_store(&flow_control_enabled, 0); - } else { - gpr_atm_no_barrier_store(&flow_control_enabled, 1); - } - gpr_free(env_variable); - } - - if (gpr_atm_no_barrier_load(&flow_control_enabled)) { + if (g_flow_control_enabled) { t->flow_control.Init(t, enable_bdp); } else { diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.h b/src/core/ext/transport/chttp2/transport/chttp2_transport.h index 596ababb19..34519ceec9 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.h +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.h @@ -27,6 +27,8 @@ extern grpc_core::TraceFlag grpc_http_trace; extern grpc_core::TraceFlag grpc_trace_http2_stream_state; extern grpc_core::DebugOnlyTraceFlag grpc_trace_chttp2_refcount; +extern bool g_flow_control_enabled; + grpc_transport* grpc_create_chttp2_transport( const grpc_channel_args* channel_args, grpc_endpoint* ep, bool is_client); -- cgit v1.2.3