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

[email protected]
Newsgroups gmane.mail.spam.spamassassin.cvs
Message-ID <175689181811.2817038.4071078122779909375@svn02-us-east.apache.org>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.