build: require boost >= 1.71.0
Refs: #5276 Change-Id: Ie428541639dcf1113acfb9e9d0a80f9be87d6cd3
This commit is contained in:
+19
-31
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2021, Regents of the University of California,
|
||||
* Copyright (c) 2014-2023, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -27,18 +27,18 @@
|
||||
|
||||
namespace nfd {
|
||||
|
||||
static thread_local unique_ptr<boost::asio::io_service> g_ioService;
|
||||
static thread_local unique_ptr<boost::asio::io_context> g_ioCtx;
|
||||
static thread_local unique_ptr<Scheduler> g_scheduler;
|
||||
static boost::asio::io_service* g_mainIoService = nullptr;
|
||||
static boost::asio::io_service* g_ribIoService = nullptr;
|
||||
static boost::asio::io_context* g_mainIoCtx = nullptr;
|
||||
static boost::asio::io_context* g_ribIoCtx = nullptr;
|
||||
|
||||
boost::asio::io_service&
|
||||
boost::asio::io_context&
|
||||
getGlobalIoService()
|
||||
{
|
||||
if (g_ioService == nullptr) {
|
||||
g_ioService = make_unique<boost::asio::io_service>();
|
||||
if (g_ioCtx == nullptr) {
|
||||
g_ioCtx = make_unique<boost::asio::io_context>();
|
||||
}
|
||||
return *g_ioService;
|
||||
return *g_ioCtx;
|
||||
}
|
||||
|
||||
Scheduler&
|
||||
@@ -55,46 +55,34 @@ void
|
||||
resetGlobalIoService()
|
||||
{
|
||||
g_scheduler.reset();
|
||||
g_ioService.reset();
|
||||
g_ioCtx.reset();
|
||||
}
|
||||
#endif
|
||||
|
||||
boost::asio::io_service&
|
||||
boost::asio::io_context&
|
||||
getMainIoService()
|
||||
{
|
||||
BOOST_ASSERT(g_mainIoService != nullptr);
|
||||
return *g_mainIoService;
|
||||
BOOST_ASSERT(g_mainIoCtx != nullptr);
|
||||
return *g_mainIoCtx;
|
||||
}
|
||||
|
||||
boost::asio::io_service&
|
||||
boost::asio::io_context&
|
||||
getRibIoService()
|
||||
{
|
||||
BOOST_ASSERT(g_ribIoService != nullptr);
|
||||
return *g_ribIoService;
|
||||
BOOST_ASSERT(g_ribIoCtx != nullptr);
|
||||
return *g_ribIoCtx;
|
||||
}
|
||||
|
||||
void
|
||||
setMainIoService(boost::asio::io_service* mainIo)
|
||||
setMainIoService(boost::asio::io_context* mainIo)
|
||||
{
|
||||
g_mainIoService = mainIo;
|
||||
g_mainIoCtx = mainIo;
|
||||
}
|
||||
|
||||
void
|
||||
setRibIoService(boost::asio::io_service* ribIo)
|
||||
setRibIoService(boost::asio::io_context* ribIo)
|
||||
{
|
||||
g_ribIoService = ribIo;
|
||||
}
|
||||
|
||||
void
|
||||
runOnMainIoService(const std::function<void()>& f)
|
||||
{
|
||||
getMainIoService().post(f);
|
||||
}
|
||||
|
||||
void
|
||||
runOnRibIoService(const std::function<void()>& f)
|
||||
{
|
||||
getRibIoService().post(f);
|
||||
g_ribIoCtx = ribIo;
|
||||
}
|
||||
|
||||
} // namespace nfd
|
||||
|
||||
+14
-21
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022 Regents of the University of California,
|
||||
* Copyright (c) 2014-2023 Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -27,46 +27,39 @@
|
||||
|
||||
#include "core/common.hpp"
|
||||
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
|
||||
namespace nfd {
|
||||
|
||||
/** \brief Returns the global io_service instance for the calling thread.
|
||||
/**
|
||||
* \brief Returns the global io_context instance for the calling thread.
|
||||
*/
|
||||
boost::asio::io_service&
|
||||
boost::asio::io_context&
|
||||
getGlobalIoService();
|
||||
|
||||
/** \brief Returns the global Scheduler instance for the calling thread.
|
||||
/**
|
||||
* \brief Returns the global Scheduler instance for the calling thread.
|
||||
*/
|
||||
Scheduler&
|
||||
getScheduler();
|
||||
|
||||
boost::asio::io_service&
|
||||
boost::asio::io_context&
|
||||
getMainIoService();
|
||||
|
||||
boost::asio::io_service&
|
||||
boost::asio::io_context&
|
||||
getRibIoService();
|
||||
|
||||
void
|
||||
setMainIoService(boost::asio::io_service* mainIo);
|
||||
setMainIoService(boost::asio::io_context* mainIo);
|
||||
|
||||
void
|
||||
setRibIoService(boost::asio::io_service* ribIo);
|
||||
|
||||
/** \brief Run a function on the main io_service instance.
|
||||
*/
|
||||
void
|
||||
runOnMainIoService(const std::function<void()>& f);
|
||||
|
||||
/** \brief Run a function on the RIB io_service instance.
|
||||
*/
|
||||
void
|
||||
runOnRibIoService(const std::function<void()>& f);
|
||||
setRibIoService(boost::asio::io_context* ribIo);
|
||||
|
||||
#ifdef NFD_WITH_TESTS
|
||||
/** \brief Destroy the global io_service instance.
|
||||
/**
|
||||
* \brief Destroy the global io_context instance.
|
||||
*
|
||||
* It will be recreated at the next invocation of getGlobalIoService().
|
||||
* It will be recreated at the next invocation of getGlobalIoService().
|
||||
*/
|
||||
void
|
||||
resetGlobalIoService();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, Regents of the University of California,
|
||||
* Copyright (c) 2014-2023, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -128,13 +128,7 @@ TcpTransport::reconnect()
|
||||
BOOST_ASSERT(getState() == TransportState::DOWN);
|
||||
|
||||
// recreate the socket
|
||||
m_socket = protocol::socket(
|
||||
#if BOOST_VERSION >= 107000
|
||||
m_socket.get_executor()
|
||||
#else
|
||||
m_socket.get_io_service()
|
||||
#endif // BOOST_VERSION >= 107000
|
||||
);
|
||||
m_socket = protocol::socket(m_socket.get_executor());
|
||||
this->resetReceiveBuffer();
|
||||
this->resetSendQueue();
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <ndn-cxx/lp/prefix-announcement-header.hpp>
|
||||
#include <ndn-cxx/lp/tags.hpp>
|
||||
|
||||
#include <boost/asio/post.hpp>
|
||||
#include <boost/range/adaptor/reversed.hpp>
|
||||
|
||||
namespace nfd::fw {
|
||||
@@ -188,26 +189,28 @@ SelfLearningStrategy::asyncProcessData(const shared_ptr<pit::Entry>& pitEntry, c
|
||||
// (the PIT entry's expiry timer was set to 0 before dispatching)
|
||||
this->setExpiryTimer(pitEntry, 1_s);
|
||||
|
||||
runOnRibIoService([this, pitEntryWeak = weak_ptr<pit::Entry>{pitEntry}, inFaceId = inFace.getId(), data] {
|
||||
rib::Service::get().getRibManager().slFindAnn(data.getName(),
|
||||
[this, pitEntryWeak, inFaceId, data] (std::optional<ndn::PrefixAnnouncement> paOpt) {
|
||||
if (paOpt) {
|
||||
runOnMainIoService([this, pitEntryWeak, inFaceId, data, pa = std::move(*paOpt)] {
|
||||
auto pitEntry = pitEntryWeak.lock();
|
||||
auto inFace = this->getFace(inFaceId);
|
||||
if (pitEntry && inFace) {
|
||||
NFD_LOG_DEBUG("Found PrefixAnnouncement=" << pa.getAnnouncedName());
|
||||
data.setTag(make_shared<lp::PrefixAnnouncementTag>(lp::PrefixAnnouncementHeader(pa)));
|
||||
this->sendDataToAll(data, pitEntry, *inFace);
|
||||
this->setExpiryTimer(pitEntry, 0_ms);
|
||||
}
|
||||
else {
|
||||
NFD_LOG_DEBUG("PIT entry or face no longer exists");
|
||||
}
|
||||
});
|
||||
}
|
||||
boost::asio::post(getRibIoService(),
|
||||
[this, pitEntryWeak = weak_ptr<pit::Entry>{pitEntry}, inFaceId = inFace.getId(), data] {
|
||||
rib::Service::get().getRibManager().slFindAnn(data.getName(),
|
||||
[this, pitEntryWeak, inFaceId, data] (std::optional<ndn::PrefixAnnouncement> paOpt) {
|
||||
if (paOpt) {
|
||||
boost::asio::post(getMainIoService(),
|
||||
[this, pitEntryWeak, inFaceId, data, pa = std::move(*paOpt)] {
|
||||
auto pitEntry = pitEntryWeak.lock();
|
||||
auto inFace = this->getFace(inFaceId);
|
||||
if (pitEntry && inFace) {
|
||||
NFD_LOG_DEBUG("Found PrefixAnnouncement=" << pa.getAnnouncedName());
|
||||
data.setTag(make_shared<lp::PrefixAnnouncementTag>(lp::PrefixAnnouncementHeader(pa)));
|
||||
this->sendDataToAll(data, pitEntry, *inFace);
|
||||
this->setExpiryTimer(pitEntry, 0_ms);
|
||||
}
|
||||
else {
|
||||
NFD_LOG_DEBUG("PIT entry or face no longer exists");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -235,24 +238,26 @@ void
|
||||
SelfLearningStrategy::addRoute(const shared_ptr<pit::Entry>& pitEntry, const Face& inFace,
|
||||
const Data& data, const ndn::PrefixAnnouncement& pa)
|
||||
{
|
||||
runOnRibIoService([pitEntryWeak = weak_ptr<pit::Entry>{pitEntry}, inFaceId = inFace.getId(), data, pa] {
|
||||
rib::Service::get().getRibManager().slAnnounce(pa, inFaceId, ROUTE_RENEW_LIFETIME,
|
||||
[] (RibManager::SlAnnounceResult res) {
|
||||
NFD_LOG_DEBUG("Add route via PrefixAnnouncement with result=" << res);
|
||||
});
|
||||
});
|
||||
boost::asio::post(getRibIoService(),
|
||||
[pitEntryWeak = weak_ptr<pit::Entry>{pitEntry}, inFaceId = inFace.getId(), data, pa] {
|
||||
rib::Service::get().getRibManager().slAnnounce(pa, inFaceId, ROUTE_RENEW_LIFETIME,
|
||||
[] (RibManager::SlAnnounceResult res) {
|
||||
NFD_LOG_DEBUG("Add route via PrefixAnnouncement with result=" << res);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void
|
||||
SelfLearningStrategy::renewRoute(const Name& name, FaceId inFaceId, time::milliseconds maxLifetime)
|
||||
{
|
||||
// renew route with PA or ignore PA (if route has no PA)
|
||||
runOnRibIoService([name, inFaceId, maxLifetime] {
|
||||
rib::Service::get().getRibManager().slRenew(name, inFaceId, maxLifetime,
|
||||
[] (RibManager::SlAnnounceResult res) {
|
||||
NFD_LOG_DEBUG("Renew route with result=" << res);
|
||||
});
|
||||
});
|
||||
boost::asio::post(getRibIoService(),
|
||||
[name, inFaceId, maxLifetime] {
|
||||
rib::Service::get().getRibManager().slRenew(name, inFaceId, maxLifetime,
|
||||
[] (RibManager::SlAnnounceResult res) {
|
||||
NFD_LOG_DEBUG("Renew route with result=" << res);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace nfd::fw
|
||||
|
||||
+4
-4
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, Regents of the University of California,
|
||||
* Copyright (c) 2014-2023, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -70,7 +70,7 @@ namespace nfd {
|
||||
/** \brief Executes NFD with RIB manager
|
||||
*
|
||||
* NFD (main forwarding procedure) and RIB manager execute in two different threads.
|
||||
* Each thread has its own instances of global io_service and global scheduler.
|
||||
* Each thread has its own instances of global io_context and global scheduler.
|
||||
*
|
||||
* When either of the daemons fails, execution of non-failed daemon will be terminated as
|
||||
* well. In other words, when NFD fails, RIB manager will be terminated; when RIB manager
|
||||
@@ -107,9 +107,9 @@ public:
|
||||
// a separate thread) fails.
|
||||
std::atomic_int retval(0);
|
||||
|
||||
boost::asio::io_service* const mainIo = &getGlobalIoService();
|
||||
boost::asio::io_context* const mainIo = &getGlobalIoService();
|
||||
setMainIoService(mainIo);
|
||||
boost::asio::io_service* ribIo = nullptr;
|
||||
boost::asio::io_context* ribIo = nullptr;
|
||||
|
||||
// Mutex and conditional variable to implement synchronization between main and RIB manager
|
||||
// threads:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, Regents of the University of California,
|
||||
* Copyright (c) 2014-2023, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -46,7 +46,7 @@ class Readvertise;
|
||||
* \brief Initializes and executes the NFD-RIB service thread.
|
||||
*
|
||||
* Only one instance of this class can be created at any time.
|
||||
* After initialization, NFD-RIB instance can be started by running the global io_service.
|
||||
* After initialization, NFD-RIB instance can be started by running the global io_context.
|
||||
*/
|
||||
class Service : noncopyable
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, Regents of the University of California,
|
||||
* Copyright (c) 2014-2023, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -29,6 +29,8 @@
|
||||
#include "tests/daemon/global-io-fixture.hpp"
|
||||
#include "tests/daemon/rib-io-fixture.hpp"
|
||||
|
||||
#include <boost/asio/post.hpp>
|
||||
|
||||
#include <thread>
|
||||
|
||||
namespace nfd::tests {
|
||||
@@ -37,8 +39,8 @@ BOOST_FIXTURE_TEST_SUITE(TestGlobal, GlobalIoFixture)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(ThreadLocalIoService)
|
||||
{
|
||||
boost::asio::io_service* s1 = &getGlobalIoService();
|
||||
boost::asio::io_service* s2 = nullptr;
|
||||
boost::asio::io_context* s1 = &getGlobalIoService();
|
||||
boost::asio::io_context* s2 = nullptr;
|
||||
|
||||
std::thread t([&s2] { s2 = &getGlobalIoService(); });
|
||||
t.join();
|
||||
@@ -63,8 +65,8 @@ BOOST_AUTO_TEST_CASE(ThreadLocalScheduler)
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(MainRibIoService, RibIoFixture)
|
||||
{
|
||||
boost::asio::io_service* mainIo = &g_io;
|
||||
boost::asio::io_service* ribIo = g_ribIo;
|
||||
boost::asio::io_context* mainIo = &g_io;
|
||||
boost::asio::io_context* ribIo = g_ribIo;
|
||||
|
||||
BOOST_CHECK(mainIo != ribIo);
|
||||
BOOST_CHECK(&getGlobalIoService() == mainIo);
|
||||
@@ -72,15 +74,15 @@ BOOST_FIXTURE_TEST_CASE(MainRibIoService, RibIoFixture)
|
||||
BOOST_CHECK(&getRibIoService() == ribIo);
|
||||
auto mainThreadId = std::this_thread::get_id();
|
||||
|
||||
runOnRibIoService([&] {
|
||||
boost::asio::post(getRibIoService(), [&] {
|
||||
BOOST_CHECK(mainThreadId != std::this_thread::get_id());
|
||||
BOOST_CHECK(&getGlobalIoService() == ribIo);
|
||||
BOOST_CHECK(&getMainIoService() == mainIo);
|
||||
BOOST_CHECK(&getRibIoService() == ribIo);
|
||||
});
|
||||
|
||||
runOnRibIoService([&] {
|
||||
runOnMainIoService([&] {
|
||||
boost::asio::post(getRibIoService(), [&] {
|
||||
boost::asio::post(getMainIoService(), [&] {
|
||||
BOOST_CHECK(mainThreadId == std::this_thread::get_id());
|
||||
BOOST_CHECK(&getGlobalIoService() == mainIo);
|
||||
BOOST_CHECK(&getMainIoService() == mainIo);
|
||||
@@ -92,7 +94,7 @@ BOOST_FIXTURE_TEST_CASE(MainRibIoService, RibIoFixture)
|
||||
BOOST_FIXTURE_TEST_CASE(PollInAllThreads, RibIoFixture)
|
||||
{
|
||||
bool hasRibRun = false;
|
||||
runOnRibIoService([&] { hasRibRun = true; });
|
||||
boost::asio::post(getRibIoService(), [&] { hasRibRun = true; });
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
BOOST_CHECK_EQUAL(hasRibRun, false);
|
||||
|
||||
@@ -101,9 +103,9 @@ BOOST_FIXTURE_TEST_CASE(PollInAllThreads, RibIoFixture)
|
||||
|
||||
hasRibRun = false;
|
||||
bool hasMainRun = false;
|
||||
runOnMainIoService([&] {
|
||||
boost::asio::post(getMainIoService(), [&] {
|
||||
hasMainRun = true;
|
||||
runOnRibIoService([&] { hasRibRun = true; });
|
||||
boost::asio::post(getRibIoService(), [&] { hasRibRun = true; });
|
||||
});
|
||||
BOOST_CHECK_EQUAL(hasMainRun, false);
|
||||
BOOST_CHECK_EQUAL(hasRibRun, false);
|
||||
@@ -116,7 +118,7 @@ BOOST_FIXTURE_TEST_CASE(PollInAllThreads, RibIoFixture)
|
||||
BOOST_FIXTURE_TEST_CASE(AdvanceClocks, RibIoTimeFixture)
|
||||
{
|
||||
bool hasRibRun = false;
|
||||
runOnRibIoService([&] { hasRibRun = true; });
|
||||
boost::asio::post(getRibIoService(), [&] { hasRibRun = true; });
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
BOOST_CHECK_EQUAL(hasRibRun, false);
|
||||
|
||||
@@ -127,7 +129,7 @@ BOOST_FIXTURE_TEST_CASE(AdvanceClocks, RibIoTimeFixture)
|
||||
bool hasMainRun = false;
|
||||
getScheduler().schedule(250_ms, [&] {
|
||||
hasMainRun = true;
|
||||
runOnRibIoService([&] { hasRibRun = true; });
|
||||
boost::asio::post(getRibIoService(), [&] { hasRibRun = true; });
|
||||
});
|
||||
BOOST_CHECK_EQUAL(hasMainRun, false);
|
||||
BOOST_CHECK_EQUAL(hasRibRun, false);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, Regents of the University of California,
|
||||
* Copyright (c) 2014-2023, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -34,7 +34,7 @@
|
||||
namespace nfd::tests {
|
||||
|
||||
/** \brief Enumerate network interfaces using the given NetworkMonitor
|
||||
* \param netmon a NetworkMonitor constructed on the global io_service.
|
||||
* \param netmon a NetworkMonitor constructed on the global io_context.
|
||||
* \note This function is blocking
|
||||
* \note Signals are supported if caller keeps \p netmon running
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, Regents of the University of California,
|
||||
* Copyright (c) 2014-2023, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -48,7 +48,7 @@ class AcceptorWithCleanup : public unix_stream::acceptor
|
||||
{
|
||||
public:
|
||||
explicit
|
||||
AcceptorWithCleanup(boost::asio::io_service& io, const std::string& path = "")
|
||||
AcceptorWithCleanup(boost::asio::io_context& io, const std::string& path = "")
|
||||
: unix_stream::acceptor(io)
|
||||
{
|
||||
this->open();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, Regents of the University of California,
|
||||
* Copyright (c) 2014-2023, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -42,11 +42,7 @@ size_t
|
||||
GlobalIoFixture::pollIo()
|
||||
{
|
||||
if (g_io.stopped()) {
|
||||
#if BOOST_VERSION >= 106600
|
||||
g_io.restart();
|
||||
#else
|
||||
g_io.reset();
|
||||
#endif
|
||||
}
|
||||
return g_io.poll();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, Regents of the University of California,
|
||||
* Copyright (c) 2014-2023, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -30,10 +30,11 @@
|
||||
|
||||
namespace nfd::tests {
|
||||
|
||||
/** \brief A fixture providing proper setup and teardown of the global io_service.
|
||||
/**
|
||||
* \brief A fixture providing proper setup and teardown of the global io_context.
|
||||
*
|
||||
* Every daemon fixture or test case should inherit from this fixture,
|
||||
* to have per test case io_service initialization and cleanup.
|
||||
* Every daemon fixture or test case should inherit from this fixture,
|
||||
* to have per test case io_context initialization and cleanup.
|
||||
*/
|
||||
class GlobalIoFixture
|
||||
{
|
||||
@@ -42,18 +43,21 @@ protected:
|
||||
|
||||
~GlobalIoFixture();
|
||||
|
||||
/** \brief Poll the global io_service.
|
||||
/**
|
||||
* \brief Poll the global io_context.
|
||||
*/
|
||||
size_t
|
||||
pollIo();
|
||||
|
||||
protected:
|
||||
/** \brief Reference to the global io_service instance.
|
||||
/**
|
||||
* \brief Reference to the global io_context instance.
|
||||
*/
|
||||
boost::asio::io_service& g_io;
|
||||
boost::asio::io_context& g_io;
|
||||
};
|
||||
|
||||
/** \brief GlobalIoFixture that also overrides steady clock and system clock.
|
||||
/**
|
||||
* \brief GlobalIoFixture that also overrides steady clock and system clock.
|
||||
*/
|
||||
class GlobalIoTimeFixture : public ClockFixture, public GlobalIoFixture
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, Regents of the University of California,
|
||||
* Copyright (c) 2014-2023, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -34,7 +34,8 @@
|
||||
|
||||
namespace nfd::tests {
|
||||
|
||||
/** \brief A base test fixture that provides both main and RIB io_service.
|
||||
/**
|
||||
* \brief A base test fixture that provides both main and RIB io_context.
|
||||
*/
|
||||
class RibIoFixture : public GlobalIoFixture
|
||||
{
|
||||
@@ -44,27 +45,31 @@ protected:
|
||||
~RibIoFixture();
|
||||
|
||||
protected:
|
||||
/** \brief Poll main and RIB thread io_service to process all pending I/O events.
|
||||
/**
|
||||
* \brief Poll main and RIB thread io_context to process all pending I/O events.
|
||||
*
|
||||
* This call will execute all pending I/O events, including events that are posted
|
||||
* inside the processing event, i.e., main and RIB thread io_service will be polled
|
||||
* inside the processing event, i.e., main and RIB thread io_context will be polled
|
||||
* repeatedly until all pending events are processed.
|
||||
*
|
||||
* \warning Must be called from the main thread
|
||||
* \warning Must be called from the main thread.
|
||||
*/
|
||||
void
|
||||
poll();
|
||||
|
||||
protected:
|
||||
/** \brief Pointer to global main io_service.
|
||||
/**
|
||||
* \brief Pointer to global main io_context.
|
||||
*/
|
||||
boost::asio::io_service* g_mainIo = nullptr;
|
||||
boost::asio::io_context* g_mainIo = nullptr;
|
||||
|
||||
/** \brief Pointer to global RIB io_service.
|
||||
/**
|
||||
* \brief Pointer to global RIB io_context.
|
||||
*/
|
||||
boost::asio::io_service* g_ribIo = nullptr;
|
||||
boost::asio::io_context* g_ribIo = nullptr;
|
||||
|
||||
/** \brief Global RIB thread.
|
||||
/**
|
||||
* \brief Global RIB thread.
|
||||
*/
|
||||
std::thread g_ribThread;
|
||||
|
||||
@@ -76,7 +81,8 @@ private:
|
||||
std::condition_variable m_ribPollEndCv;
|
||||
};
|
||||
|
||||
/** \brief RibIoFixture that also overrides steady clock and system clock.
|
||||
/**
|
||||
* \brief RibIoFixture that also overrides steady clock and system clock.
|
||||
*/
|
||||
class RibIoTimeFixture : public ClockFixture, public RibIoFixture
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, Regents of the University of California,
|
||||
* Copyright (c) 2014-2023, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -29,7 +29,9 @@
|
||||
#include "tests/test-common.hpp"
|
||||
#include "tests/daemon/rib-io-fixture.hpp"
|
||||
|
||||
#include <boost/asio/post.hpp>
|
||||
#include <boost/property_tree/info_parser.hpp>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace nfd::tests {
|
||||
@@ -63,7 +65,7 @@ BOOST_AUTO_TEST_CASE(Basic)
|
||||
BOOST_CHECK_THROW(Service::get(), std::logic_error);
|
||||
BOOST_CHECK_THROW(Service(section, m_ribKeyChain), std::logic_error);
|
||||
|
||||
runOnRibIoService([&] {
|
||||
boost::asio::post(getRibIoService(), [&] {
|
||||
{
|
||||
BOOST_CHECK_THROW(Service::get(), std::logic_error);
|
||||
Service ribService(section, m_ribKeyChain);
|
||||
@@ -87,7 +89,7 @@ BOOST_AUTO_TEST_CASE(EmptyLocalhostSecurity)
|
||||
}
|
||||
)CONFIG";
|
||||
|
||||
runOnRibIoService([&] {
|
||||
boost::asio::post(getRibIoService(), [&] {
|
||||
BOOST_CHECK_NO_THROW(Service(makeSection(CONFIG), m_ribKeyChain));
|
||||
});
|
||||
poll();
|
||||
@@ -102,7 +104,7 @@ BOOST_AUTO_TEST_CASE(EmptyPrefixAnnouncementValidation)
|
||||
}
|
||||
)CONFIG";
|
||||
|
||||
runOnRibIoService([&] {
|
||||
boost::asio::post(getRibIoService(), [&] {
|
||||
BOOST_CHECK_NO_THROW(Service(makeSection(CONFIG), m_ribKeyChain));
|
||||
});
|
||||
poll();
|
||||
@@ -131,7 +133,7 @@ BOOST_AUTO_TEST_CASE(LocalhopAndPropagate)
|
||||
}
|
||||
)CONFIG";
|
||||
|
||||
runOnRibIoService([&] {
|
||||
boost::asio::post(getRibIoService(), [&] {
|
||||
BOOST_CHECK_EXCEPTION(Service(makeSection(CONFIG), m_ribKeyChain), ConfigFile::Error,
|
||||
[] (const auto& e) {
|
||||
return e.what() == "localhop_security and auto_prefix_propagate "
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, Regents of the University of California,
|
||||
* Copyright (c) 2014-2023, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
#include "tests/clock-fixture.hpp"
|
||||
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
|
||||
namespace nfd::tests {
|
||||
|
||||
@@ -39,17 +39,13 @@ private:
|
||||
afterTick() final
|
||||
{
|
||||
if (m_io.stopped()) {
|
||||
#if BOOST_VERSION >= 106600
|
||||
m_io.restart();
|
||||
#else
|
||||
m_io.reset();
|
||||
#endif
|
||||
}
|
||||
m_io.poll();
|
||||
}
|
||||
|
||||
protected:
|
||||
boost::asio::io_service m_io;
|
||||
boost::asio::io_context m_io;
|
||||
};
|
||||
|
||||
} // namespace nfd::tests
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ def build(bld):
|
||||
# main
|
||||
bld.objects(target=f'other-tests-{module}-main',
|
||||
source='../main.cpp',
|
||||
use='BOOST',
|
||||
use='BOOST_TESTS',
|
||||
defines=[f'BOOST_TEST_MODULE={name}'])
|
||||
# module
|
||||
bld.program(name=module,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, Regents of the University of California,
|
||||
* Copyright (c) 2014-2023, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -66,10 +66,10 @@ public:
|
||||
/** \param stageName stage name
|
||||
* \param nCalls pointer to a variable which is incremented each time doStart is invoked
|
||||
* \param result expected result, nullopt to cause a failued
|
||||
* \param io io_service to asynchronously post the result
|
||||
* \param io io_context to asynchronously post the result
|
||||
*/
|
||||
DummyStage(const std::string& stageName, int* nCalls,
|
||||
const std::optional<FaceUri>& result, boost::asio::io_service& io)
|
||||
const std::optional<FaceUri>& result, boost::asio::io_context& io)
|
||||
: m_stageName(stageName)
|
||||
, m_nCalls(nCalls)
|
||||
, m_result(result)
|
||||
@@ -90,7 +90,8 @@ private:
|
||||
if (m_nCalls != nullptr) {
|
||||
++(*m_nCalls);
|
||||
}
|
||||
m_io.post([this] {
|
||||
|
||||
boost::asio::post(m_io, [this] {
|
||||
if (m_result) {
|
||||
this->succeed(*m_result);
|
||||
}
|
||||
@@ -104,7 +105,7 @@ private:
|
||||
std::string m_stageName;
|
||||
int* m_nCalls;
|
||||
std::optional<FaceUri> m_result;
|
||||
boost::asio::io_service& m_io;
|
||||
boost::asio::io_context& m_io;
|
||||
};
|
||||
|
||||
/** \brief Two-stage Procedure where the first stage succeeds and the second stage fails.
|
||||
@@ -133,7 +134,7 @@ public:
|
||||
int nCalls2 = 0;
|
||||
|
||||
private:
|
||||
boost::asio::io_service& m_io;
|
||||
boost::asio::io_context& m_io;
|
||||
};
|
||||
|
||||
/** \brief Two-stage Procedure where the first stage fails and the second stage succeeds.
|
||||
@@ -160,7 +161,7 @@ public:
|
||||
int nCalls2 = 0;
|
||||
|
||||
private:
|
||||
boost::asio::io_service& m_io;
|
||||
boost::asio::io_context& m_io;
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(NdnAutoconfig)
|
||||
|
||||
@@ -45,7 +45,7 @@ module2
|
||||
class DummyModule : public Module
|
||||
{
|
||||
public:
|
||||
DummyModule(const std::string& moduleName, boost::asio::io_service& io)
|
||||
DummyModule(const std::string& moduleName, boost::asio::io_context& io)
|
||||
: m_moduleName(moduleName)
|
||||
, m_scheduler(io)
|
||||
, m_res(0)
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ def build(bld):
|
||||
target='tests-common',
|
||||
features='pch',
|
||||
source=bld.path.ant_glob('*.cpp', excl='main.cpp'),
|
||||
use='core-objects',
|
||||
use='BOOST_TESTS core-objects',
|
||||
headers='../core/common.hpp boost-test.hpp',
|
||||
defines=[tmpdir])
|
||||
|
||||
@@ -43,7 +43,7 @@ def build(bld):
|
||||
# main() for the module
|
||||
bld.objects(target=f'unit-tests-{module}-main',
|
||||
source='main.cpp',
|
||||
use='BOOST',
|
||||
use='BOOST_TESTS',
|
||||
defines=[f'BOOST_TEST_MODULE=NFD {module.capitalize()}'])
|
||||
|
||||
subdir = 'daemon/rib' if module == 'rib' else module
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2014-2022, Regents of the University of California,
|
||||
* Copyright (c) 2014-2023, Regents of the University of California,
|
||||
* Arizona Board of Regents,
|
||||
* Colorado State University,
|
||||
* University Pierre & Marie Curie, Sorbonne University,
|
||||
@@ -140,11 +140,7 @@ NdnFchDiscovery::doStart()
|
||||
{
|
||||
try {
|
||||
boost::asio::ip::tcp::iostream requestStream;
|
||||
#if BOOST_VERSION >= 106700
|
||||
requestStream.expires_after(std::chrono::seconds(3));
|
||||
#else
|
||||
requestStream.expires_from_now(boost::posix_time::seconds(3));
|
||||
#endif // BOOST_VERSION >= 106700
|
||||
|
||||
Url url(m_url);
|
||||
if (!url.isValid()) {
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
void
|
||||
runOnce();
|
||||
|
||||
boost::asio::io_service&
|
||||
boost::asio::io_context&
|
||||
getIoService()
|
||||
{
|
||||
return m_face.getIoService();
|
||||
|
||||
+2
-2
@@ -63,7 +63,7 @@ def build(bld):
|
||||
bld.objects(target=srcObjects,
|
||||
source=srcFiles,
|
||||
features='pch',
|
||||
headers=subdir.find_node(name + '-pch.hpp'),
|
||||
headers=subdir.find_node(f'{name}-pch.hpp'),
|
||||
use='core-objects LIBRESOLV',
|
||||
includes=name)
|
||||
testableObjects.append(srcObjects)
|
||||
@@ -71,7 +71,7 @@ def build(bld):
|
||||
bld.program(name=name,
|
||||
target=f'{top}/bin/{name}',
|
||||
source=[mainFile],
|
||||
use='core-objects ' + srcObjects,
|
||||
use=f'core-objects {srcObjects}',
|
||||
includes=name)
|
||||
|
||||
bld.objects(target='tools-objects',
|
||||
|
||||
@@ -23,8 +23,9 @@ You should have received a copy of the GNU General Public License along with
|
||||
NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
from waflib import Context, Logs, Utils
|
||||
import os, subprocess
|
||||
|
||||
VERSION = '22.12'
|
||||
APPNAME = 'nfd'
|
||||
@@ -113,16 +114,15 @@ def configure(conf):
|
||||
|
||||
conf.check_cxx(header_name='valgrind/valgrind.h', define_name='HAVE_VALGRIND', mandatory=False)
|
||||
|
||||
boost_libs = ['system', 'program_options', 'filesystem']
|
||||
if conf.env.WITH_TESTS or conf.env.WITH_OTHER_TESTS:
|
||||
boost_libs.append('unit_test_framework')
|
||||
|
||||
conf.check_boost(lib=boost_libs, mt=True)
|
||||
if conf.env.BOOST_VERSION_NUMBER < 106501:
|
||||
conf.fatal('The minimum supported version of Boost is 1.65.1.\n'
|
||||
conf.check_boost(lib='filesystem program_options', mt=True)
|
||||
if conf.env.BOOST_VERSION_NUMBER < 107100:
|
||||
conf.fatal('The minimum supported version of Boost is 1.71.0.\n'
|
||||
'Please upgrade your distribution or manually install a newer version of Boost.\n'
|
||||
'For more information, see https://redmine.named-data.net/projects/nfd/wiki/Boost')
|
||||
|
||||
if conf.env.WITH_TESTS or conf.env.WITH_OTHER_TESTS:
|
||||
conf.check_boost(lib='unit_test_framework', mt=True, uselib_store='BOOST_TESTS')
|
||||
|
||||
conf.load('unix-socket')
|
||||
|
||||
if not conf.options.without_libpcap:
|
||||
@@ -160,8 +160,8 @@ def build(bld):
|
||||
|
||||
bld.objects(
|
||||
target='core-objects',
|
||||
source=bld.path.find_node('core').ant_glob('*.cpp') + ['core/version.cpp'],
|
||||
use='version.cpp version.hpp NDN_CXX BOOST LIBRT',
|
||||
source=bld.path.find_dir('core').ant_glob('*.cpp') + ['core/version.cpp'],
|
||||
use='version.cpp version.hpp BOOST NDN_CXX LIBRT',
|
||||
includes='.',
|
||||
export_includes='.')
|
||||
|
||||
@@ -199,9 +199,10 @@ def build(bld):
|
||||
source='daemon/main.cpp',
|
||||
use='daemon-objects SYSTEMD')
|
||||
|
||||
bld.recurse('tools')
|
||||
bld.recurse('tests')
|
||||
bld.recurse('tools')
|
||||
|
||||
# Install sample configs
|
||||
bld(features='subst',
|
||||
source='nfd.conf.sample.in',
|
||||
target='nfd.conf.sample',
|
||||
@@ -209,7 +210,6 @@ def build(bld):
|
||||
IF_HAVE_LIBPCAP='' if bld.env.HAVE_LIBPCAP else '; ',
|
||||
IF_HAVE_WEBSOCKET='' if bld.env.HAVE_WEBSOCKET else '; ',
|
||||
UNIX_SOCKET_PATH='/run/nfd.sock' if Utils.unversioned_sys_platform() == 'linux' else '/var/run/nfd.sock')
|
||||
|
||||
bld.install_files('${SYSCONFDIR}/ndn', 'autoconfig.conf.sample')
|
||||
|
||||
if bld.env.HAVE_SYSTEMD:
|
||||
|
||||
Reference in New Issue
Block a user