aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/ext
diff options
context:
space:
mode:
authorGravatar David Garcia Quintas <dgq@google.com>2016-07-18 13:08:42 -0700
committerGravatar David Garcia Quintas <dgq@google.com>2016-07-18 13:08:42 -0700
commit5a87616c43fbec62e27ebb01f5562b9d34ebd83c (patch)
tree8c8b7d00b3e7f729b86065e2f4e3d1fe89bd2c21 /src/core/ext
parenta26c77b3147521fc4951c4c105e8e529bd46d2b9 (diff)
Save a cb sched
Diffstat (limited to 'src/core/ext')
-rw-r--r--src/core/ext/lb_policy/grpclb/grpclb.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/core/ext/lb_policy/grpclb/grpclb.c b/src/core/ext/lb_policy/grpclb/grpclb.c
index b0f2e1f51d..750fd28a6c 100644
--- a/src/core/ext/lb_policy/grpclb/grpclb.c
+++ b/src/core/ext/lb_policy/grpclb/grpclb.c
@@ -135,7 +135,6 @@ typedef struct wrapped_rr_closure_arg {
static void wrapped_rr_closure(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) {
wrapped_rr_closure_arg *wc_arg = arg;
-
if (wc_arg->rr_policy != NULL) {
if (grpc_lb_glb_trace) {
gpr_log(GPR_INFO, "Unreffing RR (0x%" PRIxPTR ")",
@@ -143,10 +142,8 @@ static void wrapped_rr_closure(grpc_exec_ctx *exec_ctx, void *arg,
}
GRPC_LB_POLICY_UNREF(exec_ctx, wc_arg->rr_policy, "wrapped_rr_closure");
}
-
- if (wc_arg->wrapped_closure != NULL) {
- grpc_exec_ctx_sched(exec_ctx, wc_arg->wrapped_closure, error, NULL);
- }
+ GPR_ASSERT(wc_arg->wrapped_closure != NULL);
+ grpc_exec_ctx_sched(exec_ctx, wc_arg->wrapped_closure, error, NULL);
gpr_free(wc_arg->owning_pending_node);
}
@@ -842,7 +839,7 @@ static int glb_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
gpr_log(GPR_INFO, "about to PICK from 0x%" PRIxPTR "",
(intptr_t)p->rr_policy);
}
- GRPC_LB_POLICY_REF(p->rr_policy, "rr_pick");
+ GRPC_LB_POLICY_REF(p->rr_policy, "glb_pick");
memset(&p->wc_arg, 0, sizeof(wrapped_rr_closure_arg));
p->wc_arg.rr_policy = p->rr_policy;
p->wc_arg.wrapped_closure = on_complete;
@@ -851,10 +848,15 @@ static int glb_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
initial_metadata_flags, target,
&p->wrapped_on_complete);
if (r != 0) {
- /* the call to grpc_lb_policy_pick has been sychronous. Invoke a neutered
- * wrapped closure: it'll only take care of unreffing the RR policy */
+ /* the call to grpc_lb_policy_pick has been sychronous. Unreffing the RR
+ * policy and notify the original callback */
p->wc_arg.wrapped_closure = NULL;
- grpc_exec_ctx_sched(exec_ctx, &p->wrapped_on_complete, GRPC_ERROR_NONE,
+ if (grpc_lb_glb_trace) {
+ gpr_log(GPR_INFO, "Unreffing RR (0x%" PRIxPTR ")",
+ (intptr_t)p->wc_arg.rr_policy);
+ }
+ GRPC_LB_POLICY_UNREF(exec_ctx, p->wc_arg.rr_policy, "glb_pick");
+ grpc_exec_ctx_sched(exec_ctx, p->wc_arg.wrapped_closure, GRPC_ERROR_NONE,
NULL);
}
} else {