Blob Blame History Raw
From 8879d72884396de4ae2ff41649de5f2d916d272b Mon Sep 17 00:00:00 2001
From: Milind Changire <mchangir@redhat.com>
Date: Fri, 13 Apr 2018 10:53:46 +0530
Subject: [PATCH 257/260] rpc: rearm listener socket early

Problem:
On node reboot, when glusterd starts volumes, a setup with a large
number of bricks might cause SYN Flooding and connections to be dropped
if the connections are not accepted quickly enough.

Solution:
accept() the connection and rearm the listener socket early to receive
more connection requests as soon as possible.

mainline:
> Reviewed-on: https://review.gluster.org/19833
> Change-Id: Ibed421e50284c3f7a8fcdb4de7ac86cf53d4b74e
> fixes: bz#1564600
> Signed-off-by: Milind Changire <mchangir@redhat.com>

Change-Id: I4bf45b8a12f738ed9b398246e22dfd29e6b1010c
BUG: 1563804
Signed-off-by: Milind Changire <mchangir@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/135513
Tested-by: RHGS Build Bot <nigelb@redhat.com>
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
---
 rpc/rpc-transport/socket/src/socket.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c
index a6be911..b98efdc 100644
--- a/rpc/rpc-transport/socket/src/socket.c
+++ b/rpc/rpc-transport/socket/src/socket.c
@@ -2746,6 +2746,9 @@ socket_server_event_handler (int fd, int idx, int gen, void *data,
         if (poll_in) {
                 new_sock = accept (priv->sock, SA (&new_sockaddr), &addrlen);
 
+                if (ctx)
+                        event_handled (ctx->event_pool, fd, idx, gen);
+
                 if (new_sock == -1) {
                         gf_log (this->name, GF_LOG_WARNING,
                                 "accept on %d failed (%s)",
@@ -2968,8 +2971,6 @@ socket_server_event_handler (int fd, int idx, int gen, void *data,
                 }
         }
 out:
-        event_handled (ctx->event_pool, fd, idx, gen);
-
         if (cname && (cname != this->ssl_name)) {
                 GF_FREE(cname);
         }
-- 
1.8.3.1