[svn:qpsmtpd] rev 420 - in branches/high_perf: . lib/Danga lib/Qpsmtpd

[email protected] 17 May 2005 11:48:04 -0000
Newsgroups perl.cvs.qpsmtpd
Message-ID <[email protected]>
Author: msergeant
Date: Tue May 17 04:48:02 2005
New Revision: 420

Modified:
   branches/high_perf/lib/Danga/Socket.pm
   branches/high_perf/lib/Qpsmtpd/PollServer.pm
   branches/high_perf/qpsmtpd
Log:
Make number of accepts we perform lower if MAXCONNIP is used
Make connection hook get called after we do all the accept()s


Modified: branches/high_perf/lib/Danga/Socket.pm
==============================================================================
--- branches/high_perf/lib/Danga/Socket.pm	(original)
+++ branches/high_perf/lib/Danga/Socket.pm	Tue May 17 04:48:02 2005
@@ -77,7 +77,6 @@ our (
      );
 
 %OtherFds = ();
-$LocalPostLoopCallback = 0;
 
 #####################################################################
 ### C L A S S   M E T H O D S

Modified: branches/high_perf/lib/Qpsmtpd/PollServer.pm
==============================================================================
--- branches/high_perf/lib/Qpsmtpd/PollServer.pm	(original)
+++ branches/high_perf/lib/Qpsmtpd/PollServer.pm	Tue May 17 04:48:02 2005
@@ -47,6 +47,7 @@ sub new {
     $self = fields::new($self) unless ref $self;
     $self->SUPER::new( @_ );
     $self->{start_time} = time;
+    $self->{mode} = 'connect';
     $self->load_plugins;
     return $self;
 }
@@ -111,8 +112,17 @@ sub process_line {
 sub _process_line {
     my $self = shift;
     my $line = shift;
-
-    if ($self->{mode} eq 'cmd') {
+    
+    if ($self->{mode} eq 'connect') {
+        warn("Connection incoming\n");
+        my $rc = $self->start_conversation;
+        if ($rc != DONE) {
+            $self->close;
+            return;
+        }
+        $self->{mode} = 'cmd';
+    }
+    elsif ($self->{mode} eq 'cmd') {
         $line =~ s/\r?\n//;
         return $self->process_cmd($line);
     }

Modified: branches/high_perf/qpsmtpd
==============================================================================
--- branches/high_perf/qpsmtpd	(original)
+++ branches/high_perf/qpsmtpd	Tue May 17 04:48:02 2005
@@ -289,10 +289,14 @@ sub config_handler {
     return;
 }
 
+# TODO:
+#  - Make number of accepts() we do dependant on whether MAXCONNIP is set
+
 # Accept all new connections
 sub accept_handler {
-    for (1..10000) {
-        last unless _accept_handler();
+    my $max = $MAXCONNIP ? 100 : 1000;
+    for (1 .. $max) {
+        last if ! _accept_handler();
     }
 }
 
@@ -359,11 +363,7 @@ sub _accept_handler {
             $client->log(LOGINFO, "accepted connection $running/$MAXCONN ($num_conn/$MAXCONNIP) from $rem_ip");
         }
         
-        my $rc = $client->start_conversation;
-        if ($rc != DONE) {
-            $client->close;
-            return 1;
-        }
+        $client->push_back_read("Connect\n");
         $client->watch_read(1);
         return 1;
     }