From: Michal 'vorner' Vaner Date: Thu, 5 Jan 2012 08:41:50 +0000 (+0100) Subject: Merge branch 'work/sock/cppclient' into scfinal X-Git-Tag: trac2351_base~304^2~16 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=43fda10b4f6f788050dbed8198fa85ea5b385a80;p=thirdparty%2Fkea.git Merge branch 'work/sock/cppclient' into scfinal --- 43fda10b4f6f788050dbed8198fa85ea5b385a80 diff --cc src/bin/resolver/tests/resolver_config_unittest.cc index 63d75c2bac,87d4826dfc..a381abfdba --- a/src/bin/resolver/tests/resolver_config_unittest.cc +++ b/src/bin/resolver/tests/resolver_config_unittest.cc @@@ -81,8 -62,12 +82,11 @@@ protected scoped_ptr query_message; scoped_ptr client; scoped_ptr request; - ResolverConfig() : dnss(ios, NULL, NULL, NULL) { + ResolverConfig() : + dnss(ios, NULL, NULL, NULL), + sock_requestor_(dnss, address_store_, 53210) + { server.setDNSService(dnss); - server.setConfigured(); } const RequestContext& createRequest(const string& source_addr) { endpoint.reset(IOEndpoint::create(IPPROTO_UDP, IOAddress(source_addr), diff --cc src/lib/asiodns/tcp_server.cc index 2606a21aa9,b351f71ee9..d116bdbe0b --- a/src/lib/asiodns/tcp_server.cc +++ b/src/lib/asiodns/tcp_server.cc @@@ -69,8 -69,33 +69,33 @@@ TCPServer::TCPServer(io_service& io_ser acceptor_->listen(); } + TCPServer::TCPServer(io_service& io_service, int fd, int af, + const SimpleCallback* checkin, + const DNSLookup* lookup, + const DNSAnswer* answer) : + io_(io_service), done_(false), + checkin_callback_(checkin), lookup_callback_(lookup), + answer_callback_(answer) + { + if (af != AF_INET && af != AF_INET6) { + isc_throw(InvalidParameter, "Address family must be either AF_INET " + "or AF_INET6, not " << af); + } + LOG_DEBUG(logger, DBGLVL_TRACE_BASIC, ASIODNS_FD_ADD_TCP).arg(fd); + + try { + acceptor_.reset(new tcp::acceptor(io_service)); + acceptor_->assign(af == AF_INET6 ? tcp::v6() : tcp::v4(), fd); + acceptor_->listen(); + } catch (const std::exception& exception) { + // Whatever the thing throws, it is something from ASIO and we convert + // it + isc_throw(IOError, exception.what()); + } + } + void -TCPServer::operator()(error_code ec, size_t length) { +TCPServer::operator()(asio::error_code ec, size_t length) { /// Because the coroutine reentry block is implemented as /// a switch statement, inline variable declarations are not /// permitted. Certain variables used below can be declared here.