More small performance optimisations

git-svn-id: https://svn.perl.org/qpsmtpd/trunk@841 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
Matt Sergeant 2008-02-01 19:06:35 +00:00
parent 5f6d3dba0d
commit 3553eee269

View File

@ -291,7 +291,7 @@ sub load_plugins {
my @loaded; my @loaded;
if ($hooks->{queue}) { if ($hooks->{queue}) {
$self->log(LOGWARN, "Plugins already loaded"); #$self->log(LOGWARN, "Plugins already loaded");
return @plugins; return @plugins;
} }
@ -412,13 +412,9 @@ sub run_continuation {
my $code = shift @$todo; my $code = shift @$todo;
#my $t2 = $SAMPLER->($hook . "_" . $code->{name}, undef, 1); #my $t2 = $SAMPLER->($hook . "_" . $code->{name}, undef, 1);
#warn("Got sampler called: ${hook}_$code->{name}\n"); #warn("Got sampler called: ${hook}_$code->{name}\n");
if ( $hook eq 'logging' ) { # without calling $self->log()
eval { (@r) = $code->{code}->($self, $self->transaction, @$args); };
$@ and warn("FATAL LOGGING PLUGIN ERROR: ", $@) and next;
}
else {
$self->varlog(LOGDEBUG, $hook, $code->{name}); $self->varlog(LOGDEBUG, $hook, $code->{name});
eval { (@r) = $code->{code}->($self, $self->transaction, @$args); }; my $tran = $self->transaction;
eval { (@r) = $code->{code}->($self, $tran, @$args); };
$@ and $self->log(LOGCRIT, "FATAL PLUGIN ERROR: ", $@) and next; $@ and $self->log(LOGCRIT, "FATAL PLUGIN ERROR: ", $@) and next;
!defined $r[0] !defined $r[0]
@ -426,8 +422,10 @@ sub run_continuation {
." running the $hook hook returned undef!") ." running the $hook hook returned undef!")
and next; and next;
if ($self->transaction) { # note this is wrong as $tran is always true in the
my $tnotes = $self->transaction->notes( $code->{name} ); # current code...
if ($tran) {
my $tnotes = $tran->notes( $code->{name} );
$tnotes->{"hook_$hook"}->{'return'} = $r[0] $tnotes->{"hook_$hook"}->{'return'} = $r[0]
if (!defined $tnotes || ref $tnotes eq "HASH"); if (!defined $tnotes || ref $tnotes eq "HASH");
} }
@ -457,8 +455,6 @@ sub run_continuation {
$self->run_hooks_no_respond("ok", $code->{name}, $r[0], $r[1]) unless ($hook eq "ok"); $self->run_hooks_no_respond("ok", $code->{name}, $r[0], $r[1]) unless ($hook eq "ok");
} }
}
last unless $r[0] == DECLINED; last unless $r[0] == DECLINED;
} }
$r[0] = DECLINED if not defined $r[0]; $r[0] = DECLINED if not defined $r[0];