diff options
author | 2015-05-28 16:27:39 -0700 | |
---|---|---|
committer | 2015-05-31 12:48:44 -0700 | |
commit | 284488b4347685a83f97b6123a8d7115bb8ee032 (patch) | |
tree | ab5c9a96ed3e0c38966f9db8fbb56673db20a76b /src/core/surface/server.c | |
parent | 2738ae8c44786b8798d4b111e289b4baf1a134c6 (diff) |
removed managed closures from server.c
Diffstat (limited to 'src/core/surface/server.c')
-rw-r--r-- | src/core/surface/server.c | 45 |
1 files changed, 20 insertions, 25 deletions
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; |