From 6f08c4facb0cb2e08348c137f5c10bfb44e49e1d Mon Sep 17 00:00:00 2001 From: Asias He Date: Mon, 26 Oct 2015 21:19:16 +0800 Subject: [PATCH] dns: Move gethostbyname to source file Fix multiple definition of gethostbyname. --- configure.py | 1 + dns.cc | 43 +++++++++++++++++++++++++++++++++++++++++++ dns.hh | 13 ++----------- 3 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 dns.cc diff --git a/configure.py b/configure.py index 502469db1b..08147f6700 100755 --- a/configure.py +++ b/configure.py @@ -398,6 +398,7 @@ scylla_core = (['database.cc', 'init.cc', 'repair/repair.cc', 'exceptions/exceptions.cc', + 'dns.cc', ] + [Antlr3Grammar('cql3/Cql.g')] + [Thrift('interface/cassandra.thrift', 'Cassandra')] diff --git a/dns.cc b/dns.cc new file mode 100644 index 0000000000..8e6bbf8319 --- /dev/null +++ b/dns.cc @@ -0,0 +1,43 @@ +/* + * Copyright 2015 ScyllaDB + */ + +/* + * This file is part of Scylla. + * + * Scylla is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Scylla is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Scylla. If not, see . + */ + +#include +#include +#include "core/sstring.hh" +#include "core/future.hh" +#include "dns.hh" + + +namespace dns { + +future gethostbyname(sstring name) { + hostent e = {name, {}, address_family::INET}; + host_addr a; + if (name == "localhost") { + a.in.s_addr = static_cast(boost::asio::ip::address_v4::loopback().to_ulong()); + } else { + a.in.s_addr = static_cast(boost::asio::ip::address_v4::from_string(name).to_ulong()); + } + e.addresses.push_back(std::move(a)); + return make_ready_future(std::move(e)); +} + +} diff --git a/dns.hh b/dns.hh index 5f18497490..c9af424d73 100644 --- a/dns.hh +++ b/dns.hh @@ -48,15 +48,6 @@ struct hostent { // ATTENTION: this is stub only. It translates "localhost" into loopback address // otherwise it assumes that string is an IP address already -future gethostbyname(sstring name) { - hostent e = {name, {}, address_family::INET}; - host_addr a; - if (name == "localhost") { - a.in.s_addr = static_cast(boost::asio::ip::address_v4::loopback().to_ulong()); - } else { - a.in.s_addr = static_cast(boost::asio::ip::address_v4::from_string(name).to_ulong()); - } - e.addresses.push_back(std::move(a)); - return make_ready_future(std::move(e)); -} +future gethostbyname(sstring name); + }