summaryrefslogtreecommitdiff
path: root/ucbhelper
diff options
context:
space:
mode:
authorRĂ¼diger Timm <rt@openoffice.org>2005-10-18 07:47:58 +0000
committerRĂ¼diger Timm <rt@openoffice.org>2005-10-18 07:47:58 +0000
commit1b4f07f8c201edb0827448af230677c85dcff0b7 (patch)
tree7348ae1753584d6294c398a3e7713176351e79c5 /ucbhelper
parent967fecee033224a4d9e95dbc3780f2f3d215a9e6 (diff)
INTEGRATION: CWS kso201bugs01 (1.6.16); FILE MERGED
2005/10/06 10:26:20 kso 1.6.16.2: RESYNC: (1.6-1.7); FILE MERGED 2005/10/05 14:45:12 kso 1.6.16.1: #i49238# - DNS name resolution results are now cached for performance reasons.
Diffstat (limited to 'ucbhelper')
-rw-r--r--ucbhelper/source/client/proxydecider.cxx63
1 files changed, 55 insertions, 8 deletions
diff --git a/ucbhelper/source/client/proxydecider.cxx b/ucbhelper/source/client/proxydecider.cxx
index e0c3b90804d5..28c432a61402 100644
--- a/ucbhelper/source/client/proxydecider.cxx
+++ b/ucbhelper/source/client/proxydecider.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: proxydecider.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: rt $ $Date: 2005-09-09 16:35:26 $
+ * last change: $Author: rt $ $Date: 2005-10-18 08:47:58 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -41,6 +41,7 @@
#include <utility>
#include <vector>
+#include <list>
#ifndef _OSL_MUTEX_HXX_
#include <osl/mutex.hxx>
@@ -111,6 +112,47 @@ public:
typedef std::pair< WildCard, WildCard > NoProxyListEntry;
//=========================================================================
+
+class HostnameCache
+{
+ typedef std::pair< rtl::OUString, rtl::OUString > HostListEntry;
+
+ std::list< HostListEntry > m_aHostList;
+ sal_Int32 m_nCapacity;
+
+public:
+ explicit HostnameCache( sal_Int32 nCapacity )
+ : m_nCapacity( nCapacity ) {}
+
+ bool get( const rtl::OUString & rKey, rtl::OUString & rValue ) const
+ {
+ std::list< HostListEntry >::const_iterator it
+ = m_aHostList.begin();
+ const std::list< HostListEntry >::const_iterator end
+ = m_aHostList.end();
+
+ while ( it != end )
+ {
+ if ( (*it).first == rKey )
+ {
+ rValue = (*it).second;
+ return true;
+ }
+ it++;
+ }
+ return false;
+ }
+
+ void put( const rtl::OUString & rKey, const rtl::OUString & rValue )
+ {
+ if ( m_aHostList.size() == m_nCapacity )
+ m_aHostList.resize( m_nCapacity / 2 );
+
+ m_aHostList.push_front( HostListEntry( rKey, rValue ) );
+ }
+};
+
+//=========================================================================
class InternetProxyDecider_Impl :
public cppu::WeakImplHelper1< util::XChangesListener >
{
@@ -121,6 +163,7 @@ class InternetProxyDecider_Impl :
sal_Int32 m_nProxyType;
uno::Reference< util::XChangesNotifier > m_xNotifier;
std::vector< NoProxyListEntry > m_aNoProxyList;
+ mutable HostnameCache m_aHostnames;
private:
bool shouldUseProxy( const rtl::OUString & rHost,
@@ -238,7 +281,8 @@ bool WildCard::Matches( const rtl::OUString& rString ) const
InternetProxyDecider_Impl::InternetProxyDecider_Impl(
const uno::Reference< lang::XMultiServiceFactory >& rxSMgr )
-: m_nProxyType( 0 )
+ : m_nProxyType( 0 ),
+ m_aHostnames( 256 ) // cache size
{
try
{
@@ -531,10 +575,14 @@ const InternetProxyServer & InternetProxyDecider_Impl::getProxy(
aHost = rHost;
}
- // This might be quite expensive (DNS lookup).
- const osl::SocketAddr aAddr( aHost, nPort );
- rtl::OUString aFullyQualifiedHost(
- aAddr.getHostname().toAsciiLowerCase() );
+ rtl::OUString aFullyQualifiedHost;
+ if ( !m_aHostnames.get( aHost, aFullyQualifiedHost ) )
+ {
+ // This might be quite expensive (DNS lookup).
+ const osl::SocketAddr aAddr( aHost, nPort );
+ aFullyQualifiedHost = aAddr.getHostname().toAsciiLowerCase();
+ m_aHostnames.put( aHost, aFullyQualifiedHost );
+ }
// Error resolving name? -> fallback.
if ( !aFullyQualifiedHost.getLength() )
@@ -756,7 +804,6 @@ void InternetProxyDecider_Impl::setNoProxyList(
// This might be quite expensive (DNS lookup).
const osl::SocketAddr aAddr( aServer, 0 );
rtl::OUString aTmp = aAddr.getHostname().toAsciiLowerCase();
-
if ( aTmp != aServer.toAsciiLowerCase() )
{
if ( bIPv6Address )