diff options
author | David Garcia Quintas <dgq@google.com> | 2015-05-28 16:27:39 -0700 |
---|---|---|
committer | David Garcia Quintas <dgq@google.com> | 2015-05-31 12:48:44 -0700 |
commit | 284488b4347685a83f97b6123a8d7115bb8ee032 (patch) | |
tree | ab5c9a96ed3e0c38966f9db8fbb56673db20a76b /src/core/surface | |
parent | 2738ae8c44786b8798d4b111e289b4baf1a134c6 (diff) |
removed managed closures from server.c
Diffstat (limited to 'src/core/surface')
-rw-r--r-- | src/core/surface/call.c | 8 | ||||
-rw-r--r-- | src/core/surface/channel.c | 8 | ||||
-rw-r--r-- | src/core/surface/server.c | 45 |
3 files changed, 28 insertions, 33 deletions
diff --git a/src/core/surface/call.c b/src/core/surface/call.c index 3a739315a2..948d0cdc36 100644 --- a/src/core/surface/call.c +++ b/src/core/surface/call.c @@ -226,7 +226,7 @@ struct grpc_call { gpr_slice_buffer incoming_message; gpr_uint32 incoming_message_length; - grpc_iomgr_closure destroy_iocb; + grpc_iomgr_closure destroy_closure; }; #define CALL_STACK_FROM_CALL(call) ((grpc_call_stack *)((call) + 1)) @@ -368,9 +368,9 @@ void grpc_call_internal_unref(grpc_call *c, int allow_immediate_deletion) { if (allow_immediate_deletion) { destroy_call(c, 1); } else { - c->destroy_iocb.cb = destroy_call; - c->destroy_iocb.cb_arg = c; - grpc_iomgr_add_callback(&c->destroy_iocb); + c->destroy_closure.cb = destroy_call; + c->destroy_closure.cb_arg = c; + grpc_iomgr_add_callback(&c->destroy_closure); } } } diff --git a/src/core/surface/channel.c b/src/core/surface/channel.c index d018db7bb0..947011c613 100644 --- a/src/core/surface/channel.c +++ b/src/core/surface/channel.c @@ -61,7 +61,7 @@ struct grpc_channel { gpr_mu registered_call_mu; registered_call *registered_calls; - grpc_iomgr_closure destroy_iocb; + grpc_iomgr_closure destroy_closure; }; #define CHANNEL_STACK_FROM_CHANNEL(c) ((grpc_channel_stack *)((c) + 1)) @@ -194,9 +194,9 @@ static void destroy_channel(void *p, int ok) { void grpc_channel_internal_unref(grpc_channel *channel) { if (gpr_unref(&channel->refs)) { - channel->destroy_iocb.cb = destroy_channel; - channel->destroy_iocb.cb_arg = channel; - grpc_iomgr_add_callback(&channel->destroy_iocb); + channel->destroy_closure.cb = destroy_channel; + channel->destroy_closure.cb_arg = channel; + grpc_iomgr_add_callback(&channel->destroy_closure); } } diff --git a/src/core/surface/server.c b/src/core/surface/server.c index 378d50486b..21b5f9162d 100644 --- a/src/core/surface/server.c +++ b/src/core/surface/server.c @@ -122,8 +122,8 @@ struct channel_data { channel_registered_method *registered_methods; gpr_uint32 registered_method_slots; gpr_uint32 registered_method_max_probes; - grpc_iomgr_closure finish_shutdown_channel_iocb; - grpc_iomgr_closure finish_destroy_channel_iocb; + grpc_iomgr_closure finish_shutdown_channel_closure; + grpc_iomgr_closure finish_destroy_channel_closure; }; struct grpc_server { @@ -180,6 +180,8 @@ struct call_data { void (*on_done_recv)(void *user_data, int success); void *recv_user_data; + grpc_iomgr_closure kill_zombie_closure; + call_data **root[CALL_LIST_COUNT]; call_link links[CALL_LIST_COUNT]; }; @@ -306,9 +308,9 @@ static void destroy_channel(channel_data *chand) { GPR_ASSERT(chand->server != NULL); orphan_channel(chand); server_ref(chand->server); - chand->finish_destroy_channel_iocb.cb = finish_destroy_channel; - chand->finish_destroy_channel_iocb.cb_arg = chand; - grpc_iomgr_add_callback(&chand->finish_destroy_channel_iocb); + chand->finish_destroy_channel_closure.cb = finish_destroy_channel; + chand->finish_destroy_channel_closure.cb_arg = chand; + grpc_iomgr_add_callback(&chand->finish_destroy_channel_closure); } static void finish_start_new_rpc_and_unlock(grpc_server *server, @@ -419,29 +421,24 @@ static void server_on_recv(void *ptr, int success) { case GRPC_STREAM_RECV_CLOSED: gpr_mu_lock(&chand->server->mu); if (calld->state == NOT_STARTED) { - grpc_iomgr_closure *kill_zombie_closure = - gpr_malloc(sizeof(grpc_iomgr_closure)); calld->state = ZOMBIED; - grpc_iomgr_managed_closure_init(kill_zombie_closure, kill_zombie, elem); - grpc_iomgr_add_callback(kill_zombie_closure); + grpc_iomgr_closure_init(&calld->kill_zombie_closure, kill_zombie, elem); + grpc_iomgr_add_callback(&calld->kill_zombie_closure); } gpr_mu_unlock(&chand->server->mu); break; case GRPC_STREAM_CLOSED: gpr_mu_lock(&chand->server->mu); if (calld->state == NOT_STARTED) { - grpc_iomgr_closure *kill_zombie_closure = - gpr_malloc(sizeof(grpc_iomgr_closure)); calld->state = ZOMBIED; - grpc_iomgr_managed_closure_init(kill_zombie_closure, kill_zombie, elem); - grpc_iomgr_add_callback(kill_zombie_closure); + grpc_iomgr_closure_init(&calld->kill_zombie_closure, kill_zombie, elem); + grpc_iomgr_add_callback(&calld->kill_zombie_closure); } else if (calld->state == PENDING) { - grpc_iomgr_closure *kill_zombie_closure = - gpr_malloc(sizeof(grpc_iomgr_closure)); call_list_remove(calld, PENDING_START); calld->state = ZOMBIED; - grpc_iomgr_managed_closure_init(kill_zombie_closure, kill_zombie, elem); - grpc_iomgr_add_callback(kill_zombie_closure); + grpc_iomgr_closure_init(&calld->kill_zombie_closure, kill_zombie, elem); + grpc_iomgr_add_callback(&calld->kill_zombie_closure); + } gpr_mu_unlock(&chand->server->mu); break; @@ -515,9 +512,9 @@ static void finish_shutdown_channel(void *cd, int success) { static void shutdown_channel(channel_data *chand) { grpc_channel_internal_ref(chand->channel); - chand->finish_shutdown_channel_iocb.cb = finish_shutdown_channel; - chand->finish_shutdown_channel_iocb.cb_arg = chand; - grpc_iomgr_add_callback(&chand->finish_shutdown_channel_iocb); + chand->finish_shutdown_channel_closure.cb = finish_shutdown_channel; + chand->finish_shutdown_channel_closure.cb_arg = chand; + grpc_iomgr_add_callback(&chand->finish_shutdown_channel_closure); } static void init_call_elem(grpc_call_element *elem, @@ -958,14 +955,12 @@ void grpc_server_destroy(grpc_server *server) { /* TODO(dgq): If we knew the size of the call list (or an upper bound), we * could allocate all the memory for the closures in advance in a single * chunk */ - grpc_iomgr_closure *kill_zombie_closure = - gpr_malloc(sizeof(grpc_iomgr_closure)); gpr_log(GPR_DEBUG, "server destroys call %p", calld->call); calld->state = ZOMBIED; - grpc_iomgr_managed_closure_init( - kill_zombie_closure, kill_zombie, + grpc_iomgr_closure_init( + &calld->kill_zombie_closure, kill_zombie, grpc_call_stack_element(grpc_call_get_call_stack(calld->call), 0)); - grpc_iomgr_add_callback(kill_zombie_closure); + grpc_iomgr_add_callback(&calld->kill_zombie_closure); } for (c = server->root_channel_data.next; c != &server->root_channel_data; |