Fairness patch - prevent bad pipelining clients from hogging the event loop

git-svn-id: https://svn.perl.org/qpsmtpd/trunk@852 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
Matt Sergeant 2008-03-13 19:48:45 +00:00
parent 41d00e8b91
commit f84ba8eb92

View File

@ -113,7 +113,7 @@ sub process_read_buf {
$self->{line} .= $$bref; $self->{line} .= $$bref;
return if $self->{pause_count} || $self->{closed}; return if $self->{pause_count} || $self->{closed};
while ($self->{line} =~ s/^(.*?\n)//) { if ($self->{line} =~ s/^(.*?\n)//) {
my $line = $1; my $line = $1;
$self->{alive_time} = time; $self->{alive_time} = time;
my $resp = $self->process_line($line); my $resp = $self->process_line($line);
@ -121,6 +121,12 @@ sub process_read_buf {
$self->write($resp) if $resp; $self->write($resp) if $resp;
# $self->watch_read(0) if $self->{pause_count}; # $self->watch_read(0) if $self->{pause_count};
return if $self->{pause_count} || $self->{closed}; return if $self->{pause_count} || $self->{closed};
# read more in a timer, to give other clients a look in
$self->AddTimer(0, sub {
if (length($self->{line}) && !$self->paused) {
$self->process_read_buf(\""); # " for bad syntax highlighters
}
});
} }
} }