unset indata{} after DATA is finished.

git-svn-id: https://svn.perl.org/qpsmtpd/trunk@192 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
Matt Sergeant 2003-11-06 15:41:03 +00:00
parent c2fb24c4e4
commit b55eae7e36

View File

@ -42,6 +42,7 @@ sub main {
# before quitting! # before quitting!
while (!$QUIT) { while (!$QUIT) {
foreach my $client ($select->can_read(1)) { foreach my $client ($select->can_read(1)) {
#print "Reading $client\n";
if ($client == $server) { if ($client == $server) {
my $client_addr; my $client_addr;
$client = $server->accept(); $client = $server->accept();
@ -68,6 +69,7 @@ sub main {
my $qp = Qpsmtpd::SelectServer->new(); my $qp = Qpsmtpd::SelectServer->new();
$qp->client($qpclient); $qp->client($qpclient);
$qp{$qpclient} = $qp; $qp{$qpclient} = $qp;
$qp->log(1, "Connection number " . keys(%qp));
$inbuffer{$qpclient} = ''; $inbuffer{$qpclient} = '';
$outbuffer{$qpclient} = ''; $outbuffer{$qpclient} = '';
$ready{$qpclient} = []; $ready{$qpclient} = [];
@ -95,13 +97,16 @@ sub main {
$inbuffer{$client} .= $data; $inbuffer{$client} .= $data;
while ($inbuffer{$client} =~ s/^([^\r\n]*)\r?\n//) { while ($inbuffer{$client} =~ s/^([^\r\n]*)\r?\n//) {
#print "<$1\n";
push @{$ready{$client}}, $1; push @{$ready{$client}}, $1;
} }
} }
} }
#print "Processing...\n";
foreach my $client (keys %ready) { foreach my $client (keys %ready) {
my $qp = $qp{$client}; my $qp = $qp{$client};
#print "Processing $client = $qp\n";
foreach my $req (@{$ready{$client}}) { foreach my $req (@{$ready{$client}}) {
if ($indata{$client}) { if ($indata{$client}) {
$qp->data_line($req . CRLF); $qp->data_line($req . CRLF);
@ -115,6 +120,7 @@ sub main {
delete $ready{$client}; delete $ready{$client};
} }
#print "Writing...\n";
foreach my $client ($select->can_write(1)) { foreach my $client ($select->can_write(1)) {
next unless $outbuffer{$client}; next unless $outbuffer{$client};
#print "Writing to $client\n"; #print "Writing to $client\n";
@ -148,6 +154,7 @@ sub main {
sub freeclient { sub freeclient {
my $client = shift; my $client = shift;
#print "Freeing client: $client\n";
delete $inbuffer{$client}; delete $inbuffer{$client};
delete $outbuffer{$client}; delete $outbuffer{$client};
delete $ready{$client}; delete $ready{$client};
@ -207,8 +214,9 @@ sub respond {
sub disconnect { sub disconnect {
my $self = shift; my $self = shift;
$self->SUPER::disconnect(@_); #print "Disconnecting\n";
$self->{__quitting} = 1; $self->{__quitting} = 1;
$self->SUPER::disconnect(@_);
} }
sub data { sub data {
@ -231,6 +239,7 @@ sub data_line {
if ($_ eq ".\r\n") { if ($_ eq ".\r\n") {
$self->log(6, "max_size: $self->{__max_size} / size: $self->{__size}"); $self->log(6, "max_size: $self->{__max_size} / size: $self->{__size}");
delete $indata{$self->client()};
my $smtp = $self->connection->hello eq "ehlo" ? "ESMTP" : "SMTP"; my $smtp = $self->connection->hello eq "ehlo" ? "ESMTP" : "SMTP";