1From 5850cba2957cc894477e735a74aa6c246b499ff4 Mon Sep 17 00:00:00 2001 2From: Yash Tibrewal <yashkt@google.com> 3Date: Mon, 11 Apr 2022 15:49:18 -0700 4Subject: [PATCH] Ignore Connection Aborted errors on accept (#29318) 5 6* Ignore Connection Aborted errors on accept 7 8* Reviewer comments 9--- 10 src/core/lib/iomgr/tcp_server_posix.cc | 32 +++++++++++++------------- 11 1 file changed, 16 insertions(+), 16 deletions(-) 12 13diff --git a/src/core/lib/iomgr/tcp_server_posix.cc b/src/core/lib/iomgr/tcp_server_posix.cc 14index c40ddbf646..f02bb8396a 100644 15--- a/src/core/lib/iomgr/tcp_server_posix.cc 16+++ b/src/core/lib/iomgr/tcp_server_posix.cc 17@@ -204,22 +204,22 @@ static void on_read(void* arg, grpc_error_handle err) { 18 strip off the ::ffff:0.0.0.0/96 prefix first. */ 19 int fd = grpc_accept4(sp->fd, &addr, 1, 1); 20 if (fd < 0) { 21- switch (errno) { 22- case EINTR: 23- continue; 24- case EAGAIN: 25- grpc_fd_notify_on_read(sp->emfd, &sp->read_closure); 26- return; 27- default: 28- gpr_mu_lock(&sp->server->mu); 29- if (!sp->server->shutdown_listeners) { 30- gpr_log(GPR_ERROR, "Failed accept4: %s", strerror(errno)); 31- } else { 32- /* if we have shutdown listeners, accept4 could fail, and we 33- needn't notify users */ 34- } 35- gpr_mu_unlock(&sp->server->mu); 36- goto error; 37+ if (errno == EINTR) { 38+ continue; 39+ } else if (errno == EAGAIN || errno == ECONNABORTED || 40+ errno == EWOULDBLOCK) { 41+ grpc_fd_notify_on_read(sp->emfd, &sp->read_closure); 42+ return; 43+ } else { 44+ gpr_mu_lock(&sp->server->mu); 45+ if (!sp->server->shutdown_listeners) { 46+ gpr_log(GPR_ERROR, "Failed accept4: %s", strerror(errno)); 47+ } else { 48+ /* if we have shutdown listeners, accept4 could fail, and we 49+ needn't notify users */ 50+ } 51+ gpr_mu_unlock(&sp->server->mu); 52+ goto error; 53 } 54 } 55 56-- 572.33.0 58 59