diff --git a/src/core/channel/call_op_string.c b/src/core/channel/call_op_string.c index 23e22d93d10..534ee29bac2 100644 --- a/src/core/channel/call_op_string.c +++ b/src/core/channel/call_op_string.c @@ -43,12 +43,14 @@ static void put_metadata(gpr_strvec *b, grpc_mdelem *md) { gpr_strvec_add(b, gpr_strdup(" key=")); - gpr_strvec_add(b, gpr_hexdump((char *)GPR_SLICE_START_PTR(md->key->slice), - GPR_SLICE_LENGTH(md->key->slice), GPR_HEXDUMP_PLAINTEXT)); + gpr_strvec_add( + b, gpr_hexdump((char *)GPR_SLICE_START_PTR(md->key->slice), + GPR_SLICE_LENGTH(md->key->slice), GPR_HEXDUMP_PLAINTEXT)); gpr_strvec_add(b, gpr_strdup(" value=")); gpr_strvec_add(b, gpr_hexdump((char *)GPR_SLICE_START_PTR(md->value->slice), - GPR_SLICE_LENGTH(md->value->slice), GPR_HEXDUMP_PLAINTEXT)); + GPR_SLICE_LENGTH(md->value->slice), + GPR_HEXDUMP_PLAINTEXT)); } static void put_metadata_list(gpr_strvec *b, grpc_call_op_metadata md) { @@ -58,7 +60,8 @@ static void put_metadata_list(gpr_strvec *b, grpc_call_op_metadata md) { } if (gpr_time_cmp(md.deadline, gpr_inf_future) != 0) { char *tmp; - gpr_asprintf(&tmp, " deadline=%d.%09d", md.deadline.tv_sec, md.deadline.tv_nsec); + gpr_asprintf(&tmp, " deadline=%d.%09d", md.deadline.tv_sec, + md.deadline.tv_nsec); gpr_strvec_add(b, tmp); } } diff --git a/src/core/channel/census_filter.c b/src/core/channel/census_filter.c index 7031e523da4..6eeba36565b 100644 --- a/src/core/channel/census_filter.c +++ b/src/core/channel/census_filter.c @@ -62,13 +62,12 @@ static void init_rpc_stats(census_rpc_stats* stats) { static void extract_and_annotate_method_tag(grpc_call_op* op, call_data* calld, channel_data* chand) { - grpc_linked_mdelem *m; + grpc_linked_mdelem* m; for (m = op->data.metadata.list.head; m; m = m->next) { if (m->md->key == chand->path_str) { - gpr_log(GPR_DEBUG, - (const char*)GPR_SLICE_START_PTR(m->md->value->slice)); - census_add_method_tag(calld->op_id, (const char*)GPR_SLICE_START_PTR( - m->md->value->slice)); + gpr_log(GPR_DEBUG, (const char*)GPR_SLICE_START_PTR(m->md->value->slice)); + census_add_method_tag( + calld->op_id, (const char*)GPR_SLICE_START_PTR(m->md->value->slice)); } } } @@ -181,11 +180,11 @@ static void destroy_channel_elem(grpc_channel_element* elem) { } const grpc_channel_filter grpc_client_census_filter = { - client_call_op, channel_op, sizeof(call_data), - client_init_call_elem, client_destroy_call_elem, sizeof(channel_data), - init_channel_elem, destroy_channel_elem, "census-client"}; + client_call_op, channel_op, sizeof(call_data), client_init_call_elem, + client_destroy_call_elem, sizeof(channel_data), init_channel_elem, + destroy_channel_elem, "census-client"}; const grpc_channel_filter grpc_server_census_filter = { - server_call_op, channel_op, sizeof(call_data), - server_init_call_elem, server_destroy_call_elem, sizeof(channel_data), - init_channel_elem, destroy_channel_elem, "census-server"}; + server_call_op, channel_op, sizeof(call_data), server_init_call_elem, + server_destroy_call_elem, sizeof(channel_data), init_channel_elem, + destroy_channel_elem, "census-server"}; diff --git a/src/core/channel/channel_stack.c b/src/core/channel/channel_stack.c index 874d6c54fe2..7fc492fcea0 100644 --- a/src/core/channel/channel_stack.c +++ b/src/core/channel/channel_stack.c @@ -77,9 +77,9 @@ size_t grpc_channel_stack_size(const grpc_channel_filter **filters, return size; } -#define CHANNEL_ELEMS_FROM_STACK(stk) \ - ((grpc_channel_element *)( \ - (char *)(stk) + ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(grpc_channel_stack)))) +#define CHANNEL_ELEMS_FROM_STACK(stk) \ + ((grpc_channel_element *)((char *)(stk) + ROUND_UP_TO_ALIGNMENT_SIZE( \ + sizeof(grpc_channel_stack)))) #define CALL_ELEMS_FROM_STACK(stk) \ ((grpc_call_element *)((char *)(stk) + \ @@ -193,14 +193,13 @@ void grpc_channel_next_op(grpc_channel_element *elem, grpc_channel_op *op) { grpc_channel_stack *grpc_channel_stack_from_top_element( grpc_channel_element *elem) { - return (grpc_channel_stack *)((char *)(elem) - - ROUND_UP_TO_ALIGNMENT_SIZE( - sizeof(grpc_channel_stack))); + return (grpc_channel_stack *)((char *)(elem)-ROUND_UP_TO_ALIGNMENT_SIZE( + sizeof(grpc_channel_stack))); } grpc_call_stack *grpc_call_stack_from_top_element(grpc_call_element *elem) { - return (grpc_call_stack *)((char *)(elem) - ROUND_UP_TO_ALIGNMENT_SIZE( - sizeof(grpc_call_stack))); + return (grpc_call_stack *)((char *)(elem)-ROUND_UP_TO_ALIGNMENT_SIZE( + sizeof(grpc_call_stack))); } static void do_nothing(void *user_data, grpc_op_error error) {} @@ -225,7 +224,9 @@ void grpc_call_element_send_finish(grpc_call_element *cur_elem) { grpc_call_next_op(cur_elem, &finish_op); } -void grpc_call_element_recv_status(grpc_call_element *cur_elem, grpc_status_code status, const char *message) { +void grpc_call_element_recv_status(grpc_call_element *cur_elem, + grpc_status_code status, + const char *message) { abort(); } @@ -246,19 +247,18 @@ static void assert_valid_list(grpc_mdelem_list *list) { } } -void grpc_call_op_metadata_init(grpc_call_op_metadata *comd) { - abort(); -} +void grpc_call_op_metadata_init(grpc_call_op_metadata *comd) { abort(); } -void grpc_call_op_metadata_destroy(grpc_call_op_metadata *comd) { - abort(); -} +void grpc_call_op_metadata_destroy(grpc_call_op_metadata *comd) { abort(); } -void grpc_call_op_metadata_merge(grpc_call_op_metadata *target, grpc_call_op_metadata *add) { +void grpc_call_op_metadata_merge(grpc_call_op_metadata *target, + grpc_call_op_metadata *add) { abort(); } -void grpc_call_op_metadata_add_head(grpc_call_op_metadata *comd, grpc_linked_mdelem *storage, grpc_mdelem *elem_to_add) { +void grpc_call_op_metadata_add_head(grpc_call_op_metadata *comd, + grpc_linked_mdelem *storage, + grpc_mdelem *elem_to_add) { storage->md = elem_to_add; grpc_call_op_metadata_link_head(comd, storage); } @@ -276,11 +276,14 @@ static void link_head(grpc_mdelem_list *list, grpc_linked_mdelem *storage) { assert_valid_list(list); } -void grpc_call_op_metadata_link_head(grpc_call_op_metadata *comd, grpc_linked_mdelem *storage) { +void grpc_call_op_metadata_link_head(grpc_call_op_metadata *comd, + grpc_linked_mdelem *storage) { link_head(&comd->list, storage); } -void grpc_call_op_metadata_add_tail(grpc_call_op_metadata *comd, grpc_linked_mdelem *storage, grpc_mdelem *elem_to_add) { +void grpc_call_op_metadata_add_tail(grpc_call_op_metadata *comd, + grpc_linked_mdelem *storage, + grpc_mdelem *elem_to_add) { storage->md = elem_to_add; grpc_call_op_metadata_link_tail(comd, storage); } @@ -298,11 +301,15 @@ static void link_tail(grpc_mdelem_list *list, grpc_linked_mdelem *storage) { assert_valid_list(list); } -void grpc_call_op_metadata_link_tail(grpc_call_op_metadata *comd, grpc_linked_mdelem *storage) { +void grpc_call_op_metadata_link_tail(grpc_call_op_metadata *comd, + grpc_linked_mdelem *storage) { link_tail(&comd->list, storage); } -void grpc_call_op_metadata_filter(grpc_call_op_metadata *comd, grpc_mdelem *(*filter)(void *user_data, grpc_mdelem *elem), void *user_data) { +void grpc_call_op_metadata_filter(grpc_call_op_metadata *comd, + grpc_mdelem *(*filter)(void *user_data, + grpc_mdelem *elem), + void *user_data) { grpc_linked_mdelem *l; grpc_linked_mdelem *next; diff --git a/src/core/channel/channel_stack.h b/src/core/channel/channel_stack.h index 53143ac278f..4cd73ab6bfe 100644 --- a/src/core/channel/channel_stack.h +++ b/src/core/channel/channel_stack.h @@ -108,15 +108,25 @@ typedef struct grpc_call_op_metadata { void grpc_call_op_metadata_init(grpc_call_op_metadata *comd); void grpc_call_op_metadata_destroy(grpc_call_op_metadata *comd); -void grpc_call_op_metadata_merge(grpc_call_op_metadata *target, grpc_call_op_metadata *add); - -void grpc_call_op_metadata_link_head(grpc_call_op_metadata *comd, grpc_linked_mdelem *storage); -void grpc_call_op_metadata_link_tail(grpc_call_op_metadata *comd, grpc_linked_mdelem *storage); - -void grpc_call_op_metadata_add_head(grpc_call_op_metadata *comd, grpc_linked_mdelem *storage, grpc_mdelem *elem_to_add); -void grpc_call_op_metadata_add_tail(grpc_call_op_metadata *comd, grpc_linked_mdelem *storage, grpc_mdelem *elem_to_add); - -void grpc_call_op_metadata_filter(grpc_call_op_metadata *comd, grpc_mdelem *(*filter)(void *user_data, grpc_mdelem *elem), void *user_data); +void grpc_call_op_metadata_merge(grpc_call_op_metadata *target, + grpc_call_op_metadata *add); + +void grpc_call_op_metadata_link_head(grpc_call_op_metadata *comd, + grpc_linked_mdelem *storage); +void grpc_call_op_metadata_link_tail(grpc_call_op_metadata *comd, + grpc_linked_mdelem *storage); + +void grpc_call_op_metadata_add_head(grpc_call_op_metadata *comd, + grpc_linked_mdelem *storage, + grpc_mdelem *elem_to_add); +void grpc_call_op_metadata_add_tail(grpc_call_op_metadata *comd, + grpc_linked_mdelem *storage, + grpc_mdelem *elem_to_add); + +void grpc_call_op_metadata_filter(grpc_call_op_metadata *comd, + grpc_mdelem *(*filter)(void *user_data, + grpc_mdelem *elem), + void *user_data); /* A single filterable operation to be performed on a call */ typedef struct { @@ -315,11 +325,13 @@ void grpc_call_log_op(char *file, int line, gpr_log_severity severity, void grpc_call_element_send_cancel(grpc_call_element *cur_elem); void grpc_call_element_send_finish(grpc_call_element *cur_elem); -void grpc_call_element_recv_status(grpc_call_element *cur_elem, grpc_status_code status, const char *message); +void grpc_call_element_recv_status(grpc_call_element *cur_elem, + grpc_status_code status, + const char *message); extern int grpc_trace_channel; #define GRPC_CALL_LOG_OP(sev, elem, op) \ if (grpc_trace_channel) grpc_call_log_op(sev, elem, op) -#endif /* GRPC_INTERNAL_CORE_CHANNEL_CHANNEL_STACK_H */ +#endif /* GRPC_INTERNAL_CORE_CHANNEL_CHANNEL_STACK_H */ diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index 7b9c080eff6..e66c5bf3664 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -440,9 +440,10 @@ static void destroy_channel_elem(grpc_channel_element *elem) { } const grpc_channel_filter grpc_client_channel_filter = { - call_op, channel_op, sizeof(call_data), - init_call_elem, destroy_call_elem, sizeof(channel_data), - init_channel_elem, destroy_channel_elem, "client-channel", }; + call_op, channel_op, sizeof(call_data), init_call_elem, destroy_call_elem, + sizeof(channel_data), init_channel_elem, destroy_channel_elem, + "client-channel", +}; grpc_transport_setup_result grpc_client_channel_transport_setup_complete( grpc_channel_stack *channel_stack, grpc_transport *transport, diff --git a/src/core/channel/connected_channel.c b/src/core/channel/connected_channel.c index 519f05cb666..f7fed7cae96 100644 --- a/src/core/channel/connected_channel.c +++ b/src/core/channel/connected_channel.c @@ -131,7 +131,8 @@ static void call_op(grpc_call_element *elem, grpc_call_element *from_elem, grpc_sopb_add_metadata(&calld->outgoing_sopb, m->md); } if (gpr_time_cmp(op->data.metadata.deadline, gpr_inf_future) != 0) { - grpc_sopb_add_deadline(&calld->outgoing_sopb, op->data.metadata.deadline); + grpc_sopb_add_deadline(&calld->outgoing_sopb, + op->data.metadata.deadline); } grpc_sopb_add_flow_ctl_cb(&calld->outgoing_sopb, op->done_cb, op->user_data); @@ -145,7 +146,7 @@ static void call_op(grpc_call_element *elem, grpc_call_element *from_elem, grpc_sopb_add_begin_message(&calld->outgoing_sopb, grpc_byte_buffer_length(op->data.message), op->flags); - /* fall-through */ + /* fall-through */ case GRPC_SEND_PREFORMATTED_MESSAGE: copy_byte_buffer_to_stream_ops(op->data.message, &calld->outgoing_sopb); calld->outgoing_buffer_length_estimate += @@ -266,9 +267,9 @@ static void destroy_channel_elem(grpc_channel_element *elem) { } const grpc_channel_filter grpc_connected_channel_filter = { - call_op, channel_op, sizeof(call_data), - init_call_elem, destroy_call_elem, sizeof(channel_data), - init_channel_elem, destroy_channel_elem, "connected", }; + call_op, channel_op, sizeof(call_data), init_call_elem, destroy_call_elem, + sizeof(channel_data), init_channel_elem, destroy_channel_elem, "connected", +}; static gpr_slice alloc_recv_buffer(void *user_data, grpc_transport *transport, grpc_stream *stream, size_t size_hint) { @@ -314,8 +315,8 @@ static void finish_message(channel_data *chand, call_data *calld) { call_op.type = GRPC_RECV_MESSAGE; call_op.done_cb = do_nothing; /* TODO(ctiller): this could be a lot faster if coded directly */ - call_op.data.message = grpc_byte_buffer_create( - calld->incoming_message.slices, calld->incoming_message.count); + call_op.data.message = grpc_byte_buffer_create(calld->incoming_message.slices, + calld->incoming_message.count); gpr_slice_buffer_reset_and_unref(&calld->incoming_message); /* disable window updates until we get a request more from above */ @@ -327,14 +328,15 @@ static void finish_message(channel_data *chand, call_data *calld) { grpc_call_next_op(elem, &call_op); } -static void metadata_done_cb(void *ptr, grpc_op_error error) { - gpr_free(ptr); -} +static void metadata_done_cb(void *ptr, grpc_op_error error) { gpr_free(ptr); } static void add_incoming_metadata(call_data *calld, grpc_mdelem *elem) { if (calld->incoming_metadata_count == calld->incoming_metadata_capacity) { - calld->incoming_metadata_capacity = GPR_MAX(8, 2 * calld->incoming_metadata_capacity); - calld->incoming_metadata = gpr_realloc(calld->incoming_metadata, sizeof(*calld->incoming_metadata) * calld->incoming_metadata_capacity); + calld->incoming_metadata_capacity = + GPR_MAX(8, 2 * calld->incoming_metadata_capacity); + calld->incoming_metadata = gpr_realloc( + calld->incoming_metadata, + sizeof(*calld->incoming_metadata) * calld->incoming_metadata_capacity); } calld->incoming_metadata[calld->incoming_metadata_count++].md = elem; } @@ -345,19 +347,21 @@ static void flush_metadata(grpc_call_element *elem) { size_t i; for (i = 1; i < calld->incoming_metadata_count; i++) { - calld->incoming_metadata[i].prev = &calld->incoming_metadata[i-1]; + calld->incoming_metadata[i].prev = &calld->incoming_metadata[i - 1]; } for (i = 0; i < calld->incoming_metadata_count - 1; i++) { - calld->incoming_metadata[i].next = &calld->incoming_metadata[i+1]; + calld->incoming_metadata[i].next = &calld->incoming_metadata[i + 1]; } - calld->incoming_metadata[0].prev = calld->incoming_metadata[calld->incoming_metadata_count-1].next = NULL; + calld->incoming_metadata[0].prev = + calld->incoming_metadata[calld->incoming_metadata_count - 1].next = NULL; op.type = GRPC_RECV_METADATA; op.dir = GRPC_CALL_UP; op.flags = 0; op.data.metadata.list.head = &calld->incoming_metadata[0]; - op.data.metadata.list.tail = &calld->incoming_metadata[calld->incoming_metadata_count - 1]; + op.data.metadata.list.tail = + &calld->incoming_metadata[calld->incoming_metadata_count - 1]; op.data.metadata.garbage.head = op.data.metadata.garbage.tail = NULL; op.data.metadata.deadline = calld->deadline; op.done_cb = metadata_done_cb; @@ -525,7 +529,8 @@ static void transport_closed(void *user_data, grpc_transport *transport) { const grpc_transport_callbacks connected_channel_transport_callbacks = { alloc_recv_buffer, accept_stream, recv_batch, - transport_goaway, transport_closed, }; + transport_goaway, transport_closed, +}; grpc_transport_setup_result grpc_connected_channel_bind_transport( grpc_channel_stack *channel_stack, grpc_transport *transport) { diff --git a/src/core/channel/http_client_filter.c b/src/core/channel/http_client_filter.c index 5506fa180a6..fd3a15d9df2 100644 --- a/src/core/channel/http_client_filter.c +++ b/src/core/channel/http_client_filter.c @@ -80,10 +80,14 @@ static void call_op(grpc_call_element *elem, grpc_call_element *from_elem, case GRPC_SEND_METADATA: /* Send : prefixed headers, which have to be before any application * layer headers. */ - grpc_call_op_metadata_add_head(&op->data.metadata, &calld->method, grpc_mdelem_ref(channeld->method)); - grpc_call_op_metadata_add_head(&op->data.metadata, &calld->scheme, grpc_mdelem_ref(channeld->scheme)); - grpc_call_op_metadata_add_tail(&op->data.metadata, &calld->te_trailers, grpc_mdelem_ref(channeld->te_trailers)); - grpc_call_op_metadata_add_tail(&op->data.metadata, &calld->content_type, grpc_mdelem_ref(channeld->content_type)); + grpc_call_op_metadata_add_head(&op->data.metadata, &calld->method, + grpc_mdelem_ref(channeld->method)); + grpc_call_op_metadata_add_head(&op->data.metadata, &calld->scheme, + grpc_mdelem_ref(channeld->scheme)); + grpc_call_op_metadata_add_tail(&op->data.metadata, &calld->te_trailers, + grpc_mdelem_ref(channeld->te_trailers)); + grpc_call_op_metadata_add_tail(&op->data.metadata, &calld->content_type, + grpc_mdelem_ref(channeld->content_type)); grpc_call_next_op(elem, op); break; case GRPC_RECV_METADATA: @@ -116,8 +120,7 @@ static void channel_op(grpc_channel_element *elem, /* Constructor for call_data */ static void init_call_elem(grpc_call_element *elem, - const void *server_transport_data) { -} + const void *server_transport_data) {} /* Destructor for call_data */ static void destroy_call_elem(grpc_call_element *elem) { @@ -178,6 +181,6 @@ static void destroy_channel_elem(grpc_channel_element *elem) { } const grpc_channel_filter grpc_http_client_filter = { - call_op, channel_op, sizeof(call_data), - init_call_elem, destroy_call_elem, sizeof(channel_data), - init_channel_elem, destroy_channel_elem, "http-client"}; + call_op, channel_op, sizeof(call_data), init_call_elem, destroy_call_elem, + sizeof(channel_data), init_channel_elem, destroy_channel_elem, + "http-client"}; diff --git a/src/core/channel/http_server_filter.c b/src/core/channel/http_server_filter.c index 535bcfdca7b..432b41908a1 100644 --- a/src/core/channel/http_server_filter.c +++ b/src/core/channel/http_server_filter.c @@ -83,12 +83,9 @@ static grpc_mdelem *server_filter(void *user_data, grpc_mdelem *md) { call_data *calld = elem->call_data; /* Check if it is one of the headers we care about. */ - if (md == channeld->te_trailers || - md == channeld->method_post || - md == channeld->http_scheme || - md == channeld->https_scheme || - md == channeld->grpc_scheme || - md == channeld->content_type) { + if (md == channeld->te_trailers || md == channeld->method_post || + md == channeld->http_scheme || md == channeld->https_scheme || + md == channeld->grpc_scheme || md == channeld->content_type) { /* swallow it */ if (md == channeld->method_post) { calld->seen_post = 1; @@ -101,8 +98,8 @@ static grpc_mdelem *server_filter(void *user_data, grpc_mdelem *md) { require */ return NULL; } else if (md->key == channeld->content_type->key) { - if (strncmp(grpc_mdstr_as_c_string(md->value), - "application/grpc+", 17) == 0) { + if (strncmp(grpc_mdstr_as_c_string(md->value), "application/grpc+", 17) == + 0) { /* Although the C implementation doesn't (currently) generate them, any custom +-suffix is explicitly valid. */ @@ -121,8 +118,7 @@ static grpc_mdelem *server_filter(void *user_data, grpc_mdelem *md) { md->key == channeld->http_scheme->key || md->key == channeld->content_type->key) { gpr_log(GPR_ERROR, "Invalid %s: header: '%s'", - grpc_mdstr_as_c_string(md->key), - grpc_mdstr_as_c_string(md->value)); + grpc_mdstr_as_c_string(md->key), grpc_mdstr_as_c_string(md->value)); /* swallow it and error everything out. */ /* TODO(klempner): We ought to generate more descriptive error messages on the wire here. */ @@ -168,8 +164,8 @@ static void call_op(grpc_call_element *elem, grpc_call_element *from_elem, /* Have we seen the required http2 transport headers? (:method, :scheme, content-type, with :path and :authority covered at the channel level right now) */ - if (calld->seen_post && calld->seen_scheme && - calld->seen_te_trailers && calld->seen_path) { + if (calld->seen_post && calld->seen_scheme && calld->seen_te_trailers && + calld->seen_path) { grpc_call_next_op(elem, op); } else { if (!calld->seen_post) { @@ -192,7 +188,8 @@ static void call_op(grpc_call_element *elem, grpc_call_element *from_elem, case GRPC_SEND_METADATA: /* If we haven't sent status 200 yet, we need to so so because it needs to come before any non : prefixed metadata. */ - grpc_call_op_metadata_add_head(&op->data.metadata, &calld->status, grpc_mdelem_ref(channeld->status_ok)); + grpc_call_op_metadata_add_head(&op->data.metadata, &calld->status, + grpc_mdelem_ref(channeld->status_ok)); grpc_call_next_op(elem, op); break; default: @@ -233,8 +230,7 @@ static void init_call_elem(grpc_call_element *elem, } /* Destructor for call_data */ -static void destroy_call_elem(grpc_call_element *elem) { -} +static void destroy_call_elem(grpc_call_element *elem) {} /* Constructor for channel_data */ static void init_channel_elem(grpc_channel_element *elem, diff --git a/src/core/security/auth.c b/src/core/security/auth.c index 14e06dd3109..6c87aab7370 100644 --- a/src/core/security/auth.c +++ b/src/core/security/auth.c @@ -79,7 +79,8 @@ static void on_credentials_metadata(void *user_data, grpc_mdelem **md_elems, size_t i; GPR_ASSERT(num_md <= MAX_CREDENTIAL_METADATA_COUNT); for (i = 0; i < num_md; i++) { - grpc_call_op_metadata_add_tail(&op.data.metadata, &calld->md_links[i], grpc_mdelem_ref(md_elems[i])); + grpc_call_op_metadata_add_tail(&op.data.metadata, &calld->md_links[i], + grpc_mdelem_ref(md_elems[i])); } grpc_call_next_op(elem, &op); } @@ -164,7 +165,8 @@ static void call_op(grpc_call_element *elem, grpc_call_element *from_elem, case GRPC_SEND_METADATA: for (l = op->data.metadata.list.head; l; l = l->next) { grpc_mdelem *md = l->md; - /* Pointer comparison is OK for md_elems created from the same context. */ + /* Pointer comparison is OK for md_elems created from the same context. + */ if (md->key == channeld->authority_string) { if (calld->host != NULL) grpc_mdstr_unref(calld->host); calld->host = grpc_mdstr_ref(md->value); @@ -264,7 +266,8 @@ static void init_channel_elem(grpc_channel_element *elem, channeld->path_string = grpc_mdstr_from_string(channeld->md_ctx, ":path"); channeld->error_msg_key = grpc_mdstr_from_string(channeld->md_ctx, "grpc-message"); - channeld->status_key = grpc_mdstr_from_string(channeld->md_ctx, "grpc-status"); + channeld->status_key = + grpc_mdstr_from_string(channeld->md_ctx, "grpc-status"); } /* Destructor for channel data */ @@ -288,6 +291,5 @@ static void destroy_channel_elem(grpc_channel_element *elem) { } const grpc_channel_filter grpc_client_auth_filter = { - call_op, channel_op, sizeof(call_data), - init_call_elem, destroy_call_elem, sizeof(channel_data), - init_channel_elem, destroy_channel_elem, "auth"}; + call_op, channel_op, sizeof(call_data), init_call_elem, destroy_call_elem, + sizeof(channel_data), init_channel_elem, destroy_channel_elem, "auth"}; diff --git a/src/core/surface/call.c b/src/core/surface/call.c index 9c0c65e21c5..bd3374297e6 100644 --- a/src/core/surface/call.c +++ b/src/core/surface/call.c @@ -217,7 +217,7 @@ struct grpc_call { legacy_state *legacy_state; }; -#define CALL_STACK_FROM_CALL(call) ((grpc_call_stack *)((call)+1)) +#define CALL_STACK_FROM_CALL(call) ((grpc_call_stack *)((call) + 1)) #define CALL_FROM_CALL_STACK(call_stack) (((grpc_call *)(call_stack)) - 1) #define CALL_ELEM_FROM_CALL(call, idx) \ grpc_call_stack_element(CALL_STACK_FROM_CALL(call), idx) @@ -237,8 +237,10 @@ static void enact_send_action(grpc_call *call, send_action sa); static void set_deadline_alarm(grpc_call *call, gpr_timespec deadline); grpc_call *grpc_call_create(grpc_channel *channel, grpc_completion_queue *cq, - const void *server_transport_data, grpc_mdelem **add_initial_metadata, - size_t add_initial_metadata_count, gpr_timespec send_deadline) { + const void *server_transport_data, + grpc_mdelem **add_initial_metadata, + size_t add_initial_metadata_count, + gpr_timespec send_deadline) { size_t i; grpc_channel_stack *channel_stack = grpc_channel_get_channel_stack(channel); grpc_call *call = @@ -606,7 +608,8 @@ static send_action choose_send_action(grpc_call *call) { return SEND_NOTHING; } -static grpc_mdelem_list chain_metadata_from_app(grpc_call *call, size_t count, grpc_metadata *metadata) { +static grpc_mdelem_list chain_metadata_from_app(grpc_call *call, size_t count, + grpc_metadata *metadata) { size_t i; grpc_mdelem_list out; if (count == 0) { @@ -615,18 +618,18 @@ static grpc_mdelem_list chain_metadata_from_app(grpc_call *call, size_t count, g } for (i = 0; i < count; i++) { grpc_metadata *md = &metadata[i]; - grpc_metadata *next_md = (i == count-1) ? NULL : &metadata[i+1]; - grpc_metadata *prev_md = (i == 0) ? NULL : &metadata[i-1]; - grpc_linked_mdelem *l = (grpc_linked_mdelem*)&md->internal_data; + grpc_metadata *next_md = (i == count - 1) ? NULL : &metadata[i + 1]; + grpc_metadata *prev_md = (i == 0) ? NULL : &metadata[i - 1]; + grpc_linked_mdelem *l = (grpc_linked_mdelem *)&md->internal_data; assert(sizeof(grpc_linked_mdelem) == sizeof(md->internal_data)); - l->md = grpc_mdelem_from_string_and_buffer( - call->metadata_context, md->key, - (const gpr_uint8 *)md->value, md->value_length); - l->next = next_md ? (grpc_linked_mdelem*)&next_md->internal_data : NULL; - l->prev = prev_md ? (grpc_linked_mdelem*)&prev_md->internal_data : NULL; + l->md = grpc_mdelem_from_string_and_buffer(call->metadata_context, md->key, + (const gpr_uint8 *)md->value, + md->value_length); + l->next = next_md ? (grpc_linked_mdelem *)&next_md->internal_data : NULL; + l->prev = prev_md ? (grpc_linked_mdelem *)&prev_md->internal_data : NULL; } - out.head = (grpc_linked_mdelem*)&(metadata[0].internal_data); - out.tail = (grpc_linked_mdelem*)&(metadata[count-1].internal_data); + out.head = (grpc_linked_mdelem *)&(metadata[0].internal_data); + out.tail = (grpc_linked_mdelem *)&(metadata[count - 1].internal_data); return out; } @@ -649,11 +652,13 @@ static void enact_send_action(grpc_call *call, send_action sa) { op.type = GRPC_SEND_METADATA; op.dir = GRPC_CALL_DOWN; op.flags = flags; - op.data.metadata.list = chain_metadata_from_app(call, data.send_metadata.count, data.send_metadata.metadata); + op.data.metadata.list = chain_metadata_from_app( + call, data.send_metadata.count, data.send_metadata.metadata); op.data.metadata.garbage.head = op.data.metadata.garbage.tail = NULL; op.data.metadata.deadline = call->send_deadline; for (i = 0; i < call->send_initial_metadata_count; i++) { - grpc_call_op_metadata_link_head(&op.data.metadata, &call->send_initial_metadata[i]); + grpc_call_op_metadata_link_head(&op.data.metadata, + &call->send_initial_metadata[i]); } op.done_cb = do_nothing; op.user_data = NULL; @@ -685,20 +690,23 @@ static void enact_send_action(grpc_call *call, send_action sa) { op.type = GRPC_SEND_METADATA; op.dir = GRPC_CALL_DOWN; op.flags = flags; - op.data.metadata.list = chain_metadata_from_app(call, data.send_metadata.count, data.send_metadata.metadata); + op.data.metadata.list = chain_metadata_from_app( + call, data.send_metadata.count, data.send_metadata.metadata); op.data.metadata.garbage.head = op.data.metadata.garbage.tail = NULL; op.data.metadata.deadline = call->send_deadline; /* send status */ /* TODO(ctiller): cache common status values */ data = call->request_data[GRPC_IOREQ_SEND_STATUS]; gpr_ltoa(data.send_status.code, status_str); - grpc_call_op_metadata_add_tail(&op.data.metadata, &call->status_link, - grpc_mdelem_from_metadata_strings( + grpc_call_op_metadata_add_tail( + &op.data.metadata, &call->status_link, + grpc_mdelem_from_metadata_strings( call->metadata_context, grpc_mdstr_ref(grpc_channel_get_status_string(call->channel)), grpc_mdstr_from_string(call->metadata_context, status_str))); if (data.send_status.details) { - grpc_call_op_metadata_add_tail(&op.data.metadata, &call->details_link, + grpc_call_op_metadata_add_tail( + &op.data.metadata, &call->details_link, grpc_mdelem_from_metadata_strings( call->metadata_context, grpc_mdstr_ref(grpc_channel_get_message_string(call->channel)), @@ -953,7 +961,7 @@ static gpr_uint32 decode_status(grpc_mdelem *md) { gpr_uint32 status; void *user_data = grpc_mdelem_get_user_data(md, destroy_status); if (user_data) { - status = ((gpr_uint32)(gpr_intptr) user_data) - STATUS_OFFSET; + status = ((gpr_uint32)(gpr_intptr)user_data) - STATUS_OFFSET; } else { if (!gpr_parse_bytes_to_uint32(grpc_mdstr_as_c_string(md->value), GPR_SLICE_LENGTH(md->value->slice), @@ -975,7 +983,8 @@ void grpc_call_recv_message(grpc_call_element *elem, unlock(call); } -int grpc_call_recv_metadata(grpc_call_element *elem, grpc_call_op_metadata *md) { +int grpc_call_recv_metadata(grpc_call_element *elem, + grpc_call_op_metadata *md) { grpc_call *call = CALL_FROM_TOP_ELEM(elem); grpc_linked_mdelem *l; grpc_metadata_array *dest; @@ -1005,8 +1014,9 @@ int grpc_call_recv_metadata(grpc_call_element *elem, grpc_call_op_metadata *md) mdusr->value = grpc_mdstr_as_c_string(md->value); mdusr->value_length = GPR_SLICE_LENGTH(md->value->slice); if (call->owned_metadata_count == call->owned_metadata_capacity) { - call->owned_metadata_capacity = GPR_MAX( - call->owned_metadata_capacity + 8, call->owned_metadata_capacity * 2); + call->owned_metadata_capacity = + GPR_MAX(call->owned_metadata_capacity + 8, + call->owned_metadata_capacity * 2); call->owned_metadata = gpr_realloc(call->owned_metadata, sizeof(grpc_mdelem *) * call->owned_metadata_capacity); diff --git a/src/core/surface/call.h b/src/core/surface/call.h index 25b0fd3cc0f..93c5e8e3f3b 100644 --- a/src/core/surface/call.h +++ b/src/core/surface/call.h @@ -85,8 +85,10 @@ typedef void (*grpc_ioreq_completion_func)(grpc_call *call, void *user_data); grpc_call *grpc_call_create(grpc_channel *channel, grpc_completion_queue *cq, - const void *server_transport_data, grpc_mdelem **add_initial_metadata, - size_t add_initial_metadata_count, gpr_timespec send_deadline); + const void *server_transport_data, + grpc_mdelem **add_initial_metadata, + size_t add_initial_metadata_count, + gpr_timespec send_deadline); void grpc_call_set_completion_queue(grpc_call *call, grpc_completion_queue *cq); grpc_completion_queue *grpc_call_get_completion_queue(grpc_call *call); @@ -98,7 +100,7 @@ void grpc_call_internal_unref(grpc_call *call, int allow_immediate_deletion); the completion queue/surface layer */ /* receive metadata - returns 1 if this was initial metadata */ int grpc_call_recv_metadata(grpc_call_element *surface_element, - grpc_call_op_metadata *md); + grpc_call_op_metadata *md); void grpc_call_recv_message(grpc_call_element *surface_element, grpc_byte_buffer *message); void grpc_call_read_closed(grpc_call_element *surface_element); @@ -123,4 +125,4 @@ void grpc_call_log_batch(char *file, int line, gpr_log_severity severity, #define GRPC_CALL_LOG_BATCH(sev, call, ops, nops, tag) \ if (grpc_trace_batch) grpc_call_log_batch(sev, call, ops, nops, tag) -#endif /* GRPC_INTERNAL_CORE_SURFACE_CALL_H */ +#endif /* GRPC_INTERNAL_CORE_SURFACE_CALL_H */ diff --git a/src/core/surface/client.c b/src/core/surface/client.c index 71ca26e65db..b987c2de5f6 100644 --- a/src/core/surface/client.c +++ b/src/core/surface/client.c @@ -39,13 +39,9 @@ #include #include -typedef struct { - void *unused; -} call_data; +typedef struct { void *unused; } call_data; -typedef struct { - void *unused; -} channel_data; +typedef struct { void *unused; } channel_data; static void call_op(grpc_call_element *elem, grpc_call_element *from_elem, grpc_call_op *op) { @@ -104,6 +100,6 @@ static void init_channel_elem(grpc_channel_element *elem, static void destroy_channel_elem(grpc_channel_element *elem) {} const grpc_channel_filter grpc_client_surface_filter = { - call_op, channel_op, sizeof(call_data), - init_call_elem, destroy_call_elem, sizeof(channel_data), - init_channel_elem, destroy_channel_elem, "client", }; + call_op, channel_op, sizeof(call_data), init_call_elem, destroy_call_elem, + sizeof(channel_data), init_channel_elem, destroy_channel_elem, "client", +}; diff --git a/src/core/surface/lame_client.c b/src/core/surface/lame_client.c index f2497e28e6a..74e9628385c 100644 --- a/src/core/surface/lame_client.c +++ b/src/core/surface/lame_client.c @@ -42,13 +42,9 @@ #include #include -typedef struct { - void *unused; -} call_data; +typedef struct { void *unused; } call_data; -typedef struct { - void *unused; -} channel_data; +typedef struct { void *unused; } channel_data; static void call_op(grpc_call_element *elem, grpc_call_element *from_elem, grpc_call_op *op) { @@ -56,7 +52,8 @@ static void call_op(grpc_call_element *elem, grpc_call_element *from_elem, switch (op->type) { case GRPC_SEND_START: - grpc_call_element_recv_status(elem, GRPC_STATUS_UNKNOWN, "Rpc sent on a lame channel."); + grpc_call_element_recv_status(elem, GRPC_STATUS_UNKNOWN, + "Rpc sent on a lame channel."); grpc_call_stream_closed(elem); break; case GRPC_SEND_METADATA: @@ -95,13 +92,13 @@ static void init_channel_elem(grpc_channel_element *elem, GPR_ASSERT(is_last); } -static void destroy_channel_elem(grpc_channel_element *elem) { -} +static void destroy_channel_elem(grpc_channel_element *elem) {} static const grpc_channel_filter lame_filter = { - call_op, channel_op, sizeof(call_data), - init_call_elem, destroy_call_elem, sizeof(channel_data), - init_channel_elem, destroy_channel_elem, "lame-client", }; + call_op, channel_op, sizeof(call_data), init_call_elem, destroy_call_elem, + sizeof(channel_data), init_channel_elem, destroy_channel_elem, + "lame-client", +}; grpc_channel *grpc_lame_client_channel_create(void) { static const grpc_channel_filter *filters[] = {&lame_filter}; diff --git a/src/core/surface/server.c b/src/core/surface/server.c index e0d7950dea7..f5ff9409f3a 100644 --- a/src/core/surface/server.c +++ b/src/core/surface/server.c @@ -463,7 +463,8 @@ static void channel_op(grpc_channel_element *elem, case GRPC_ACCEPT_CALL: /* create a call */ grpc_call_create(chand->channel, NULL, - op->data.accept_call.transport_server_data, NULL, 0, gpr_inf_future); + op->data.accept_call.transport_server_data, NULL, 0, + gpr_inf_future); break; case GRPC_TRANSPORT_CLOSED: /* if the transport is closed for a server channel, we destroy the