SA Bugzilla – Bug 3016
Received.PM: gethostbyname() timeout too long - should use Net::DNS instead
Last modified: 2004-03-03 14:15:24 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!
Created attachment 1752 [details] Checking this takes 45 seconds
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.
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..
ok, 16 seconds now. ;) That's about as good as it's going to get while still being resilient to intermittent outages...