size_t
CtrlAgentProcess::runIO() {
- size_t cnt = getIOService()->getIOService().poll();
+ size_t cnt = getIOService()->poll();
if (!cnt) {
- cnt = getIOService()->getIOService().run_one();
+ cnt = getIOService()->runOne();
}
return (cnt);
}
}
// We have stopped listeners but there may be some pending handlers
// related to these listeners. Need to invoke these handlers.
- getIOService()->getIOService().poll();
+ getIOService()->poll();
// Finally, we're ready to remove no longer used listeners.
http_listeners_.erase(http_listeners_.begin(),
http_listeners_.end() - leaving);
// We have some cancelled operations for which we need to invoke the
// handlers with the operation_aborted error code.
- getIOService()->getIOService().reset();
+ getIOService()->restart();
getIOService()->poll();
EXPECT_EQ(expected_responses, server_socket_->getResponseNum());
// We have some cancelled operations for which we need to invoke the
// handlers with the operation_aborted error code.
- getIOService()->getIOService().reset();
+ getIOService()->restart();
getIOService()->poll();
// Answer of 3 is specific to the stub response we send when the
// Poll runs all that are ready. If none are ready it returns immediately
// with a count of zero.
- size_t cnt = getIOService()->getIOService().poll();
+ size_t cnt = getIOService()->poll();
if (!cnt) {
// Poll ran no handlers either none are ready or the service has been
- // stopped. Either way, call run_one to wait for a IO event. If the
+ // stopped. Either way, call runOne to wait for a IO event. If the
// service is stopped it will return immediately with a cnt of zero.
- cnt = getIOService()->getIOService().run_one();
+ cnt = getIOService()->runOne();
}
return (cnt);
} catch (...) {
// Don't want to throw exceptions from the destructor. The server
// is shutting down anyway.
- ;
}
server_ = NULL; // forget this instance. There should be no callback anymore
while (!stopped && (!cond || !cond())) {
io_service->runOne();
}
- io_service->getIOService().reset();
+ io_service->restart();
}
/// @brief This test verifies that the timer used to fetch the configuration
} catch (...) {
// Don't want to throw exceptions from the destructor. The server
// is shutting down anyway.
- ;
}
server_ = NULL; // forget this instance. There should be no callback anymore
while (!stopped && (!cond || !cond())) {
io_service->runOne();
}
- io_service->getIOService().reset();
+ io_service->restart();
}
/// @brief This test verifies that the timer used to fetch the configuration
size_t
NetconfProcess::runIO() {
- size_t cnt = getIOService()->getIOService().poll();
+ size_t cnt = getIOService()->poll();
if (!cnt) {
- cnt = getIOService()->getIOService().run_one();
+ cnt = getIOService()->runOne();
}
return (cnt);
}
UnixControlSocketTest::reflectServer() {
// Acceptor.
boost::asio::local::stream_protocol::acceptor
- acceptor(io_service_.getIOService());
+ acceptor(io_service_.getInternalIOService());
EXPECT_NO_THROW_LOG(acceptor.open());
boost::asio::local::stream_protocol::endpoint
endpoint(unixSocketFilePath());
EXPECT_NO_THROW_LOG(acceptor.bind(endpoint));
EXPECT_NO_THROW_LOG(acceptor.listen());
boost::asio::local::stream_protocol::socket
- socket(io_service_.getIOService());
+ socket(io_service_.getInternalIOService());
// Ready.
signalReady();
NetconfAgentTest::fakeServer() {
// Acceptor.
boost::asio::local::stream_protocol::acceptor
- acceptor(io_service_->getIOService());
+ acceptor(io_service_->getInternalIOService());
EXPECT_NO_THROW_LOG(acceptor.open());
boost::asio::local::stream_protocol::endpoint
endpoint(unixSocketFilePath());
EXPECT_NO_THROW_LOG(acceptor.bind(endpoint));
EXPECT_NO_THROW_LOG(acceptor.listen());
boost::asio::local::stream_protocol::socket
- socket(io_service_->getIOService());
+ socket(io_service_->getInternalIOService());
// Ready.
signalReady();
///
/// Stops all test servers.
~HAMtServiceTest() {
- io_service_->getIOService().reset();
+ io_service_->restart();
io_service_->poll();
MultiThreadingMgr::instance().setMode(false);
CmdResponseCreator::command_accept_list_.clear();
listener_->stop();
listener2_->stop();
listener3_->stop();
- io_service_->getIOService().reset();
+ io_service_->restart();
io_service_->poll();
MultiThreadingMgr::instance().setMode(false);
}
// Stop the IO service. This should cause the thread to terminate.
io_service_->stop();
thread->join();
- io_service_->getIOService().reset();
+ io_service_->restart();
io_service_->poll();
}
// Stop the IO service. This should cause the thread to terminate.
io_service_->stop();
thread->join();
- io_service_->getIOService().reset();
+ io_service_->restart();
io_service_->poll();
}
// Stop the IO service. This should cause the thread to terminate.
io_service_->stop();
thread->join();
- io_service_->getIOService().reset();
+ io_service_->restart();
io_service_->poll();
// The partner of our server is online and should have responded with
// Stop the IO service. This should cause the thread to terminate.
io_service_->stop();
thread->join();
- io_service_->getIOService().reset();
+ io_service_->restart();
io_service_->poll();
// The partner of our server is online and should have responded with
// Stop the IO service. This should cause the thread to terminate.
io_service_->stop();
thread->join();
- io_service_->getIOService().reset();
+ io_service_->restart();
io_service_->poll();
// The partner of our server is online and should have responded with
// Stop the IO service. This should cause the thread to terminate.
io_service_->stop();
thread->join();
- io_service_->getIOService().reset();
+ io_service_->restart();
io_service_->poll();
ASSERT_TRUE(rsp);
// Stop the IO service. This should cause the thread to terminate.
io_service_->stop();
thread->join();
- io_service_->getIOService().reset();
+ io_service_->restart();
io_service_->poll();
ASSERT_TRUE(rsp);
// Stop the IO service. This should cause the thread to terminate.
io_service_->stop();
thread->join();
- io_service_->getIOService().reset();
+ io_service_->restart();
io_service_->poll();
ASSERT_TRUE(rsp);
// Stop the IO service. This should cause the thread to terminate.
io_service_->stop();
thread->join();
- io_service_->getIOService().reset();
+ io_service_->restart();
io_service_->poll();
// The partner of our server is online and should have responded with
// Stop the IO service. This should cause the thread to terminate.
io_service_->stop();
thread->join();
- io_service_->getIOService().reset();
+ io_service_->restart();
io_service_->poll();
// The partner of our server is online and should have responded with
// Stop the IO service. This should cause the thread to terminate.
io_service_->stop();
thread->join();
- io_service_->getIOService().reset();
+ io_service_->restart();
io_service_->poll();
// The partner should have responded with an error.
// Stop the IO service. This should cause the thread to terminate.
io_service_->stop();
thread->join();
- io_service_->getIOService().reset();
+ io_service_->restart();
io_service_->poll();
// The partner should have responded with an error.
void
HATest::runIOService(long ms) {
- io_service_->getIOService().reset();
+ io_service_->restart();
IntervalTimer timer(*io_service_);
timer.setup(std::bind(&IOService::stop, io_service_), ms,
IntervalTimer::ONE_SHOT);
void
HATest::runIOService(long ms, std::function<bool()> stop_condition) {
- io_service_->getIOService().reset();
+ io_service_->restart();
IntervalTimer timer(*io_service_);
bool timeout = false;
timer.setup(std::bind(&HATest::stopIOServiceHandler, this, std::ref(timeout)),
boost::shared_ptr<std::thread>
HATest::runIOServiceInThread() {
- io_service_->getIOService().reset();
+ io_service_->restart();
bool running = false;
std::mutex mutex;
msgbuf(new OutputBuffer(512)),
received(buff),
callback(cb),
- timer(service.getIOService()),
+ timer(service.getInternalIOService()),
protocol(proto),
cumulative(0),
expected(0),
// Timeout interval chosen to ensure no timeout
protocol_(IOFetch::TCP), // for initialization - will be changed
cumulative_(0),
- timer_(service_.getIOService()),
+ timer_(service_.getInternalIOService()),
receive_buffer_(),
expected_buffer_(new OutputBuffer(512)),
send_buffer_(),
expected_ = IOFetch::STOPPED;
// Post the query
- service_.getIOService().post(fetch);
+ service_.post(fetch);
// Post query_.stop() (yes, the std::bind thing is just
// query_.stop()).
- service_.getIOService().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.
// Stop before it is started
fetch.stop();
- service_.getIOService().post(fetch);
+ service_.post(fetch);
service_.run();
EXPECT_TRUE(run_);
protocol_ = protocol;
expected_ = IOFetch::TIME_OUT;
- service_.getIOService().post(fetch);
+ service_.post(fetch);
service_.run();
EXPECT_TRUE(run_);
}
}
// Socket into which the connection will be accepted.
- tcp::socket socket(service_.getIOService());
+ 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_.getIOService(),
+ 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_.getIOService().post(tcp_fetch_);
+ service_.post(tcp_fetch_);
// ... and execute all the callbacks. This exits when the fetch
// completes.
protocol_ = IOFetch::UDP;
// Set up the server.
- udp::socket socket(service_.getIOService(), 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";
std::bind(&IOFetchTest::udpReceiveHandler,
this, &remote, &socket,
ph::_1, ph::_2, bad_qid, second_send));
- service_.getIOService().post(udp_fetch_);
+ service_.post(udp_fetch_);
if (debug_) {
cout << "udpSendReceive: async_receive_from posted,"
"waiting for callback" << endl;
};
IntervalTimerImpl::IntervalTimerImpl(IOService& io_service) :
- interval_(0), timer_(io_service.getIOService()),
+ interval_(0), timer_(io_service.getInternalIOService()),
mode_(IntervalTimer::REPEATING) {
}
/// @param io_service Reference to the IO service.
explicit IOAcceptor(IOService& io_service)
: IOSocket(),
- acceptor_(new typename ProtocolType::acceptor(io_service.getIOService())) {
+ acceptor_(new typename ProtocolType::acceptor(io_service.getInternalIOService())) {
}
/// @brief Destructor.
/// This method return control to the caller as soon as the
/// first handler has completed. (If no handlers are ready when
/// it is run, it will block until one is.)
- void runOne() {
- io_service_.run_one();
+ ///
+ /// \return The number of handlers that were executed.
+ size_t runOne() {
+ return (static_cast<size_t>(io_service_.run_one()));
};
/// \brief Run the underlying event loop for a ready events.
///
/// This method executes handlers for all ready events and returns.
/// It will return immediately if there are no ready events.
- void poll() {
- io_service_.poll();
+ ///
+ /// \return The number of handlers that were executed.
+ size_t poll() {
+ return (static_cast<size_t>(io_service_.poll()));
+ };
+
+ /// \brief Run the underlying event loop for a ready events.
+ ///
+ /// This method executes handlers for all ready events and returns.
+ /// It will return immediately if there are no ready events.
+ ///
+ /// \return The number of handlers that were executed.
+ size_t pollOne() {
+ return (static_cast<size_t>(io_service_.poll_one()));
};
/// \brief Stop the underlying event loop.
/// that share the same \c io_service with the authoritative server.
/// It will eventually be removed once the wrapper interface is
/// generalized.
- boost::asio::io_service& getIOService() {
+ boost::asio::io_service& getInternalIOService() {
return (io_service_);
}
io_impl_->run();
}
-void
+size_t
IOService::runOne() {
- io_impl_->runOne();
+ return (io_impl_->runOne());
}
-void
+size_t
IOService::poll() {
- io_impl_->poll();
+ return (io_impl_->poll());
+}
+
+size_t
+IOService::pollOne() {
+ return (io_impl_->pollOne());
}
void
}
boost::asio::io_service&
-IOService::getIOService() {
- return (io_impl_->getIOService());
+IOService::getInternalIOService() {
+ return (io_impl_->getInternalIOService());
}
void
/// This method return control to the caller as soon as the
/// first handler has completed. (If no handlers are ready when
/// it is run, it will block until one is.)
- void runOne();
+ ///
+ /// \return The number of handlers that were executed.
+ size_t runOne();
+
+ /// \brief Run the underlying event loop for a ready events.
+ ///
+ /// This method executes handlers for all ready events and returns.
+ /// It will return immediately if there are no ready events.
+ ///
+ /// \return The number of handlers that were executed.
+ size_t poll();
/// \brief Run the underlying event loop for a ready events.
///
/// This method executes handlers for all ready events and returns.
/// It will return immediately if there are no ready events.
- void poll();
+ ///
+ /// \return The number of handlers that were executed.
+ size_t pollOne();
/// \brief Stop the underlying event loop.
///
/// that share the same \c io_service with the authoritative server.
/// It will eventually be removed once the wrapper interface is
/// generalized.
- boost::asio::io_service& getIOService();
+ boost::asio::io_service& getInternalIOService();
/// \brief Post a callback to the end of the queue.
///
IOSignalSetImpl::IOSignalSetImpl(IOServicePtr io_service,
IOSignalHandler handler)
: io_service_(io_service),
- signal_set_(io_service_->getIOService()),
+ signal_set_(io_service_->getInternalIOService()),
handler_(handler) {
}
template <typename Callback, typename TlsStreamImpl>
TlsStreamBase<Callback, TlsStreamImpl>::
TlsStreamBase(IOService& service, TlsContextPtr context)
- : TlsStreamImpl(service.getIOService(), context->getContext()),
+ : TlsStreamImpl(service.getInternalIOService(), context->getContext()),
role_(context->getRole()) {
}
template <typename C>
TCPSocket<C>::TCPSocket(IOService& service) :
- socket_ptr_(new boost::asio::ip::tcp::socket(service.getIOService())),
+ socket_ptr_(new boost::asio::ip::tcp::socket(service.getInternalIOService())),
socket_(*socket_ptr_)
{
}
// we've hit our goals. It won't return zero unless is out of
// work or the service has been stopped by the test timer.
int cnt = 0;
- while (((cnt = io_service_.getIOService().run_one()) > 0) && (repeater_count < 5)) {
+ while (((cnt = io_service_.runOne()) > 0) && (repeater_count < 5)) {
// deliberately empty
};
// we've hit our goals. It won't return zero unless is out of
// work or the service has been stopped by the test timer.
int cnt = 0;
- while ((cnt = io_service_.getIOService().run_one()) && (one_shot_count < 4)) {
+ while ((cnt = io_service_.runOne()) && (one_shot_count < 4)) {
// deliberately empty
};
///
/// @param io_service IO service to be stopped on error.
explicit TCPClient(IOService& io_service)
- : io_service_(io_service.getIOService()), socket_(io_service_) {
+ : io_service_(io_service.getInternalIOService()), socket_(io_service_) {
}
/// @brief Destructor.
TCPEndpoint server_endpoint(server_address, SERVER_PORT);
// Endpoint describing server
TCPEndpoint server_remote_endpoint; // Address where server received message from
- tcp::socket server_socket(service.getIOService());
+ tcp::socket server_socket(service.getInternalIOService());
// Socket used for server
// Step 1. Create the connection between the client and the server. Set
server_cb.queued() = TCPCallback::ACCEPT;
server_cb.called() = TCPCallback::NONE;
server_cb.setCode(42); // Some error
- tcp::acceptor acceptor(service.getIOService(),
+ tcp::acceptor acceptor(service.getInternalIOService(),
tcp::endpoint(tcp::v4(), SERVER_PORT));
acceptor.set_option(tcp::acceptor::reuse_address(true));
acceptor.async_accept(server_socket, server_cb);
///
/// @param io_service IO service to be stopped on error.
explicit TLSClient(IOService& io_service)
- : io_service_(io_service.getIOService()), socket_(io_service_) {
+ : io_service_(io_service.getInternalIOService()), socket_(io_service_) {
}
/// @brief Destructor.
TlsContextPtr server_ctx;
test::configServer(server_ctx);
// Stream used for server.
- TlsStreamImpl server(service.getIOService(), server_ctx->getContext());
+ TlsStreamImpl server(service.getInternalIOService(), server_ctx->getContext());
// Step 1. Create the connection between the client and the server. Set
// up the server to accept incoming connections and have the client open
server_cb.queued() = TLSCallback::ACCEPT;
server_cb.called() = TLSCallback::NONE;
server_cb.setCode(42); // Some error
- tcp::acceptor acceptor(service.getIOService(),
+ tcp::acceptor acceptor(service.getInternalIOService(),
tcp::endpoint(tcp::v4(), SERVER_PORT));
acceptor.set_option(tcp::acceptor::reuse_address(true));
acceptor.async_accept(server.lowest_layer(), server_cb);
exps.addThrow("PEM lib");
exps.addThrow("PEM lib (SSL routines)");
exps.addThrow("unsupported (DECODER routines)");
+ exps.addThrow("unsupported");
// Another possible error.
exps.addThrow("No such file or directory");
exps.runCanThrow([] {
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.getIOService(), server_ep);
+ tcp::acceptor acceptor(service.getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.getIOService(), server_ep);
+ tcp::acceptor acceptor(service.getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.getIOService(), server_ep);
+ tcp::acceptor acceptor(service.getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.getIOService(), server_ep);
+ tcp::acceptor acceptor(service.getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Client part.
- tcp::socket client(service.getIOService());
+ tcp::socket client(service.getInternalIOService());
// Connect to.
client.open(tcp::v4());
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.getIOService(), server_ep);
+ tcp::acceptor acceptor(service.getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Client part.
- tcp::socket client(service.getIOService());
+ tcp::socket client(service.getInternalIOService());
// Connect to.
client.open(tcp::v4());
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.getIOService(), server_ep);
+ tcp::acceptor acceptor(service.getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.getIOService(), server_ep);
+ tcp::acceptor acceptor(service.getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.getIOService(), server_ep);
+ tcp::acceptor acceptor(service.getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.getIOService(), server_ep);
+ tcp::acceptor acceptor(service.getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.getIOService(), server_ep);
+ tcp::acceptor acceptor(service.getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.getIOService(), server_ep);
+ tcp::acceptor acceptor(service.getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Client part.
- tcp::socket client(service.getIOService());
+ tcp::socket client(service.getInternalIOService());
// Connect to.
client.open(tcp::v4());
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.getIOService(), server_ep);
+ tcp::acceptor acceptor(service.getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.getIOService(), server_ep);
+ tcp::acceptor acceptor(service.getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.getIOService(), server_ep);
+ tcp::acceptor acceptor(service.getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.getIOService(), server_ep);
+ tcp::acceptor acceptor(service.getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.getIOService(), server_ep);
+ tcp::acceptor acceptor(service.getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.getIOService(), server_ep);
+ tcp::acceptor acceptor(service.getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.getIOService(), server_ep);
+ tcp::acceptor acceptor(service.getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.getIOService(), server_ep);
+ tcp::acceptor acceptor(service.getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.getIOService(), server_ep);
+ tcp::acceptor acceptor(service.getInternalIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// The server - with which the client communicates. For convenience, we
// use the same io_service, and use the endpoint object created for
// the client to send to as the endpoint object in the constructor.
- boost::asio::ip::udp::socket server(service.getIOService(),
+ boost::asio::ip::udp::socket server(service.getInternalIOService(),
server_endpoint.getASIOEndpoint());
server.set_option(socket_base::reuse_address(true));
/// @return Pointer to the socket.
UnixSocketPtr getSocket() {
if (!next_socket_) {
- next_socket_.reset(new UnixSocket(io_service_.getIOService()));
+ next_socket_.reset(new UnixSocket(io_service_.getInternalIOService()));
}
return (next_socket_);
}
const std::string& custom_response)
: io_service_(io_service),
server_endpoint_(socket_file_path),
- server_acceptor_(io_service_.getIOService()),
+ server_acceptor_(io_service_.getInternalIOService()),
test_timer_(io_service_),
custom_response_(custom_response),
connection_pool_(new ConnectionPool(io_service)),
template <typename C>
UDPSocket<C>::UDPSocket(IOService& service) :
- socket_ptr_(new boost::asio::ip::udp::socket(service.getIOService())),
+ socket_ptr_(new boost::asio::ip::udp::socket(service.getInternalIOService())),
socket_(*socket_ptr_), isopen_(false)
{
}
///
/// @param io_service IO service to be used by the socket class.
UnixDomainSocketImpl(IOService& io_service)
- : socket_(io_service.getIOService()) {
+ : socket_(io_service.getInternalIOService()) {
}
/// @brief Destructor.
// responses. The reuse address option is set so as both sockets can
// use the same address. This new socket is bound to the test address
// and port, where requests will be sent.
- socket_.reset(new udp::socket(service_.getIOService(),
+ socket_.reset(new udp::socket(service_.getInternalIOService(),
boost::asio::ip::udp::v4()));
socket_->set_option(socket_base::reuse_address(true));
socket_->bind(udp::endpoint(address::from_string(TEST_ADDRESS),
// Since the callback, operator(), calls stop() on the io_service,
// we must reset it in order for subsequent calls to run() or
// runOne() to work.
- service_.getIOService().reset();
+ service_.restart();
}
/// @brief Performs a single request-response exchange with or without TSIG.
ASSERT_NO_THROW(message.setZone(Name("example.com"), RRClass::IN()));
// Setup our "loopback" server.
- udp::socket udp_socket(service_.getIOService(), boost::asio::ip::udp::v4());
+ udp::socket udp_socket(service_.getInternalIOService(), boost::asio::ip::udp::v4());
udp_socket.set_option(socket_base::reuse_address(true));
udp_socket.bind(udp::endpoint(address::from_string(TEST_ADDRESS),
TEST_PORT));
// Since the callback, operator(), calls stop() on the io_service,
// we must reset it in order for subsequent calls to run() or
// runOne() to work.
- service_.getIOService().reset();
+ service_.restart();
}
};
server_socket_(), receive_pending_(false), perpetual_receive_(true),
tsig_key_() {
- server_socket_.reset(new boost::asio::ip::udp::socket(io_service_.getIOService(),
+ server_socket_.reset(new boost::asio::ip::udp::socket(io_service_.getInternalIOService(),
boost::asio::ip::udp::v4()));
server_socket_->set_option(boost::asio::socket_base::reuse_address(true));
:io_service_(io_service), address_(server.getIpAddress()),
port_(server.getPort()), server_socket_(), receive_pending_(false),
perpetual_receive_(true), tsig_key_() {
- server_socket_.reset(new boost::asio::ip::udp::socket(io_service_.getIOService(),
+ server_socket_.reset(new boost::asio::ip::udp::socket(io_service_.getInternalIOService(),
boost::asio::ip::udp::v4()));
server_socket_->set_option(boost::asio::socket_base::reuse_address(true));
isc::asiolink::UDPEndpoint endpoint(address_, port_);
int
TimedIO::runTimedIO(int run_time) {
run_time_ = run_time;
- int cnt = io_service_->getIOService().poll();
+ int cnt = io_service_->poll();
if (cnt == 0) {
timer_.setup(std::bind(&TimedIO::timesUp, this), run_time_);
- cnt = io_service_->getIOService().run_one();
+ cnt = io_service_->runOne();
timer_.cancel();
}
// We shouldn't be here if IO isn't ready to execute.
// By running poll we're guaranteed not to hang.
- /// @todo Trac# 3325 requests that asiolink::IOService provide a
- /// wrapper for poll().
- io_service_->getIOService().poll_one();
+ io_service_->pollOne();
}
} // namespace dhcp_ddns
// Create the low level socket.
try {
asio_socket_.reset(new boost::asio::ip::udp::
- socket(io_service.getIOService(),
+ socket(io_service.getInternalIOService(),
(ip_address_.isV4() ? boost::asio::ip::udp::v4() :
boost::asio::ip::udp::v6())));
// Create the low level socket.
try {
asio_socket_.reset(new boost::asio::ip::udp::
- socket(io_service.getIOService(),
+ socket(io_service.getInternalIOService(),
(ip_address_.isV4() ? boost::asio::ip::udp::v4() :
boost::asio::ip::udp::v6())));
// Create a UDP socket through which our "sender" will send the NCR.
boost::asio::ip::udp::socket
- udp_socket(io_service_.getIOService(), boost::asio::ip::udp::v4());
+ udp_socket(io_service_.getInternalIOService(), boost::asio::ip::udp::v4());
// Create an endpoint pointed at the listener.
boost::asio::ip::udp::endpoint
}, timeout_ms, IntervalTimer::ONE_SHOT);
io_service_->run();
- io_service_->getIOService().reset();
+ io_service_->restart();
}
/// @brief Setup timers according to the configuration and run them
io_service_->stop();
}, timeout, asiolink::IntervalTimer::ONE_SHOT);
io_service_->run();
- io_service_->getIOService().reset();
+ io_service_->restart();
}
// This test checks that the interface names can be explicitly selected
}, ms, IntervalTimer::ONE_SHOT);
io_service_->run();
- io_service_->getIOService().reset();
+ io_service_->restart();
}
/// @brief Waits for the specified process to finish.
}, 1, IntervalTimer::REPEATING);
io_service_->run();
- io_service_->getIOService().reset();
+ io_service_->restart();
return (!elapsed);
}
io_service_->stop();
}, timeout, IntervalTimer::ONE_SHOT);
io_service_->run();
- io_service_->getIOService().reset();
+ io_service_->restart();
}
void
/// @param timeout Optional value specifying for how long the io service
/// should be ran.
void runIOService(long timeout = 0) {
- io_service_.getIOService().reset();
+ io_service_.restart();
if (timeout > 0) {
run_io_service_timer_.setup(std::bind(&HttpListenerTest::timeoutHandler,
timeout, IntervalTimer::ONE_SHOT);
}
io_service_.run();
- io_service_.getIOService().reset();
+ io_service_.restart();
io_service_.poll();
}
// This test verifies that listener can't be bound to the port to which
// other server is bound.
TEST_F(HttpListenerTest, addressInUse) {
- tcp::acceptor acceptor(io_service_.getIOService());
+ tcp::acceptor acceptor(io_service_.getInternalIOService());
// Use other port than SERVER_PORT to make sure that this TCP connection
// doesn't affect subsequent tests.
tcp::endpoint endpoint(address::from_string(SERVER_ADDRESS),
explicit TestHttpClient(IOService& io_service,
const std::string& server_address = "127.0.0.1",
uint16_t port = 18123)
- : io_service_(io_service.getIOService()), socket_(io_service_),
+ : io_service_(io_service.getInternalIOService()), socket_(io_service_),
buf_(), response_(), server_address_(server_address),
server_port_(port), receive_done_(false) {
}
/// @param timeout Optional value specifying for how long the io service
/// should be ran (ms).
void runIOService(long timeout = 0) {
- io_service_.getIOService().reset();
+ io_service_.restart();
if (timeout > 0) {
run_io_service_timer_.setup(std::bind(&HttpListenerTest::timeoutHandler,
timeout, IntervalTimer::ONE_SHOT);
}
io_service_.run();
- io_service_.getIOService().reset();
+ io_service_.restart();
io_service_.poll();
}
/// @param io_service IO service to be stopped on error.
/// @param tls_context TLS context.
TestHttpClient(IOService& io_service, TlsContextPtr tls_context)
- : io_service_(io_service.getIOService()),
+ : io_service_(io_service.getInternalIOService()),
stream_(io_service_, tls_context->getContext()),
buf_(), response_() {
}
/// @param timeout Optional value specifying for how long the io service
/// should be ran.
void runIOService(long timeout = 0) {
- io_service_.getIOService().reset();
+ io_service_.restart();
if (timeout > 0) {
run_io_service_timer_.setup(std::bind(&HttpsListenerTest::timeoutHandler,
timeout, IntervalTimer::ONE_SHOT);
}
io_service_.run();
- io_service_.getIOService().reset();
+ io_service_.restart();
io_service_.poll();
}
// This test verifies that listener can't be bound to the port to which
// other server is bound.
TEST_F(HttpsListenerTest, addressInUse) {
- tcp::acceptor acceptor(io_service_.getIOService());
+ tcp::acceptor acceptor(io_service_.getInternalIOService());
// Use other port than SERVER_PORT to make sure that this TCP connection
// doesn't affect subsequent tests.
tcp::endpoint endpoint(address::from_string(SERVER_ADDRESS),
} catch (...) {
// Don't want to throw exceptions from the destructor. The process
// is shutting down anyway.
- ;
}
}
/// @param timeout Optional value specifying for how long the io service
/// should be ran.
void runIOService(long timeout = 0) {
- io_service_.getIOService().reset();
+ io_service_.restart();
if (timeout > 0) {
run_io_service_timer_.setup(std::bind(&TcpListenerTest::timeoutHandler,
IntervalTimer::ONE_SHOT);
}
io_service_.run();
- io_service_.getIOService().reset();
+ io_service_.restart();
io_service_.poll();
}
isc::asiolink::TlsContextPtr(),
const std::string& server_address = "127.0.0.1",
uint16_t port = 18123)
- : io_service_(io_service.getIOService()),
+ : io_service_(io_service.getInternalIOService()),
tls_context_(tls_context),
tcp_socket_(), tls_socket_(),
done_callback_(done_callback),
/// @param timeout Optional value specifying for how long the io service
/// should be ran.
void runIOService(long timeout = 0) {
- io_service_.getIOService().reset();
+ io_service_.restart();
if (timeout > 0) {
run_io_service_timer_.setup(std::bind(&TlsListenerTest::timeoutHandler,
IntervalTimer::ONE_SHOT);
}
io_service_.run();
- io_service_.getIOService().reset();
+ io_service_.restart();
io_service_.poll();
}