Skip to content

Commit

Permalink
prefork: use new instance instead of cloning
Browse files Browse the repository at this point in the history
Create a new instance instead of cloning^copying the base instance,
see http://www.nntp.perl.org/group/perl.qpsmtpd/2008/07/msg8134.html ff.
  • Loading branch information
vetinari authored and abh committed Sep 17, 2010
1 parent 33d8825 commit 0b0e4e9
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions qpsmtpd-prefork
Expand Up @@ -49,7 +49,7 @@ foreach my $sig_name ( split( /\s/, $Config{sig_name} ) )
my $VERSION = "1.0";

# qpsmtpd instances
my ($qpsmtpd, $qpsmtpd_base);
my ($qpsmtpd);

# cmd's needed by IPC
my $ipcrm = '/usr/bin/ipcrm';
Expand Down Expand Up @@ -276,15 +276,14 @@ sub run {
# Hup handler
$SIG{HUP} = sub {
# reload qpmstpd plugins
$qpsmtpd = $qpsmtpd_base = qpsmtpd_instance('restart' => 1); # reload plugins...
$qpsmtpd = qpsmtpd_instance('restart' => 1); # reload plugins...
$qpsmtpd->load_plugins;
kill 'HUP' => keys %children;
info("reload daemon requested");
};

# setup qpsmtpd_instance(s), _base is for resetting to a known state
# after each connection
$qpsmtpd = $qpsmtpd_base = qpsmtpd_instance();
# setup qpsmtpd_instance
$qpsmtpd = qpsmtpd_instance();

if ($detach) {
open STDIN, '/dev/null' or die "/dev/null: $!";
Expand Down Expand Up @@ -462,8 +461,8 @@ 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;
# clear a previously running instance by creating a new instance
$qpsmtpd = qpsmtpd_instance();

# set STDIN/STDOUT and autoflush
# ... no longer use POSIX::dup2: it failes after a few
Expand Down

0 comments on commit 0b0e4e9

Please sign in to comment.