aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/ext/filters
diff options
context:
space:
mode:
authorGravatar David Garcia Quintas <dgq@google.com>2017-11-09 17:27:44 -0800
committerGravatar David Garcia Quintas <dgq@google.com>2017-11-09 17:34:28 -0800
commit94eae043c723919442b5f837bc97e9c0763cc25b (patch)
treedfe869a13f75727b8ea5d241909d77f9b3e90fad /src/core/ext/filters
parentce1c7db84cb75055caef33f8bf80b40b6965ebce (diff)
PF: don't unref errors when about to loop in pf_conn cb
Diffstat (limited to 'src/core/ext/filters')
-rw-r--r--src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc
index 125a4186aa..e87911bc94 100644
--- a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc
+++ b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc
@@ -444,6 +444,7 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
sd->curr_connectivity_state == GRPC_CHANNEL_SHUTDOWN) {
grpc_lb_subchannel_data_stop_connectivity_watch(exec_ctx, sd);
}
+ bool updated_error = false;
while (true) {
switch (sd->curr_connectivity_state) {
case GRPC_CHANNEL_READY: {
@@ -486,6 +487,7 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
}
// Renew notification.
grpc_lb_subchannel_data_start_connectivity_watch(exec_ctx, sd);
+ if (updated_error) GRPC_ERROR_UNREF(error);
return;
}
case GRPC_CHANNEL_TRANSIENT_FAILURE: {
@@ -506,11 +508,13 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
}
sd->curr_connectivity_state =
grpc_subchannel_check_connectivity(sd->subchannel, &error);
- GRPC_ERROR_UNREF(error);
if (sd->curr_connectivity_state == GRPC_CHANNEL_TRANSIENT_FAILURE) {
+ GRPC_ERROR_UNREF(error);
// Reuses the connectivity refs from the previous watch.
grpc_lb_subchannel_data_start_connectivity_watch(exec_ctx, sd);
return;
+ } else {
+ updated_error = true;
}
break; // Go back to top of loop.
}
@@ -524,6 +528,7 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
}
// Renew notification.
grpc_lb_subchannel_data_start_connectivity_watch(exec_ctx, sd);
+ if (updated_error) GRPC_ERROR_UNREF(error);
return;
}
case GRPC_CHANNEL_SHUTDOWN: {
@@ -544,6 +549,7 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
shutdown_locked(exec_ctx, p,
GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
"Pick first exhausted channels", &error, 1));
+ if (updated_error) GRPC_ERROR_UNREF(error);
return;
}
if (sd->subchannel_list == p->subchannel_list) {
@@ -553,11 +559,13 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx* exec_ctx, void* arg,
}
sd->curr_connectivity_state =
grpc_subchannel_check_connectivity(sd->subchannel, &error);
- GRPC_ERROR_UNREF(error);
if (sd->curr_connectivity_state == GRPC_CHANNEL_TRANSIENT_FAILURE) {
+ GRPC_ERROR_UNREF(error);
// Reuses the connectivity refs from the previous watch.
grpc_lb_subchannel_data_start_connectivity_watch(exec_ctx, sd);
return;
+ } else {
+ updated_error = true;
}
// For any other state, go back to top of loop.
// We will reuse the connectivity refs from the previous watch.