[svn:qpsmtpd] rev 452 - branches/high_perf

[email protected] 24 Jun 2005 16:07:48 -0000
Newsgroups perl.cvs.qpsmtpd
Message-ID <[email protected]>
Author: msergeant
Date: Fri Jun 24 09:07:48 2005
New Revision: 452

Modified:
   branches/high_perf/qpsmtpd
Log:
Automatically ramp up the number of connections we accept when under heavy
load


Modified: branches/high_perf/qpsmtpd
==============================================================================
--- branches/high_perf/qpsmtpd	(original)
+++ branches/high_perf/qpsmtpd	Fri Jun 24 09:07:48 2005
@@ -90,6 +90,7 @@ if ($USER =~ /^([\w\-]+)$/) { $USER = $1
 if ($MAXCONN =~ /^(\d+)$/) { $MAXCONN = $1 } else { &help }
 if ($PROCS =~ /^(\d+)$/) { $PROCS = $1 } else { &help }
 if ($NUMACCEPT =~ /^(\d+)$/) { $NUMACCEPT = $1 } else { &help }
+my $_NUMACCEPT = $NUMACCEPT;
 
 $PROCS = 1 if $LineMode;
 # This is a bit of a hack, but we get to approximate MAXCONN stuff when we
@@ -310,8 +311,16 @@ sub accept_handler {
             return;
         }
         $running++;
-        last if ! _accept_handler($running);
+        if (! _accept_handler($running)) {
+            # got here because we have too many accepts.
+            $NUMACCEPT = $_NUMACCEPT;
+            return;
+        }
     }
+    
+    # got here because we have accept's left.
+    # So double the number we accept next time.
+    $NUMACCEPT *= 2;
 }
 
 use Errno qw(EAGAIN EWOULDBLOCK);