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;