Qpsmtpd: remove PLUGIN_DIR label, replace implicit

if statements with chained 'and' with if block (2x)
This commit is contained in:
Matt Simerson 2014-09-15 19:00:07 -07:00
parent f8e2fdb966
commit 79d2b99211

View File

@ -395,14 +395,14 @@ sub _load_plugin {
# don't reload plugins if they are already loaded # don't reload plugins if they are already loaded
if (!defined &{"${package}::plugin_name"}) { if (!defined &{"${package}::plugin_name"}) {
PLUGIN_DIR: for my $dir (@plugin_dirs) { for my $dir (@plugin_dirs) {
next if !-e "$dir/$plugin"; next if !-e "$dir/$plugin";
Qpsmtpd::Plugin->compile($plugin_name, $package, Qpsmtpd::Plugin->compile($plugin_name, $package,
"$dir/$plugin", $self->{_test_mode}, $plugin); "$dir/$plugin", $self->{_test_mode}, $plugin);
if ($safe_line !~ /logging/) { if ($safe_line !~ /logging/) {
$self->log(LOGDEBUG, "Loading $safe_line from $dir/$plugin"); $self->log(LOGDEBUG, "Loading $safe_line from $dir/$plugin");
}; };
last PLUGIN_DIR; last;
} }
if (! defined &{"${package}::plugin_name"}) { if (! defined &{"${package}::plugin_name"}) {
die "Plugin $plugin_name not found in our plugin dirs (", join(', ', @plugin_dirs), ")"; die "Plugin $plugin_name not found in our plugin dirs (", join(', ', @plugin_dirs), ")";
@ -456,9 +456,10 @@ sub run_hooks_no_respond {
my @r; my @r;
for my $code (@{$hooks->{$hook}}) { for my $code (@{$hooks->{$hook}}) {
eval { (@r) = $code->{code}->($self, $self->transaction, @_); }; eval { (@r) = $code->{code}->($self, $self->transaction, @_); };
$@ if ($@) {
and warn("FATAL PLUGIN ERROR [" . $code->{name} . "]: ", $@) warn("FATAL PLUGIN ERROR [" . $code->{name} . "]: ", $@);
and next; next;
}
if ($r[0] == YIELD) { if ($r[0] == YIELD) {
die "YIELD not valid from $hook hook"; die "YIELD not valid from $hook hook";
} }
@ -490,11 +491,10 @@ sub run_continuation {
$self->varlog(LOGDEBUG, $hook, $code->{name}); $self->varlog(LOGDEBUG, $hook, $code->{name});
my $tran = $self->transaction; my $tran = $self->transaction;
eval { (@r) = $code->{code}->($self, $tran, @$args); }; eval { (@r) = $code->{code}->($self, $tran, @$args); };
$@ if ($@) {
and $self->log(LOGCRIT, "FATAL PLUGIN ERROR [" . $code->{name} . "]: ", $@);
$self->log(LOGCRIT, "FATAL PLUGIN ERROR [" . $code->{name} . "]: ", next;
$@) }
and next;
!defined $r[0] !defined $r[0]
and $self->log(LOGERROR, and $self->log(LOGERROR,