From 85cd1aae2b0eed339312bd37db78e17d61c9fba2 Mon Sep 17 00:00:00 2001 From: Hanno Hecker Date: Sun, 2 Sep 2007 07:32:57 +0000 Subject: [PATCH] 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 --- qpsmtpd-prefork | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/qpsmtpd-prefork b/qpsmtpd-prefork index dfa78d2..622c850 100755 --- a/qpsmtpd-prefork +++ b/qpsmtpd-prefork @@ -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; @@ -367,6 +368,9 @@ sub new_child { or die "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) @@ -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;