trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject [trafficserver] branch 7.1.x updated: Throttling results in tight loop if there are no new connections
Date Thu, 08 Aug 2019 21:03:05 GMT
This is an automated email from the ASF dual-hosted git repository.

eze pushed a commit to branch 7.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/7.1.x by this push:
     new 3558e2a  Throttling results in tight loop if there are no new connections
3558e2a is described below

commit 3558e2adb514e2e73750244f483ef482b5208aae
Author: Vijay Mamidi <vijayabhaskar_mamidi@yahoo.com>
AuthorDate: Tue Apr 23 10:12:17 2019 +0800

    Throttling results in tight loop if there are no new connections
    
    (cherry picked from commit 1e9e4ed3be52dc8ef2433baba6816df4eb032055)
---
 iocore/net/UnixNetAccept.cc | 44 ++++++++------------------------------------
 1 file changed, 8 insertions(+), 36 deletions(-)

diff --git a/iocore/net/UnixNetAccept.cc b/iocore/net/UnixNetAccept.cc
index 77408d4..b3b635f 100644
--- a/iocore/net/UnixNetAccept.cc
+++ b/iocore/net/UnixNetAccept.cc
@@ -39,29 +39,6 @@ safe_delay(int msec)
   socketManager.poll(nullptr, 0, msec);
 }
 
-static int
-drain_throttled_accepts(NetAccept *na)
-{
-  struct pollfd afd;
-  Connection con[THROTTLE_AT_ONCE];
-
-  afd.fd     = na->server.fd;
-  afd.events = POLLIN;
-
-  // Try to close at most THROTTLE_AT_ONCE accept requests
-  // Stop if there is nothing waiting
-  int n = 0;
-  for (; n < THROTTLE_AT_ONCE && socketManager.poll(&afd, 1, 0) > 0; n++)
{
-    int res = 0;
-    if ((res = na->server.accept(&con[n])) < 0) {
-      return res;
-    }
-    con[n].close();
-  }
-  // Return the number of accept cases we closed
-  return n;
-}
-
 //
 // General case network connection accept code
 //
@@ -252,20 +229,7 @@ NetAccept::do_blocking_accept(EThread *t)
   // added by YTS Team, yamsat
   do {
     ink_hrtime now = Thread::get_hrtime();
-
-    // Throttle accepts
-    while (!opt.backdoor && check_net_throttle(ACCEPT)) {
-      check_throttle_warning(ACCEPT);
-      int num_throttled = drain_throttled_accepts(this);
-      if (num_throttled < 0) {
-        goto Lerror;
-      }
-      NET_SUM_DYN_STAT(net_connections_throttled_in_stat, num_throttled);
-      now = Thread::get_hrtime();
-    }
-
     if ((res = server.accept(&con)) < 0) {
-    Lerror:
       int seriousness = accept_error_seriousness(res);
       if (seriousness >= 0) { // not so bad
         if (!seriousness)     // bad enough to warn about
@@ -280,6 +244,14 @@ NetAccept::do_blocking_accept(EThread *t)
       }
       return -1;
     }
+    // check for throttle
+    if (!opt.backdoor && check_net_throttle(ACCEPT)) {
+      check_throttle_warning(ACCEPT);
+      // close the connection as we are in throttle state
+      con.close();
+      NET_SUM_DYN_STAT(net_connections_throttled_in_stat, 1);
+      continue;
+    }
 
     // Use 'nullptr' to Bypass thread allocator
     vc = (UnixNetVConnection *)this->getNetProcessor()->allocate_vc(nullptr);


Mime
View raw message