Author: vetinari
Date: Sun Jun 15 02:28:02 2008
New Revision: 927
Modified:
trunk/lib/Qpsmtpd.pm
trunk/lib/Qpsmtpd/SMTP.pm
trunk/qpsmtpd-forkserver
trunk/qpsmtpd-prefork
Log:
prefork, forkserver: restart on SIGHUP:
* reset to defaults
* clear config cache
* reload all plugins (includes compiling, register()/init())
Modified: trunk/lib/Qpsmtpd.pm
==============================================================================
--- trunk/lib/Qpsmtpd.pm (original)
+++ trunk/lib/Qpsmtpd.pm Sun Jun 15 02:28:02 2008
@@ -15,9 +15,27 @@
timeout => 1200,
);
my $_config_cache = {};
+my %config_dir_memo;
#DashProfiler->add_profile("qpsmtpd");
#my $SAMPLER = DashProfiler->prepare("qpsmtpd");
+my $LOGGING_LOADED = 0;
+
+sub _restart {
+ my $self = shift;
+ my %args = @_;
+ if ($args{restart}) {
+ # reset all global vars to defaults
+ $self->clear_config_cache;
+ $hooks = {};
+ $LOGGING_LOADED = 0;
+ %config_dir_memo = ();
+ $TraceLevel = LOGWARN;
+ $Spool_dir = undef;
+ $Size_threshold = undef;
+ }
+}
+
sub DESTROY {
#warn $_ for DashProfiler->profile_as_text("qpsmtpd");
@@ -27,7 +45,6 @@
sub TRACE_LEVEL { $TraceLevel }; # leave for plugin compatibility
-my $LOGGING_LOADED = 0;
sub hooks { $hooks; }
@@ -146,7 +163,6 @@
}
}
-my %config_dir_memo;
sub config_dir {
my ($self, $config) = @_;
if (exists $config_dir_memo{$config}) {
Modified: trunk/lib/Qpsmtpd/SMTP.pm
==============================================================================
--- trunk/lib/Qpsmtpd/SMTP.pm (original)
+++ trunk/lib/Qpsmtpd/SMTP.pm Sun Jun 15 02:28:02 2008
@@ -37,6 +37,7 @@
my (%commands); @[EMAIL PROTECTED] = ('') x @commands;
# this list of valid commands should probably be a method or a set of methods
$self->{_commands} = \%commands;
+ $self->SUPER::_restart(%args) if $args{restart}; # calls Qpsmtpd::_restart()
$self;
}
Modified: trunk/qpsmtpd-forkserver
==============================================================================
--- trunk/qpsmtpd-forkserver (original)
+++ trunk/qpsmtpd-forkserver Sun Jun 15 02:28:02 2008
@@ -218,6 +218,13 @@
$qpsmtpd->spool_dir;
$qpsmtpd->size_threshold;
+$SIG{HUP} = sub {
+ $qpsmtpd = Qpsmtpd::TcpServer->new('restart' => 1);
+ $qpsmtpd->load_plugins;
+ $qpsmtpd->spool_dir;
+ $qpsmtpd->size_threshold;
+};
+
while (1) {
REAPER();
my $running = scalar keys %childstatus;
Modified: trunk/qpsmtpd-prefork
==============================================================================
--- trunk/qpsmtpd-prefork (original)
+++ trunk/qpsmtpd-prefork Sun Jun 15 02:28:02 2008
@@ -252,6 +252,7 @@
# Hup handler
$SIG{HUP} = sub {
# reload qpmstpd plugins
+ $qpsmtpd = $qpsmtpd_base = qpsmtpd_instance('restart' => 1); # reload
plugins...
$qpsmtpd->load_plugins;
kill 'HUP' => keys %children;
info("reload daemon requested");
@@ -457,7 +458,8 @@
# arg0: void
# ret0: ref to qpsmtpd_instance
sub qpsmtpd_instance {
- my $qpsmtpd = Qpsmtpd::TcpServer::Prefork->new();
+ my %args = @_;
+ my $qpsmtpd = Qpsmtpd::TcpServer::Prefork->new(%args);
$qpsmtpd->load_plugins;
$qpsmtpd->spool_dir;
$qpsmtpd->size_threshold;