[svn:qpsmtpd] rev 409 - branches/high_perf/plugins

[email protected] 28 Apr 2005 21:38:02 -0000
Newsgroups perl.cvs.qpsmtpd
Message-ID <[email protected]>
Author: msergeant
Date: Thu Apr 28 14:38:02 2005
New Revision: 409

Modified:
   branches/high_perf/plugins/check_earlytalker
Log:
Fixes for early_talker under high_perf code


Modified: branches/high_perf/plugins/check_earlytalker
==============================================================================
--- branches/high_perf/plugins/check_earlytalker	(original)
+++ branches/high_perf/plugins/check_earlytalker	Thu Apr 28 14:38:02 2005
@@ -44,7 +44,7 @@
 
 =cut
 
-use IO::Select;
+use Time::HiRes ();
 
 use warnings;
 use strict;
@@ -70,8 +70,16 @@
 
 sub connect_handler {
   my ($self, $transaction) = @_;
+  my $qp = $self->qp;
+  my $end = Time::HiRes::time + $self->{_args}->{'wait'} ;
+  my $time;
+  for( $time = Time::HiRes::time; $time < $end && !length($qp->{line}) ; $time = Time::HiRes::time ) {
+    $qp->can_read($end-$time);
+    }
+  my $earlytalker = 0;
+  $earlytalker = 1 if $time < $end ;
 
-  if ($self->qp->can_read($self->{_args}->{'wait'})) {
+  if ($earlytalker) {
     $self->log(LOGNOTICE, 'remote host started talking before we said hello');
     if ($self->{_args}->{'defer-reject'}) {
 	$self->connection->notes('earlytalker', 1);