prefork: clear a previously running instance by cloning the base instance

git-svn-id: https://svn.perl.org/qpsmtpd/trunk@784 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
Hanno Hecker 2007-09-02 07:32:57 +00:00
parent a5c22bcb7c
commit 85cd1aae2b

View File

@ -34,8 +34,8 @@ delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
# version # version
my $VERSION = "1.0"; my $VERSION = "1.0";
# qpsmtpd instance # qpsmtpd instances
my $qpsmtpd; my ($qpsmtpd, $qpsmtpd_base);
# cmd's needed by IPC # cmd's needed by IPC
my $ipcrm = '/usr/bin/ipcrm'; my $ipcrm = '/usr/bin/ipcrm';
@ -221,8 +221,9 @@ sub run {
info("reload daemon requested"); info("reload daemon requested");
}; };
# setup qpsmtpd_instance # setup qpsmtpd_instance(s), _base is for resetting to a known state
$qpsmtpd = qpmsptd_instance(); # after each connection
$qpsmtpd = $qpsmtpd_base = qpsmtpd_instance();
# child reaper # child reaper
$SIG{CHLD} = \&reaper; $SIG{CHLD} = \&reaper;
@ -367,6 +368,9 @@ sub new_child {
or die or die
"failed to create new object - $!"; # wait here until client connects "failed to create new object - $!"; # wait here until client connects
info("connect from: " . $client->peerhost . ":" . $client->peerport); info("connect from: " . $client->peerhost . ":" . $client->peerport);
# clear a previously running instance by cloning the base:
$qpsmtpd = $qpsmtpd_base;
# set STDIN/STDOUT and autoflush # set STDIN/STDOUT and autoflush
POSIX::dup2(fileno($client), 0) POSIX::dup2(fileno($client), 0)
@ -410,7 +414,7 @@ sub respond_client {
# qpsmtpd_instance: setup qpsmtpd instance # qpsmtpd_instance: setup qpsmtpd instance
# arg0: void # arg0: void
# ret0: ref to qpsmtpd_instance # ret0: ref to qpsmtpd_instance
sub qpmsptd_instance { sub qpsmtpd_instance {
my $qpsmtpd = Qpsmtpd::TcpServer::Prefork->new(); my $qpsmtpd = Qpsmtpd::TcpServer::Prefork->new();
$qpsmtpd->load_plugins; $qpsmtpd->load_plugins;
$qpsmtpd->spool_dir; $qpsmtpd->spool_dir;