From 1c22628118f67ab9fcd754cae6a997d0996f4c6e Mon Sep 17 00:00:00 2001 From: Matt Sergeant Date: Fri, 24 Jun 2005 16:07:48 +0000 Subject: [PATCH] Automatically ramp up the number of connections we accept when under heavy load git-svn-id: https://svn.perl.org/qpsmtpd/branches/high_perf@452 958fd67b-6ff1-0310-b445-bb7760255be9 --- qpsmtpd | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/qpsmtpd b/qpsmtpd index 42fb28e..84b7760 100755 --- a/qpsmtpd +++ b/qpsmtpd @@ -90,6 +90,7 @@ if ($USER =~ /^([\w\-]+)$/) { $USER = $1 } else { &help } 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);