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