aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/ext/filters/client_channel/retry_throttle.cc
diff options
context:
space:
mode:
authorGravatar Noah Eisen <ncteisen@google.com>2018-02-09 09:34:04 -0800
committerGravatar Noah Eisen <ncteisen@google.com>2018-02-09 09:34:04 -0800
commit4d20a666850b732cf1562487fb5f46ab9654105f (patch)
tree9059162d0f125e02780f506c2476d5d9bbc0eb7d /src/core/ext/filters/client_channel/retry_throttle.cc
parentcddf6f838aa48c8d5c9f75cee5a8ed8abdcb25b9 (diff)
Run clang fmt
Diffstat (limited to 'src/core/ext/filters/client_channel/retry_throttle.cc')
-rw-r--r--src/core/ext/filters/client_channel/retry_throttle.cc24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/core/ext/filters/client_channel/retry_throttle.cc b/src/core/ext/filters/client_channel/retry_throttle.cc
index d1e0820560..dd33b69102 100644
--- a/src/core/ext/filters/client_channel/retry_throttle.cc
+++ b/src/core/ext/filters/client_channel/retry_throttle.cc
@@ -60,7 +60,8 @@ bool grpc_server_retry_throttle_data_record_failure(
get_replacement_throttle_data_if_needed(&throttle_data);
// We decrement milli_tokens by 1000 (1 token) for each failure.
const int new_value = static_cast<int>(gpr_atm_no_barrier_clamped_add(
- &throttle_data->milli_tokens, static_cast<gpr_atm>(-1000), static_cast<gpr_atm>(0),
+ &throttle_data->milli_tokens, static_cast<gpr_atm>(-1000),
+ static_cast<gpr_atm>(0),
static_cast<gpr_atm>(throttle_data->max_milli_tokens)));
// Retries are allowed as long as the new value is above the threshold
// (max_milli_tokens / 2).
@@ -73,8 +74,10 @@ void grpc_server_retry_throttle_data_record_success(
get_replacement_throttle_data_if_needed(&throttle_data);
// We increment milli_tokens by milli_token_ratio for each success.
gpr_atm_no_barrier_clamped_add(
- &throttle_data->milli_tokens, static_cast<gpr_atm>(throttle_data->milli_token_ratio),
- static_cast<gpr_atm>(0), static_cast<gpr_atm>(throttle_data->max_milli_tokens));
+ &throttle_data->milli_tokens,
+ static_cast<gpr_atm>(throttle_data->milli_token_ratio),
+ static_cast<gpr_atm>(0),
+ static_cast<gpr_atm>(throttle_data->max_milli_tokens));
}
grpc_server_retry_throttle_data* grpc_server_retry_throttle_data_ref(
@@ -100,7 +103,8 @@ static grpc_server_retry_throttle_data* grpc_server_retry_throttle_data_create(
int max_milli_tokens, int milli_token_ratio,
grpc_server_retry_throttle_data* old_throttle_data) {
grpc_server_retry_throttle_data* throttle_data =
- static_cast<grpc_server_retry_throttle_data*>(gpr_malloc(sizeof(*throttle_data)));
+ static_cast<grpc_server_retry_throttle_data*>(
+ gpr_malloc(sizeof(*throttle_data)));
memset(throttle_data, 0, sizeof(*throttle_data));
gpr_ref_init(&throttle_data->refs, 1);
throttle_data->max_milli_tokens = max_milli_tokens;
@@ -112,7 +116,7 @@ static grpc_server_retry_throttle_data* grpc_server_retry_throttle_data_create(
// we will start out doing the same thing on the new one.
if (old_throttle_data != nullptr) {
double token_fraction =
- static_cast<int>gpr_atm_acq_load(&old_throttle_data->milli_tokens) /
+ static_cast<int> gpr_atm_acq_load(&old_throttle_data->milli_tokens) /
static_cast<double>(old_throttle_data->max_milli_tokens);
initial_milli_tokens = static_cast<int>(token_fraction * max_milli_tokens);
}
@@ -178,13 +182,14 @@ grpc_server_retry_throttle_data* grpc_retry_throttle_map_get_data_for_server(
const char* server_name, int max_milli_tokens, int milli_token_ratio) {
gpr_mu_lock(&g_mu);
grpc_server_retry_throttle_data* throttle_data =
- static_cast<grpc_server_retry_throttle_data*>(grpc_avl_get(g_avl, const_cast<char*>(server_name),
- nullptr));
+ static_cast<grpc_server_retry_throttle_data*>(
+ grpc_avl_get(g_avl, const_cast<char*>(server_name), nullptr));
if (throttle_data == nullptr) {
// Entry not found. Create a new one.
throttle_data = grpc_server_retry_throttle_data_create(
max_milli_tokens, milli_token_ratio, nullptr);
- g_avl = grpc_avl_add(g_avl, const_cast<char*>(server_name), throttle_data, nullptr);
+ g_avl = grpc_avl_add(g_avl, const_cast<char*>(server_name), throttle_data,
+ nullptr);
} else {
if (throttle_data->max_milli_tokens != max_milli_tokens ||
throttle_data->milli_token_ratio != milli_token_ratio) {
@@ -192,7 +197,8 @@ grpc_server_retry_throttle_data* grpc_retry_throttle_map_get_data_for_server(
// the original one.
throttle_data = grpc_server_retry_throttle_data_create(
max_milli_tokens, milli_token_ratio, throttle_data);
- g_avl = grpc_avl_add(g_avl, const_cast<char*>(server_name), throttle_data, nullptr);
+ g_avl = grpc_avl_add(g_avl, const_cast<char*>(server_name), throttle_data,
+ nullptr);
} else {
// Entry found. Increase refcount.
grpc_server_retry_throttle_data_ref(throttle_data);