aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/iomgr/fd_posix.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/iomgr/fd_posix.c')
-rw-r--r--src/core/iomgr/fd_posix.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/core/iomgr/fd_posix.c b/src/core/iomgr/fd_posix.c
index 63615ea25f..b697fcc64a 100644
--- a/src/core/iomgr/fd_posix.c
+++ b/src/core/iomgr/fd_posix.c
@@ -165,7 +165,7 @@ static void maybe_wake_one_watcher(grpc_fd *fd) {
gpr_mu_unlock(&fd->watcher_mu);
}
-static void wake_all_watchers(grpc_fd *fd) {
+static void wake_all_watchers_locked(grpc_fd *fd) {
grpc_fd_watcher *watcher;
for (watcher = fd->inactive_watcher_root.next;
watcher != &fd->inactive_watcher_root; watcher = watcher->next) {
@@ -184,7 +184,9 @@ void grpc_fd_orphan(grpc_fd *fd, grpc_iomgr_cb_func on_done, void *user_data) {
fd->on_done_user_data = user_data;
shutdown(fd->fd, SHUT_RDWR);
ref_by(fd, 1); /* remove active status, but keep referenced */
- wake_all_watchers(fd);
+ gpr_mu_lock(&fd->watcher_mu);
+ wake_all_watchers_locked(fd);
+ gpr_mu_unlock(&fd->watcher_mu);
unref_by(fd, 2); /* drop the reference */
}