daemon: use asio::defer() instead of asio::post() where appropriate
Change-Id: I24d0fab6499d6430dd500ca157daa87f48960d15
This commit is contained in:
@@ -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,
|
||||
@@ -32,6 +32,8 @@
|
||||
|
||||
#include <array>
|
||||
|
||||
#include <boost/asio/defer.hpp>
|
||||
|
||||
namespace nfd::face {
|
||||
|
||||
struct Unicast {};
|
||||
@@ -149,7 +151,7 @@ DatagramTransport<T, U>::doClose()
|
||||
|
||||
// Ensure that the Transport stays alive at least until
|
||||
// all pending handlers are dispatched
|
||||
getGlobalIoService().post([this] {
|
||||
boost::asio::defer(getGlobalIoService(), [this] {
|
||||
this->setState(TransportState::CLOSED);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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,7 @@
|
||||
|
||||
#include <pcap/pcap.h>
|
||||
|
||||
#include <boost/asio/defer.hpp>
|
||||
#include <boost/endian/conversion.hpp>
|
||||
|
||||
namespace nfd::face {
|
||||
@@ -87,7 +88,7 @@ EthernetTransport::doClose()
|
||||
|
||||
// Ensure that the Transport stays alive at least
|
||||
// until all pending handlers are dispatched
|
||||
getGlobalIoService().post([this] {
|
||||
boost::asio::defer(getGlobalIoService(), [this] {
|
||||
this->setState(TransportState::CLOSED);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
@@ -26,6 +26,8 @@
|
||||
#include "internal-transport.hpp"
|
||||
#include "common/global.hpp"
|
||||
|
||||
#include <boost/asio/post.hpp>
|
||||
|
||||
namespace nfd::face {
|
||||
|
||||
NFD_LOG_MEMBER_INIT(InternalForwarderTransport, InternalForwarderTransport);
|
||||
@@ -47,7 +49,7 @@ InternalForwarderTransport::InternalForwarderTransport(const FaceUri& localUri,
|
||||
void
|
||||
InternalForwarderTransport::receivePacket(const Block& packet)
|
||||
{
|
||||
getGlobalIoService().post([this, packet] {
|
||||
boost::asio::post(getGlobalIoService(), [this, packet] {
|
||||
NFD_LOG_FACE_TRACE("Received: " << packet.size() << " bytes");
|
||||
receive(packet);
|
||||
});
|
||||
@@ -105,7 +107,7 @@ InternalClientTransport::connectToForwarder(InternalForwarderTransport* forwarde
|
||||
void
|
||||
InternalClientTransport::receivePacket(const Block& packet)
|
||||
{
|
||||
getGlobalIoService().post([this, packet] {
|
||||
boost::asio::post(getGlobalIoService(), [this, packet] {
|
||||
NFD_LOG_TRACE("Received: " << packet.size() << " bytes");
|
||||
if (m_receiveCallback) {
|
||||
m_receiveCallback(packet);
|
||||
|
||||
@@ -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,
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
#include <queue>
|
||||
|
||||
#include <boost/asio/defer.hpp>
|
||||
#include <boost/asio/write.hpp>
|
||||
|
||||
namespace nfd::face {
|
||||
@@ -149,7 +150,7 @@ StreamTransport<T>::doClose()
|
||||
|
||||
// Ensure that the Transport stays alive at least until
|
||||
// all pending handlers are dispatched
|
||||
getGlobalIoService().post([this] { deferredClose(); });
|
||||
boost::asio::defer(getGlobalIoService(), [this] { deferredClose(); });
|
||||
|
||||
// Some bug or feature of Boost.Asio (see https://redmine.named-data.net/issues/1856):
|
||||
//
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
#include "tcp-transport.hpp"
|
||||
#include "common/global.hpp"
|
||||
|
||||
#include <boost/asio/defer.hpp>
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <linux/sockios.h>
|
||||
#include <sys/ioctl.h>
|
||||
@@ -105,7 +107,7 @@ TcpTransport::handleError(const boost::system::error_code& error)
|
||||
m_socket.cancel(ec);
|
||||
|
||||
// do this asynchronously because there could be some callbacks still pending
|
||||
getGlobalIoService().post([this] { reconnect(); });
|
||||
boost::asio::defer(getGlobalIoService(), [this] { reconnect(); });
|
||||
}
|
||||
else {
|
||||
StreamTransport::handleError(error);
|
||||
@@ -175,7 +177,7 @@ TcpTransport::handleReconnectTimeout()
|
||||
MAX_RECONNECT_DELAY);
|
||||
|
||||
// do this asynchronously because there could be some callbacks still pending
|
||||
getGlobalIoService().post([this] { reconnect(); });
|
||||
boost::asio::defer(getGlobalIoService(), [this] { reconnect(); });
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include "common/logger.hpp"
|
||||
#include "face/channel.hpp"
|
||||
|
||||
#include <boost/asio/defer.hpp>
|
||||
|
||||
namespace nfd {
|
||||
|
||||
NFD_LOG_INIT(FaceTable);
|
||||
@@ -100,7 +102,7 @@ FaceTable::remove(FaceId faceId)
|
||||
" local=" << face->getLocalUri());
|
||||
|
||||
// defer Face deallocation, so that Transport isn't deallocated during afterStateChange signal
|
||||
getGlobalIoService().post([face] {});
|
||||
boost::asio::defer(getGlobalIoService(), [face] {});
|
||||
}
|
||||
|
||||
FaceTable::ForwardRange
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#include "rib/rib.hpp"
|
||||
#include "table/fib.hpp"
|
||||
|
||||
#include <boost/asio/defer.hpp>
|
||||
|
||||
#include <ndn-cxx/lp/tags.hpp>
|
||||
#include <ndn-cxx/mgmt/nfd/rib-entry.hpp>
|
||||
#include <ndn-cxx/mgmt/nfd/status-dataset.hpp>
|
||||
@@ -446,11 +448,12 @@ RibManager::removeInvalidFaces(const std::vector<ndn::nfd::FaceStatus>& activeFa
|
||||
{
|
||||
NFD_LOG_DEBUG("Checking for invalid face registrations");
|
||||
|
||||
std::set<uint64_t> activeFaceIds;
|
||||
std::set<uint64_t> activeIds;
|
||||
for (const auto& faceStatus : activeFaces) {
|
||||
activeFaceIds.insert(faceStatus.getFaceId());
|
||||
activeIds.insert(faceStatus.getFaceId());
|
||||
}
|
||||
getGlobalIoService().post([=] { m_rib.beginRemoveFailedFaces(activeFaceIds); });
|
||||
boost::asio::defer(getGlobalIoService(),
|
||||
[this, active = std::move(activeIds)] { m_rib.beginRemoveFailedFaces(active); });
|
||||
|
||||
// Reschedule the check for future clean up
|
||||
scheduleActiveFaceFetch(ACTIVE_FACE_FETCH_INTERVAL);
|
||||
@@ -463,7 +466,8 @@ RibManager::onNotification(const ndn::nfd::FaceEventNotification& notification)
|
||||
|
||||
if (notification.getKind() == ndn::nfd::FACE_EVENT_DESTROYED) {
|
||||
NFD_LOG_DEBUG("Received notification for destroyed FaceId " << notification.getFaceId());
|
||||
getGlobalIoService().post([this, id = notification.getFaceId()] { m_rib.beginRemoveFace(id); });
|
||||
boost::asio::defer(getGlobalIoService(),
|
||||
[this, id = notification.getFaceId()] { m_rib.beginRemoveFace(id); });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
@@ -31,6 +31,8 @@
|
||||
|
||||
#include "channel-fixture.hpp"
|
||||
|
||||
#include <boost/asio/defer.hpp>
|
||||
|
||||
namespace nfd::tests {
|
||||
|
||||
using face::TcpChannel;
|
||||
@@ -57,7 +59,7 @@ protected:
|
||||
void
|
||||
connect(TcpChannel& channel) final
|
||||
{
|
||||
g_io.post([&] {
|
||||
boost::asio::defer(g_io, [&] {
|
||||
channel.connect(listenerEp, {},
|
||||
[this] (const shared_ptr<Face>& newFace) {
|
||||
BOOST_REQUIRE(newFace != nullptr);
|
||||
|
||||
@@ -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,
|
||||
@@ -31,6 +31,8 @@
|
||||
|
||||
#include "channel-fixture.hpp"
|
||||
|
||||
#include <boost/asio/defer.hpp>
|
||||
|
||||
namespace nfd::tests {
|
||||
|
||||
using face::UdpChannel;
|
||||
@@ -52,7 +54,7 @@ protected:
|
||||
void
|
||||
connect(UdpChannel& channel) final
|
||||
{
|
||||
g_io.post([&] {
|
||||
boost::asio::defer(g_io, [&] {
|
||||
channel.connect(listenerEp, {},
|
||||
[this] (const shared_ptr<Face>& newFace) {
|
||||
BOOST_REQUIRE(newFace != nullptr);
|
||||
|
||||
@@ -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,
|
||||
@@ -185,7 +185,7 @@ private:
|
||||
data->setContent(resp.wireEncode());
|
||||
m_keyChain.sign(*data, ndn::security::SigningInfo(ndn::security::SigningInfo::SIGNER_TYPE_SHA256));
|
||||
|
||||
m_face.getIoService().post([this, data] { m_face.receive(*data); });
|
||||
boost::asio::post(m_face.getIoService(), [this, data] { m_face.receive(*data); });
|
||||
};
|
||||
|
||||
const Name commandPrefix("/localhost/nfd/fib/add-nexthop");
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
#include "tests/daemon/global-io-fixture.hpp"
|
||||
#include "tests/daemon/rib/create-route.hpp"
|
||||
|
||||
#include <boost/asio/defer.hpp>
|
||||
|
||||
#include <ndn-cxx/util/dummy-client-face.hpp>
|
||||
|
||||
namespace nfd::tests {
|
||||
@@ -80,7 +82,7 @@ private:
|
||||
uint32_t nTimeouts)
|
||||
{
|
||||
updates.push_back(update);
|
||||
getGlobalIoService().post([=] {
|
||||
boost::asio::defer(getGlobalIoService(), [=] {
|
||||
if (mockSuccess) {
|
||||
onUpdateSuccess(update, onSuccess, onFailure);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include <ndn-cxx/mgmt/nfd/control-response.hpp>
|
||||
#include <ndn-cxx/util/dummy-client-face.hpp>
|
||||
|
||||
#include <boost/asio/defer.hpp>
|
||||
#include <boost/concept/assert.hpp>
|
||||
|
||||
namespace nfd::tests {
|
||||
@@ -52,7 +53,7 @@ protected:
|
||||
{
|
||||
face.onSendInterest.connect([this] (const Interest& interest) {
|
||||
if (processInterest) {
|
||||
m_io.post([=] { processInterest(interest); });
|
||||
boost::asio::defer(m_io, [=] { processInterest(interest); });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user