Skip to content

Commit

Permalink
[#3112] renamed getIOService to getInternalIOService
Browse files Browse the repository at this point in the history
  • Loading branch information
Razvan Becheriu committed Dec 11, 2023
1 parent 9ecab51 commit ad78b20
Show file tree
Hide file tree
Showing 49 changed files with 163 additions and 137 deletions.
6 changes: 3 additions & 3 deletions src/bin/agent/ca_process.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ CtrlAgentProcess::run() {

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);
}
Expand Down Expand Up @@ -208,7 +208,7 @@ CtrlAgentProcess::garbageCollectListeners(size_t leaving) {
}
// 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);
Expand Down
4 changes: 2 additions & 2 deletions src/bin/agent/tests/ca_command_mgr_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class CtrlAgentCommandMgrTest : public DControllerTest {

// 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());
Expand Down Expand Up @@ -413,7 +413,7 @@ TEST_F(CtrlAgentCommandMgrTest, forwardListCommands) {

// 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
Expand Down
6 changes: 3 additions & 3 deletions src/bin/d2/d2_process.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ D2Process::runIO() {

// 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);
Expand Down
1 change: 0 additions & 1 deletion src/bin/dhcp4/ctrl_dhcp4_srv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1303,7 +1303,6 @@ ControlledDhcpv4Srv::~ControlledDhcpv4Srv() {
} 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
Expand Down
2 changes: 1 addition & 1 deletion src/bin/dhcp4/tests/kea_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class JSONFileBackendTest : public isc::dhcp::test::BaseServerTest {
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
Expand Down
1 change: 0 additions & 1 deletion src/bin/dhcp6/ctrl_dhcp6_srv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,6 @@ ControlledDhcpv6Srv::~ControlledDhcpv6Srv() {
} 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
Expand Down
2 changes: 1 addition & 1 deletion src/bin/dhcp6/tests/kea_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class JSONFileBackendTest : public dhcp::test::BaseServerTest {
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
Expand Down
4 changes: 2 additions & 2 deletions src/bin/netconf/netconf_process.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ NetconfProcess::run() {

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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/bin/netconf/tests/control_socket_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,14 @@ void
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();
Expand Down
4 changes: 2 additions & 2 deletions src/bin/netconf/tests/netconf_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ void
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());
Expand All @@ -268,7 +268,7 @@ NetconfAgentTest::fakeServer() {
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();
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/dhcp/high_availability/tests/ha_mt_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class HAMtServiceTest : public HATest {
///
/// Stops all test servers.
~HAMtServiceTest() {
io_service_->getIOService().reset();
io_service_->restart();
io_service_->poll();
MultiThreadingMgr::instance().setMode(false);
CmdResponseCreator::command_accept_list_.clear();
Expand Down
26 changes: 13 additions & 13 deletions src/hooks/dhcp/high_availability/tests/ha_service_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ class HAServiceTest : public HATest {
listener_->stop();
listener2_->stop();
listener3_->stop();
io_service_->getIOService().reset();
io_service_->restart();
io_service_->poll();
MultiThreadingMgr::instance().setMode(false);
}
Expand Down Expand Up @@ -2072,7 +2072,7 @@ class HAServiceTest : public HATest {
// 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();
}

Expand Down Expand Up @@ -2122,7 +2122,7 @@ class HAServiceTest : public HATest {
// 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();
}

Expand Down Expand Up @@ -4693,7 +4693,7 @@ TEST_F(HAServiceTest, processMaintenanceStartSuccess) {
// 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
Expand Down Expand Up @@ -4745,7 +4745,7 @@ TEST_F(HAServiceTest, processMaintenanceStartSuccessAuthorized) {
// 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
Expand Down Expand Up @@ -4788,7 +4788,7 @@ TEST_F(HAServiceTest, processMaintenanceStartPartnerDown) {
// 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
Expand Down Expand Up @@ -4832,7 +4832,7 @@ TEST_F(HAServiceTest, processMaintenanceStartPartnerError) {
// 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);
Expand Down Expand Up @@ -4874,7 +4874,7 @@ TEST_F(HAServiceTest, processMaintenanceStartPartnerUnauthorized) {
// 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);
Expand Down Expand Up @@ -4917,7 +4917,7 @@ TEST_F(HAServiceTest, processMaintenanceStartNotAllowed) {
// 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);
Expand Down Expand Up @@ -4961,7 +4961,7 @@ TEST_F(HAServiceTest, processMaintenanceCancelSuccess) {
// 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
Expand Down Expand Up @@ -5012,7 +5012,7 @@ TEST_F(HAServiceTest, processMaintenanceCancelSuccessAuthorized) {
// 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
Expand Down Expand Up @@ -5055,7 +5055,7 @@ TEST_F(HAServiceTest, processMaintenanceCancelPartnerError) {
// 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.
Expand Down Expand Up @@ -5101,7 +5101,7 @@ TEST_F(HAServiceTest, processMaintenanceCancelPartnerUnauthorized) {
// 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.
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/dhcp/high_availability/tests/ha_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ HATest::startHAService() {

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);
Expand All @@ -81,7 +81,7 @@ HATest::runIOService(long ms) {

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)),
Expand All @@ -96,7 +96,7 @@ HATest::runIOService(long ms, std::function<bool()> stop_condition) {

boost::shared_ptr<std::thread>
HATest::runIOServiceInThread() {
io_service_->getIOService().reset();
io_service_->restart();

bool running = false;
std::mutex mutex;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/asiodns/io_fetch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ struct IOFetchData {
msgbuf(new OutputBuffer(512)),
received(buff),
callback(cb),
timer(service.getIOService()),
timer(service.getInternalIOService()),
protocol(proto),
cumulative(0),
expected(0),
Expand Down
21 changes: 10 additions & 11 deletions src/lib/asiodns/tests/io_fetch_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class IOFetchTest : public virtual ::testing::Test, public virtual IOFetch::Call
// 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_(),
Expand Down Expand Up @@ -474,12 +474,11 @@ class IOFetchTest : public virtual ::testing::Test, public virtual IOFetch::Call
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.
Expand All @@ -501,7 +500,7 @@ class IOFetchTest : public virtual ::testing::Test, public virtual IOFetch::Call

// Stop before it is started
fetch.stop();
service_.getIOService().post(fetch);
service_.post(fetch);

service_.run();
EXPECT_TRUE(run_);
Expand All @@ -517,7 +516,7 @@ class IOFetchTest : public virtual ::testing::Test, public virtual IOFetch::Call
protocol_ = protocol;
expected_ = IOFetch::TIME_OUT;

service_.getIOService().post(fetch);
service_.post(fetch);
service_.run();
EXPECT_TRUE(run_);
}
Expand All @@ -543,17 +542,17 @@ class IOFetchTest : public virtual ::testing::Test, public virtual IOFetch::Call
}

// 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.
Expand All @@ -575,7 +574,7 @@ class IOFetchTest : public virtual ::testing::Test, public virtual IOFetch::Call
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";
Expand All @@ -587,7 +586,7 @@ class IOFetchTest : public virtual ::testing::Test, public virtual IOFetch::Call
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;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/asiolink/interval_timer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class IntervalTimerImpl :
};

IntervalTimerImpl::IntervalTimerImpl(IOService& io_service) :
interval_(0), timer_(io_service.getIOService()),
interval_(0), timer_(io_service.getInternalIOService()),
mode_(IntervalTimer::REPEATING) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/asiolink/io_acceptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class IOAcceptor : public IOSocket {
/// @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.
Expand Down
Loading

0 comments on commit ad78b20

Please sign in to comment.