|
|
@ -134,7 +134,9 @@ static void unref_by(grpc_fd *fd, int n) { |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
old = gpr_atm_full_fetch_add(&fd->refst, -n); |
|
|
|
old = gpr_atm_full_fetch_add(&fd->refst, -n); |
|
|
|
if (old == n) { |
|
|
|
if (old == n) { |
|
|
|
grpc_iomgr_add_callback(&fd->on_done_closure); |
|
|
|
if (fd->on_done_closure) { |
|
|
|
|
|
|
|
grpc_iomgr_add_callback(fd->on_done_closure); |
|
|
|
|
|
|
|
} |
|
|
|
freelist_fd(fd); |
|
|
|
freelist_fd(fd); |
|
|
|
grpc_iomgr_unregister_object(&fd->iomgr_object); |
|
|
|
grpc_iomgr_unregister_object(&fd->iomgr_object); |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -153,8 +155,6 @@ void grpc_fd_global_shutdown(void) { |
|
|
|
gpr_mu_destroy(&fd_freelist_mu); |
|
|
|
gpr_mu_destroy(&fd_freelist_mu); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void do_nothing(void *ignored, int success) {} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
grpc_fd *grpc_fd_create(int fd, const char *name) { |
|
|
|
grpc_fd *grpc_fd_create(int fd, const char *name) { |
|
|
|
grpc_fd *r = alloc_fd(fd); |
|
|
|
grpc_fd *r = alloc_fd(fd); |
|
|
|
grpc_iomgr_register_object(&r->iomgr_object, name); |
|
|
|
grpc_iomgr_register_object(&r->iomgr_object, name); |
|
|
@ -195,9 +195,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) { |
|
|
|
void grpc_fd_orphan(grpc_fd *fd, grpc_iomgr_closure *on_done) { |
|
|
|
grpc_iomgr_closure_init(&fd->on_done_closure, on_done ? on_done : do_nothing, |
|
|
|
fd->on_done_closure = on_done; |
|
|
|
user_data); |
|
|
|
|
|
|
|
shutdown(fd->fd, SHUT_RDWR); |
|
|
|
shutdown(fd->fd, SHUT_RDWR); |
|
|
|
REF_BY(fd, 1, "orphan"); /* remove active status, but keep referenced */ |
|
|
|
REF_BY(fd, 1, "orphan"); /* remove active status, but keep referenced */ |
|
|
|
gpr_mu_lock(&fd->watcher_mu); |
|
|
|
gpr_mu_lock(&fd->watcher_mu); |
|
|
@ -212,17 +211,14 @@ void grpc_fd_ref(grpc_fd *fd, const char *reason, const char *file, int line) { |
|
|
|
ref_by(fd, 2, reason, file, line); |
|
|
|
ref_by(fd, 2, reason, file, line); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void grpc_fd_unref(grpc_fd *fd, const char *reason, const char *file, int line) {
|
|
|
|
void grpc_fd_unref(grpc_fd *fd, const char *reason, const char *file, |
|
|
|
|
|
|
|
int line) { |
|
|
|
unref_by(fd, 2, reason, file, line); |
|
|
|
unref_by(fd, 2, reason, file, line); |
|
|
|
} |
|
|
|
} |
|
|
|
#else |
|
|
|
#else |
|
|
|
void grpc_fd_ref(grpc_fd *fd) {
|
|
|
|
void grpc_fd_ref(grpc_fd *fd) { ref_by(fd, 2); } |
|
|
|
ref_by(fd, 2);
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void grpc_fd_unref(grpc_fd *fd) {
|
|
|
|
void grpc_fd_unref(grpc_fd *fd) { unref_by(fd, 2); } |
|
|
|
unref_by(fd, 2);
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
static void process_callback(grpc_iomgr_closure *closure, int success, |
|
|
|
static void process_callback(grpc_iomgr_closure *closure, int success, |
|
|
|