You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by jm...@apache.org on 2005/06/28 09:12:09 UTC

svn commit: r202143 - /spamassassin/trunk/spamd/spamd.raw

Author: jm
Date: Tue Jun 28 00:12:06 2005
New Revision: 202143

URL: http://svn.apache.org/viewcvs?rev=202143&view=rev
Log:
useful feature for future spamd debugging; SIGUSR2 will now dump a stack trace, including the msgid of the most recent message scanned.  thanks to the qpsmtpd team for this one

Modified:
    spamassassin/trunk/spamd/spamd.raw

Modified: spamassassin/trunk/spamd/spamd.raw
URL: http://svn.apache.org/viewcvs/spamassassin/trunk/spamd/spamd.raw?rev=202143&r1=202142&r2=202143&view=diff
==============================================================================
--- spamassassin/trunk/spamd/spamd.raw (original)
+++ spamassassin/trunk/spamd/spamd.raw Tue Jun 28 00:12:06 2005
@@ -52,6 +52,7 @@
 use Cwd ();
 use File::Spec 0.8;
 use File::Path;
+use Carp ();
 
 # Check to make sure the script version and the module version matches.
 # If not, die here!  Also, deal with unchanged VERSION macro.
@@ -734,6 +735,10 @@
 my $got_sighup;
 setup_parent_sig_handlers();
 
+# bonus: SIGUSR2 to dump a stack trace.  this is never reset
+my $current_msgid = "(none)";
+$SIG{USR2} = \&backtrace_handler;
+
 my $select_mask = '';
 vec($select_mask, $server->fileno, 1) = 1;
 $backchannel->set_selector(\$select_mask);
@@ -1224,6 +1229,7 @@
 
   $msgid        ||= "(unknown)";
   $current_user ||= "(unknown)";
+  $current_msgid = $msgid;      # for the SIGUSR2 backtrace
   info("spamd: " . ($method eq 'PROCESS' ? "processing" : "checking")
        . " message $msgid"
        . ( $rmsgid ? " aka $rmsgid" : "" )
@@ -2034,6 +2040,11 @@
     info("spamd: server socket closed");
   }
   $got_sighup = 1;
+}
+
+sub backtrace_handler {
+  Carp::cluck("spamd: caught SIGUSR2 - dumping backtrace. ".
+        "most recent message: $current_msgid\n");
 }
 
 sub daemonize {