File ignore-connection-aborted-errors-on-accept.patch of Package grpc.42944
From c7f0ce44de4e43435f09ffbce78012e514b5805e Mon Sep 17 00:00:00 2001
From: Yash Tibrewal <yashkt@google.com>
Date: Mon, 11 Apr 2022 15:49:18 -0700
Subject: [PATCH 1/2] Ignore Connection Aborted errors on accept (#29318)
* Ignore Connection Aborted errors on accept
* Reviewer comments
---
src/core/lib/iomgr/tcp_server_posix.cc | 32 +++++++++++++-------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/src/core/lib/iomgr/tcp_server_posix.cc b/src/core/lib/iomgr/tcp_server_posix.cc
index b1637e9981..f8ac9f186b 100644
--- a/src/core/lib/iomgr/tcp_server_posix.cc
+++ b/src/core/lib/iomgr/tcp_server_posix.cc
@@ -201,22 +201,22 @@ static void on_read(void* arg, grpc_error* err) {
strip off the ::ffff:0.0.0.0/96 prefix first. */
int fd = grpc_accept4(sp->fd, &addr, 1, 1);
if (fd < 0) {
- switch (errno) {
- case EINTR:
- continue;
- case EAGAIN:
- grpc_fd_notify_on_read(sp->emfd, &sp->read_closure);
- return;
- default:
- gpr_mu_lock(&sp->server->mu);
- if (!sp->server->shutdown_listeners) {
- gpr_log(GPR_ERROR, "Failed accept4: %s", strerror(errno));
- } else {
- /* if we have shutdown listeners, accept4 could fail, and we
- needn't notify users */
- }
- gpr_mu_unlock(&sp->server->mu);
- goto error;
+ if (errno == EINTR) {
+ continue;
+ } else if (errno == EAGAIN || errno == ECONNABORTED ||
+ errno == EWOULDBLOCK) {
+ grpc_fd_notify_on_read(sp->emfd, &sp->read_closure);
+ return;
+ } else {
+ gpr_mu_lock(&sp->server->mu);
+ if (!sp->server->shutdown_listeners) {
+ gpr_log(GPR_ERROR, "Failed accept4: %s", strerror(errno));
+ } else {
+ /* if we have shutdown listeners, accept4 could fail, and we
+ needn't notify users */
+ }
+ gpr_mu_unlock(&sp->server->mu);
+ goto error;
}
}
--
2.53.0