File: improve-CNAME-caching.patch

package info (click to toggle)
spamassassin 4.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 22,988 kB
  • sloc: perl: 88,863; ansic: 5,193; sh: 3,737; javascript: 339; sql: 295; makefile: 209; python: 49
file content (29 lines) | stat: -rw-r--r-- 1,276 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
From 4c6ae4d6215f4c553ac9ffcaabb380e2904b7027 Mon Sep 17 00:00:00 2001
From: Giovanni Bechis <gbechis@apache.org>
Date: Wed, 3 Sep 2025 08:16:10 +0000
Subject: [PATCH] improve CNAME caching

git-svn-id: https://svn.apache.org/repos/asf/spamassassin/trunk@1928197 13f79535-47bb-0310-9956-ffa450edef68
---
 lib/Mail/SpamAssassin/PerMsgStatus.pm | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/Mail/SpamAssassin/PerMsgStatus.pm b/lib/Mail/SpamAssassin/PerMsgStatus.pm
index 11eedf0201..16b2dda527 100644
--- a/lib/Mail/SpamAssassin/PerMsgStatus.pm
+++ b/lib/Mail/SpamAssassin/PerMsgStatus.pm
@@ -2918,10 +2918,14 @@ sub add_uri_detail_list {
       my $pkt;
       eval {
         return if not defined $host;
+        return if exists $self->{dns_cname_cache}{$host};
         my $handle = $orig_resolver->bgsend($host, 'CNAME');
         $pkt = $orig_resolver->bgread($handle);
         return if !$pkt; # aborted / timed out
         my @answ = $pkt->answer;
+        # Set an invalid value in the cache, it will be overwritten later
+        # if a CNAME is present
+        $self->{dns_cname_cache}{$host} = 'invalid';
         foreach my $ans ( @answ ) {
           return if not defined $ans->cname;
           if(not exists $self->{dns_cname_cache}{$host}) {