Needed SAtimeout as a conditional parameter

Ian Samuel <[email protected]> Mon, 11 Sep 2006 11:33:26 -0400
Newsgroups gmane.mail.exim.spamassassin
Message-ID <[email protected]>
Hi,

Along with using SApermreject as an Exim conditional statement, I needed the 
same for SAtimeout.

I hacked together the attached patch to do that.

I do not pretend to be a programmer, so if I have made any errors please let 
me know.  :-)

Thanks!

i.

-- 
Ian Samuel, B.Sc.
Sr. Linux System Administrator

_______________________________________________
SA-Exim mailing list
[email protected]
http://lists.merlins.org/lists/listinfo/sa-exim
sa-exim-4.2.1-SAtimeoutConditional.patch (text/x-diff, 2.8 KB)
--- sa-exim-4.2.1.orig/sa-exim.c	2005-03-08 15:39:51.000000000 -0500
+++ sa-exim-4.2.1/sa-exim.c	2006-09-11 11:12:03.000000000 -0400
@@ -561,7 +561,9 @@
     static int SAerrmaxarchivebody=1024*1048576;
     static int SAmaxrcptlistlength=0;
     static int SAaddSAEheaderBeforeSA=1;
-    static int SAtimeout=240;
+    static char *SAtimeout="240";
+    static float SAtimeoutthreshold;
+    static int SAtimeoutthresholdi;
     static char *SAtimeoutsave=NULL;
     static char *SAtimeoutSavCond="1";
     static char *SAerrorsave=NULL;
@@ -722,7 +724,7 @@
 	    M_CHECKFORVAR(SAerrmaxarchivebody, "%d");
 	    M_CHECKFORVAR(SAmaxrcptlistlength, "%d");
 	    M_CHECKFORVAR(SAaddSAEheaderBeforeSA, "%d");
-	    M_CHECKFORVAR(SAtimeout, "%d");
+	    M_CHECKFORSTR(SAtimeout);
 	    M_CHECKFORSTR(SAtimeoutsave);
 	    M_CHECKFORSTR(SAtimeoutSavCond);
 	    M_CHECKFORSTR(SAerrorsave);
@@ -773,6 +775,8 @@
 	log_write(0, LOG_MAIN, "SA: Debug3: expanded " #VAR " = %.2f", VAR ## threshold); \
     }\
 
+    M_CONDTOFLOAT(SAtimeout);
+    SAtimeoutthresholdi = SAtimeoutthreshold;
     M_CONDTOFLOAT(SAteergrube);
     M_CONDTOFLOAT(SAdevnull);
     M_CONDTOFLOAT(SApermreject);
@@ -1004,18 +1008,18 @@
 	log_write(0, LOG_MAIN, "SA: Debug6: fed spam to spamc, reading result");
     }
     
-    if (SAtimeout)
+    if (SAtimeoutthresholdi)
     {
 	if (SAEximDebug > 2)
 	{
-	    log_write(0, LOG_MAIN, "SA: Debug3: Setting timeout of %d secs before reading from spamc", SAtimeout);
+	    log_write(0, LOG_MAIN, "SA: Debug3: Setting timeout of %d secs before reading from spamc", SAtimeoutthresholdi);
 	}
 	/* SA can take very long to run for various reasons, let's not wait
 	 * forever, that's just bad at SMTP time */
 	if (setjmp(jmp_env) == 0)
 	{
 	    signal(SIGALRM, alarm_handler);
-	    alarm (SAtimeout);
+	    alarm (SAtimeoutthresholdi);
 	}
 	else
 	{
@@ -1023,10 +1027,10 @@
 	    signal(SIGCHLD, old_sigchld);
 	    fclose((FILE *)readfh);
 
-	    header_add(' ', "X-SA-Exim-Scanned: No (on %s); SA Timed out after %d secs\n", primary_hostname, SAtimeout);
+	    header_add(' ', "X-SA-Exim-Scanned: No (on %s); SA Timed out after %d secs\n", primary_hostname, SAtimeoutthresholdi);
 
 	    /* We sent it to LOG_REJECT too so that we get a header dump */
-	    log_write(0, LOG_MAIN | LOG_REJECT, "SA: Action: spamd took more than %d secs to run, accepting message (scanned in %d/%d secs | Message-Id: %s). %s", SAtimeout, scantime, fulltime, safemesgid, mailinfo);
+	    log_write(0, LOG_MAIN | LOG_REJECT, "SA: Action: spamd took more than %d secs to run, accepting message (scanned in %d/%d secs | Message-Id: %s). %s", SAtimeoutthresholdi, scantime, fulltime, safemesgid, mailinfo);
 
 	    ret=savemail(fd, fdstart, SAtimeoutsave, "SAtimeoutsave", (char *)mesgfn, SAerrmaxarchivebody, SAtimeoutSavCond);
 	    CHECKERR(ret,where,line);