From c5dd26b6afa01ea1e502d60450c04d04ccee5468 Mon Sep 17 00:00:00 2001 From: Matt Sergeant Date: Fri, 16 Nov 2007 15:06:30 +0000 Subject: [PATCH] Hook/plugin caching git-svn-id: https://svn.perl.org/qpsmtpd/trunk@814 958fd67b-6ff1-0310-b445-bb7760255be9 --- lib/Qpsmtpd.pm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/Qpsmtpd.pm b/lib/Qpsmtpd.pm index 455cc02..745d504 100644 --- a/lib/Qpsmtpd.pm +++ b/lib/Qpsmtpd.pm @@ -18,7 +18,7 @@ sub load_logging { # need to do this differently that other plugins so as to # not trigger logging activity my $self = shift; - return if $self->{hooks}->{"logging"}; + return if $hooks->{"logging"}; my $configdir = $self->config_dir("logging"); my $configfile = "$configdir/logging"; my @loggers = $self->_config_from_file($configfile,'logging'); @@ -263,12 +263,14 @@ sub expand_inclusion_ { sub load_plugins { my $self = shift; - $self->log(LOGWARN, "Plugins already loaded") if $self->{hooks}; - $self->{hooks} = {}; - my @plugins = $self->config('plugins'); my @loaded; + if (keys %$hooks) { + $self->log(LOGWARN, "Plugins already loaded"); + return @plugins; + } + for my $plugin_line (@plugins) { my $this_plugin = $self->_load_plugin($plugin_line, $self->plugin_dirs); push @loaded, $this_plugin if $this_plugin; @@ -345,7 +347,6 @@ sub transaction { sub run_hooks { my ($self, $hook) = (shift, shift); - my $hooks = $self->{hooks}; if ($hooks->{$hook}) { my @r; my @local_hooks = @{$hooks->{$hook}}; @@ -436,7 +437,6 @@ sub _register_hook { my $self = shift; my ($hook, $code, $unshift) = @_; - my $hooks = $self->{hooks}; if ($unshift) { unshift @{$hooks->{$hook}}, $code; }