The first attached file turns off SIG{ALRM} when processing mode=command.
If check_earlytalker is called inside alarm(2), it will almost be
definition trip the alarm. When it trips the alarm, the mode doesn't get
set back to cmd.
The second attached file hangles a case where $PushBackSet{$fd} can be
undef. Why it's undef, I wasn't able to figure out. The second chunk in
that file deletes $PushBackSet{$fd} when the Danga::Socket dies, but that
didn't seem to help; I left it in because it seemed like a good idea. It
also deletes $DescriptorMap{$fd}, but only because that also seems like a
good idea.
Also, a question if I may. Matt, what is the significance of "Connect\n"
in the call $client->push_back_read("Connect\n")?
Brian=== lib/Qpsmtpd/PollServer.pm
==================================================================
--- lib/Qpsmtpd/PollServer.pm (revision 1448)
+++ lib/Qpsmtpd/PollServer.pm (local)
@@ -122,15 +122,20 @@
my ($pkg, $file, $line) = caller();
die "ALARM: ($self->{mode}) $pkg, $file, $line";
};
- my $prev = alarm(2); # must process a command in < 2 seconds
- eval { $self->_process_line($line) };
- alarm($prev);
- if ($@) {
- print STDERR "Error: [EMAIL PROTECTED]";
- return $self->fault("command failed unexpectedly") if $self->{mode} eq
'cmd';
- return $self->fault("error processing data lines") if $self->{mode} eq
'data';
- return $self->fault("unknown error");
+ if( $self->{mode} eq 'connect' ) {
+ eval { $self->_process_line($line) }
}
+ else {
+ my $prev = alarm(2); # must process a command in < 2 seconds
+ eval { $self->_process_line($line) };
+ alarm($prev);
+ if ($@) {
+ print STDERR "Error: [EMAIL PROTECTED]";
+ return $self->fault("command failed unexpectedly") if
$self->{mode} eq 'cmd';
+ return $self->fault("error processing data lines") if
$self->{mode} eq 'data';
+ return $self->fault("unknown error");
+ }
+ }
return;
}
=== lib/Danga/Socket.pm
==================================================================
--- lib/Danga/Socket.pm (revision 1527)
+++ lib/Danga/Socket.pm (local)
@@ -358,6 +358,7 @@
while ($loop) {
$loop = 0;
foreach my $fd (keys %PushBackSet) {
+ next if ! $PushBackSet{$fd};
my Danga::Socket $pob = $PushBackSet{$fd};
next unless (! $pob->{closed} &&
$pob->{event_watch} & POLLIN);
@@ -819,6 +820,8 @@
sub DESTROY {
my Danga::Socket $self = shift;
delete $PLCMap{$self->{fd}};
+ delete $PushBackSet{$self->{fd}};
+ delete $DescriptorMap{$self->{fd}};
}
#####################################################################