Author: vetinari
Date: Sun Sep  2 00:32:57 2007
New Revision: 784

Modified:
   trunk/qpsmtpd-prefork

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


Modified: trunk/qpsmtpd-prefork
==============================================================================
--- trunk/qpsmtpd-prefork       (original)
+++ trunk/qpsmtpd-prefork       Sun Sep  2 00:32:57 2007
@@ -34,8 +34,8 @@
 # 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 @@
         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 @@
           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 @@
 # 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;

Reply via email to