diff options
author | David Garcia Quintas <dgq@google.com> | 2015-05-28 15:44:52 -0700 |
---|---|---|
committer | David Garcia Quintas <dgq@google.com> | 2015-05-31 12:48:43 -0700 |
commit | a25e6de0ca8740ef59709db52bcaba72e6ccaf83 (patch) | |
tree | 68da0c7d01ad80ff8b4cff01c47a3f3d40840925 /src | |
parent | 07997b6e89d155716b9dd79e02664ac95799baab (diff) |
fd_posix: removed redundant on_done
Diffstat (limited to 'src')
-rw-r--r-- | src/core/iomgr/fd_posix.c | 15 | ||||
-rw-r--r-- | src/core/iomgr/fd_posix.h | 6 |
2 files changed, 8 insertions, 13 deletions
diff --git a/src/core/iomgr/fd_posix.c b/src/core/iomgr/fd_posix.c index 6dcf1a3ec0..379ca66c85 100644 --- a/src/core/iomgr/fd_posix.c +++ b/src/core/iomgr/fd_posix.c @@ -117,10 +117,7 @@ static void ref_by(grpc_fd *fd, int n) { static void unref_by(grpc_fd *fd, int n) { gpr_atm old = gpr_atm_full_fetch_add(&fd->refst, -n); if (old == n) { - close(fd->fd); - grpc_iomgr_closure_init(&fd->on_done_iocb, fd->on_done, - fd->on_done_user_data); - grpc_iomgr_add_callback(&fd->on_done_iocb); + grpc_iomgr_add_callback(&fd->on_done_closure); freelist_fd(fd); grpc_iomgr_unref(); } else { @@ -183,8 +180,8 @@ static void wake_all_watchers_locked(grpc_fd *fd) { } void grpc_fd_orphan(grpc_fd *fd, grpc_iomgr_cb_func on_done, void *user_data) { - fd->on_done = on_done ? on_done : do_nothing; - fd->on_done_user_data = user_data; + grpc_iomgr_closure_init(&fd->on_done_closure, on_done ? on_done : do_nothing, + user_data); shutdown(fd->fd, SHUT_RDWR); ref_by(fd, 1); /* remove active status, but keep referenced */ gpr_mu_lock(&fd->watcher_mu); @@ -303,11 +300,11 @@ void grpc_fd_shutdown(grpc_fd *fd) { gpr_mu_lock(&fd->set_state_mu); GPR_ASSERT(!gpr_atm_no_barrier_load(&fd->shutdown)); gpr_atm_rel_store(&fd->shutdown, 1); - set_ready_locked(&fd->readst, fd->shutdown_iocbs, &ncb); - set_ready_locked(&fd->writest, fd->shutdown_iocbs, &ncb); + set_ready_locked(&fd->readst, fd->shutdown_closures, &ncb); + set_ready_locked(&fd->writest, fd->shutdown_closures, &ncb); gpr_mu_unlock(&fd->set_state_mu); GPR_ASSERT(ncb <= 2); - process_callbacks(fd->shutdown_iocbs, ncb, 0, 0); + process_callbacks(fd->shutdown_closures, ncb, 0, 0); } void grpc_fd_notify_on_read(grpc_fd *fd, grpc_iomgr_closure *closure) { diff --git a/src/core/iomgr/fd_posix.h b/src/core/iomgr/fd_posix.h index 2d9c3245e3..db9b2a74f6 100644 --- a/src/core/iomgr/fd_posix.h +++ b/src/core/iomgr/fd_posix.h @@ -91,12 +91,10 @@ struct grpc_fd { gpr_atm readst; gpr_atm writest; - grpc_iomgr_cb_func on_done; - void *on_done_user_data; struct grpc_fd *freelist_next; - grpc_iomgr_closure on_done_iocb; - grpc_iomgr_closure shutdown_iocbs[2]; + grpc_iomgr_closure on_done_closure; + grpc_iomgr_closure shutdown_closures[2]; }; /* Create a wrapped file descriptor. |