diff options
author | 2017-12-01 03:19:21 -0800 | |
---|---|---|
committer | 2018-01-22 12:54:10 -0800 | |
commit | c4431e4fcd1afc37859da8ca21736b3b67d4f154 (patch) | |
tree | ad4853ab3d484701c1bdb8d1015f87c74950dab8 /src/core/ext/filters | |
parent | f46028f5dbc5beac240178363932749ab7ece1ea (diff) |
Try again when idle_state is unexpected
Diffstat (limited to 'src/core/ext/filters')
-rw-r--r-- | src/core/ext/filters/max_age/max_age_filter.cc | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/core/ext/filters/max_age/max_age_filter.cc b/src/core/ext/filters/max_age/max_age_filter.cc index cab17acdf2..ec8aaccfa5 100644 --- a/src/core/ext/filters/max_age/max_age_filter.cc +++ b/src/core/ext/filters/max_age/max_age_filter.cc @@ -98,20 +98,23 @@ struct channel_data { calls, the max_idle_timer should be cancelled. */ static void increase_call_count(channel_data* chand) { if (gpr_atm_full_fetch_add(&chand->call_count, 1) == 0) { - gpr_atm idle_state = gpr_atm_acq_load(&chand->idle_state); - switch (idle_state) { - case MAX_IDLE_STATE_TIMER_SET: - /* max_idle_timer_cb may have already set idle_state to - MAX_IDLE_STATE_INIT, in this case, we don't need to set it to - MAX_IDLE_STATE_SEEN_EXIT_IDLE */ - gpr_atm_rel_cas(&chand->idle_state, MAX_IDLE_STATE_TIMER_SET, - MAX_IDLE_STATE_SEEN_EXIT_IDLE); - break; - case MAX_IDLE_STATE_SEEN_ENTER_IDLE: - gpr_atm_rel_store(&chand->idle_state, MAX_IDLE_STATE_SEEN_EXIT_IDLE); - break; - default: - abort(); + while (true) { + gpr_atm idle_state = gpr_atm_acq_load(&chand->idle_state); + switch (idle_state) { + case MAX_IDLE_STATE_TIMER_SET: + /* max_idle_timer_cb may have already set idle_state to + MAX_IDLE_STATE_INIT, in this case, we don't need to set it to + MAX_IDLE_STATE_SEEN_EXIT_IDLE */ + gpr_atm_rel_cas(&chand->idle_state, MAX_IDLE_STATE_TIMER_SET, + MAX_IDLE_STATE_SEEN_EXIT_IDLE); + return; + case MAX_IDLE_STATE_SEEN_ENTER_IDLE: + gpr_atm_rel_store(&chand->idle_state, MAX_IDLE_STATE_SEEN_EXIT_IDLE); + return; + default: + /* try again */ + break; + } } } } @@ -140,7 +143,8 @@ static void decrease_call_count(channel_data* chand) { } break; default: - abort(); + /* try again */ + break; } } } @@ -219,7 +223,7 @@ static void close_max_idle_channel(void* arg, grpc_error* error) { MAX_IDLE_STATE_TIMER_SET); break; } else { - abort(); + /* try again */ } } } else if (error != GRPC_ERROR_CANCELLED) { |