|
|
@ -71,6 +71,7 @@ struct grpc_fd { |
|
|
|
int shutdown; |
|
|
|
int shutdown; |
|
|
|
int closed; |
|
|
|
int closed; |
|
|
|
int released; |
|
|
|
int released; |
|
|
|
|
|
|
|
gpr_atm pollhup; |
|
|
|
grpc_error* shutdown_error; |
|
|
|
grpc_error* shutdown_error; |
|
|
|
|
|
|
|
|
|
|
|
/* The watcher list.
|
|
|
|
/* The watcher list.
|
|
|
@ -339,6 +340,7 @@ static grpc_fd* fd_create(int fd, const char* name) { |
|
|
|
r->on_done_closure = nullptr; |
|
|
|
r->on_done_closure = nullptr; |
|
|
|
r->closed = 0; |
|
|
|
r->closed = 0; |
|
|
|
r->released = 0; |
|
|
|
r->released = 0; |
|
|
|
|
|
|
|
gpr_atm_no_barrier_store(&r->pollhup, 0); |
|
|
|
r->read_notifier_pollset = nullptr; |
|
|
|
r->read_notifier_pollset = nullptr; |
|
|
|
|
|
|
|
|
|
|
|
char* name2; |
|
|
|
char* name2; |
|
|
@ -964,7 +966,8 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset, |
|
|
|
pfds[0].events = POLLIN; |
|
|
|
pfds[0].events = POLLIN; |
|
|
|
pfds[0].revents = 0; |
|
|
|
pfds[0].revents = 0; |
|
|
|
for (i = 0; i < pollset->fd_count; i++) { |
|
|
|
for (i = 0; i < pollset->fd_count; i++) { |
|
|
|
if (fd_is_orphaned(pollset->fds[i])) { |
|
|
|
if (fd_is_orphaned(pollset->fds[i]) || |
|
|
|
|
|
|
|
gpr_atm_no_barrier_load(&pollset->fds[i]->pollhup) == 1) { |
|
|
|
GRPC_FD_UNREF(pollset->fds[i], "multipoller"); |
|
|
|
GRPC_FD_UNREF(pollset->fds[i], "multipoller"); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
pollset->fds[fd_count++] = pollset->fds[i]; |
|
|
|
pollset->fds[fd_count++] = pollset->fds[i]; |
|
|
@ -1031,6 +1034,12 @@ static grpc_error* pollset_work(grpc_exec_ctx* exec_ctx, grpc_pollset* pollset, |
|
|
|
pfds[i].fd, (pfds[i].revents & POLLIN_CHECK) != 0, |
|
|
|
pfds[i].fd, (pfds[i].revents & POLLIN_CHECK) != 0, |
|
|
|
(pfds[i].revents & POLLOUT_CHECK) != 0, pfds[i].revents); |
|
|
|
(pfds[i].revents & POLLOUT_CHECK) != 0, pfds[i].revents); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/* This is a mitigation to prevent poll() from spinning on a
|
|
|
|
|
|
|
|
** POLLHUP https://github.com/grpc/grpc/pull/13665
|
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
if (pfds[i].revents & POLLHUP) { |
|
|
|
|
|
|
|
gpr_atm_no_barrier_store(&watchers[i].fd->pollhup, 1); |
|
|
|
|
|
|
|
} |
|
|
|
fd_end_poll(exec_ctx, &watchers[i], pfds[i].revents & POLLIN_CHECK, |
|
|
|
fd_end_poll(exec_ctx, &watchers[i], pfds[i].revents & POLLIN_CHECK, |
|
|
|
pfds[i].revents & POLLOUT_CHECK, pollset); |
|
|
|
pfds[i].revents & POLLOUT_CHECK, pollset); |
|
|
|
} |
|
|
|
} |
|
|
|