clang-format

pull/7970/head
Mark D. Roth 8 years ago
parent 6ad991783f
commit 932b10c75b
  1. 6
      src/core/ext/client_config/client_channel.c
  2. 6
      src/core/ext/lb_policy/grpclb/grpclb.c
  3. 6
      src/core/ext/lb_policy/pick_first/pick_first.c
  4. 6
      src/core/ext/lb_policy/round_robin/round_robin.c
  5. 25
      src/core/lib/channel/deadline_filter.c
  6. 2
      src/core/lib/channel/deadline_filter.h
  7. 21
      src/core/lib/iomgr/error.c
  8. 5
      src/core/lib/surface/call.c

@ -563,9 +563,9 @@ static bool pick_subchannel(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
cpa = closure->cb_arg; cpa = closure->cb_arg;
if (cpa->connected_subchannel == connected_subchannel) { if (cpa->connected_subchannel == connected_subchannel) {
cpa->connected_subchannel = NULL; cpa->connected_subchannel = NULL;
grpc_exec_ctx_sched(exec_ctx, cpa->on_ready, grpc_exec_ctx_sched(
GRPC_ERROR_CREATE_REFERENCING( exec_ctx, cpa->on_ready,
"Pick cancelled", &error, 1), NULL); GRPC_ERROR_CREATE_REFERENCING("Pick cancelled", &error, 1), NULL);
} }
} }
gpr_mu_unlock(&chand->mu); gpr_mu_unlock(&chand->mu);

@ -545,9 +545,9 @@ static void glb_cancel_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
grpc_polling_entity_del_from_pollset_set( grpc_polling_entity_del_from_pollset_set(
exec_ctx, pp->pollent, glb_policy->base.interested_parties); exec_ctx, pp->pollent, glb_policy->base.interested_parties);
*target = NULL; *target = NULL;
grpc_exec_ctx_sched(exec_ctx, &pp->wrapped_on_complete, grpc_exec_ctx_sched(
GRPC_ERROR_CREATE_REFERENCING( exec_ctx, &pp->wrapped_on_complete,
"Pick Cancelled", &error, 1), NULL); GRPC_ERROR_CREATE_REFERENCING("Pick Cancelled", &error, 1), NULL);
gpr_free(pp); gpr_free(pp);
} else { } else {
pp->next = glb_policy->pending_picks; pp->next = glb_policy->pending_picks;

@ -141,9 +141,9 @@ static void pf_cancel_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
grpc_polling_entity_del_from_pollset_set(exec_ctx, pp->pollent, grpc_polling_entity_del_from_pollset_set(exec_ctx, pp->pollent,
p->base.interested_parties); p->base.interested_parties);
*target = NULL; *target = NULL;
grpc_exec_ctx_sched(exec_ctx, pp->on_complete, grpc_exec_ctx_sched(
GRPC_ERROR_CREATE_REFERENCING( exec_ctx, pp->on_complete,
"Pick Cancelled", &error, 1), NULL); GRPC_ERROR_CREATE_REFERENCING("Pick Cancelled", &error, 1), NULL);
gpr_free(pp); gpr_free(pp);
} else { } else {
pp->next = p->pending_picks; pp->next = p->pending_picks;

@ -294,9 +294,9 @@ static void rr_cancel_pick(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol,
grpc_polling_entity_del_from_pollset_set(exec_ctx, pp->pollent, grpc_polling_entity_del_from_pollset_set(exec_ctx, pp->pollent,
p->base.interested_parties); p->base.interested_parties);
*target = NULL; *target = NULL;
grpc_exec_ctx_sched(exec_ctx, pp->on_complete, grpc_exec_ctx_sched(
GRPC_ERROR_CREATE_REFERENCING( exec_ctx, pp->on_complete,
"Pick cancelled", &error, 1), NULL); GRPC_ERROR_CREATE_REFERENCING("Pick cancelled", &error, 1), NULL);
gpr_free(pp); gpr_free(pp);
} else { } else {
pp->next = p->pending_picks; pp->next = p->pending_picks;

@ -45,8 +45,8 @@
// //
// Timer callback. // Timer callback.
static void timer_callback(grpc_exec_ctx *exec_ctx, void *arg, static void timer_callback(grpc_exec_ctx* exec_ctx, void* arg,
grpc_error *error) { grpc_error* error) {
grpc_call_element* elem = arg; grpc_call_element* elem = arg;
grpc_deadline_state* deadline_state = elem->call_data; grpc_deadline_state* deadline_state = elem->call_data;
gpr_mu_lock(&deadline_state->timer_mu); gpr_mu_lock(&deadline_state->timer_mu);
@ -54,16 +54,15 @@ static void timer_callback(grpc_exec_ctx *exec_ctx, void *arg,
gpr_mu_unlock(&deadline_state->timer_mu); gpr_mu_unlock(&deadline_state->timer_mu);
if (error != GRPC_ERROR_CANCELLED) { if (error != GRPC_ERROR_CANCELLED) {
gpr_slice msg = gpr_slice_from_static_string("Deadline Exceeded"); gpr_slice msg = gpr_slice_from_static_string("Deadline Exceeded");
grpc_call_element_send_cancel_with_message(exec_ctx, elem, grpc_call_element_send_cancel_with_message(
GRPC_STATUS_DEADLINE_EXCEEDED, exec_ctx, elem, GRPC_STATUS_DEADLINE_EXCEEDED, &msg);
&msg);
gpr_slice_unref(msg); gpr_slice_unref(msg);
} }
GRPC_CALL_STACK_UNREF(exec_ctx, deadline_state->call_stack, "deadline_timer"); GRPC_CALL_STACK_UNREF(exec_ctx, deadline_state->call_stack, "deadline_timer");
} }
// Starts the deadline timer. // Starts the deadline timer.
static void start_timer_if_needed(grpc_exec_ctx *exec_ctx, static void start_timer_if_needed(grpc_exec_ctx* exec_ctx,
grpc_call_element* elem, grpc_call_element* elem,
gpr_timespec deadline) { gpr_timespec deadline) {
grpc_deadline_state* deadline_state = elem->call_data; grpc_deadline_state* deadline_state = elem->call_data;
@ -91,7 +90,7 @@ static void cancel_timer_if_needed(grpc_exec_ctx* exec_ctx,
} }
// Callback run when the call is complete. // Callback run when the call is complete.
static void on_complete(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { static void on_complete(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
grpc_deadline_state* deadline_state = arg; grpc_deadline_state* deadline_state = arg;
cancel_timer_if_needed(exec_ctx, deadline_state); cancel_timer_if_needed(exec_ctx, deadline_state);
// Invoke the next callback. // Invoke the next callback.
@ -159,8 +158,7 @@ static void init_channel_elem(grpc_exec_ctx* exec_ctx,
// Destructor for channel_data. Used for both client and server filters. // Destructor for channel_data. Used for both client and server filters.
static void destroy_channel_elem(grpc_exec_ctx* exec_ctx, static void destroy_channel_elem(grpc_exec_ctx* exec_ctx,
grpc_channel_element* elem) { grpc_channel_element* elem) {}
}
// Call data used for both client and server filter. // Call data used for both client and server filter.
typedef struct base_call_data { typedef struct base_call_data {
@ -180,7 +178,7 @@ typedef struct server_call_data {
} server_call_data; } server_call_data;
// Constructor for call_data. Used for both client and server filters. // Constructor for call_data. Used for both client and server filters.
static grpc_error *init_call_elem(grpc_exec_ctx* exec_ctx, static grpc_error* init_call_elem(grpc_exec_ctx* exec_ctx,
grpc_call_element* elem, grpc_call_element* elem,
grpc_call_element_args* args) { grpc_call_element_args* args) {
base_call_data* calld = elem->call_data; base_call_data* calld = elem->call_data;
@ -208,13 +206,12 @@ static void client_start_transport_stream_op(grpc_exec_ctx* exec_ctx,
} }
// Callback for receiving initial metadata on the server. // Callback for receiving initial metadata on the server.
static void recv_initial_metadata_ready(grpc_exec_ctx *exec_ctx, void *arg, static void recv_initial_metadata_ready(grpc_exec_ctx* exec_ctx, void* arg,
grpc_error *error) { grpc_error* error) {
grpc_call_element* elem = arg; grpc_call_element* elem = arg;
server_call_data* calld = elem->call_data; server_call_data* calld = elem->call_data;
// Get deadline from metadata and start the timer if needed. // Get deadline from metadata and start the timer if needed.
start_timer_if_needed(exec_ctx, elem, start_timer_if_needed(exec_ctx, elem, calld->recv_initial_metadata->deadline);
calld->recv_initial_metadata->deadline);
// Invoke the next callback. // Invoke the next callback.
calld->next_recv_initial_metadata_ready->cb( calld->next_recv_initial_metadata_ready->cb(
exec_ctx, calld->next_recv_initial_metadata_ready->cb_arg, error); exec_ctx, calld->next_recv_initial_metadata_ready->cb_arg, error);

@ -74,4 +74,4 @@ void grpc_deadline_state_client_start_transport_stream_op(
extern const grpc_channel_filter grpc_client_deadline_filter; extern const grpc_channel_filter grpc_client_deadline_filter;
extern const grpc_channel_filter grpc_server_deadline_filter; extern const grpc_channel_filter grpc_server_deadline_filter;
#endif // GRPC_CORE_LIB_CHANNEL_DEADLINE_FILTER_H #endif /* GRPC_CORE_LIB_CHANNEL_DEADLINE_FILTER_H */

@ -330,13 +330,13 @@ typedef struct {
const char *msg; const char *msg;
} special_error_status_map; } special_error_status_map;
static special_error_status_map error_status_map[] = { static special_error_status_map error_status_map[] = {
{ GRPC_ERROR_NONE, GRPC_STATUS_OK, "" }, {GRPC_ERROR_NONE, GRPC_STATUS_OK, ""},
{ GRPC_ERROR_CANCELLED, GRPC_STATUS_CANCELLED, "RPC cancelled" }, {GRPC_ERROR_CANCELLED, GRPC_STATUS_CANCELLED, "RPC cancelled"},
{ GRPC_ERROR_OOM, GRPC_STATUS_RESOURCE_EXHAUSTED, "Out of memory" }, {GRPC_ERROR_OOM, GRPC_STATUS_RESOURCE_EXHAUSTED, "Out of memory"},
}; };
static grpc_error *recursively_find_error_with_status(grpc_error* error, static grpc_error *recursively_find_error_with_status(grpc_error *error,
intptr_t* status) { intptr_t *status) {
// If the error itself has a status code, return it. // If the error itself has a status code, return it.
if (grpc_error_get_int(error, GRPC_ERROR_INT_GRPC_STATUS, status)) { if (grpc_error_get_int(error, GRPC_ERROR_INT_GRPC_STATUS, status)) {
return error; return error;
@ -345,12 +345,10 @@ static grpc_error *recursively_find_error_with_status(grpc_error* error,
intptr_t key = 0; intptr_t key = 0;
while (true) { while (true) {
grpc_error *child_error = gpr_avl_get(error->errs, (void *)key++); grpc_error *child_error = gpr_avl_get(error->errs, (void *)key++);
if (child_error == NULL) if (child_error == NULL) break;
break;
grpc_error *result = grpc_error *result =
recursively_find_error_with_status(child_error, status); recursively_find_error_with_status(child_error, status);
if (result != NULL) if (result != NULL) return result;
return result;
} }
return NULL; return NULL;
} }
@ -359,8 +357,7 @@ void grpc_error_get_status(grpc_error *error, grpc_status_code *code,
const char **msg) { const char **msg) {
// Handle special errors via the static map. // Handle special errors via the static map.
for (size_t i = 0; for (size_t i = 0;
i < sizeof(error_status_map) / sizeof(special_error_status_map); i < sizeof(error_status_map) / sizeof(special_error_status_map); ++i) {
++i) {
if (error == error_status_map[i].error) { if (error == error_status_map[i].error) {
*code = error_status_map[i].code; *code = error_status_map[i].code;
*msg = error_status_map[i].msg; *msg = error_status_map[i].msg;
@ -371,7 +368,7 @@ void grpc_error_get_status(grpc_error *error, grpc_status_code *code,
// Start with the parent error and recurse through the tree of children // Start with the parent error and recurse through the tree of children
// until we find the first one that has a status code. // until we find the first one that has a status code.
intptr_t status = GRPC_STATUS_UNKNOWN; // Default in case we don't find one. intptr_t status = GRPC_STATUS_UNKNOWN; // Default in case we don't find one.
grpc_error* found_error = recursively_find_error_with_status(error, &status); grpc_error *found_error = recursively_find_error_with_status(error, &status);
*code = (grpc_status_code)status; *code = (grpc_status_code)status;
// Now populate msg. // Now populate msg.
// If we found an error with a status code above, use that; otherwise, // If we found an error with a status code above, use that; otherwise,

@ -253,8 +253,7 @@ grpc_call *grpc_call_create(
call->metadata_batch[i][j].deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); call->metadata_batch[i][j].deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC);
} }
} }
send_deadline = send_deadline = gpr_convert_clock_type(send_deadline, GPR_CLOCK_MONOTONIC);
gpr_convert_clock_type(send_deadline, GPR_CLOCK_MONOTONIC);
GRPC_CHANNEL_INTERNAL_REF(channel, "call"); GRPC_CHANNEL_INTERNAL_REF(channel, "call");
/* initial refcount dropped by grpc_call_destroy */ /* initial refcount dropped by grpc_call_destroy */
grpc_error *error = grpc_call_stack_init( grpc_error *error = grpc_call_stack_init(
@ -438,7 +437,7 @@ static void set_status_details(grpc_call *call, status_source source,
static void set_status_from_error(grpc_call *call, status_source source, static void set_status_from_error(grpc_call *call, status_source source,
grpc_error *error) { grpc_error *error) {
grpc_status_code status; grpc_status_code status;
const char* msg; const char *msg;
grpc_error_get_status(error, &status, &msg); grpc_error_get_status(error, &status, &msg);
set_status_code(call, source, (uint32_t)status); set_status_code(call, source, (uint32_t)status);
set_status_details(call, source, grpc_mdstr_from_string(msg)); set_status_details(call, source, grpc_mdstr_from_string(msg));

Loading…
Cancel
Save