summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHaavard <havardpe@yahoo-inc.com>2017-07-11 08:39:03 +0000
committerHaavard <havardpe@yahoo-inc.com>2017-07-11 08:39:03 +0000
commitaebc140f653110a5016f478b9e766babee25f05f (patch)
tree92279baa1136830b7a37e334c44ba9736dceeec8 /vespalib
parent2cfbdc9f1f88bac016b01c7da1f8d42e38f9312a (diff)
do not cache identity resolve results
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/tests/net/async_resolver/async_resolver_test.cpp6
-rw-r--r--vespalib/src/vespa/vespalib/net/async_resolver.cpp4
2 files changed, 6 insertions, 4 deletions
diff --git a/vespalib/src/tests/net/async_resolver/async_resolver_test.cpp b/vespalib/src/tests/net/async_resolver/async_resolver_test.cpp
index 4938d2ab68e..806a7f34cbe 100644
--- a/vespalib/src/tests/net/async_resolver/async_resolver_test.cpp
+++ b/vespalib/src/tests/net/async_resolver/async_resolver_test.cpp
@@ -184,11 +184,11 @@ TEST_F("require that resolved hosts are cached", ResolveFixture()) {
EXPECT_EQUAL(f1.get_total_cnt(), 1u);
}
-TEST_F("require that host names resolving to themselves (ip addresses) are also cached", ResolveFixture()) {
+TEST_F("require that host names resolving to themselves (ip addresses) are not cached", ResolveFixture()) {
EXPECT_EQUAL(f1.resolve("tcp/127.0.0.1:123"), "tcp/127.0.0.1:123");
EXPECT_EQUAL(f1.resolve("tcp/127.0.0.1:456"), "tcp/127.0.0.1:456");
- EXPECT_EQUAL(f1.get_cnt("127.0.0.1"), 1u);
- EXPECT_EQUAL(f1.get_total_cnt(), 1u);
+ EXPECT_EQUAL(f1.get_cnt("127.0.0.1"), 2u);
+ EXPECT_EQUAL(f1.get_total_cnt(), 2u);
}
TEST_F("require that cached results expire at the right time", ResolveFixture()) {
diff --git a/vespalib/src/vespa/vespalib/net/async_resolver.cpp b/vespalib/src/vespa/vespalib/net/async_resolver.cpp
index f6e31715d06..babfcd3764d 100644
--- a/vespalib/src/vespa/vespalib/net/async_resolver.cpp
+++ b/vespalib/src/vespa/vespalib/net/async_resolver.cpp
@@ -105,7 +105,9 @@ AsyncResolver::CachingHostResolver::ip_address(const vespalib::string &host_name
return ip_address;
}
ip_address = _resolver->ip_address(host_name);
- store(host_name, ip_address);
+ if (ip_address != host_name) {
+ store(host_name, ip_address);
+ }
return ip_address;
}