diff --git a/plugins/check_earlytalker b/plugins/check_earlytalker index 29d79e9..27f5d9c 100644 --- a/plugins/check_earlytalker +++ b/plugins/check_earlytalker @@ -44,7 +44,7 @@ and terminating the SMTP connection. =cut -use IO::Select; +use Time::HiRes (); use warnings; use strict; @@ -70,8 +70,16 @@ sub register { 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);