diff options
author | 2015-02-18 16:19:13 -0800 | |
---|---|---|
committer | 2015-02-18 16:19:13 -0800 | |
commit | fb89ee38d5d464a48b9866d7c7941976a031e8fb (patch) | |
tree | 527cbb04eb0c6e05f065e640e8c810dc042983cf | |
parent | d9f3dfe7ebb251baab7494f5512c5fa68399ae7a (diff) | |
parent | 59ea16ff44843aaf4501f361d31af564ee7f2bcf (diff) |
Merge pull request #597 from ctiller/chex5
Fix a race where an fd can be deleted during polling
-rw-r--r-- | src/core/iomgr/fd_posix.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/core/iomgr/fd_posix.c b/src/core/iomgr/fd_posix.c index e3571e8e28..4f52339bc1 100644 --- a/src/core/iomgr/fd_posix.c +++ b/src/core/iomgr/fd_posix.c @@ -295,6 +295,8 @@ gpr_uint32 grpc_fd_begin_poll(grpc_fd *fd, grpc_pollset *pollset, grpc_fd_watcher *watcher) { /* keep track of pollers that have requested our events, in case they change */ + grpc_fd_ref(fd); + gpr_mu_lock(&fd->watcher_mu); watcher->next = &fd->watcher_root; watcher->prev = watcher->next->prev; @@ -312,6 +314,8 @@ void grpc_fd_end_poll(grpc_fd_watcher *watcher) { watcher->next->prev = watcher->prev; watcher->prev->next = watcher->next; gpr_mu_unlock(&watcher->fd->watcher_mu); + + grpc_fd_unref(watcher->fd); } void grpc_fd_become_readable(grpc_fd *fd, int allow_synchronous_callback) { |