spamassassin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j.@apache.org
Subject svn commit: r158200 - in spamassassin/trunk: MANIFEST spamd/spamd.raw t/spamd_prefork_stress.t t/spamd_prefork_stress_2.t
Date Sat, 19 Mar 2005 03:36:53 GMT
Author: jm
Date: Fri Mar 18 19:36:52 2005
New Revision: 158200

URL: http://svn.apache.org/viewcvs?view=rev&rev=158200
Log:
bug 4190: avoid race condition in the old-style forking algorithm, workaround thanks to Alexey
Kravchuk

Added:
    spamassassin/trunk/t/spamd_prefork_stress_2.t   (with props)
Modified:
    spamassassin/trunk/MANIFEST
    spamassassin/trunk/spamd/spamd.raw
    spamassassin/trunk/t/spamd_prefork_stress.t

Modified: spamassassin/trunk/MANIFEST
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/MANIFEST?view=diff&r1=158199&r2=158200
==============================================================================
--- spamassassin/trunk/MANIFEST (original)
+++ spamassassin/trunk/MANIFEST Fri Mar 18 19:36:52 2005
@@ -376,6 +376,7 @@
 t/spamd_port.t
 t/spamd_protocol_10.t
 t/spamd_prefork_stress.t
+t/spamd_prefork_stress_2.t
 t/spamd_report.t
 t/spamd_report_ifspam.t
 t/spamd_ssl.t

Modified: spamassassin/trunk/spamd/spamd.raw
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/spamd/spamd.raw?view=diff&r1=158199&r2=158200
==============================================================================
--- spamassassin/trunk/spamd/spamd.raw (original)
+++ spamassassin/trunk/spamd/spamd.raw Fri Mar 18 19:36:52 2005
@@ -859,7 +859,11 @@
 
 while (1) {
   if (!$scaling) {
-    sleep;    # wait for a signal (ie: child's death)
+    # wait for a signal (ie: child's death)
+    # bug 4190: use a time-limited sleep, and call child_handler() even
+    # if haven't received a SIGCHLD, due to inherent race condition
+    sleep 10;
+    child_handler();
   } else {
     $scaling->main_server_poll($opt{'server-scale-period'});
   }

Modified: spamassassin/trunk/t/spamd_prefork_stress.t
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/t/spamd_prefork_stress.t?view=diff&r1=158199&r2=158200
==============================================================================
--- spamassassin/trunk/t/spamd_prefork_stress.t (original)
+++ spamassassin/trunk/t/spamd_prefork_stress.t Fri Mar 18 19:36:52 2005
@@ -3,12 +3,12 @@
 # Warning: do not run this test on a live server; it will kill your
 # spamd children ;)
 
-my $RUN_THIS_TEST = 0;          # edit and set to 1 if you really want
-
 use lib '.'; use lib 't';
 use SATest; sa_t_init("spamd_prefork_stress");
 use Test;
 
+our $RUN_THIS_TEST;
+
 # require pkill and pgrep be installed to run this test
 BEGIN {
   $RUN_THIS_TEST = conf_bool('run_spamd_prefork_stress_test');
@@ -19,7 +19,8 @@
 
 exit if $SKIP_SPAMD_TESTS;
 
-print "NOTE: this test requires /usr/bin/pkill, /usr/bin/pgrep.\n";
+print "NOTE: this test requires /usr/bin/pkill, /usr/bin/pgrep, and\n".
+    "'run_spamd_prefork_stress_test' set to 'y'.\n";
 exit unless $RUN_THIS_TEST;
 
 system("pgrep", "spamd child");

Added: spamassassin/trunk/t/spamd_prefork_stress_2.t
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/t/spamd_prefork_stress_2.t?view=auto&rev=158200
==============================================================================
--- spamassassin/trunk/t/spamd_prefork_stress_2.t (added)
+++ spamassassin/trunk/t/spamd_prefork_stress_2.t Fri Mar 18 19:36:52 2005
@@ -0,0 +1,60 @@
+#!/usr/bin/perl
+#
+# Warning: do not run this test on a live server; it will kill your
+# spamd children ;)
+
+use lib '.'; use lib 't';
+use SATest; sa_t_init("spamd_prefork_stress_2");
+use Test;
+
+our $RUN_THIS_TEST;
+
+# require pkill and pgrep be installed to run this test
+BEGIN {
+  $RUN_THIS_TEST = conf_bool('run_spamd_prefork_stress_test');
+  (-x "/usr/bin/pkill") or $RUN_THIS_TEST = 0;
+  (-x "/usr/bin/pgrep") or $RUN_THIS_TEST = 0;
+  plan tests => ($SKIP_SPAMD_TESTS || !$RUN_THIS_TEST ? 0 : 14) 
+};
+
+exit if $SKIP_SPAMD_TESTS;
+
+print "NOTE: this test requires /usr/bin/pkill, /usr/bin/pgrep, and\n".
+    "'run_spamd_prefork_stress_test' set to 'y'.\n";
+exit unless $RUN_THIS_TEST;
+
+system("pgrep", "spamd child");
+if ($? >> 8 == 0) {
+  die "not running test: existing 'spamd child' processes would be killed.\n";
+}
+
+# ---------------------------------------------------------------------------
+
+%patterns = (
+
+q{ X-Spam-Status: Yes, score=}, 'status',
+q{ X-Spam-Flag: YES}, 'flag',
+q{ X-Spam-Level: **********}, 'stars',
+q{ FROM_ENDS_IN_NUMS}, 'endsinnums',
+q{ NO_REAL_NAME}, 'noreal',
+
+
+);
+
+start_spamd("-L -m1 --round-robin");
+ok ($spamd_pid > 1);
+ok (spamcrun ("< data/spam/001", \&patterns_run_cb));
+ok_all_patterns();
+
+my $i = 0;
+for ($i = 0; $i < 1999; $i++) {
+  print "killing [$i]\n";
+  system ("pkill", "-f", "spamd child");
+}
+
+clear_pattern_counters();
+ok (spamcrun ("< data/spam/001", \&patterns_run_cb));
+ok_all_patterns();
+ok (stop_spamd());
+
+

Propchange: spamassassin/trunk/t/spamd_prefork_stress_2.t
------------------------------------------------------------------------------
    svn:executable = *



Mime
View raw message