From ab33b488c42c1238b1b2ebbf3bf4f0db61103497 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Sat, 21 Nov 2015 08:11:04 -0800 Subject: clang-format, bugfix --- src/core/surface/lame_client.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/core/surface/lame_client.c') diff --git a/src/core/surface/lame_client.c b/src/core/surface/lame_client.c index 0247116ebb..4a55544ac1 100644 --- a/src/core/surface/lame_client.c +++ b/src/core/surface/lame_client.c @@ -103,8 +103,7 @@ static void lame_start_transport_op(grpc_exec_ctx *exec_ctx, } static void init_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, - grpc_call_element_args *args) { -} + grpc_call_element_args *args) {} static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) {} -- cgit v1.2.3 From 7b4356194d33c4582c487d0004ef17ea7b138839 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 24 Nov 2015 08:15:05 -0800 Subject: Finish initial scrape, clang-format --- src/core/channel/channel_stack.c | 6 +- src/core/channel/channel_stack.h | 13 ++-- src/core/channel/client_uchannel.c | 7 +- src/core/channel/client_uchannel.h | 2 +- src/core/channel/connected_channel.c | 6 +- src/core/channel/subchannel_call_holder.c | 4 +- src/core/client_config/subchannel.c | 15 ++--- src/core/client_config/subchannel.h | 4 +- src/core/iomgr/tcp_server.h | 3 +- src/core/iomgr/tcp_server_posix.c | 13 ++-- src/core/iomgr/tcp_server_windows.c | 10 +-- src/core/surface/call.c | 21 +++--- src/core/surface/channel.c | 43 ++++++------- src/core/surface/channel_connectivity.c | 33 ++-------- src/core/surface/channel_create.c | 1 - src/core/surface/lame_client.c | 6 +- src/core/transport/metadata.c | 6 +- src/core/transport/static_metadata.c | 103 +++++------------------------- test/core/channel/channel_stack_test.c | 25 +++++--- test/core/end2end/tests/hpack_size.c | 6 +- test/core/util/reconnect_server.c | 3 +- 21 files changed, 116 insertions(+), 214 deletions(-) (limited to 'src/core/surface/lame_client.c') diff --git a/src/core/channel/channel_stack.c b/src/core/channel/channel_stack.c index 53433a0923..54b0375c25 100644 --- a/src/core/channel/channel_stack.c +++ b/src/core/channel/channel_stack.c @@ -101,10 +101,10 @@ grpc_call_element *grpc_call_stack_element(grpc_call_stack *call_stack, return CALL_ELEMS_FROM_STACK(call_stack) + index; } -void grpc_channel_stack_init(grpc_exec_ctx *exec_ctx,int initial_refs, - grpc_iomgr_cb_func destroy, void *destroy_arg, +void grpc_channel_stack_init(grpc_exec_ctx *exec_ctx, int initial_refs, + grpc_iomgr_cb_func destroy, void *destroy_arg, const grpc_channel_filter **filters, - size_t filter_count, + size_t filter_count, const grpc_channel_args *channel_args, grpc_channel_stack *stack) { size_t call_size = diff --git a/src/core/channel/channel_stack.h b/src/core/channel/channel_stack.h index 593adcd7b5..766f543404 100644 --- a/src/core/channel/channel_stack.h +++ b/src/core/channel/channel_stack.h @@ -179,11 +179,10 @@ grpc_call_element *grpc_call_stack_element(grpc_call_stack *stack, size_t i); size_t grpc_channel_stack_size(const grpc_channel_filter **filters, size_t filter_count); /* Initialize a channel stack given some filters */ -void grpc_channel_stack_init(grpc_exec_ctx *exec_ctx,int initial_refs, - grpc_iomgr_cb_func destroy, void *destroy_arg, +void grpc_channel_stack_init(grpc_exec_ctx *exec_ctx, int initial_refs, + grpc_iomgr_cb_func destroy, void *destroy_arg, const grpc_channel_filter **filters, - size_t filter_count, - const grpc_channel_args *args, + size_t filter_count, const grpc_channel_args *args, grpc_channel_stack *stack); /* Destroy a channel stack */ void grpc_channel_stack_destroy(grpc_exec_ctx *exec_ctx, @@ -213,10 +212,12 @@ void grpc_call_stack_set_pollset(grpc_exec_ctx *exec_ctx, #define GRPC_CHANNEL_STACK_UNREF(exec_ctx, channel_stack, reason) \ grpc_stream_unref(exec_ctx, &(channel_stack)->refcount, reason) #else -#define GRPC_CALL_STACK_REF(call_stack, reason) grpc_stream_ref(&(call_stack)->refcount) +#define GRPC_CALL_STACK_REF(call_stack, reason) \ + grpc_stream_ref(&(call_stack)->refcount) #define GRPC_CALL_STACK_UNREF(exec_ctx, call_stack, reason) \ grpc_stream_unref(exec_ctx, &(call_stack)->refcount) -#define GRPC_CHANNEL_STACK_REF(channel_stack, reason) grpc_stream_ref(&(channel_stack)->refcount) +#define GRPC_CHANNEL_STACK_REF(channel_stack, reason) \ + grpc_stream_ref(&(channel_stack)->refcount) #define GRPC_CHANNEL_STACK_UNREF(exec_ctx, channel_stack, reason) \ grpc_stream_unref(exec_ctx, &(channel_stack)->refcount) #endif diff --git a/src/core/channel/client_uchannel.c b/src/core/channel/client_uchannel.c index b30d030197..ff50ebfb60 100644 --- a/src/core/channel/client_uchannel.c +++ b/src/core/channel/client_uchannel.c @@ -205,7 +205,7 @@ grpc_connectivity_state grpc_client_uchannel_check_connectivity_state( } void grpc_client_uchannel_watch_connectivity_state( - grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, + grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, grpc_pollset *pollset, grpc_connectivity_state *state, grpc_closure *on_complete) { channel_data *chand = elem->channel_data; gpr_mu_lock(&chand->mu_state); @@ -219,8 +219,6 @@ grpc_channel *grpc_client_uchannel_create(grpc_subchannel *subchannel, grpc_channel *channel = NULL; #define MAX_FILTERS 3 const grpc_channel_filter *filters[MAX_FILTERS]; - grpc_channel *master = grpc_subchannel_get_master(subchannel); - char *target = grpc_channel_get_target(master); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; size_t n = 0; @@ -232,9 +230,8 @@ grpc_channel *grpc_client_uchannel_create(grpc_subchannel *subchannel, GPR_ASSERT(n <= MAX_FILTERS); channel = - grpc_channel_create_from_filters(&exec_ctx, target, filters, n, args, 1); + grpc_channel_create_from_filters(&exec_ctx, NULL, filters, n, args, 1); - gpr_free(target); return channel; } diff --git a/src/core/channel/client_uchannel.h b/src/core/channel/client_uchannel.h index a5cf271042..92a831493c 100644 --- a/src/core/channel/client_uchannel.h +++ b/src/core/channel/client_uchannel.h @@ -48,7 +48,7 @@ grpc_connectivity_state grpc_client_uchannel_check_connectivity_state( grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, int try_to_connect); void grpc_client_uchannel_watch_connectivity_state( - grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, + grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, grpc_pollset *pollset, grpc_connectivity_state *state, grpc_closure *on_complete); grpc_channel *grpc_client_uchannel_create(grpc_subchannel *subchannel, diff --git a/src/core/channel/connected_channel.c b/src/core/channel/connected_channel.c index 73a7dcc81f..e8eb9dcfc5 100644 --- a/src/core/channel/connected_channel.c +++ b/src/core/channel/connected_channel.c @@ -89,9 +89,9 @@ static void init_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, int r; GPR_ASSERT(elem->filter == &grpc_connected_channel_filter); - r = grpc_transport_init_stream(exec_ctx, chand->transport, - TRANSPORT_STREAM_FROM_CALL_DATA(calld), - &args->call_stack->refcount, args->server_transport_data); + r = grpc_transport_init_stream( + exec_ctx, chand->transport, TRANSPORT_STREAM_FROM_CALL_DATA(calld), + &args->call_stack->refcount, args->server_transport_data); GPR_ASSERT(r == 0); } diff --git a/src/core/channel/subchannel_call_holder.c b/src/core/channel/subchannel_call_holder.c index 63069baa84..9875dd8080 100644 --- a/src/core/channel/subchannel_call_holder.c +++ b/src/core/channel/subchannel_call_holder.c @@ -243,8 +243,8 @@ static void fail_locked(grpc_exec_ctx *exec_ctx, holder->waiting_ops_count = 0; } -char *grpc_subchannel_call_holder_get_peer(grpc_exec_ctx *exec_ctx, - grpc_subchannel_call_holder *holder) { +char *grpc_subchannel_call_holder_get_peer( + grpc_exec_ctx *exec_ctx, grpc_subchannel_call_holder *holder) { grpc_subchannel_call *subchannel_call = GET_CALL(holder); if (subchannel_call) { diff --git a/src/core/client_config/subchannel.c b/src/core/client_config/subchannel.c index 6cc2364eaa..c84ef54eef 100644 --- a/src/core/client_config/subchannel.c +++ b/src/core/client_config/subchannel.c @@ -173,15 +173,16 @@ static void connection_destroy(grpc_exec_ctx *exec_ctx, void *arg, gpr_free(c); } -void grpc_connected_subchannel_ref( - grpc_connected_subchannel *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) { +void grpc_connected_subchannel_ref(grpc_connected_subchannel *c + GRPC_SUBCHANNEL_REF_EXTRA_ARGS) { GRPC_CHANNEL_STACK_REF(CHANNEL_STACK_FROM_CONNECTION(c), REF_REASON); } void grpc_connected_subchannel_unref(grpc_exec_ctx *exec_ctx, grpc_connected_subchannel *c GRPC_SUBCHANNEL_REF_EXTRA_ARGS) { - GRPC_CHANNEL_STACK_UNREF(exec_ctx, CHANNEL_STACK_FROM_CONNECTION(c), REF_REASON); + GRPC_CHANNEL_STACK_UNREF(exec_ctx, CHANNEL_STACK_FROM_CONNECTION(c), + REF_REASON); } /* @@ -432,8 +433,8 @@ static void publish_transport(grpc_exec_ctx *exec_ctx, grpc_subchannel *c) { channel_stack_size = grpc_channel_stack_size(filters, num_filters); con = gpr_malloc(channel_stack_size); stk = CHANNEL_STACK_FROM_CONNECTION(con); - grpc_channel_stack_init(exec_ctx, 1, connection_destroy, con, filters, num_filters, c->args, - stk); + grpc_channel_stack_init(exec_ctx, 1, connection_destroy, con, filters, + num_filters, c->args, stk); grpc_connected_channel_bind_transport(stk, c->connecting_result.transport); gpr_free((void *)c->connecting_result.filters); memset(&c->connecting_result, 0, sizeof(c->connecting_result)); @@ -626,10 +627,6 @@ grpc_subchannel_call *grpc_connected_subchannel_create_call( return call; } -grpc_channel *grpc_subchannel_get_master(grpc_subchannel *subchannel) { - return subchannel->master; -} - grpc_call_stack *grpc_subchannel_call_get_call_stack( grpc_subchannel_call *subchannel_call) { return SUBCHANNEL_CALL_TO_CALL_STACK(subchannel_call); diff --git a/src/core/client_config/subchannel.h b/src/core/client_config/subchannel.h index b7db363866..b50d1e8ecc 100644 --- a/src/core/client_config/subchannel.h +++ b/src/core/client_config/subchannel.h @@ -77,8 +77,8 @@ void grpc_subchannel_ref(grpc_subchannel *channel void grpc_subchannel_unref(grpc_exec_ctx *exec_ctx, grpc_subchannel *channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS); -void grpc_connected_subchannel_ref( - grpc_connected_subchannel *channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS); +void grpc_connected_subchannel_ref(grpc_connected_subchannel *channel + GRPC_SUBCHANNEL_REF_EXTRA_ARGS); void grpc_connected_subchannel_unref(grpc_exec_ctx *exec_ctx, grpc_connected_subchannel *channel GRPC_SUBCHANNEL_REF_EXTRA_ARGS); diff --git a/src/core/iomgr/tcp_server.h b/src/core/iomgr/tcp_server.h index 3df36174e7..3294e13797 100644 --- a/src/core/iomgr/tcp_server.h +++ b/src/core/iomgr/tcp_server.h @@ -64,8 +64,7 @@ void grpc_tcp_server_start(grpc_exec_ctx *exec_ctx, grpc_tcp_server *server, /* TODO(ctiller): deprecate this, and make grpc_tcp_server_add_ports to handle all of the multiple socket port matching logic in one place */ grpc_tcp_listener *grpc_tcp_server_add_port(grpc_tcp_server *s, - const void *addr, - size_t addr_len); + const void *addr, size_t addr_len); /* Returns the file descriptor of the Nth listening socket on this server, or -1 if the index is out of bounds. diff --git a/src/core/iomgr/tcp_server_posix.c b/src/core/iomgr/tcp_server_posix.c index 1439dfcd6e..0ece77c4e8 100644 --- a/src/core/iomgr/tcp_server_posix.c +++ b/src/core/iomgr/tcp_server_posix.c @@ -374,8 +374,8 @@ error: } static grpc_tcp_listener *add_socket_to_server(grpc_tcp_server *s, int fd, - const struct sockaddr *addr, - size_t addr_len) { + const struct sockaddr *addr, + size_t addr_len) { grpc_tcp_listener *sp = NULL; int port; char *addr_str; @@ -410,8 +410,7 @@ static grpc_tcp_listener *add_socket_to_server(grpc_tcp_server *s, int fd, } grpc_tcp_listener *grpc_tcp_server_add_port(grpc_tcp_server *s, - const void *addr, - size_t addr_len) { + const void *addr, size_t addr_len) { int allocated_port = -1; grpc_tcp_listener *sp; grpc_tcp_listener *sp2 = NULL; @@ -499,7 +498,8 @@ done: int grpc_tcp_server_get_fd(grpc_tcp_server *s, unsigned port_index) { grpc_tcp_listener *sp; - for (sp = s->head; sp && port_index != 0; sp = sp->next, port_index--); + for (sp = s->head; sp && port_index != 0; sp = sp->next, port_index--) + ; if (port_index == 0 && sp) { return sp->fd; } else { @@ -527,8 +527,7 @@ void grpc_tcp_server_start(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s, } sp->read_closure.cb = on_read; sp->read_closure.cb_arg = sp; - grpc_fd_notify_on_read(exec_ctx, sp->emfd, - &sp->read_closure); + grpc_fd_notify_on_read(exec_ctx, sp->emfd, &sp->read_closure); s->active_ports++; } gpr_mu_unlock(&s->mu); diff --git a/src/core/iomgr/tcp_server_windows.c b/src/core/iomgr/tcp_server_windows.c index e4a1d7f498..a2425cd4d2 100644 --- a/src/core/iomgr/tcp_server_windows.c +++ b/src/core/iomgr/tcp_server_windows.c @@ -352,8 +352,8 @@ static void on_accept(grpc_exec_ctx *exec_ctx, void *arg, int from_iocp) { } static grpc_tcp_listener *add_socket_to_server(grpc_tcp_server *s, SOCKET sock, - const struct sockaddr *addr, - size_t addr_len) { + const struct sockaddr *addr, + size_t addr_len) { grpc_tcp_listener *sp = NULL; int port; int status; @@ -400,8 +400,7 @@ static grpc_tcp_listener *add_socket_to_server(grpc_tcp_server *s, SOCKET sock, } grpc_tcp_listener *grpc_tcp_server_add_port(grpc_tcp_server *s, - const void *addr, - size_t addr_len) { + const void *addr, size_t addr_len) { grpc_tcp_listener *sp; SOCKET sock; struct sockaddr_in6 addr6_v4mapped; @@ -459,7 +458,8 @@ grpc_tcp_listener *grpc_tcp_server_add_port(grpc_tcp_server *s, int grpc_tcp_server_get_fd(grpc_tcp_server *s, unsigned port_index) { grpc_tcp_listener *sp; - for (sp = s->head; sp && port_index != 0; sp = sp->next, port_index--); + for (sp = s->head; sp && port_index != 0; sp = sp->next, port_index--) + ; if (port_index == 0 && sp) { return _open_osfhandle(sp->socket->socket, 0); } else { diff --git a/src/core/surface/call.c b/src/core/surface/call.c index 49a0c7e04e..315eeb0449 100644 --- a/src/core/surface/call.c +++ b/src/core/surface/call.c @@ -341,21 +341,18 @@ grpc_completion_queue *grpc_call_get_completion_queue(grpc_call *call) { } #ifdef GRPC_STREAM_REFCOUNT_DEBUG -void grpc_call_internal_ref(grpc_call *c, const char *reason) { - grpc_call_stack_ref(CALL_STACK_FROM_CALL(c), reason); -} -void grpc_call_internal_unref(grpc_exec_ctx *exec_ctx, grpc_call *c, - const char *reason) { - grpc_call_stack_unref(exec_ctx, CALL_STACK_FROM_CALL(c), reason); -} +#define REF_REASON reason +#define REF_ARG , const char *reason #else -void grpc_call_internal_ref(grpc_call *c) { - grpc_call_stack_ref(CALL_STACK_FROM_CALL(c)); +#define REF_REASON "" +#define REF_ARG +#endif +void grpc_call_internal_ref(grpc_call *c REF_ARG) { + GRPC_CALL_STACK_REF(CALL_STACK_FROM_CALL(c), REF_REASON); } -void grpc_call_internal_unref(grpc_exec_ctx *exec_ctx, grpc_call *c) { - grpc_call_stack_unref(exec_ctx, CALL_STACK_FROM_CALL(c)); +void grpc_call_internal_unref(grpc_exec_ctx *exec_ctx, grpc_call *c REF_ARG) { + GRPC_CALL_STACK_UNREF(exec_ctx, CALL_STACK_FROM_CALL(c), REF_REASON); } -#endif static void destroy_call(grpc_exec_ctx *exec_ctx, void *call, int success) { size_t i; diff --git a/src/core/surface/channel.c b/src/core/surface/channel.c index 1632b79d0e..a78fd0aae2 100644 --- a/src/core/surface/channel.c +++ b/src/core/surface/channel.c @@ -80,6 +80,8 @@ struct grpc_channel { /* the protobuf library will (by default) start warning at 100megs */ #define DEFAULT_MAX_MESSAGE_LENGTH (100 * 1024 * 1024) +static void destroy_channel(grpc_exec_ctx *exec_ctx, void *arg, int success); + grpc_channel *grpc_channel_create_from_filters( grpc_exec_ctx *exec_ctx, const char *target, const grpc_channel_filter **filters, size_t num_filters, @@ -92,8 +94,6 @@ grpc_channel *grpc_channel_create_from_filters( channel->target = gpr_strdup(target); GPR_ASSERT(grpc_is_initialized() && "call grpc_init()"); channel->is_client = is_client; - /* decremented by grpc_channel_destroy */ - gpr_ref_init(&channel->refs, 1); gpr_mu_init(&channel->registered_call_mu); channel->registered_calls = NULL; @@ -151,7 +151,8 @@ grpc_channel *grpc_channel_create_from_filters( gpr_free(default_authority); } - grpc_channel_stack_init(exec_ctx, filters, num_filters, channel, args, + grpc_channel_stack_init(exec_ctx, 1, destroy_channel, channel, filters, + num_filters, args, CHANNEL_STACK_FROM_CHANNEL(channel)); return channel; @@ -248,17 +249,25 @@ grpc_call *grpc_channel_create_registered_call( rc->authority ? GRPC_MDELEM_REF(rc->authority) : NULL, deadline); } -#ifdef GRPC_CHANNEL_REF_COUNT_DEBUG -void grpc_channel_internal_ref(grpc_channel *c, const char *reason) { - gpr_log(GPR_DEBUG, "CHANNEL: ref %p %d -> %d [%s]", c, c->refs.count, - c->refs.count + 1, reason); +#ifdef GRPC_STREAM_REFCOUNT_DEBUG +#define REF_REASON reason +#define REF_ARG , const char *reason #else -void grpc_channel_internal_ref(grpc_channel *c) { +#define REF_REASON "" +#define REF_ARG #endif - gpr_ref(&c->refs); +void grpc_channel_internal_ref(grpc_channel *c REF_ARG) { + GRPC_CHANNEL_STACK_REF(CHANNEL_STACK_FROM_CHANNEL(c), REF_REASON); } -static void destroy_channel(grpc_exec_ctx *exec_ctx, grpc_channel *channel) { +void grpc_channel_internal_unref(grpc_exec_ctx *exec_ctx, + grpc_channel *c REF_ARG) { + GRPC_CHANNEL_STACK_UNREF(exec_ctx, CHANNEL_STACK_FROM_CHANNEL(c), REF_REASON); +} + +static void destroy_channel(grpc_exec_ctx *exec_ctx, void *arg, + int iomgr_success) { + grpc_channel *channel = arg; grpc_channel_stack_destroy(exec_ctx, CHANNEL_STACK_FROM_CHANNEL(channel)); while (channel->registered_calls) { registered_call *rc = channel->registered_calls; @@ -277,20 +286,6 @@ static void destroy_channel(grpc_exec_ctx *exec_ctx, grpc_channel *channel) { gpr_free(channel); } -#ifdef GRPC_CHANNEL_REF_COUNT_DEBUG -void grpc_channel_internal_unref(grpc_exec_ctx *exec_ctx, grpc_channel *channel, - const char *reason) { - gpr_log(GPR_DEBUG, "CHANNEL: unref %p %d -> %d [%s]", channel, - channel->refs.count, channel->refs.count - 1, reason); -#else -void grpc_channel_internal_unref(grpc_exec_ctx *exec_ctx, - grpc_channel *channel) { -#endif - if (gpr_unref(&channel->refs)) { - destroy_channel(exec_ctx, channel); - } -} - void grpc_channel_destroy(grpc_channel *channel) { grpc_transport_op op; grpc_channel_element *elem; diff --git a/src/core/surface/channel_connectivity.c b/src/core/surface/channel_connectivity.c index df2774b527..ad1c9b334e 100644 --- a/src/core/surface/channel_connectivity.c +++ b/src/core/surface/channel_connectivity.c @@ -83,7 +83,6 @@ typedef struct { gpr_mu mu; callback_phase phase; int success; - int removed; grpc_closure on_complete; grpc_timer alarm; grpc_connectivity_state state; @@ -135,30 +134,15 @@ static void finished_completion(grpc_exec_ctx *exec_ctx, void *pw, static void partly_done(grpc_exec_ctx *exec_ctx, state_watcher *w, int due_to_completion) { int delete = 0; - grpc_channel_element *client_channel_elem = NULL; - gpr_mu_lock(&w->mu); - if (w->removed == 0) { - w->removed = 1; - client_channel_elem = grpc_channel_stack_last_element( - grpc_channel_get_channel_stack(w->channel)); - if (client_channel_elem->filter == &grpc_client_channel_filter) { - grpc_client_channel_del_interested_party(exec_ctx, client_channel_elem, - grpc_cq_pollset(w->cq)); - } else { - grpc_client_uchannel_del_interested_party(exec_ctx, client_channel_elem, - grpc_cq_pollset(w->cq)); - } - } - gpr_mu_unlock(&w->mu); if (due_to_completion) { - gpr_mu_lock(&w->mu); - w->success = 1; - gpr_mu_unlock(&w->mu); grpc_timer_cancel(exec_ctx, &w->alarm); } gpr_mu_lock(&w->mu); + if (due_to_completion) { + w->success = 1; + } switch (w->phase) { case WAITING: w->phase = CALLING_BACK; @@ -212,7 +196,6 @@ void grpc_channel_watch_connectivity_state( w->phase = WAITING; w->state = last_observed_state; w->success = 0; - w->removed = 0; w->cq = cq; w->tag = tag; w->channel = channel; @@ -223,16 +206,14 @@ void grpc_channel_watch_connectivity_state( if (client_channel_elem->filter == &grpc_client_channel_filter) { GRPC_CHANNEL_INTERNAL_REF(channel, "watch_channel_connectivity"); - grpc_client_channel_add_interested_party(&exec_ctx, client_channel_elem, - grpc_cq_pollset(cq)); grpc_client_channel_watch_connectivity_state(&exec_ctx, client_channel_elem, - &w->state, &w->on_complete); + grpc_cq_pollset(cq), &w->state, + &w->on_complete); } else if (client_channel_elem->filter == &grpc_client_uchannel_filter) { GRPC_CHANNEL_INTERNAL_REF(channel, "watch_uchannel_connectivity"); - grpc_client_uchannel_add_interested_party(&exec_ctx, client_channel_elem, - grpc_cq_pollset(cq)); grpc_client_uchannel_watch_connectivity_state( - &exec_ctx, client_channel_elem, &w->state, &w->on_complete); + &exec_ctx, client_channel_elem, grpc_cq_pollset(cq), &w->state, + &w->on_complete); } grpc_exec_ctx_finish(&exec_ctx); diff --git a/src/core/surface/channel_create.c b/src/core/surface/channel_create.c index 026592db95..d7722f26a7 100644 --- a/src/core/surface/channel_create.c +++ b/src/core/surface/channel_create.c @@ -151,7 +151,6 @@ static grpc_subchannel *subchannel_factory_create_subchannel( c->base.vtable = &connector_vtable; gpr_ref_init(&c->refs, 1); args->args = final_args; - args->master = f->master; s = grpc_subchannel_create(&c->base, args); grpc_connector_unref(exec_ctx, &c->base); grpc_channel_args_destroy(final_args); diff --git a/src/core/surface/lame_client.c b/src/core/surface/lame_client.c index 4a55544ac1..a60e9d20da 100644 --- a/src/core/surface/lame_client.c +++ b/src/core/surface/lame_client.c @@ -49,7 +49,6 @@ typedef struct { } call_data; typedef struct { - grpc_channel *master; grpc_status_code error_code; const char *error_message; } channel_data; @@ -84,8 +83,7 @@ static void lame_start_transport_stream_op(grpc_exec_ctx *exec_ctx, } static char *lame_get_peer(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) { - channel_data *chand = elem->channel_data; - return grpc_channel_get_target(chand->master); + return NULL; } static void lame_start_transport_op(grpc_exec_ctx *exec_ctx, @@ -111,10 +109,8 @@ static void destroy_call_elem(grpc_exec_ctx *exec_ctx, static void init_channel_elem(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, grpc_channel_element_args *args) { - channel_data *chand = elem->channel_data; GPR_ASSERT(args->is_first); GPR_ASSERT(args->is_last); - chand->master = args->master; } static void destroy_channel_elem(grpc_exec_ctx *exec_ctx, diff --git a/src/core/transport/metadata.c b/src/core/transport/metadata.c index a76d1ad3a5..56e83a0a75 100644 --- a/src/core/transport/metadata.c +++ b/src/core/transport/metadata.c @@ -217,7 +217,8 @@ void grpc_mdctx_global_shutdown(void) { gc_mdtab(shard); /* TODO(ctiller): GPR_ASSERT(shard->count == 0); */ if (shard->count != 0) { - gpr_log(GPR_DEBUG, "WARNING: %d metadata elements were leaked", shard->count); + gpr_log(GPR_DEBUG, "WARNING: %d metadata elements were leaked", + shard->count); } gpr_free(shard->elems); } @@ -226,7 +227,8 @@ void grpc_mdctx_global_shutdown(void) { gpr_mu_destroy(&shard->mu); /* TODO(ctiller): GPR_ASSERT(shard->count == 0); */ if (shard->count != 0) { - gpr_log(GPR_DEBUG, "WARNING: %d metadata strings were leaked", shard->count); + gpr_log(GPR_DEBUG, "WARNING: %d metadata strings were leaked", + shard->count); } gpr_free(shard->strs); } diff --git a/src/core/transport/static_metadata.c b/src/core/transport/static_metadata.c index e7aff325c2..c2bfef0397 100644 --- a/src/core/transport/static_metadata.c +++ b/src/core/transport/static_metadata.c @@ -65,92 +65,23 @@ const gpr_uint8 80, 81, 82, 33, 83, 33, 84, 33, 85, 33, 86, 33}; const char *const grpc_static_metadata_strings[GRPC_STATIC_MDSTR_COUNT] = { - "0", - "1", - "2", - "200", - "204", - "206", - "304", - "400", - "404", - "500", - "accept", - "accept-charset", - "accept-encoding", - "accept-language", - "accept-ranges", - "access-control-allow-origin", - "age", - "allow", - "application/grpc", - ":authority", - "authorization", - "cache-control", - "content-disposition", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-range", - "content-type", - "cookie", - "date", - "deflate", - "deflate,gzip", - "", - "etag", - "expect", - "expires", - "from", - "GET", - "grpc", - "grpc-accept-encoding", - "grpc-encoding", - "grpc-internal-encoding-request", - "grpc-message", - "grpc-status", - "grpc-timeout", - "gzip", - "gzip, deflate", - "host", - "http", - "https", - "identity", - "identity,deflate", - "identity,deflate,gzip", - "identity,gzip", - "if-match", - "if-modified-since", - "if-none-match", - "if-range", - "if-unmodified-since", - "last-modified", - "link", - "location", - "max-forwards", - ":method", - ":path", - "POST", - "proxy-authenticate", - "proxy-authorization", - "range", - "referer", - "refresh", - "retry-after", - ":scheme", - "server", - "set-cookie", - "/", - "/index.html", - ":status", - "strict-transport-security", - "te", - "trailers", - "transfer-encoding", - "user-agent", - "vary", - "via", + "0", "1", "2", "200", "204", "206", "304", "400", "404", "500", "accept", + "accept-charset", "accept-encoding", "accept-language", "accept-ranges", + "access-control-allow-origin", "age", "allow", "application/grpc", + ":authority", "authorization", "cache-control", "content-disposition", + "content-encoding", "content-language", "content-length", + "content-location", "content-range", "content-type", "cookie", "date", + "deflate", "deflate,gzip", "", "etag", "expect", "expires", "from", "GET", + "grpc", "grpc-accept-encoding", "grpc-encoding", + "grpc-internal-encoding-request", "grpc-message", "grpc-status", + "grpc-timeout", "gzip", "gzip, deflate", "host", "http", "https", + "identity", "identity,deflate", "identity,deflate,gzip", "identity,gzip", + "if-match", "if-modified-since", "if-none-match", "if-range", + "if-unmodified-since", "last-modified", "link", "location", "max-forwards", + ":method", ":path", "POST", "proxy-authenticate", "proxy-authorization", + "range", "referer", "refresh", "retry-after", ":scheme", "server", + "set-cookie", "/", "/index.html", ":status", "strict-transport-security", + "te", "trailers", "transfer-encoding", "user-agent", "vary", "via", "www-authenticate"}; const gpr_uint8 grpc_static_accept_encoding_metadata[8] = {0, 29, 26, 30, diff --git a/test/core/channel/channel_stack_test.c b/test/core/channel/channel_stack_test.c index 9dbb879300..cab31bc69d 100644 --- a/test/core/channel/channel_stack_test.c +++ b/test/core/channel/channel_stack_test.c @@ -81,6 +81,16 @@ static char *get_peer(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) { return gpr_strdup("peer"); } +static void free_channel(grpc_exec_ctx *exec_ctx, void *arg, int success) { + grpc_channel_stack_destroy(exec_ctx, arg); + gpr_free(arg); +} + +static void free_call(grpc_exec_ctx *exec_ctx, void *arg, int success) { + grpc_call_stack_destroy(exec_ctx, arg); + gpr_free(arg); +} + static void test_create_channel_stack(void) { const grpc_channel_filter filter = { call_func, channel_func, sizeof(int), call_init_func, @@ -105,16 +115,16 @@ static void test_create_channel_stack(void) { chan_args.args = &arg; channel_stack = gpr_malloc(grpc_channel_stack_size(&filters, 1)); - grpc_channel_stack_init(&exec_ctx, &filters, 1, NULL, &chan_args, - channel_stack); + grpc_channel_stack_init(&exec_ctx, 1, free_channel, channel_stack, &filters, + 1, &chan_args, channel_stack); GPR_ASSERT(channel_stack->count == 1); channel_elem = grpc_channel_stack_element(channel_stack, 0); channel_data = (int *)channel_elem->channel_data; GPR_ASSERT(*channel_data == 0); call_stack = gpr_malloc(channel_stack->call_stack_size); - grpc_call_stack_init(&exec_ctx, channel_stack, 0, NULL, NULL, NULL, NULL, - call_stack); + grpc_call_stack_init(&exec_ctx, channel_stack, 1, free_call, call_stack, NULL, + NULL, call_stack); GPR_ASSERT(call_stack->count == 1); call_elem = grpc_call_stack_element(call_stack, 0); GPR_ASSERT(call_elem->filter == channel_elem->filter); @@ -123,12 +133,11 @@ static void test_create_channel_stack(void) { GPR_ASSERT(*call_data == 0); GPR_ASSERT(*channel_data == 1); - grpc_call_stack_destroy(&exec_ctx, call_stack); - gpr_free(call_stack); + GRPC_CALL_STACK_UNREF(&exec_ctx, call_stack, "done"); + grpc_exec_ctx_flush(&exec_ctx); GPR_ASSERT(*channel_data == 2); - grpc_channel_stack_destroy(&exec_ctx, channel_stack); - gpr_free(channel_stack); + GRPC_CHANNEL_STACK_UNREF(&exec_ctx, channel_stack, "done"); grpc_exec_ctx_finish(&exec_ctx); } diff --git a/test/core/end2end/tests/hpack_size.c b/test/core/end2end/tests/hpack_size.c index 297ea8d542..997969d3cc 100644 --- a/test/core/end2end/tests/hpack_size.c +++ b/test/core/end2end/tests/hpack_size.c @@ -262,9 +262,9 @@ static void drain_cq(grpc_completion_queue *cq) { static void shutdown_server(grpc_end2end_test_fixture *f) { if (!f->server) return; grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); - GPR_ASSERT(grpc_completion_queue_pluck( - f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) - .type == GRPC_OP_COMPLETE); + GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(1000), + GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), + NULL).type == GRPC_OP_COMPLETE); grpc_server_destroy(f->server); f->server = NULL; } diff --git a/test/core/util/reconnect_server.c b/test/core/util/reconnect_server.c index c064fb32c6..f5d5d3c403 100644 --- a/test/core/util/reconnect_server.c +++ b/test/core/util/reconnect_server.c @@ -122,8 +122,7 @@ void reconnect_server_start(reconnect_server *server, int port) { memset(&addr.sin_addr, 0, sizeof(addr.sin_addr)); server->tcp_server = grpc_tcp_server_create(); - listener = - grpc_tcp_server_add_port(server->tcp_server, &addr, sizeof(addr)); + listener = grpc_tcp_server_add_port(server->tcp_server, &addr, sizeof(addr)); port_added = grpc_tcp_listener_get_port(listener); GPR_ASSERT(port_added == port); -- cgit v1.2.3