You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by gb...@apache.org on 2025/09/03 09:30:18 UTC

svn commit: r1928199 - spamassassin/trunk/lib/Mail/SpamAssassin

Author: gbechis
Date: Wed Sep  3 09:30:17 2025
New Revision: 1928199

Log:
limit CNAME cache to 10 entries by default and make it configurable
increase speed processing when there are a huge number of uris

Modified:
   spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm
   spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm	Wed Sep  3 08:30:16 2025	(r1928198)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm	Wed Sep  3 09:30:17 2025	(r1928199)
@@ -2108,6 +2108,19 @@ dns_block_rule query blockage will last
     type => $CONF_TYPE_NUMERIC,
   });
 
+=item dns_max_cname_cache n   (default: 10 entries)
+
+When we find CNAMEs of uris, limit the cache to 10 entries
+and stop processing CNAMEs to limit resource usage.
+
+=cut
+
+  push (@cmds, {
+    setting => 'dns_max_cname_cache',
+    default => 10,
+    type => $CONF_TYPE_NUMERIC,
+  });
+
 =back
 
 =head2 LEARNING OPTIONS

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm	Wed Sep  3 08:30:16 2025	(r1928198)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm	Wed Sep  3 09:30:17 2025	(r1928199)
@@ -2909,7 +2909,8 @@ sub add_uri_detail_list {
       $hosts{$host} = $domain;
     }
 
-    if($self->is_dns_available()) {
+    my $dns_max_cname_cache = $self->{main}->{conf}->{dns_max_cname_cache};
+    if($self->is_dns_available() and (not defined $self->{dns_cname_cache} or scalar %{$self->{dns_cname_cache}} < $dns_max_cname_cache)) {
       # XXX we cannot call bgsend_and_start_lookup,
       # otherwise get_uri_detail_list() might not
       # return domains extracted from CNAME dns queries