182744510Sopenharmony_ciFrom 5850cba2957cc894477e735a74aa6c246b499ff4 Mon Sep 17 00:00:00 2001
282744510Sopenharmony_ciFrom: Yash Tibrewal <yashkt@google.com>
382744510Sopenharmony_ciDate: Mon, 11 Apr 2022 15:49:18 -0700
482744510Sopenharmony_ciSubject: [PATCH] Ignore Connection Aborted errors on accept (#29318)
582744510Sopenharmony_ci
682744510Sopenharmony_ci* Ignore Connection Aborted errors on accept
782744510Sopenharmony_ci
882744510Sopenharmony_ci* Reviewer comments
982744510Sopenharmony_ci---
1082744510Sopenharmony_ci src/core/lib/iomgr/tcp_server_posix.cc | 32 +++++++++++++-------------
1182744510Sopenharmony_ci 1 file changed, 16 insertions(+), 16 deletions(-)
1282744510Sopenharmony_ci
1382744510Sopenharmony_cidiff --git a/src/core/lib/iomgr/tcp_server_posix.cc b/src/core/lib/iomgr/tcp_server_posix.cc
1482744510Sopenharmony_ciindex c40ddbf646..f02bb8396a 100644
1582744510Sopenharmony_ci--- a/src/core/lib/iomgr/tcp_server_posix.cc
1682744510Sopenharmony_ci+++ b/src/core/lib/iomgr/tcp_server_posix.cc
1782744510Sopenharmony_ci@@ -204,22 +204,22 @@ static void on_read(void* arg, grpc_error_handle err) {
1882744510Sopenharmony_ci        strip off the ::ffff:0.0.0.0/96 prefix first. */
1982744510Sopenharmony_ci     int fd = grpc_accept4(sp->fd, &addr, 1, 1);
2082744510Sopenharmony_ci     if (fd < 0) {
2182744510Sopenharmony_ci-      switch (errno) {
2282744510Sopenharmony_ci-        case EINTR:
2382744510Sopenharmony_ci-          continue;
2482744510Sopenharmony_ci-        case EAGAIN:
2582744510Sopenharmony_ci-          grpc_fd_notify_on_read(sp->emfd, &sp->read_closure);
2682744510Sopenharmony_ci-          return;
2782744510Sopenharmony_ci-        default:
2882744510Sopenharmony_ci-          gpr_mu_lock(&sp->server->mu);
2982744510Sopenharmony_ci-          if (!sp->server->shutdown_listeners) {
3082744510Sopenharmony_ci-            gpr_log(GPR_ERROR, "Failed accept4: %s", strerror(errno));
3182744510Sopenharmony_ci-          } else {
3282744510Sopenharmony_ci-            /* if we have shutdown listeners, accept4 could fail, and we
3382744510Sopenharmony_ci-               needn't notify users */
3482744510Sopenharmony_ci-          }
3582744510Sopenharmony_ci-          gpr_mu_unlock(&sp->server->mu);
3682744510Sopenharmony_ci-          goto error;
3782744510Sopenharmony_ci+      if (errno == EINTR) {
3882744510Sopenharmony_ci+        continue;
3982744510Sopenharmony_ci+      } else if (errno == EAGAIN || errno == ECONNABORTED ||
4082744510Sopenharmony_ci+                 errno == EWOULDBLOCK) {
4182744510Sopenharmony_ci+        grpc_fd_notify_on_read(sp->emfd, &sp->read_closure);
4282744510Sopenharmony_ci+        return;
4382744510Sopenharmony_ci+      } else {
4482744510Sopenharmony_ci+        gpr_mu_lock(&sp->server->mu);
4582744510Sopenharmony_ci+        if (!sp->server->shutdown_listeners) {
4682744510Sopenharmony_ci+          gpr_log(GPR_ERROR, "Failed accept4: %s", strerror(errno));
4782744510Sopenharmony_ci+        } else {
4882744510Sopenharmony_ci+          /* if we have shutdown listeners, accept4 could fail, and we
4982744510Sopenharmony_ci+             needn't notify users */
5082744510Sopenharmony_ci+        }
5182744510Sopenharmony_ci+        gpr_mu_unlock(&sp->server->mu);
5282744510Sopenharmony_ci+        goto error;
5382744510Sopenharmony_ci       }
5482744510Sopenharmony_ci     }
5582744510Sopenharmony_ci 
5682744510Sopenharmony_ci-- 
5782744510Sopenharmony_ci2.33.0
5882744510Sopenharmony_ci
59