aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2016-03-05 07:40:46 -0800
committerGravatar Craig Tiller <ctiller@google.com>2016-03-05 07:40:46 -0800
commit72724bce84b4bc027ce8dd3f7508b9216788434b (patch)
treec389b2e53791d75fa14a9c8ce91f924aa0e7f49e /src
parent9f285e41a4d5323feb332e76c872649bb0dbca52 (diff)
parentf1b6d61965adf0cf264c826b0a08b5a8b32e57c3 (diff)
Merge pull request #5609 from ctiller/fix_mac_race
Fix race in poll() based pollset
Diffstat (limited to 'src')
-rw-r--r--src/core/iomgr/pollset_multipoller_with_poll_posix.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/core/iomgr/pollset_multipoller_with_poll_posix.c b/src/core/iomgr/pollset_multipoller_with_poll_posix.c
index 4dddfff230..92d6fb7241 100644
--- a/src/core/iomgr/pollset_multipoller_with_poll_posix.c
+++ b/src/core/iomgr/pollset_multipoller_with_poll_posix.c
@@ -122,6 +122,7 @@ static void multipoll_with_poll_pollset_maybe_work_and_unlock(
} else {
h->fds[fd_count++] = h->fds[i];
watchers[pfd_count].fd = h->fds[i];
+ GRPC_FD_REF(watchers[pfd_count].fd, "multipoller_start");
pfds[pfd_count].fd = h->fds[i]->fd;
pfds[pfd_count].revents = 0;
pfd_count++;
@@ -135,8 +136,10 @@ static void multipoll_with_poll_pollset_maybe_work_and_unlock(
gpr_mu_unlock(&pollset->mu);
for (i = 2; i < pfd_count; i++) {
- pfds[i].events = (short)grpc_fd_begin_poll(watchers[i].fd, pollset, worker,
- POLLIN, POLLOUT, &watchers[i]);
+ grpc_fd *fd = watchers[i].fd;
+ pfds[i].events = (short)grpc_fd_begin_poll(fd, pollset, worker, POLLIN,
+ POLLOUT, &watchers[i]);
+ GRPC_FD_UNREF(fd, "multipoller_start");
}
/* TODO(vpai): Consider first doing a 0 timeout poll here to avoid