Hook/plugin caching

git-svn-id: https://svn.perl.org/qpsmtpd/trunk@814 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
Matt Sergeant 2007-11-16 15:06:30 +00:00
parent d4dda86bfd
commit c5dd26b6af

View File

@ -18,7 +18,7 @@ sub load_logging {
# need to do this differently that other plugins so as to # need to do this differently that other plugins so as to
# not trigger logging activity # not trigger logging activity
my $self = shift; my $self = shift;
return if $self->{hooks}->{"logging"}; return if $hooks->{"logging"};
my $configdir = $self->config_dir("logging"); my $configdir = $self->config_dir("logging");
my $configfile = "$configdir/logging"; my $configfile = "$configdir/logging";
my @loggers = $self->_config_from_file($configfile,'logging'); my @loggers = $self->_config_from_file($configfile,'logging');
@ -263,12 +263,14 @@ sub expand_inclusion_ {
sub load_plugins { sub load_plugins {
my $self = shift; my $self = shift;
$self->log(LOGWARN, "Plugins already loaded") if $self->{hooks};
$self->{hooks} = {};
my @plugins = $self->config('plugins'); my @plugins = $self->config('plugins');
my @loaded; my @loaded;
if (keys %$hooks) {
$self->log(LOGWARN, "Plugins already loaded");
return @plugins;
}
for my $plugin_line (@plugins) { for my $plugin_line (@plugins) {
my $this_plugin = $self->_load_plugin($plugin_line, $self->plugin_dirs); my $this_plugin = $self->_load_plugin($plugin_line, $self->plugin_dirs);
push @loaded, $this_plugin if $this_plugin; push @loaded, $this_plugin if $this_plugin;
@ -345,7 +347,6 @@ sub transaction {
sub run_hooks { sub run_hooks {
my ($self, $hook) = (shift, shift); my ($self, $hook) = (shift, shift);
my $hooks = $self->{hooks};
if ($hooks->{$hook}) { if ($hooks->{$hook}) {
my @r; my @r;
my @local_hooks = @{$hooks->{$hook}}; my @local_hooks = @{$hooks->{$hook}};
@ -436,7 +437,6 @@ sub _register_hook {
my $self = shift; my $self = shift;
my ($hook, $code, $unshift) = @_; my ($hook, $code, $unshift) = @_;
my $hooks = $self->{hooks};
if ($unshift) { if ($unshift) {
unshift @{$hooks->{$hook}}, $code; unshift @{$hooks->{$hook}}, $code;
} }