mgmt: FaceManager no longer owns FaceSystem
refs #3904
Change-Id: I2ef6fd36a51493eea27d8eb0e1c7dc022766f948
diff --git a/daemon/face/face-system.hpp b/daemon/face/face-system.hpp
index bca7702..d1f38b9 100644
--- a/daemon/face/face-system.hpp
+++ b/daemon/face/face-system.hpp
@@ -67,6 +67,12 @@
ProtocolFactory*
getFactoryByScheme(const std::string& scheme);
+ FaceTable&
+ getFaceTable()
+ {
+ return m_faceTable;
+ }
+
/** \brief register handler for face_system section of NFD configuration file
*/
void
diff --git a/daemon/mgmt/face-manager.cpp b/daemon/mgmt/face-manager.cpp
index a2bfc3c..4d1929d 100644
--- a/daemon/mgmt/face-manager.cpp
+++ b/daemon/mgmt/face-manager.cpp
@@ -35,10 +35,11 @@
NFD_LOG_INIT("FaceManager");
-FaceManager::FaceManager(FaceTable& faceTable, Dispatcher& dispatcher, CommandAuthenticator& authenticator)
+FaceManager::FaceManager(FaceSystem& faceSystem,
+ Dispatcher& dispatcher, CommandAuthenticator& authenticator)
: NfdManagerBase(dispatcher, authenticator, "faces")
- , m_faceSystem(faceTable)
- , m_faceTable(faceTable)
+ , m_faceSystem(faceSystem)
+ , m_faceTable(faceSystem.getFaceTable())
{
registerCommandHandler<ndn::nfd::FaceCreateCommand>("create",
bind(&FaceManager::createFace, this, _2, _3, _4, _5));
diff --git a/daemon/mgmt/face-manager.hpp b/daemon/mgmt/face-manager.hpp
index 3c92e93..9a8c503 100644
--- a/daemon/mgmt/face-manager.hpp
+++ b/daemon/mgmt/face-manager.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+ * Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -41,9 +41,8 @@
class FaceManager : public NfdManagerBase
{
public:
- FaceManager(FaceTable& faceTable,
- Dispatcher& dispatcher,
- CommandAuthenticator& authenticator);
+ FaceManager(FaceSystem& faceSystem,
+ Dispatcher& dispatcher, CommandAuthenticator& authenticator);
/**
* @brief Subscribe to face_system section for the config file
@@ -141,7 +140,7 @@
connectFaceStateChangeSignal(const Face& face);
PUBLIC_WITH_TESTS_ELSE_PRIVATE:
- FaceSystem m_faceSystem; ///\todo #3904 accept FaceSystem& in constructor; don't own FaceSystem
+ FaceSystem& m_faceSystem;
FaceTable& m_faceTable;
std::map<FaceId, signal::ScopedConnection> m_faceStateChangeConn;
diff --git a/daemon/nfd.cpp b/daemon/nfd.cpp
index b3369db..2f2861d 100644
--- a/daemon/nfd.cpp
+++ b/daemon/nfd.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+ * Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -30,6 +30,7 @@
#include "core/privilege-helper.hpp"
#include "core/config-file.hpp"
#include "fw/forwarder.hpp"
+#include "face/face-system.hpp"
#include "face/null-face.hpp"
#include "face/internal-face.hpp"
#include "mgmt/fib-manager.hpp"
@@ -83,11 +84,12 @@
m_forwarder.reset(new Forwarder());
- initializeManagement();
-
FaceTable& faceTable = m_forwarder->getFaceTable();
faceTable.addReserved(face::makeNullFace(), face::FACEID_NULL);
faceTable.addReserved(face::makeNullFace(FaceUri("contentstore://")), face::FACEID_CONTENT_STORE);
+ m_faceSystem.reset(new face::FaceSystem(faceTable));
+
+ initializeManagement();
PrivilegeHelper::drop();
@@ -145,8 +147,7 @@
m_authenticator = CommandAuthenticator::create();
m_forwarderStatusManager.reset(new ForwarderStatusManager(*m_forwarder, *m_dispatcher));
- m_faceManager.reset(new FaceManager(m_forwarder->getFaceTable(),
- *m_dispatcher, *m_authenticator));
+ m_faceManager.reset(new FaceManager(*m_faceSystem, *m_dispatcher, *m_authenticator));
m_fibManager.reset(new FibManager(m_forwarder->getFib(), m_forwarder->getFaceTable(),
*m_dispatcher, *m_authenticator));
m_strategyChoiceManager.reset(new StrategyChoiceManager(m_forwarder->getStrategyChoice(),
diff --git a/daemon/nfd.hpp b/daemon/nfd.hpp
index f98d3b6..8082bf3 100644
--- a/daemon/nfd.hpp
+++ b/daemon/nfd.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+ * Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -50,6 +50,7 @@
namespace face {
class Face;
+class FaceSystem;
} // namespace face
/**
@@ -106,6 +107,7 @@
ConfigSection m_configSection;
unique_ptr<Forwarder> m_forwarder;
+ unique_ptr<face::FaceSystem> m_faceSystem;
ndn::KeyChain& m_keyChain;
shared_ptr<face::Face> m_internalFace;
diff --git a/tests/daemon/mgmt/face-manager-command-fixture.cpp b/tests/daemon/mgmt/face-manager-command-fixture.cpp
index 1b73841..989ff7b 100644
--- a/tests/daemon/mgmt/face-manager-command-fixture.cpp
+++ b/tests/daemon/mgmt/face-manager-command-fixture.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+ * Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -32,7 +32,8 @@
: face(getGlobalIoService(), keyChain, {true, true})
, dispatcher(face, keyChain, ndn::security::SigningInfo())
, authenticator(CommandAuthenticator::create())
- , manager(faceTable, dispatcher, *authenticator)
+ , faceSystem(faceTable)
+ , manager(faceSystem, dispatcher, *authenticator)
{
dispatcher.addTopPrefix("/localhost/nfd");
diff --git a/tests/daemon/mgmt/face-manager-command-fixture.hpp b/tests/daemon/mgmt/face-manager-command-fixture.hpp
index 8d66309..0bde982 100644
--- a/tests/daemon/mgmt/face-manager-command-fixture.hpp
+++ b/tests/daemon/mgmt/face-manager-command-fixture.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+ * Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -45,10 +45,12 @@
~FaceManagerCommandNode();
public:
- FaceTable faceTable;
- ndn::util::DummyClientFace face;
+ ndn::util::DummyClientFace face; ///< internal client face used by management
ndn::mgmt::Dispatcher dispatcher;
shared_ptr<CommandAuthenticator> authenticator;
+
+ FaceTable faceTable;
+ FaceSystem faceSystem;
FaceManager manager;
};
diff --git a/tests/daemon/mgmt/face-manager.t.cpp b/tests/daemon/mgmt/face-manager.t.cpp
index 6b54d74..ccf7175 100644
--- a/tests/daemon/mgmt/face-manager.t.cpp
+++ b/tests/daemon/mgmt/face-manager.t.cpp
@@ -25,8 +25,7 @@
#include "mgmt/face-manager.hpp"
#include "core/random.hpp"
-#include "face/tcp-factory.hpp"
-#include "face/udp-factory.hpp"
+#include "face/protocol-factory.hpp"
#include "nfd-manager-common-fixture.hpp"
#include "../face/dummy-face.hpp"
@@ -44,7 +43,8 @@
public:
FaceManagerFixture()
: m_faceTable(m_forwarder.getFaceTable())
- , m_manager(m_faceTable, m_dispatcher, *m_authenticator)
+ , m_faceSystem(m_faceTable)
+ , m_manager(m_faceSystem, m_dispatcher, *m_authenticator)
{
setTopPrefix();
setPrivilege("faces");
@@ -110,6 +110,7 @@
protected:
FaceTable& m_faceTable;
+ FaceSystem m_faceSystem;
FaceManager m_manager;
};