PR comments

pull/7746/head
David Garcia Quintas 8 years ago
parent f47d6fbdcc
commit 8424fdcb70
  1. 8
      src/core/ext/client_config/lb_policy.h
  2. 18
      src/core/ext/lb_policy/grpclb/grpclb.c
  3. 12
      src/core/ext/lb_policy/round_robin/round_robin.c

@ -144,11 +144,9 @@ void grpc_lb_policy_init(grpc_lb_policy *policy,
value will be returned.
In the asynchronous case, zero is returned and \a on_complete will be called
once \a target and \a user_data have been set. Any IO should be done under
\a
pick_args->pollent.
The opaque \a user_data output argument corresponds to information that may
need be propagated from the LB policy. It may be NULL.
Errors are signaled by receiving a NULL \a *target. */
\a pick_args->pollent. The opaque \a user_data output argument corresponds
to information that may need be propagated from the LB policy. It may be
NULL. Errors are signaled by receiving a NULL \a *target. */
int grpc_lb_policy_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
const grpc_lb_policy_pick_args *pick_args,
grpc_connected_subchannel **target, void **user_data,

@ -120,11 +120,6 @@
int grpc_lb_glb_trace = 0;
static void *user_data_copy(void *user_data) {
if (user_data == NULL) return NULL;
return GRPC_MDELEM_REF(user_data);
}
static void lb_addrs_destroy(grpc_lb_address *lb_addresses,
size_t num_addresses) {
/* free "resolved" addresses memblock */
@ -192,7 +187,7 @@ static void wrapped_rr_closure(grpc_exec_ctx *exec_ctx, void *arg,
initial_metadata_add_lb_token(wc_arg->initial_metadata,
wc_arg->lb_token_mdelem_storage,
user_data_copy(wc_arg->lb_token));
GRPC_MDELEM_REF(wc_arg->lb_token));
grpc_exec_ctx_sched(exec_ctx, wc_arg->wrapped_closure, error, NULL);
gpr_free(wc_arg->owning_pending_node);
@ -809,7 +804,7 @@ static int glb_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
/* add the load reporting initial metadata */
initial_metadata_add_lb_token(
pick_args->initial_metadata, pick_args->lb_token_mdelem_storage,
user_data_copy(glb_policy->wc_arg.lb_token));
GRPC_MDELEM_REF(glb_policy->wc_arg.lb_token));
}
} else {
grpc_polling_entity_add_to_pollset_set(exec_ctx, pick_args->pollent,
@ -894,8 +889,7 @@ typedef struct lb_client_data {
grpc_metadata_array initial_metadata_recv; /* initial MD from LB server */
grpc_metadata_array trailing_metadata_recv; /* trailing MD from LB server */
/* what's being sent to the LB server. Note that its value may vary if the
* LB
/* what's being sent to the LB server. Note that its value may vary if the LB
* server indicates a redirect. */
grpc_byte_buffer *request_payload;
@ -1103,8 +1097,7 @@ static void res_recv_cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
* it'll just create the first RR policy instance */
rr_handover(exec_ctx, lb_client->glb_policy, error);
} else {
/* unref the RR policy, eventually leading to its substitution with
* a
/* unref the RR policy, eventually leading to its substitution with a
* new one constructed from the received serverlist (see
* glb_rr_connectivity_changed) */
GRPC_LB_POLICY_UNREF(exec_ctx, lb_client->glb_policy->rr_policy,
@ -1170,8 +1163,7 @@ static void srv_status_rcvd_cb(grpc_exec_ctx *exec_ctx, void *arg,
lb_client->status_details_capacity);
}
/* TODO(dgq): deal with stream termination properly (fire up another one?
* fail
* the original call?) */
* fail the original call?) */
}
/* Code wiring the policy with the rest of the core */

@ -132,7 +132,7 @@ struct round_robin_lb_policy {
size_t num_addresses;
/** user data, one per incoming address. This pointer is borrowed and opaque.
* It'll be returned as-is in successful picks. */
void **user_data;
void **user_data_pointers;
/** all our subchannels */
size_t num_subchannels;
@ -281,7 +281,7 @@ static void rr_destroy(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) {
elem = tmp;
}
gpr_free(p->user_data);
gpr_free(p->user_data_pointers);
gpr_free(p);
}
@ -613,8 +613,8 @@ static grpc_lb_policy *round_robin_create(grpc_exec_ctx *exec_ctx,
p->num_addresses = args->num_addresses;
p->subchannels = gpr_malloc(sizeof(subchannel_data) * p->num_addresses);
memset(p->subchannels, 0, sizeof(*p->subchannels) * p->num_addresses);
p->user_data = gpr_malloc(sizeof(void *) * p->num_addresses);
memset(p->user_data, 0, sizeof(void *) * p->num_addresses);
p->user_data_pointers = gpr_malloc(sizeof(void *) * p->num_addresses);
memset(p->user_data_pointers, 0, sizeof(void *) * p->num_addresses);
grpc_subchannel_args sc_args;
size_t subchannel_idx = 0;
@ -623,7 +623,7 @@ static grpc_lb_policy *round_robin_create(grpc_exec_ctx *exec_ctx,
sc_args.addr = (struct sockaddr *)args->addresses[i].resolved_address->addr;
sc_args.addr_len = args->addresses[i].resolved_address->len;
p->user_data[i] = args->addresses[i].user_data;
p->user_data_pointers[i] = args->addresses[i].user_data;
grpc_subchannel *subchannel = grpc_client_channel_factory_create_subchannel(
exec_ctx, args->client_channel_factory, &sc_args);
@ -635,7 +635,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[i];
sd->user_data = p->user_data_pointers[i];
++subchannel_idx;
grpc_closure_init(&sd->connectivity_changed_closure,
rr_connectivity_changed, sd);

Loading…
Cancel
Save