Author: msergeant
Date: Fri May  2 10:50:29 2008
New Revision: 882

Modified:
   trunk/lib/Qpsmtpd.pm
   trunk/lib/Qpsmtpd/PollServer.pm

Log:
Don't continually check ->isa() for continue/pause_read - use OO properly
Support case where no connect hook is defined (thus continue_read() never gets 
called)


Modified: trunk/lib/Qpsmtpd.pm
==============================================================================
--- trunk/lib/Qpsmtpd.pm        (original)
+++ trunk/lib/Qpsmtpd.pm        Fri May  2 10:50:29 2008
@@ -403,11 +403,14 @@
     return (0, '');
 }
 
+sub continue_read {} # subclassed in -async
+sub pause_read { die "Continuations only work in qpsmtpd-async" }
+
 sub run_continuation {
   my $self = shift;
   #my $t1 = $SAMPLER->("run_hooks", undef, 1);
   die "No continuation in progress" unless $self->{_continuation};
-  $self->continue_read() if $self->isa('Danga::Client');
+  $self->continue_read();
   my $todo = $self->{_continuation};
   $self->{_continuation} = undef;
   my $hook = shift @$todo || die "No hook in the continuation";
@@ -441,7 +444,7 @@
     }
       
     if ($r[0] == YIELD) {
-      $self->pause_read() if $self->isa('Danga::Client');
+      $self->pause_read();
       $self->{_continuation} = [$hook, $args, @$todo];
       return @r;
     }

Modified: trunk/lib/Qpsmtpd/PollServer.pm
==============================================================================
--- trunk/lib/Qpsmtpd/PollServer.pm     (original)
+++ trunk/lib/Qpsmtpd/PollServer.pm     Fri May  2 10:50:29 2008
@@ -1,5 +1,3 @@
-# $Id: Server.pm,v 1.10 2005/02/14 22:04:48 msergeant Exp $
-
 package Qpsmtpd::PollServer;
 
 use base ('Danga::Client', 'Qpsmtpd::SMTP');
@@ -160,7 +158,7 @@
     $conn->remote_info("[$ip]");
     
     ParaDNS->new(
-        finished   => sub { $self->run_hooks("connect") },
+        finished   => sub { $self->continue_read(); 
$self->run_hooks("connect") },
         # NB: Setting remote_info to the same as remote_host
         callback   => sub { $conn->remote_info($conn->remote_host($_[0])) },
         host       => $ip,

Reply via email to