aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Mark D. Roth <roth@google.com>2016-09-16 09:53:25 -0700
committerGravatar Mark D. Roth <roth@google.com>2016-09-16 09:53:25 -0700
commit2b626466af11eed576859499baecf8c807591912 (patch)
tree4fa38e054bd6ddf552142d9a8956bc75df15492b /src/core
parent64f1f8d0406de950dd5dc84a5323d33c1a4f8c1d (diff)
Bug fixes and cleanups.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/ext/lb_policy/grpclb/grpclb.c12
-rw-r--r--src/core/ext/lb_policy/round_robin/round_robin.c12
-rw-r--r--src/core/ext/resolver/sockaddr/sockaddr_resolver.c1
3 files changed, 12 insertions, 13 deletions
diff --git a/src/core/ext/lb_policy/grpclb/grpclb.c b/src/core/ext/lb_policy/grpclb/grpclb.c
index f286bc9e00..999122fbe0 100644
--- a/src/core/ext/lb_policy/grpclb/grpclb.c
+++ b/src/core/ext/lb_policy/grpclb/grpclb.c
@@ -300,6 +300,9 @@ typedef struct glb_lb_policy {
* response has arrived. */
grpc_grpclb_serverlist *serverlist;
+ /** addresses from \a serverlist */
+ grpc_lb_addresses *addresses;
+
/** list of picks that are waiting on RR's policy connectivity */
pending_pick *pending_picks;
@@ -424,6 +427,7 @@ static grpc_lb_addresses *process_serverlist(
return lb_addresses;
}
+/* A plugin for grpc_lb_addresses_destroy that unrefs the LB token metadata. */
static void lb_token_destroy(void *token) {
if (token != NULL) GRPC_MDELEM_UNREF(token);
}
@@ -440,7 +444,12 @@ static grpc_lb_policy *create_rr(grpc_exec_ctx *exec_ctx,
grpc_lb_policy *rr = grpc_lb_policy_create(exec_ctx, "round_robin", &args);
- grpc_lb_addresses_destroy(args.addresses, lb_token_destroy);
+ if (glb_policy->addresses != NULL) {
+ /* dispose of the previous version */
+ grpc_lb_addresses_destroy(glb_policy->addresses, lb_token_destroy);
+ }
+ glb_policy->addresses = args.addresses;
+
return rr;
}
@@ -628,6 +637,7 @@ static void glb_destroy(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
grpc_grpclb_destroy_serverlist(glb_policy->serverlist);
}
gpr_mu_destroy(&glb_policy->mu);
+ grpc_lb_addresses_destroy(glb_policy->addresses, lb_token_destroy);
gpr_free(glb_policy);
}
diff --git a/src/core/ext/lb_policy/round_robin/round_robin.c b/src/core/ext/lb_policy/round_robin/round_robin.c
index 5593a5eccf..0feb0740a2 100644
--- a/src/core/ext/lb_policy/round_robin/round_robin.c
+++ b/src/core/ext/lb_policy/round_robin/round_robin.c
@@ -130,10 +130,6 @@ struct round_robin_lb_policy {
/** total number of addresses received at creation time */
size_t num_addresses;
- /** array holding the borrowed and opaque pointers to incoming user data, one
- * per incoming address. These individual pointers will be returned as-is in
- * successful picks. */
- void **user_data_pointers;
/** all our subchannels */
size_t num_subchannels;
@@ -282,7 +278,6 @@ static void rr_destroy(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
elem = tmp;
}
- gpr_free(p->user_data_pointers);
gpr_free(p);
}
@@ -626,8 +621,6 @@ static grpc_lb_policy *round_robin_create(grpc_exec_ctx *exec_ctx,
p->num_addresses = num_addrs;
p->subchannels = gpr_malloc(sizeof(*p->subchannels) * num_addrs);
memset(p->subchannels, 0, sizeof(*p->subchannels) * num_addrs);
- p->user_data_pointers = gpr_malloc(sizeof(void *) * num_addrs);
- memset(p->user_data_pointers, 0, sizeof(void *) * num_addrs);
grpc_subchannel_args sc_args;
size_t subchannel_idx = 0;
@@ -650,9 +643,7 @@ static grpc_lb_policy *round_robin_create(grpc_exec_ctx *exec_ctx,
sd->policy = p;
sd->index = subchannel_idx;
sd->subchannel = subchannel;
- sd->user_data = p->user_data_pointers[i];
- p->user_data_pointers[subchannel_idx] =
- args->addresses->addresses[i].user_data;
+ sd->user_data = args->addresses->addresses[i].user_data;
++subchannel_idx;
grpc_closure_init(&sd->connectivity_changed_closure,
rr_connectivity_changed, sd);
@@ -661,7 +652,6 @@ static grpc_lb_policy *round_robin_create(grpc_exec_ctx *exec_ctx,
if (subchannel_idx == 0) {
/* couldn't create any subchannel. Bail out */
gpr_free(p->subchannels);
- gpr_free(p->user_data_pointers);
gpr_free(p);
return NULL;
}
diff --git a/src/core/ext/resolver/sockaddr/sockaddr_resolver.c b/src/core/ext/resolver/sockaddr/sockaddr_resolver.c
index 307e0698f9..fbfe5d774b 100644
--- a/src/core/ext/resolver/sockaddr/sockaddr_resolver.c
+++ b/src/core/ext/resolver/sockaddr/sockaddr_resolver.c
@@ -129,7 +129,6 @@ static void sockaddr_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx,
lb_policy_args.client_channel_factory = r->client_channel_factory;
grpc_lb_policy *lb_policy =
grpc_lb_policy_create(exec_ctx, r->lb_policy_name, &lb_policy_args);
- gpr_free(lb_policy_args.addresses);
grpc_resolver_result_set_lb_policy(result, lb_policy);
GRPC_LB_POLICY_UNREF(exec_ctx, lb_policy, "sockaddr");
r->published = true;