Make fd_shutdown idempotent

pull/6803/head
Sree Kuchibhotla 9 years ago
parent 3131c269c1
commit 0100b2f1c0
  1. 10
      src/core/lib/iomgr/ev_epoll_linux.c

@ -942,15 +942,19 @@ static grpc_pollset *fd_get_read_notifier_pollset(grpc_exec_ctx *exec_ctx,
return notifier; return notifier;
} }
/* Might be called multiple times */
static void fd_shutdown(grpc_exec_ctx *exec_ctx, grpc_fd *fd) { static void fd_shutdown(grpc_exec_ctx *exec_ctx, grpc_fd *fd) {
gpr_mu_lock(&fd->mu); gpr_mu_lock(&fd->mu);
GPR_ASSERT(!fd->shutdown); /* Do the actual shutdown only once */
if (!fd->shutdown) {
fd->shutdown = true; fd->shutdown = true;
/* Flush any pending read and write closures. Since fd->shutdown is 'true' at shutdown(fd->fd, SHUT_RDWR);
this point, the closures would be called with 'success = false' */ /* Flush any pending read and write closures. Since fd->shutdown is 'true'
at this point, the closures would be called with 'success = false' */
set_ready_locked(exec_ctx, fd, &fd->read_closure); set_ready_locked(exec_ctx, fd, &fd->read_closure);
set_ready_locked(exec_ctx, fd, &fd->write_closure); set_ready_locked(exec_ctx, fd, &fd->write_closure);
}
gpr_mu_unlock(&fd->mu); gpr_mu_unlock(&fd->mu);
} }

Loading…
Cancel
Save