diff options
Diffstat (limited to 'src/lib/asiodns')
-rw-r--r-- | src/lib/asiodns/io_fetch.cc | 26 | ||||
-rw-r--r-- | src/lib/asiodns/io_fetch.h | 8 | ||||
-rw-r--r-- | src/lib/asiodns/tests/io_fetch_unittest.cc | 36 |
3 files changed, 35 insertions, 35 deletions
diff --git a/src/lib/asiodns/io_fetch.cc b/src/lib/asiodns/io_fetch.cc index dd6632ffdd..df8cf18565 100644 --- a/src/lib/asiodns/io_fetch.cc +++ b/src/lib/asiodns/io_fetch.cc @@ -55,17 +55,17 @@ const int DBG_ALL = DBGLVL_TRACE_DETAIL + 20; /// want keep the same data). Organising the data in this way keeps copying to /// a minimum. struct IOFetchData { - + IOServicePtr io_service_; ///< The IO service // The first two members are shared pointers to a base class because what is // actually instantiated depends on whether the fetch is over UDP or TCP, // which is not known until construction of the IOFetch. Use of a shared // pointer here is merely to ensure deletion when the data object is deleted. - boost::scoped_ptr<IOAsioSocket<IOFetch> > socket; + boost::scoped_ptr<IOAsioSocket<IOFetch>> socket; ///< Socket to use for I/O boost::scoped_ptr<IOEndpoint> remote_snd;///< Where the fetch is sent boost::scoped_ptr<IOEndpoint> remote_rcv;///< Where the response came from - OutputBufferPtr msgbuf; ///< Wire buffer for question - OutputBufferPtr received; ///< Received data put here + OutputBufferPtr msgbuf; ///< Wire buffer for question + OutputBufferPtr received; ///< Received data put here IOFetch::Callback* callback; ///< Called on I/O Completion boost::asio::deadline_timer timer; ///< Timer to measure timeouts IOFetch::Protocol protocol; ///< Protocol being used @@ -103,14 +103,14 @@ struct IOFetchData { /// \param wait Timeout for the fetch (in ms). /// /// TODO: May need to alter constructor (see comment 4 in Trac ticket #554) - IOFetchData(IOFetch::Protocol proto, IOService& service, + IOFetchData(IOFetch::Protocol proto, const IOServicePtr& service, const IOAddress& address, uint16_t port, OutputBufferPtr& buff, - IOFetch::Callback* cb, int wait) : + IOFetch::Callback* cb, int wait) : io_service_(service), socket((proto == IOFetch::UDP) ? static_cast<IOAsioSocket<IOFetch>*>( - new UDPSocket<IOFetch>(service)) : + new UDPSocket<IOFetch>(io_service_)) : static_cast<IOAsioSocket<IOFetch>*>( - new TCPSocket<IOFetch>(service)) + new TCPSocket<IOFetch>(io_service_)) ), remote_snd((proto == IOFetch::UDP) ? static_cast<IOEndpoint*>(new UDPEndpoint(address, port)) : @@ -123,7 +123,7 @@ struct IOFetchData { msgbuf(new OutputBuffer(512)), received(buff), callback(cb), - timer(service.getInternalIOService()), + timer(io_service_->getInternalIOService()), protocol(proto), cumulative(0), expected(0), @@ -151,7 +151,7 @@ struct IOFetchData { /// IOFetch Constructor - just initialize the private data -IOFetch::IOFetch(Protocol protocol, IOService& service, +IOFetch::IOFetch(Protocol protocol, const IOServicePtr& service, const isc::dns::Question& question, const IOAddress& address, uint16_t port, OutputBufferPtr& buff, Callback* cb, int wait, bool edns) { MessagePtr query_msg(new Message(Message::RENDER)); @@ -159,7 +159,7 @@ IOFetch::IOFetch(Protocol protocol, IOService& service, cb, wait, edns); } -IOFetch::IOFetch(Protocol protocol, IOService& service, +IOFetch::IOFetch(Protocol protocol, const IOServicePtr& service, OutputBufferPtr& outpkt, const IOAddress& address, uint16_t port, OutputBufferPtr& buff, Callback* cb, int wait) : data_(new IOFetchData(protocol, service, @@ -168,7 +168,7 @@ IOFetch::IOFetch(Protocol protocol, IOService& service, data_->packet = true; } -IOFetch::IOFetch(Protocol protocol, IOService& service, +IOFetch::IOFetch(Protocol protocol, const IOServicePtr& service, ConstMessagePtr query_message, const IOAddress& address, uint16_t port, OutputBufferPtr& buff, Callback* cb, int wait) { MessagePtr msg(new Message(Message::RENDER)); @@ -185,7 +185,7 @@ IOFetch::IOFetch(Protocol protocol, IOService& service, void IOFetch::initIOFetch(MessagePtr& query_msg, Protocol protocol, - IOService& service, + const IOServicePtr& service, const isc::dns::Question& question, const IOAddress& address, uint16_t port, OutputBufferPtr& buff, Callback* cb, int wait, bool edns) { diff --git a/src/lib/asiodns/io_fetch.h b/src/lib/asiodns/io_fetch.h index 4b247abfa4..fea13e0455 100644 --- a/src/lib/asiodns/io_fetch.h +++ b/src/lib/asiodns/io_fetch.h @@ -132,7 +132,7 @@ public: /// -1 indicates no timeout. /// \param edns true if the request should be EDNS. The default value is /// true. - IOFetch(Protocol protocol, isc::asiolink::IOService& service, + IOFetch(Protocol protocol, const isc::asiolink::IOServicePtr& service, const isc::dns::Question& question, const isc::asiolink::IOAddress& address, uint16_t port, isc::util::OutputBufferPtr& buff, Callback* cb, @@ -159,7 +159,7 @@ public: /// and deleting it if necessary. /// \param wait Timeout for the fetch (in ms). The default value of /// -1 indicates no timeout. - IOFetch(Protocol protocol, isc::asiolink::IOService& service, + IOFetch(Protocol protocol, const isc::asiolink::IOServicePtr& service, isc::dns::ConstMessagePtr query_message, const isc::asiolink::IOAddress& address, uint16_t port, isc::util::OutputBufferPtr& buff, Callback* cb, @@ -184,7 +184,7 @@ public: /// (default = 53) /// \param wait Timeout for the fetch (in ms). The default value of /// -1 indicates no timeout. - IOFetch(Protocol protocol, isc::asiolink::IOService& service, + IOFetch(Protocol protocol, const isc::asiolink::IOServicePtr& service, isc::util::OutputBufferPtr& outpkt, const isc::asiolink::IOAddress& address, uint16_t port, isc::util::OutputBufferPtr& buff, Callback* cb, @@ -218,7 +218,7 @@ private: /// parameter "query_message" /// \param query_message the message to be sent out. void initIOFetch(isc::dns::MessagePtr& query_message, Protocol protocol, - isc::asiolink::IOService& service, + const isc::asiolink::IOServicePtr& service, const isc::dns::Question& question, const isc::asiolink::IOAddress& address, uint16_t port, isc::util::OutputBufferPtr& buff, Callback* cb, int wait, diff --git a/src/lib/asiodns/tests/io_fetch_unittest.cc b/src/lib/asiodns/tests/io_fetch_unittest.cc index 6529c356ba..5bab99f6a3 100644 --- a/src/lib/asiodns/tests/io_fetch_unittest.cc +++ b/src/lib/asiodns/tests/io_fetch_unittest.cc @@ -55,7 +55,7 @@ const bool DEBUG = false; class IOFetchTest : public virtual ::testing::Test, public virtual IOFetch::Callback { public: - IOService service_; ///< Service to run the query + IOServicePtr service_; ///< Service to run the query IOFetch::Result expected_; ///< Expected result of the callback bool run_; ///< Did the callback run already? Question question_; ///< What to ask @@ -88,7 +88,7 @@ public: /// \brief Constructor IOFetchTest() : - service_(), + service_(new IOService()), expected_(IOFetch::NOTSET), run_(false), question_(Name("example.net"), RRClass::IN(), RRType::A()), @@ -101,7 +101,7 @@ public: // Timeout interval chosen to ensure no timeout protocol_(IOFetch::TCP), // for initialization - will be changed cumulative_(0), - timer_(service_.getInternalIOService()), + timer_(service_->getInternalIOService()), receive_buffer_(), expected_buffer_(new OutputBuffer(512)), send_buffer_(), @@ -455,7 +455,7 @@ public: } // ... and cause the run loop to exit. - service_.stop(); + service_->stop(); } // The next set of methods are the tests themselves. A number of the TCP @@ -474,15 +474,15 @@ public: expected_ = IOFetch::STOPPED; // Post the query - service_.post(fetch); + service_->post(fetch); // Post query_.stop() (yes, the std::bind thing is just // query_.stop()). - service_.post(std::bind(&IOFetch::stop, fetch, IOFetch::STOPPED)); + service_->post(std::bind(&IOFetch::stop, fetch, IOFetch::STOPPED)); // Run both of them. run() returns when everything in the I/O service // queue has completed. - service_.run(); + service_->run(); EXPECT_TRUE(run_); } @@ -500,9 +500,9 @@ public: // Stop before it is started fetch.stop(); - service_.post(fetch); + service_->post(fetch); - service_.run(); + service_->run(); EXPECT_TRUE(run_); } @@ -516,8 +516,8 @@ public: protocol_ = protocol; expected_ = IOFetch::TIME_OUT; - service_.post(fetch); - service_.run(); + service_->post(fetch); + service_->run(); EXPECT_TRUE(run_); } @@ -542,21 +542,21 @@ public: } // Socket into which the connection will be accepted. - tcp::socket socket(service_.getInternalIOService()); + tcp::socket socket(service_->getInternalIOService()); // Acceptor object - called when the connection is made, the handler // will initiate a read on the socket. - tcp::acceptor acceptor(service_.getInternalIOService(), + tcp::acceptor acceptor(service_->getInternalIOService(), tcp::endpoint(tcp::v4(), TEST_PORT)); acceptor.async_accept(socket, std::bind(&IOFetchTest::tcpAcceptHandler, this, &socket, ph::_1)); // Post the TCP fetch object to send the query and receive the response. - service_.post(tcp_fetch_); + service_->post(tcp_fetch_); // ... and execute all the callbacks. This exits when the fetch // completes. - service_.run(); + service_->run(); EXPECT_TRUE(run_); // Make sure the callback did execute // Tidy up @@ -574,7 +574,7 @@ public: protocol_ = IOFetch::UDP; // Set up the server. - udp::socket socket(service_.getInternalIOService(), udp::v4()); + udp::socket socket(service_->getInternalIOService(), udp::v4()); socket.set_option(socket_base::reuse_address(true)); socket.bind(udp::endpoint(TEST_HOST, TEST_PORT)); return_data_ = "Message returned to the client"; @@ -586,12 +586,12 @@ public: std::bind(&IOFetchTest::udpReceiveHandler, this, &remote, &socket, ph::_1, ph::_2, bad_qid, second_send)); - service_.post(udp_fetch_); + service_->post(udp_fetch_); if (debug_) { cout << "udpSendReceive: async_receive_from posted," "waiting for callback" << endl; } - service_.run(); + service_->run(); socket.close(); |