changeset 402:9096d2676c13

suppress duplicate calls to acceptable_content for messages with multiple recipients using the same filtering context
author Carl Byington <carl@five-ten-sg.com>
date Mon, 13 Mar 2017 19:09:59 -0700
parents 775174f15b61
children e70d9110d9f5
files src/dnsbl.cpp
diffstat 1 files changed, 11 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/dnsbl.cpp	Thu Mar 09 08:59:32 2017 -0800
+++ b/src/dnsbl.cpp	Mon Mar 13 19:09:59 2017 -0700
@@ -1696,10 +1696,15 @@
             }
         }
 
+        CONTEXT *con = NULL;
+        const char *st;
         for (context_map::iterator i=priv.env_to.begin(); i!=priv.env_to.end(); i++) {
             const char *rcpt   = (*i).first;
-            CONTEXT &con = *((*i).second);
-            const char *st = con.acceptable_content(*priv.memory, score, bulk, priv.queueid, priv.dkim_signers, priv.fromaddr, &priv, msg);
+            CONTEXT    *next = (*i).second;
+            if (con != next) {
+                con = next;
+                st = con->acceptable_content(*priv.memory, score, bulk, priv.queueid, priv.dkim_signers, priv.fromaddr, &priv, msg);
+            }
             if (st == token_black) {
                 // bad html tags or excessive hosts or
                 // high spam assassin score or dcc bulk threshold exceedeed
@@ -1725,8 +1730,8 @@
                 else {
                     // still unknown
                     unknowns.insert(rcpt);
-                    random |= con.get_host_random();
-                    limit   = max(limit, con.get_host_limit());
+                    random |= con->get_host_random();
+                    limit   = max(limit, con->get_host_limit());
                 }
             }
             else if (st == token_white) {