diff options
author | Craig Tiller <ctiller@google.com> | 2015-02-18 16:18:08 -0800 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2015-02-18 16:18:43 -0800 |
commit | 59ea16ff44843aaf4501f361d31af564ee7f2bcf (patch) | |
tree | 527cbb04eb0c6e05f065e640e8c810dc042983cf /src/core | |
parent | d9f3dfe7ebb251baab7494f5512c5fa68399ae7a (diff) |
Fix a race where an fd can be deleted during polling
Diffstat (limited to 'src/core')
-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) { |