size_t
CtrlAgentProcess::runIO() {
- size_t cnt = getIoService()->get_io_service().poll();
+ size_t cnt = getIOService()->getIOService().poll();
if (!cnt) {
- cnt = getIoService()->get_io_service().run_one();
+ cnt = getIOService()->getIOService().run_one();
}
return (cnt);
}
// Create http listener. It will open up a TCP socket and be
// prepared to accept incoming connection.
HttpListenerPtr http_listener
- (new HttpListener(*getIoService(), server_address,
+ (new HttpListener(*getIOService(), server_address,
server_port, tls_context, rcf,
HttpListener::RequestTimeout(TIMEOUT_AGENT_RECEIVE_COMMAND),
HttpListener::IdleTimeout(TIMEOUT_AGENT_IDLE_CONNECTION_TIMEOUT)));
}
// We have stopped listeners but there may be some pending handlers
// related to these listeners. Need to invoke these handlers.
- getIoService()->get_io_service().poll();
+ getIOService()->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()->get_io_service().reset();
+ getIOService()->getIOService().reset();
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()->get_io_service().reset();
+ getIOService()->getIOService().reset();
getIOService()->poll();
// Answer of 3 is specific to the stub response we send when the
TEST_F(CtrlAgentProcessTest, shutdown) {
// Use an asiolink IntervalTimer and callback to generate the
// shutdown invocation. (Note IntervalTimer setup is in milliseconds).
- IntervalTimer timer(*getIoService());
+ IntervalTimer timer(*getIOService());
timer.setup(std::bind(&CtrlAgentProcessTest::genShutdownCallback, this),
200);
// been received. This means that until we receive the configuration,
// D2 will neither receive nor process NameChangeRequests.
// Pass in IOService for NCR IO event processing.
- queue_mgr_.reset(new D2QueueMgr(getIoService()));
+ queue_mgr_.reset(new D2QueueMgr(getIOService()));
// Instantiate update manager.
// Pass in both queue manager and configuration manager.
// Pass in IOService for DNS update transaction IO event processing.
D2CfgMgrPtr tmp = getD2CfgMgr();
- update_mgr_.reset(new D2UpdateMgr(queue_mgr_, tmp, getIoService()));
+ update_mgr_.reset(new D2UpdateMgr(queue_mgr_, tmp, getIOService()));
// Initialize stats manager.
D2Stats::init();
void
D2Process::init() {
// CommandMgr uses IO service to run asynchronous socket operations.
- isc::config::CommandMgr::instance().setIOService(getIoService());
+ isc::config::CommandMgr::instance().setIOService(getIOService());
};
void
D2Process::runIO() {
// We want to block until at least one handler is called. We'll use
// boost::asio::io_service directly for two reasons. First off
- // asiolink::IOService::run_one is a void and boost::asio::io_service::stopped
+ // asiolink::IOService::runOne is a void and boost::asio::io_service::stopped
// is not present in older versions of boost. We need to know if any
// handlers ran or if the io_service was stopped. That latter represents
// some form of error and the application cannot proceed with a stopped
// service. Secondly, asiolink::IOService does not provide the poll
// method. This is a handy method which runs all ready handlers without
// blocking.
- asiolink::IOServicePtr& io = getIoService();
- boost::asio::io_service& asio_io_service = io->get_io_service();
// Poll runs all that are ready. If none are ready it returns immediately
// with a count of zero.
- size_t cnt = asio_io_service.poll();
+ size_t cnt = getIOService()->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
// service is stopped it will return immediately with a cnt of zero.
- cnt = asio_io_service.run_one();
+ cnt = getIOService()->getIOService().run_one();
}
return (cnt);
if (HooksManager::calloutsPresent(Hooks.hooks_index_d2_srv_configured_)) {
CalloutHandlePtr callout_handle = HooksManager::createCalloutHandle();
- callout_handle->setArgument("io_context", getIoService());
+ callout_handle->setArgument("io_context", getIOService());
callout_handle->setArgument("json_config", config_set);
callout_handle->setArgument("server_config",
getD2CfgMgr()->getD2CfgContext());
TEST_F(D2ProcessTest, normalShutdown) {
// Use an asiolink IntervalTimer and callback to generate the
// shutdown invocation. (Note IntervalTimer setup is in milliseconds).
- isc::asiolink::IntervalTimer timer(*getIoService());
+ isc::asiolink::IntervalTimer timer(*getIOService());
timer.setup(std::bind(&D2ProcessTest::genShutdownCallback, this),
2 * 1000);
TEST_F(D2ProcessTest, fatalErrorShutdown) {
// Use an asiolink IntervalTimer and callback to generate the
// the exception. (Note IntervalTimer setup is in milliseconds).
- isc::asiolink::IntervalTimer timer(*getIoService());
+ isc::asiolink::IntervalTimer timer(*getIOService());
timer.setup(std::bind(&D2ProcessTest::genFatalErrorCallback, this),
2 * 1000);
// Stopping requires IO cancel, which result in a callback.
// So process one event and verify we are STOPPED.
- io_service_->run_one();
+ io_service_->runOne();
EXPECT_EQ(D2QueueMgr::STOPPED, queue_mgr_->getMgrState());
// Verify that we can re-enter the RUNNING from STOPPED by starting the
// Stopping requires IO cancel, which result in a callback.
// So process one event and verify we are STOPPED.
- io_service_->run_one();
+ io_service_->runOne();
EXPECT_EQ(D2QueueMgr::STOPPED, queue_mgr_->getMgrState());
// Verify that we can remove the listener in the STOPPED state and
ASSERT_NO_THROW(sender_->sendRequest(send_ncr));
// running two should do the send then the receive
- io_service_->run_one();
- io_service_->run_one();
+ io_service_->runOne();
+ io_service_->runOne();
// Verify that the request can be added to the queue and queue
// size increments accordingly.
ASSERT_NO_THROW(sender_->sendRequest(send_ncr));
// running two should do the send then the receive
- EXPECT_NO_THROW(io_service_->run_one());
- EXPECT_NO_THROW(io_service_->run_one());
+ EXPECT_NO_THROW(io_service_->runOne());
+ EXPECT_NO_THROW(io_service_->runOne());
EXPECT_EQ(i+1, queue_mgr_->getQueueSize());
}
// Send another. The send should succeed.
ASSERT_NO_THROW(sender_->sendRequest(send_ncr));
- EXPECT_NO_THROW(io_service_->run_one());
+ EXPECT_NO_THROW(io_service_->runOne());
// Now execute the receive which should not throw but should move us
// to STOPPED_QUEUE_FULL state.
- EXPECT_NO_THROW(io_service_->run_one());
+ EXPECT_NO_THROW(io_service_->runOne());
EXPECT_EQ(D2QueueMgr::STOPPED_QUEUE_FULL, queue_mgr_->getMgrState());
// Verify queue size did not increase beyond max.
// Verify that we can again receive requests.
// Send should be fine.
ASSERT_NO_THROW(sender_->sendRequest(send_ncr));
- EXPECT_NO_THROW(io_service_->run_one());
+ EXPECT_NO_THROW(io_service_->runOne());
// Receive should succeed.
- EXPECT_NO_THROW(io_service_->run_one());
+ EXPECT_NO_THROW(io_service_->runOne());
EXPECT_EQ(1, queue_mgr_->getQueueSize());
}
-#line 1 "dhcp4_lexer.cc"
+#line 2 "dhcp4_lexer.cc"
-#line 3 "dhcp4_lexer.cc"
+#line 4 "dhcp4_lexer.cc"
#define YY_INT_ALIGNED short int
/* To avoid the call to exit... oops! */
#define YY_FATAL_ERROR(msg) isc::dhcp::Parser4Context::fatal(msg)
-#line 2258 "dhcp4_lexer.cc"
+#line 2259 "dhcp4_lexer.cc"
/* noyywrap disables automatic rewinding for the next file to parse. Since we
always parse only a single string, there's no need to do any wraps. And
using yywrap requires linking with -lfl, which provides the default yywrap
by moving it ahead by yyleng bytes. yyleng specifies the length of the
currently matched token. */
#define YY_USER_ACTION driver.loc_.columns(yyleng);
-#line 2284 "dhcp4_lexer.cc"
#line 2285 "dhcp4_lexer.cc"
+#line 2286 "dhcp4_lexer.cc"
#define INITIAL 0
#define COMMENT 1
}
-#line 2613 "dhcp4_lexer.cc"
+#line 2614 "dhcp4_lexer.cc"
while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
{
#line 2463 "dhcp4_lexer.ll"
ECHO;
YY_BREAK
-#line 5723 "dhcp4_lexer.cc"
+#line 5724 "dhcp4_lexer.cc"
case YY_END_OF_BUFFER:
{
while (!shutdown_) {
#endif // ENABLE_AFL
try {
- run_one();
+ runOne();
getIOService()->poll();
} catch (const std::exception& e) {
// General catch-all exception that are not caught by more specific
}
void
-Dhcpv4Srv::run_one() {
+Dhcpv4Srv::runOne() {
// client's message and server's response
Pkt4Ptr query;
*callout_handle);
// Callouts decided to drop the received packet.
- // The response (rsp) is null so the caller (run_one) will
+ // The response (rsp) is null so the caller (runOne) will
// immediately return too.
if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_DROP) {
LOG_DEBUG(hooks_logger, DBGLVL_PKT_HANDLING,
/// Main server processing step. Receives one incoming packet, calls
/// the processing packet routing and (if necessary) transmits
/// a response.
- void run_one();
+ void runOne();
/// @brief Process a single incoming DHCPv4 packet and sends the response.
///
// Receive message from the IPC socket.
pkt = ipc.receive();
- // from Dhcpv4Srv::run_one() after receivePacket()
+ // From Dhcpv4Srv::runOne() after receivePacket()
if (pkt) {
LOG_DEBUG(packet4_logger, DBG_DHCP4_BASIC, DHCP4_DHCP4O6_PACKET_RECEIVED)
.arg(static_cast<int>(pkt->getType()))
// Extract the DHCPv4 packet with DHCPv6 packet attached
Pkt4Ptr query(new Pkt4o6(msg->getData(), pkt));
- // From Dhcpv4Srv::run_one() processing and after
+ // From Dhcpv4Srv::runOne() processing and after
Pkt4Ptr rsp;
ControlledDhcpv4Srv::getInstance()->processPacket(query, rsp, false);
srv_->fakeReceive(msg_copy);
try {
- // Invoke run_one instead of run, because we want to avoid triggering
+ // Invoke runOne instead of run, because we want to avoid triggering
// IO service.
- srv_->run_one();
+ srv_->runOne();
} catch (...) {
// Suppress errors, as the DHCPv4 server does.
}
// Run as long as the timeout hasn't occurred and the interrupting
// condition is not specified or not met.
while (!stopped && (!cond || !cond())) {
- io_service->run_one();
+ io_service->runOne();
}
- io_service->get_io_service().reset();
+ io_service->getIOService().reset();
}
/// @brief This test verifies that the timer used to fetch the configuration
}
}
-int Dhcpv6Srv::run() {
+int
+Dhcpv6Srv::run() {
#ifdef ENABLE_AFL
// Set up structures needed for fuzzing.
Fuzz fuzzer(6, server_port_);
while (!shutdown_) {
#endif // ENABLE_AFL
try {
- run_one();
+ runOne();
getIOService()->poll();
} catch (const std::exception& e) {
// General catch-all standard exceptions that are not caught by more
return (getExitValue());
}
-void Dhcpv6Srv::run_one() {
+void
+Dhcpv6Srv::runOne() {
// client's message and server's response
Pkt6Ptr query;
}
// Callouts decided to drop the received packet
- // The response (rsp) is null so the caller (run_one) will
+ // The response (rsp) is null so the caller (runOne) will
// immediately return too.
if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_DROP) {
LOG_DEBUG(hooks_logger, DBGLVL_PKT_HANDLING, DHCP6_HOOK_BUFFER_RCVD_DROP)
/// Main server processing step. Receives one incoming packet, calls
/// the processing packet routing and (if necessary) transmits
/// a response.
- void run_one();
+ void runOne();
/// @brief Process a single incoming DHCPv6 packet and sends the response.
///
srv_->fakeReceive(msg_copy);
try {
- // Invoke run_one instead of run, because we want to avoid triggering
+ // Invoke runOne instead of run, because we want to avoid triggering
// IO service.
- srv_->run_one();
+ srv_->runOne();
} catch (...) {
// Suppress errors, as the DHCPv6 server does.
}
// Run as long as the timeout hasn't occurred and the interrupting
// condition is not specified or not met.
while (!stopped && (!cond || !cond())) {
- io_service->run_one();
+ io_service->runOne();
}
- io_service->get_io_service().reset();
+ io_service->getIOService().reset();
}
/// @brief This test verifies that the timer used to fetch the configuration
size_t
NetconfProcess::runIO() {
- size_t cnt = getIoService()->get_io_service().poll();
+ size_t cnt = getIOService()->getIOService().poll();
if (!cnt) {
- cnt = getIoService()->get_io_service().run_one();
+ cnt = getIOService()->getIOService().run_one();
}
return (cnt);
}
UnixControlSocketTest::reflectServer() {
// Acceptor.
boost::asio::local::stream_protocol::acceptor
- acceptor(io_service_.get_io_service());
+ acceptor(io_service_.getIOService());
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_.get_io_service());
+ socket(io_service_.getIOService());
// Ready.
signalReady();
accepted = true;
});
while (!accepted && !timeout) {
- io_service_.run_one();
+ io_service_.runOne();
}
ASSERT_FALSE(ec);
received = cnt;
});
while (!received && !timeout) {
- io_service_.run_one();
+ io_service_.runOne();
}
ASSERT_FALSE(ec);
rbuf.resize(received);
sent = cnt;
});
while (!sent && !timeout) {
- io_service_.run_one();
+ io_service_.runOne();
}
ASSERT_FALSE(ec);
signalReady();
// Until stop() is called run IO service.
while (!isStopping()) {
- io_service_.run_one();
+ io_service_.runOne();
}
// Main thread signalled that the thread should
// terminate. Launch any outstanding IO service
/// @brief Stop listener.
///
- /// Post an empty action to finish current run_one.
+ /// Post an empty action to finish current runOne.
void stop() {
// Notify the thread that it should terminate.
signalStopping();
// If the thread is blocked on running the IO
// service, post the empty handler to cause
- // run_one to return.
+ // runOne to return.
io_service_.post([]() { return; });
// We asked that the thread stops. Let's wait
// for it to signal that it has stopped.
TEST_F(NetconfProcessTest, shutdown) {
// Use an asiolink IntervalTimer and callback to generate the
// shutdown invocation. (Note IntervalTimer setup is in milliseconds).
- IntervalTimer timer(*getIoService());
+ IntervalTimer timer(*getIOService());
timer.setup(std::bind(&NetconfProcessTest::genShutdownCallback, this),
200);
NetconfAgentTest::fakeServer() {
// Acceptor.
boost::asio::local::stream_protocol::acceptor
- acceptor(io_service_->get_io_service());
+ acceptor(io_service_->getIOService());
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_->get_io_service());
+ socket(io_service_->getIOService());
// Ready.
signalReady();
accepted = true;
});
while (!accepted && !timeout) {
- io_service_->run_one();
+ io_service_->runOne();
}
ASSERT_FALSE(ec);
received = cnt;
});
while (!received && !timeout) {
- io_service_->run_one();
+ io_service_->runOne();
}
ASSERT_FALSE(ec);
rbuf.resize(received);
sent = cnt;
});
while (!sent && !timeout) {
- io_service_->run_one();
+ io_service_->runOne();
}
ASSERT_FALSE(ec);
Dhcpv4Srv::run() {
while (!shutdown_) {
try {
- run_one();
+ runOne();
getIOService()->poll();
} catch (const std::exception& e) {
// General catch-all exception that are not caught by more specific
}
@endcode
-The @c run_one() call includes a @c select() invocation with a timeout of
+The @c runOne() call includes a @c select() invocation with a timeout of
1 second. The @c poll() is not invoked for at most 1 second while the server
is performing this blocking @c select(). Future Kea releases should mitigate
this problem by introducing some mechanisms for concurrent reception and
///
/// Stops all test servers.
~HAMtServiceTest() {
- io_service_->get_io_service().reset();
+ io_service_->getIOService().reset();
io_service_->poll();
MultiThreadingMgr::instance().setMode(false);
CmdResponseCreator::command_accept_list_.clear();
listener_->stop();
listener2_->stop();
listener3_->stop();
- io_service_->get_io_service().reset();
+ io_service_->getIOService().reset();
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_->get_io_service().reset();
+ io_service_->getIOService().reset();
io_service_->poll();
}
// Stop the IO service. This should cause the thread to terminate.
io_service_->stop();
thread->join();
- io_service_->get_io_service().reset();
+ io_service_->getIOService().reset();
io_service_->poll();
}
// Stop the IO service. This should cause the thread to terminate.
io_service_->stop();
thread->join();
- io_service_->get_io_service().reset();
+ io_service_->getIOService().reset();
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_->get_io_service().reset();
+ io_service_->getIOService().reset();
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_->get_io_service().reset();
+ io_service_->getIOService().reset();
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_->get_io_service().reset();
+ io_service_->getIOService().reset();
io_service_->poll();
ASSERT_TRUE(rsp);
// Stop the IO service. This should cause the thread to terminate.
io_service_->stop();
thread->join();
- io_service_->get_io_service().reset();
+ io_service_->getIOService().reset();
io_service_->poll();
ASSERT_TRUE(rsp);
// Stop the IO service. This should cause the thread to terminate.
io_service_->stop();
thread->join();
- io_service_->get_io_service().reset();
+ io_service_->getIOService().reset();
io_service_->poll();
ASSERT_TRUE(rsp);
// Stop the IO service. This should cause the thread to terminate.
io_service_->stop();
thread->join();
- io_service_->get_io_service().reset();
+ io_service_->getIOService().reset();
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_->get_io_service().reset();
+ io_service_->getIOService().reset();
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_->get_io_service().reset();
+ io_service_->getIOService().reset();
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_->get_io_service().reset();
+ io_service_->getIOService().reset();
io_service_->poll();
// The partner should have responded with an error.
void
HATest::runIOService(long ms) {
- io_service_->get_io_service().reset();
+ io_service_->getIOService().reset();
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_->get_io_service().reset();
+ io_service_->getIOService().reset();
IntervalTimer timer(*io_service_);
bool timeout = false;
timer.setup(std::bind(&HATest::stopIOServiceHandler, this, std::ref(timeout)),
ms, IntervalTimer::ONE_SHOT);
while (!stop_condition() && !timeout) {
- io_service_->run_one();
+ io_service_->runOne();
}
timer.cancel();
boost::shared_ptr<std::thread>
HATest::runIOServiceInThread() {
- io_service_->get_io_service().reset();
+ io_service_->getIOService().reset();
bool running = false;
std::mutex mutex;
msgbuf(new OutputBuffer(512)),
received(buff),
callback(cb),
- timer(service.get_io_service()),
+ timer(service.getIOService()),
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_.get_io_service()),
+ timer_(service_.getIOService()),
receive_buffer_(),
expected_buffer_(new OutputBuffer(512)),
send_buffer_(),
expected_ = IOFetch::STOPPED;
// Post the query
- service_.get_io_service().post(fetch);
+ service_.getIOService().post(fetch);
// Post query_.stop() (yes, the std::bind thing is just
// query_.stop()).
- service_.get_io_service().post(
+ service_.getIOService().post(
std::bind(&IOFetch::stop, fetch, IOFetch::STOPPED));
// Run both of them. run() returns when everything in the I/O service
// Stop before it is started
fetch.stop();
- service_.get_io_service().post(fetch);
+ service_.getIOService().post(fetch);
service_.run();
EXPECT_TRUE(run_);
protocol_ = protocol;
expected_ = IOFetch::TIME_OUT;
- service_.get_io_service().post(fetch);
+ service_.getIOService().post(fetch);
service_.run();
EXPECT_TRUE(run_);
}
}
// Socket into which the connection will be accepted.
- tcp::socket socket(service_.get_io_service());
+ tcp::socket socket(service_.getIOService());
// Acceptor object - called when the connection is made, the handler
// will initiate a read on the socket.
- tcp::acceptor acceptor(service_.get_io_service(),
+ tcp::acceptor acceptor(service_.getIOService(),
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_.get_io_service().post(tcp_fetch_);
+ service_.getIOService().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_.get_io_service(), udp::v4());
+ udp::socket socket(service_.getIOService(), 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_.get_io_service().post(udp_fetch_);
+ service_.getIOService().post(udp_fetch_);
if (debug_) {
cout << "udpSendReceive: async_receive_from posted,"
"waiting for callback" << endl;
template <typename Callback, typename TlsStreamImpl>
TlsStreamBase<Callback, TlsStreamImpl>::
TlsStreamBase(IOService& service, TlsContextPtr context)
- : TlsStreamImpl(service.get_io_service(), context->getContext()),
+ : TlsStreamImpl(service.getIOService(), context->getContext()),
role_(context->getRole()) {
}
template <typename Callback, typename TlsStreamImpl>
TlsStreamBase<Callback, TlsStreamImpl>::
TlsStreamBase(IOService& service, TlsContextPtr context)
- : TlsStreamImpl(service.get_io_service()), role_(context->getRole()) {
+ : TlsStreamImpl(service.getIOService()), role_(context->getRole()) {
}
/// @brief Botan fake TLS stream.
};
IntervalTimerImpl::IntervalTimerImpl(IOService& io_service) :
- interval_(0), timer_(io_service.get_io_service()),
+ interval_(0), timer_(io_service.getIOService()),
mode_(IntervalTimer::REPEATING) {
}
/// @param io_service Reference to the IO service.
explicit IOAcceptor(IOService& io_service)
: IOSocket(),
- acceptor_(new typename ProtocolType::acceptor(io_service.get_io_service())) {
+ acceptor_(new typename ProtocolType::acceptor(io_service.getIOService())) {
}
/// @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 run_one() {
+ void runOne() {
io_service_.run_one();
};
/// 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& get_io_service() {
+ boost::asio::io_service& getIOService() {
return (io_service_);
}
}
void
-IOService::run_one() {
- io_impl_->run_one();
+IOService::runOne() {
+ io_impl_->runOne();
}
void
}
boost::asio::io_service&
-IOService::get_io_service() {
- return (io_impl_->get_io_service());
+IOService::getIOService() {
+ return (io_impl_->getIOService());
}
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 run_one();
+ void runOne();
/// \brief Run the underlying event loop for a ready events.
///
/// 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& get_io_service();
+ boost::asio::io_service& getIOService();
/// \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_->get_io_service()),
+ signal_set_(io_service_->getIOService()),
handler_(handler) {
}
template <typename Callback, typename TlsStreamImpl>
TlsStreamBase<Callback, TlsStreamImpl>::
TlsStreamBase(IOService& service, TlsContextPtr context)
- : TlsStreamImpl(service.get_io_service(), context->getContext()),
+ : TlsStreamImpl(service.getIOService(), context->getContext()),
role_(context->getRole()) {
}
template <typename C>
TCPSocket<C>::TCPSocket(IOService& service) :
- socket_ptr_(new boost::asio::ip::tcp::socket(service.get_io_service())),
+ socket_ptr_(new boost::asio::ip::tcp::socket(service.getIOService())),
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_.get_io_service().run_one()) > 0)
- && (repeater_count < 5)) {
+ while (((cnt = io_service_.getIOService().run_one()) > 0) && (repeater_count < 5)) {
// deliberately empty
};
// Run until a single event handler executes. This should be our
// one-shot expiring.
- io_service_.run_one();
+ io_service_.runOne();
// Verify the timer expired once.
ASSERT_EQ(one_shot_count, 1);
// Run until a single event handler executes. This should be our
// one-shot expiring.
- io_service_.run_one();
+ io_service_.runOne();
// Verify the timer expired once.
ASSERT_EQ(one_shot_count, 2);
// 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_.get_io_service().run_one())
- && (one_shot_count < 4)) {
+ while ((cnt = io_service_.getIOService().run_one()) && (one_shot_count < 4)) {
// deliberately empty
};
// The first handler executed is the IOSignal's internal timer expire
// callback.
- io_service_->run_one();
+ io_service_->runOne();
// The next handler executed is IOSignal's handler.
- io_service_->run_one();
+ io_service_->runOne();
// Polling once to be sure.
io_service_->poll();
// The first handler executed is the IOSignal's internal timer expire
// callback.
- io_service_->run_one();
+ io_service_->runOne();
// The next handler executed is IOSignal's handler.
- io_service_->run_one();
+ io_service_->runOne();
// Polling once to be sure.
io_service_->poll();
// They have not yet been called
EXPECT_TRUE(called.empty());
// Process two events
- service.run_one();
- service.run_one();
+ service.runOne();
+ service.runOne();
// Both events were called in the right order
ASSERT_EQ(2, called.size());
EXPECT_EQ(1, called[0]);
setTestTime(1000);
// The next handler executed is IOSignal's handler.
- io_service_->run_one();
+ io_service_->runOne();
// The first handler executed is the IOSignal's internal timer expire
// callback.
- io_service_->run_one();
+ io_service_->runOne();
// Polling once to be sure.
io_service_->poll();
setTestTime(1000);
// The next handler executed is IOSignal's handler.
- io_service_->run_one();
+ io_service_->runOne();
// The first handler executed is the IOSignal's internal timer expire
// callback.
- io_service_->run_one();
+ io_service_->runOne();
// Polling once to be sure.
io_service_->poll();
setTestTime(1000);
// The next handler executed is IOSignal's handler.
- io_service_->run_one();
+ io_service_->runOne();
// The first handler executed is the IOSignal's internal timer expire
// callback.
- io_service_->run_one();
+ io_service_->runOne();
// Polling once to be sure.
io_service_->poll();
setTestTime(1000);
// The next handler executed is IOSignal's handler.
- io_service_->run_one();
+ io_service_->runOne();
// The first handler executed is the IOSignal's internal timer expire
// callback.
- io_service_->run_one();
+ io_service_->runOne();
// Polling once to be sure.
io_service_->poll();
setTestTime(1000);
// The next handler executed is IOSignal's handler.
- io_service_->run_one();
+ io_service_->runOne();
// The first handler executed is the IOSignal's internal timer expire
// callback.
- io_service_->run_one();
+ io_service_->runOne();
// Polling once to be sure.
io_service_->poll();
setTestTime(1000);
// The next handler executed is IOSignal's handler.
- io_service_->run_one();
+ io_service_->runOne();
// The first handler executed is the IOSignal's internal timer expire
// callback.
- io_service_->run_one();
+ io_service_->runOne();
// Polling once to be sure.
io_service_->poll();
setTestTime(1000);
// The next handler executed is IOSignal's handler.
- io_service_->run_one();
+ io_service_->runOne();
// The first handler executed is the IOSignal's internal timer expire
// callback.
- io_service_->run_one();
+ io_service_->runOne();
// Polling once to be sure.
io_service_->poll();
///
/// @param io_service IO service to be stopped on error.
explicit TCPClient(IOService& io_service)
- : io_service_(io_service.get_io_service()), socket_(io_service_) {
+ : io_service_(io_service.getIOService()), 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.get_io_service());
+ tcp::socket server_socket(service.getIOService());
// 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.get_io_service(),
+ tcp::acceptor acceptor(service.getIOService(),
tcp::endpoint(tcp::v4(), SERVER_PORT));
acceptor.set_option(tcp::acceptor::reuse_address(true));
acceptor.async_accept(server_socket, server_cb);
client.open(&server_endpoint, client_cb);
// Run the open and the accept callback and check that they ran.
- service.run_one();
- service.run_one();
+ service.runOne();
+ service.runOne();
EXPECT_EQ(TCPCallback::ACCEPT, server_cb.called());
EXPECT_EQ(0, server_cb.getCode());
// Wait for the client callback to complete. (Must do this first on
// Solaris: if we do the synchronous read first, the test hangs.)
- service.run_one();
+ service.runOne();
// Synchronously read the data from the server.;
serverRead(server_socket, server_cb);
bool server_complete = false;
bool client_complete = false;
while (!server_complete || !client_complete) {
- service.run_one();
+ service.runOne();
// Has the server run?
if (!server_complete) {
///
/// @param io_service IO service to be stopped on error.
explicit TLSClient(IOService& io_service)
- : io_service_(io_service.get_io_service()), socket_(io_service_) {
+ : io_service_(io_service.getIOService()), socket_(io_service_) {
}
/// @brief Destructor.
TlsContextPtr server_ctx;
test::configServer(server_ctx);
// Stream used for server.
- TlsStreamImpl server(service.get_io_service(), server_ctx->getContext());
+ TlsStreamImpl server(service.getIOService(), 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.get_io_service(),
+ tcp::acceptor acceptor(service.getIOService(),
tcp::endpoint(tcp::v4(), SERVER_PORT));
acceptor.set_option(tcp::acceptor::reuse_address(true));
acceptor.async_accept(server.lowest_layer(), server_cb);
// Run the open and the accept callback and check that they ran.
while ((server_cb.called() == TLSCallback::NONE) ||
(client_cb.called() == TLSCallback::NONE)) {
- service.run_one();
+ service.runOne();
}
EXPECT_EQ(TLSCallback::ACCEPT, server_cb.called());
EXPECT_EQ(0, server_cb.getCode());
while ((server_cb.called() == TLSCallback::NONE) ||
(client_cb.called() == TLSCallback::NONE)) {
- service.run_one();
+ service.runOne();
}
EXPECT_EQ(TLSCallback::HANDSHAKE, client_cb.called());
EXPECT_EQ(0, client_cb.getCode());
// Wait for the client callback to complete. (Must do this first on
// Solaris: if we do the synchronous read first, the test hangs.)
while (client_cb.called() == TLSCallback::NONE) {
- service.run_one();
+ service.runOne();
}
// Synchronously read the data from the server.;
bool server_complete = false;
bool client_complete = false;
while (!server_complete || !client_complete) {
- service.run_one();
+ service.runOne();
// Has the server run?
if (!server_complete) {
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.get_io_service(), server_ep);
+ tcp::acceptor acceptor(service.getIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Run accept and connect.
while (!accept_cb.getCalled() || !connect_cb.getCalled()) {
- service.run_one();
+ service.runOne();
}
// Verify the error codes.
TestCallback send_cb;
async_write(client, boost::asio::buffer(send_buf), send_cb);
while (!timeout && !send_cb.getCalled()) {
- service.run_one();
+ service.runOne();
}
timer1.cancel();
TestCallback receive_cb;
server.async_read_some(boost::asio::buffer(receive_buf), receive_cb);
while (!timeout && !receive_cb.getCalled()) {
- service.run_one();
+ service.runOne();
}
timer2.cancel();
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.get_io_service(), server_ep);
+ tcp::acceptor acceptor(service.getIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Run accept and connect.
while (!accept_cb.getCalled() || !connect_cb.getCalled()) {
- service.run_one();
+ service.runOne();
}
// Verify the error codes.
TestCallback client_cb;
client.handshake(client_cb);
while (!timeout && (!server_cb.getCalled() || !client_cb.getCalled())) {
- service.run_one();
+ service.runOne();
}
timer.cancel();
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.get_io_service(), server_ep);
+ tcp::acceptor acceptor(service.getIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Run accept and connect.
while (!accept_cb.getCalled() || !connect_cb.getCalled()) {
- service.run_one();
+ service.runOne();
}
// Verify the error codes.
TestCallback client_cb;
client.async_handshake(roleToImpl(TlsRole::CLIENT), client_cb);
while (!timeout && (!server_cb.getCalled() || !client_cb.getCalled())) {
- service.run_one();
+ service.runOne();
}
timer.cancel();
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.get_io_service(), server_ep);
+ tcp::acceptor acceptor(service.getIOService(), 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.get_io_service());
+ tcp::socket client(service.getIOService());
// Connect to.
client.open(tcp::v4());
// Run accept and connect.
while (!accept_cb.getCalled() || !connect_cb.getCalled()) {
- service.run_one();
+ service.runOne();
}
// Verify the error codes.
client.async_send(boost::asio::buffer(send_buf), client_cb);
while (!timeout && (!server_cb.getCalled() || !client_cb.getCalled())) {
- service.run_one();
+ service.runOne();
}
timer.cancel();
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.get_io_service(), server_ep);
+ tcp::acceptor acceptor(service.getIOService(), 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.get_io_service());
+ tcp::socket client(service.getIOService());
// Connect to.
client.open(tcp::v4());
// Run accept and connect.
while (!accept_cb.getCalled() || !connect_cb.getCalled()) {
- service.run_one();
+ service.runOne();
}
// Verify the error codes.
client.async_send(boost::asio::buffer(send_buf), client_cb);
while (!timeout && (!server_cb.getCalled() || !client_cb.getCalled())) {
- service.run_one();
+ service.runOne();
}
timer.cancel();
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.get_io_service(), server_ep);
+ tcp::acceptor acceptor(service.getIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Run accept and connect.
while (!accept_cb.getCalled() || !connect_cb.getCalled()) {
- service.run_one();
+ service.runOne();
}
// Verify the error codes.
TestCallback client_cb;
client.async_handshake(roleToImpl(TlsRole::CLIENT), client_cb);
while (!timeout && (!server_cb.getCalled() || !client_cb.getCalled())) {
- service.run_one();
+ service.runOne();
}
timer.cancel();
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.get_io_service(), server_ep);
+ tcp::acceptor acceptor(service.getIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Run accept and connect.
while (!accept_cb.getCalled() || !connect_cb.getCalled()) {
- service.run_one();
+ service.runOne();
}
// Verify the error codes.
TestCallback client_cb;
client.async_handshake(roleToImpl(TlsRole::CLIENT), client_cb);
while (!timeout && (!server_cb.getCalled() || !client_cb.getCalled())) {
- service.run_one();
+ service.runOne();
}
timer.cancel();
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.get_io_service(), server_ep);
+ tcp::acceptor acceptor(service.getIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Run accept and connect.
while (!accept_cb.getCalled() || !connect_cb.getCalled()) {
- service.run_one();
+ service.runOne();
}
// Verify the error codes.
TestCallback send_cb(&client.lowest_layer());
async_write(client, boost::asio::buffer(send_buf), send_cb);
while (!timeout && !send_cb.getCalled()) {
- service.run_one();
+ service.runOne();
}
timer1.cancel();
TestCallback receive_cb;
server.async_read_some(boost::asio::buffer(receive_buf), receive_cb);
while (!timeout && !receive_cb.getCalled()) {
- service.run_one();
+ service.runOne();
}
timer2.cancel();
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.get_io_service(), server_ep);
+ tcp::acceptor acceptor(service.getIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Run accept and connect.
while (!accept_cb.getCalled() || !connect_cb.getCalled()) {
- service.run_one();
+ service.runOne();
}
// Verify the error codes.
TestCallback client_cb;
client.handshake(client_cb);
while (!timeout && (!server_cb.getCalled() || !client_cb.getCalled())) {
- service.run_one();
+ service.runOne();
}
timer.cancel();
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.get_io_service(), server_ep);
+ tcp::acceptor acceptor(service.getIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Run accept and connect.
while (!accept_cb.getCalled() || !connect_cb.getCalled()) {
- service.run_one();
+ service.runOne();
}
// Verify the error codes.
TestCallback client_cb(&client.lowest_layer());
client.async_handshake(roleToImpl(TlsRole::CLIENT), client_cb);
while (!timeout && (!server_cb.getCalled() || !client_cb.getCalled())) {
- service.run_one();
+ service.runOne();
}
timer.cancel();
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.get_io_service(), server_ep);
+ tcp::acceptor acceptor(service.getIOService(), 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.get_io_service());
+ tcp::socket client(service.getIOService());
// Connect to.
client.open(tcp::v4());
// Run accept and connect.
while (!accept_cb.getCalled() || !connect_cb.getCalled()) {
- service.run_one();
+ service.runOne();
}
// Verify the error codes.
client.async_send(boost::asio::buffer(send_buf), client_cb);
while (!timeout && (!server_cb.getCalled() || !client_cb.getCalled())) {
- service.run_one();
+ service.runOne();
}
timer.cancel();
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.get_io_service(), server_ep);
+ tcp::acceptor acceptor(service.getIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Run accept and connect.
while (!accept_cb.getCalled() || !connect_cb.getCalled()) {
- service.run_one();
+ service.runOne();
}
// Verify the error codes.
TestCallback client_cb;
client.async_handshake(roleToImpl(TlsRole::CLIENT), client_cb);
while (!timeout && (!server_cb.getCalled() || !client_cb.getCalled())) {
- service.run_one();
+ service.runOne();
}
timer.cancel();
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.get_io_service(), server_ep);
+ tcp::acceptor acceptor(service.getIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Run accept and connect.
while (!accept_cb.getCalled() || !connect_cb.getCalled()) {
- service.run_one();
+ service.runOne();
}
// Verify the error codes.
TestCallback client_cb;
client.async_handshake(roleToImpl(TlsRole::CLIENT), client_cb);
while (!timeout && (!server_cb.getCalled() || !client_cb.getCalled())) {
- service.run_one();
+ service.runOne();
}
timer.cancel();
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.get_io_service(), server_ep);
+ tcp::acceptor acceptor(service.getIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Run accept and connect.
while (!accept_cb.getCalled() || !connect_cb.getCalled()) {
- service.run_one();
+ service.runOne();
}
// Verify the error codes.
TestCallback client_cb;
client.async_handshake(roleToImpl(TlsRole::CLIENT), client_cb);
while (!timeout && (!server_cb.getCalled() || !client_cb.getCalled())) {
- service.run_one();
+ service.runOne();
}
timer.cancel();
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.get_io_service(), server_ep);
+ tcp::acceptor acceptor(service.getIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Run accept and connect.
while (!accept_cb.getCalled() || !connect_cb.getCalled()) {
- service.run_one();
+ service.runOne();
}
// Verify the error codes.
TestCallback client_cb;
client.async_handshake(roleToImpl(TlsRole::CLIENT), client_cb);
while (!timeout && (!server_cb.getCalled() || !client_cb.getCalled())) {
- service.run_one();
+ service.runOne();
}
timer.cancel();
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.get_io_service(), server_ep);
+ tcp::acceptor acceptor(service.getIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Run accept and connect.
while (!accept_cb.getCalled() || !connect_cb.getCalled()) {
- service.run_one();
+ service.runOne();
}
// Verify the error codes.
TestCallback client_cb;
client.async_handshake(roleToImpl(TlsRole::CLIENT), client_cb);
while (!timeout && (!server_cb.getCalled() || !client_cb.getCalled())) {
- service.run_one();
+ service.runOne();
}
timer.cancel();
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.get_io_service(), server_ep);
+ tcp::acceptor acceptor(service.getIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Run accept and connect.
while (!accept_cb.getCalled() || !connect_cb.getCalled()) {
- service.run_one();
+ service.runOne();
}
// Verify the error codes.
TestCallback client_cb;
client.handshake(client_cb);
while (!timeout && (!server_cb.getCalled() || !client_cb.getCalled())) {
- service.run_one();
+ service.runOne();
}
timer.cancel();
TestCallback shutdown_cb;
client.shutdown(shutdown_cb);
while (!timeout && !shutdown_cb.getCalled()) {
- service.run_one();
+ service.runOne();
}
timer2.cancel();
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.get_io_service(), server_ep);
+ tcp::acceptor acceptor(service.getIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Run accept and connect.
while (!accept_cb.getCalled() || !connect_cb.getCalled()) {
- service.run_one();
+ service.runOne();
}
// Verify the error codes.
TestCallback client_cb;
client.handshake(client_cb);
while (!timeout && (!server_cb.getCalled() || !client_cb.getCalled())) {
- service.run_one();
+ service.runOne();
}
timer.cancel();
TestCallback shutdown_cb;
client.shutdown(shutdown_cb);
while (!timeout && (!shutdown_cb.getCalled() || !receive_cb.getCalled())) {
- service.run_one();
+ service.runOne();
}
timer2.cancel();
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.get_io_service(), server_ep);
+ tcp::acceptor acceptor(service.getIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Run accept and connect.
while (!accept_cb.getCalled() || !connect_cb.getCalled()) {
- service.run_one();
+ service.runOne();
}
// Verify the error codes.
TestCallback client_cb;
client.handshake(client_cb);
while (!timeout && (!server_cb.getCalled() || !client_cb.getCalled())) {
- service.run_one();
+ service.runOne();
}
timer.cancel();
// Post a close which should be called after the shutdown.
service.post([&client] { client.lowest_layer().close(); });
while (!timeout && !shutdown_cb.getCalled()) {
- service.run_one();
+ service.runOne();
}
timer2.cancel();
// Accept a client.
tcp::endpoint server_ep(tcp::endpoint(address::from_string(SERVER_ADDRESS),
SERVER_PORT));
- tcp::acceptor acceptor(service.get_io_service(), server_ep);
+ tcp::acceptor acceptor(service.getIOService(), server_ep);
acceptor.set_option(tcp::acceptor::reuse_address(true));
TestCallback accept_cb;
acceptor.async_accept(server.lowest_layer(), accept_cb);
// Run accept and connect.
while (!accept_cb.getCalled() || !connect_cb.getCalled()) {
- service.run_one();
+ service.runOne();
}
// Verify the error codes.
TestCallback client_cb;
client.handshake(client_cb);
while (!timeout && (!server_cb.getCalled() || !client_cb.getCalled())) {
- service.run_one();
+ service.runOne();
}
timer.cancel();
// Post a close which should be called after the shutdown.
service.post([&client] { client.lowest_layer().close(); });
while (!timeout && (!shutdown_cb.getCalled() || !receive_cb.getCalled())) {
- service.run_one();
+ service.runOne();
}
timer2.cancel();
// 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.get_io_service(),
+ boost::asio::ip::udp::socket server(service.getIOService(),
server_endpoint.getASIOEndpoint());
server.set_option(socket_base::reuse_address(true));
EXPECT_FALSE(client_cb.getCalled());
// Execute the two callbacks.
- service.run_one();
- service.run_one();
+ service.runOne();
+ service.runOne();
EXPECT_TRUE(client_cb.getCalled());
EXPECT_EQ(0, client_cb.getCode());
server_remote_endpoint.getASIOEndpoint(), server_cb);
// Expect two callbacks to run.
- service.run_one();
- service.run_one();
+ service.runOne();
+ service.runOne();
EXPECT_TRUE(client_cb.getCalled());
EXPECT_EQ(0, client_cb.getCode());
// Run IO service to generate server's response.
while ((test_socket_->getResponseNum() < 1) &&
(!test_socket_->isStopped())) {
- io_service_.run_one();
+ io_service_.runOne();
}
// Receive response from the socket.
));
// Run IO service until connect handler is invoked.
while (!connect_handler_invoked && (!test_socket_->isStopped())) {
- io_service_.run_one();
+ io_service_.runOne();
}
// We are going to asynchronously send the 'foo' over the unix socket.
// Run IO service to generate server's response.
while ((test_socket_->getResponseNum() < 1) &&
(!test_socket_->isStopped())) {
- io_service_.run_one();
+ io_service_.runOne();
}
// There is no guarantee that all data have been sent so we only check that
// Run IO service until we get the full response from the server.
while ((response_.size() < expected_response.size()) &&
!test_socket_->isStopped()) {
- io_service_.run_one();
+ io_service_.runOne();
}
// Check that the entire response has been received and is correct.
EXPECT_TRUE(ec);
});
while (!connect_handler_invoked && !test_socket_->isStopped()) {
- io_service_.run_one();
+ io_service_.runOne();
}
// Send
EXPECT_TRUE(ec);
});
while (!send_handler_invoked && !test_socket_->isStopped()) {
- io_service_.run_one();
+ io_service_.runOne();
}
// Receive
EXPECT_TRUE(ec);
});
while (!receive_handler_invoked && !test_socket_->isStopped()) {
- io_service_.run_one();
+ io_service_.runOne();
}
}
/// @return Pointer to the socket.
UnixSocketPtr getSocket() {
if (!next_socket_) {
- next_socket_.reset(new UnixSocket(io_service_.get_io_service()));
+ next_socket_.reset(new UnixSocket(io_service_.getIOService()));
}
return (next_socket_);
}
const std::string& custom_response)
: io_service_(io_service),
server_endpoint_(socket_file_path),
- server_acceptor_(io_service_.get_io_service()),
+ server_acceptor_(io_service_.getIOService()),
test_timer_(io_service_),
custom_response_(custom_response),
connection_pool_(new ConnectionPool(io_service)),
/// It is possible to make multiple connections to the server side
/// socket simultaneously.
///
-/// The test should perform IOService::run_one until it finds that
+/// The test should perform IOService::runOne until it finds that
/// the number of responses sent by the server is greater than
/// expected. The number of responses sent so far can be retrieved
/// using @ref TestServerUnixSocket::getResponseNum.
template <typename C>
UDPSocket<C>::UDPSocket(IOService& service) :
- socket_ptr_(new boost::asio::ip::udp::socket(service.get_io_service())),
+ socket_ptr_(new boost::asio::ip::udp::socket(service.getIOService())),
socket_(*socket_ptr_), isopen_(false)
{
}
///
/// @param io_service IO service to be used by the socket class.
UnixDomainSocketImpl(IOService& io_service)
- : socket_(io_service.get_io_service()) {
+ : socket_(io_service.getIOService()) {
}
/// @brief Destructor.
/// }
/// );
/// while (!cb_invoked) {
-/// io_service.run_one();
+/// io_service.runOne();
/// }
/// @endcode
///
});
// Run the connection.
while (!handler_invoked && !test_socket_->isStopped()) {
- io_service_.run_one();
+ io_service_.runOne();
}
}
}, ClientConnection::Timeout(1000));
while (!handler_invoked && !test_socket_->isStopped()) {
- io_service_.run_one();
+ io_service_.runOne();
}
}
});
while (!handler_invoked && !test_socket_->isStopped()) {
- io_service_.run_one();
+ io_service_.runOne();
}
}
// 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_.get_io_service(),
+ socket_.reset(new udp::socket(service_.getIOService(),
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
- // run_one() to work.
- service_.get_io_service().reset();
+ // runOne() to work.
+ service_.getIOService().reset();
}
/// @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_.get_io_service(), boost::asio::ip::udp::v4());
+ udp::socket udp_socket(service_.getIOService(), 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
- // run_one() to work.
- service_.get_io_service().reset();
+ // runOne() to work.
+ service_.getIOService().reset();
}
};
server_socket_(), receive_pending_(false), perpetual_receive_(true),
tsig_key_() {
- server_socket_.reset(new boost::asio::ip::udp::socket(io_service_.get_io_service(),
+ server_socket_.reset(new boost::asio::ip::udp::socket(io_service_.getIOService(),
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_.get_io_service(),
+ server_socket_.reset(new boost::asio::ip::udp::socket(io_service_.getIOService(),
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_->get_io_service().poll();
+ int cnt = io_service_->getIOService().poll();
if (cnt == 0) {
timer_.setup(std::bind(&TimedIO::timesUp, this), run_time_);
- cnt = io_service_->get_io_service().run_one();
+ cnt = io_service_->getIOService().run_one();
timer_.cancel();
}
///
/// This method first polls IOService to run any ready handlers. If no
/// handlers are ready, it starts the internal time to run for the given
- /// amount of time and invokes service's run_one method. This method
+ /// amount of time and invokes service's runOne method. This method
/// blocks until at least one handler executes or the IO Service is stopped.
/// Upon completion of this method the timer is cancelled. Should the
- /// timer expires prior to run_one returning, the timesUp handler will be
+ /// timer expires prior to runOne returning, the timesUp handler will be
/// invoked which stops the IO service and fails the test.
///
/// Note that this method closely mimics the runIO method in D2Process.
// By running poll we're guaranteed not to hang.
/// @todo Trac# 3325 requests that asiolink::IOService provide a
/// wrapper for poll().
- io_service_->get_io_service().poll_one();
+ io_service_->getIOService().poll_one();
}
} // namespace dhcp_ddns
// Create the low level socket.
try {
asio_socket_.reset(new boost::asio::ip::udp::
- socket(io_service.get_io_service(),
+ socket(io_service.getIOService(),
(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.get_io_service(),
+ socket(io_service.getIOService(),
(ip_address_.isV4() ? boost::asio::ip::udp::v4() :
boost::asio::ip::udp::v6())));
EXPECT_TRUE(listener->isIoPending());
// Verify that IO pending is false, after cancel event occurs.
- EXPECT_NO_THROW(io_service.run_one());
+ EXPECT_NO_THROW(io_service.runOne());
EXPECT_FALSE(listener->isIoPending());
// Verify that attempting to stop listening when we are not is ok.
// Create a UDP socket through which our "sender" will send the NCR.
boost::asio::ip::udp::socket
- udp_socket(io_service_.get_io_service(), boost::asio::ip::udp::v4());
+ udp_socket(io_service_.getIOService(), boost::asio::ip::udp::v4());
// Create an endpoint pointed at the listener.
boost::asio::ip::udp::endpoint
ASSERT_NO_THROW(sendNcr(valid_msgs[i]));
// Execute no more then one event, which should be receive complete.
- EXPECT_NO_THROW(io_service_.run_one());
+ EXPECT_NO_THROW(io_service_.runOne());
// Verify the "application" status value for a successful complete.
EXPECT_EQ(NameChangeListener::SUCCESS, result_);
EXPECT_FALSE(listener_->amListening());
// Verify that IO pending is false, after cancel event occurs.
- EXPECT_NO_THROW(io_service_.run_one());
+ EXPECT_NO_THROW(io_service_.runOne());
EXPECT_FALSE(listener_->isIoPending());
}
// Loop for the number of valid messages. So long as there is at least
// on NCR in the queue, select-fd indicate ready to read. Invoke
- // IOService::run_one. This should complete the send of exactly one
+ // IOService::runOne. This should complete the send of exactly one
// message and the queue count should decrement accordingly.
for (int i = num_msgs; i > 0; i--) {
// Make sure select_fd does evaluates to ready via select and
// Loop for the number of valid messages. So long as there is at least
// on NCR in the queue, select-fd indicate ready to read. Invoke
- // IOService::run_one. This should complete the send of exactly one
+ // IOService::runOne. This should complete the send of exactly one
// message and the queue count should decrement accordingly.
for (int i = num_msgs; i > 0; i--) {
// Make sure select_fd does evaluates to ready via select and
// Execute callbacks until we have sent and received all of messages.
while (sender_->getQueueSize() > 0 || (received_ncrs_.size() < num_msgs)) {
- EXPECT_NO_THROW(io_service_.run_one());
+ EXPECT_NO_THROW(io_service_.runOne());
}
// Send queue should be empty.
EXPECT_FALSE(listener_->amListening());
// Verify that IO pending is false, after cancel event occurs.
- EXPECT_NO_THROW(io_service_.run_one());
+ EXPECT_NO_THROW(io_service_.runOne());
EXPECT_FALSE(listener_->isIoPending());
// Verify that we can gracefully stop sending.
// Execute callbacks until we have sent and received all of messages.
while (sender_->getQueueSize() > 0 || (received_ncrs_.size() < num_msgs)) {
- EXPECT_NO_THROW(io_service_.run_one());
+ EXPECT_NO_THROW(io_service_.runOne());
}
// Send queue should be empty.
EXPECT_FALSE(listener_->amListening());
// Verify that IO pending is false, after cancel event occurs.
- EXPECT_NO_THROW(io_service_.run_one());
+ EXPECT_NO_THROW(io_service_.runOne());
EXPECT_FALSE(listener_->isIoPending());
// Verify that we can gracefully stop sending.
}, timeout_ms, IntervalTimer::ONE_SHOT);
io_service_->run();
- io_service_->get_io_service().reset();
+ io_service_->getIOService().reset();
}
/// @brief Setup timers according to the configuration and run them
io_service_->stop();
}, timeout, asiolink::IntervalTimer::ONE_SHOT);
io_service_->run();
- io_service_->get_io_service().reset();
+ io_service_->getIOService().reset();
}
// This test checks that the interface names can be explicitly selected
}, ms, IntervalTimer::ONE_SHOT);
io_service_->run();
- io_service_->get_io_service().reset();
+ io_service_->getIOService().reset();
}
/// @brief Waits for the specified process to finish.
}, 1, IntervalTimer::REPEATING);
io_service_->run();
- io_service_->get_io_service().reset();
+ io_service_->getIOService().reset();
return (!elapsed);
}
io_service_->stop();
}, timeout, IntervalTimer::ONE_SHOT);
io_service_->run();
- io_service_->get_io_service().reset();
+ io_service_->getIOService().reset();
}
void
/// @param timeout Optional value specifying for how long the io service
/// should be ran.
void runIOService(long timeout = 0) {
- io_service_.get_io_service().reset();
+ io_service_.getIOService().reset();
if (timeout > 0) {
run_io_service_timer_.setup(std::bind(&HttpListenerTest::timeoutHandler,
timeout, IntervalTimer::ONE_SHOT);
}
io_service_.run();
- io_service_.get_io_service().reset();
+ io_service_.getIOService().reset();
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_.get_io_service());
+ tcp::acceptor acceptor(io_service_.getIOService());
// 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.get_io_service()), socket_(io_service_),
+ : io_service_(io_service.getIOService()), 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_.get_io_service().reset();
+ io_service_.getIOService().reset();
if (timeout > 0) {
run_io_service_timer_.setup(std::bind(&HttpListenerTest::timeoutHandler,
timeout, IntervalTimer::ONE_SHOT);
}
io_service_.run();
- io_service_.get_io_service().reset();
+ io_service_.getIOService().reset();
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.get_io_service()),
+ : io_service_(io_service.getIOService()),
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_.get_io_service().reset();
+ io_service_.getIOService().reset();
if (timeout > 0) {
run_io_service_timer_.setup(std::bind(&HttpsListenerTest::timeoutHandler,
timeout, IntervalTimer::ONE_SHOT);
}
io_service_.run();
- io_service_.get_io_service().reset();
+ io_service_.getIOService().reset();
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_.get_io_service());
+ tcp::acceptor acceptor(io_service_.getIOService());
// 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),
/// @brief Fetches the controller's IOService.
///
/// @return a reference to the controller's IOService.
- asiolink::IOServicePtr& getIoService() {
+ asiolink::IOServicePtr& getIOService() {
return (io_service_);
}
// To use run(), the "managing" layer must issue an io_service::stop
// or the call to run will continue to block, and shutdown will not
// occur.
- asiolink::IOServicePtr& io_service = getIoService();
+ asiolink::IOServicePtr& io_service = getIOService();
while (!shouldShutdown()) {
try {
- io_service->run_one();
+ io_service->runOne();
} catch (const std::exception& ex) {
isc_throw (DProcessBaseError,
std::string("Process run method failed: ") + ex.what());
/// @param timeout Optional value specifying for how long the io service
/// should be ran.
void runIOService(long timeout = 0) {
- io_service_.get_io_service().reset();
+ io_service_.getIOService().reset();
if (timeout > 0) {
run_io_service_timer_.setup(std::bind(&TcpListenerTest::timeoutHandler,
IntervalTimer::ONE_SHOT);
}
io_service_.run();
- io_service_.get_io_service().reset();
+ io_service_.getIOService().reset();
io_service_.poll();
}
isc::asiolink::TlsContextPtr(),
const std::string& server_address = "127.0.0.1",
uint16_t port = 18123)
- : io_service_(io_service.get_io_service()),
+ : io_service_(io_service.getIOService()),
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_.get_io_service().reset();
+ io_service_.getIOService().reset();
if (timeout > 0) {
run_io_service_timer_.setup(std::bind(&TlsListenerTest::timeoutHandler,
IntervalTimer::ONE_SHOT);
}
io_service_.run();
- io_service_.get_io_service().reset();
+ io_service_.getIOService().reset();
io_service_.poll();
}