prefork, forkserver: restart on SIGHUP: * reset to defaults * clear config cache * reload all plugins (includes compiling, register()/init())
git-svn-id: https://svn.perl.org/qpsmtpd/trunk@927 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
parent
28f4cd51c1
commit
a64742cc7c
@ -15,9 +15,27 @@ my %defaults = (
|
||||
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 version { $VERSION };
|
||||
|
||||
sub TRACE_LEVEL { $TraceLevel }; # leave for plugin compatibility
|
||||
|
||||
my $LOGGING_LOADED = 0;
|
||||
|
||||
sub hooks { $hooks; }
|
||||
|
||||
@ -146,7 +163,6 @@ sub config {
|
||||
}
|
||||
}
|
||||
|
||||
my %config_dir_memo;
|
||||
sub config_dir {
|
||||
my ($self, $config) = @_;
|
||||
if (exists $config_dir_memo{$config}) {
|
||||
|
@ -37,6 +37,7 @@ sub new {
|
||||
my (%commands); @commands{@commands} = ('') 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;
|
||||
}
|
||||
|
||||
|
@ -218,6 +218,13 @@ if ($PID_FILE) {
|
||||
$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;
|
||||
|
@ -252,6 +252,7 @@ sub run {
|
||||
# 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 @@ sub respond_client {
|
||||
# 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;
|
||||
|
Loading…
Reference in New Issue
Block a user