Bug 3016 - Received.PM: gethostbyname() timeout too long - should use Net::DNS instead
Summary: Received.PM: gethostbyname() timeout too long - should use Net::DNS instead
Status: RESOLVED FIXED
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: Rules (Eval Tests) (show other bugs)
Version: unspecified
Hardware: Other other
: P3 normal
Target Milestone: 3.0.0
Assignee: SpamAssassin Developer Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-02-06 07:20 UTC by Christian Becker
Modified: 2004-03-03 14:15 UTC (History)
0 users



Attachment Type Modified Status Actions Submitter/CLA Status
Checking this takes 45 seconds text/plain None Christian Becker [NoCLA]
Proposed fix patch None Christian Becker [NoCLA]

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Becker 2004-02-06 07:20:02 UTC
I suggest changing Received.pm's sub lookup_all_ips () to use Net::DNS instead 
of the system call gethostbyname(), because one will wait about 15 seconds per 
lookup if the target's nameservers (not yours) time out; there's no way to 
change this system timeout afaik, whereas Net::DNS allows you to specify a 
quick timeout.
Net::DNS is already required by the routine to work in order to check for DNS 
availability.
To see what I mean, try gethostbyname() on jackpotentry.com where both 
nameservers time out, or try the attached message with SA, it will produce a 
delay of 45 seconds for me!
Comment 1 Christian Becker 2004-02-06 07:20:58 UTC
Created attachment 1752 [details]
Checking this takes 45 seconds
Comment 2 Christian Becker 2004-02-06 09:28:41 UTC
Created attachment 1753 [details]
Proposed fix

To see results with this patch, tweak the resolver configuration within
DNS.pm's load_resolver(). For example, add a line "$self->{res}->retrans(3);"
to wait 3 seconds per nameserver instead of 5. With this config, the previous
sample message comes down to about 25 seconds for example.
Comment 3 Christian Becker 2004-02-06 09:39:45 UTC
25 seconds still sucks; this is due to SA trying to look up various aspects 
(A, MX records) of the same bogus domain, sometimes the same query is sent 
twice. This also affects the parsing of the "Received" lines. I fear there 
needs to be a shared cache in EvalTests.pm and Received.pm that tracks these 
bogus domains, so that any queries (whether A or MX) regarding those servers 
can be skipped. This is beyond my possibilities right now..
Comment 4 Justin Mason 2004-03-03 23:15:24 UTC
ok, 16 seconds now. ;)

That's about as good as it's going to get while still being resilient to
intermittent outages...