[Catalyst-commits] r13084 - in Catalyst-Runtime/5.80/trunk: .
lib/Catalyst/Engine
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Sun Mar 28 16:54:36 GMT 2010
Author: t0m
Date: 2010-03-28 17:54:36 +0100 (Sun, 28 Mar 2010)
New Revision: 13084
Modified:
Catalyst-Runtime/5.80/trunk/Changes
Catalyst-Runtime/5.80/trunk/lib/Catalyst/Engine/HTTP.pm
Log:
Cache the IP address => hostname lookups which could be performed multiple times to mitigate slow DNS servers. Poor man's replacement for 13063
Modified: Catalyst-Runtime/5.80/trunk/Changes
===================================================================
--- Catalyst-Runtime/5.80/trunk/Changes 2010-03-28 16:43:37 UTC (rev 13083)
+++ Catalyst-Runtime/5.80/trunk/Changes 2010-03-28 16:54:36 UTC (rev 13084)
@@ -11,8 +11,11 @@
in parameter filtering (for example).
- $c->model/view/controller have become a lot faster for non-regexp names
by using direct hash lookup instead of looping.
+ - IP address => hostname mapping for the server is only done once and cached
+ by Catalyst::Engine::HTTP to somewhat mitigate the problem of people
+ developing on machines pointed at slow DNS servers.
- Bug fixed:
+ Bugs fixed:
- DispatchType::Index's uri_for_action only returns for actions registered
with it (prevents 'index :Path' or similar resolving to the wrong URI)
- Make sure to construct Upload objects properly, even if there are
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Engine/HTTP.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Engine/HTTP.pm 2010-03-28 16:43:37 UTC (rev 13083)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Engine/HTTP.pm 2010-03-28 16:54:36 UTC (rev 13084)
@@ -534,13 +534,21 @@
peeraddr => $iaddr
? ( inet_ntoa($iaddr) || '127.0.0.1' )
: '127.0.0.1',
- localname => gethostbyaddr( $localiaddr, AF_INET ) || 'localhost',
+ localname => _gethostbyaddr( $localiaddr ),
localaddr => inet_ntoa($localiaddr) || '127.0.0.1',
};
return $data;
}
+{ # If you have a crappy DNS server then these can be slow, so cache 'em
+ my %hostname_cache;
+ sub _gethostbyaddr {
+ my $ip = shift;
+ $hostname_cache{$ip} ||= gethostbyaddr( $ip, AF_INET ) || 'localhost';
+ }
+}
+
sub _inet_addr { unpack "N*", inet_aton( $_[0] ) }
=head2 options
More information about the Catalyst-commits
mailing list