Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions tests/unit/dns_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,15 @@ using namespace seastar::net;
static const sstring seastar_name = "seastar.io";

static future<> test_resolve(dns_resolver::options opts) {
auto d = ::make_lw_shared<dns_resolver>(std::move(opts));
return d->get_host_by_name(seastar_name, inet_address::family::INET).then([d](hostent e) {
return d->get_host_by_addr(e.addr_list.front()).then([d, a = e.addr_list.front()](hostent e) {
return d->get_host_by_name(e.names.front(), inet_address::family::INET).then([a](hostent e) {
BOOST_REQUIRE(std::count(e.addr_list.begin(), e.addr_list.end(), a));
});
});
}).finally([d]{
return d->close();
});
auto d = dns_resolver(std::move(opts));
{
auto hostname = seastar_name;
hostent e = co_await d.get_host_by_name(hostname, inet_address::family::INET);
hostent a = co_await d.get_host_by_addr(e.addr_list.front());
hostent e2 = co_await d.get_host_by_name(a.names.front(), inet_address::family::INET);
BOOST_REQUIRE(std::count(e2.addr_list.begin(), e2.addr_list.end(), e.addr_list.front()));
co_await d.close();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not an accurate translation, we lose d.close() on exception. And since you do expect failures, we shouldn't leak here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failures that are "expected" don't lose close -- the d is created once before loop, and in case loop continues it re-uses that single resolver. Exceptions that are not caught make test fail anyway

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aha

}
}

static future<> test_bad_name(dns_resolver::options opts) {
Expand Down