logic: Don't shutdown face when destructing Logic instance
refs: #4525
Change-Id: I3a50b818c6553d08fc807869107e53f55775c43d
diff --git a/tests/unit-tests/dummy-forwarder.cpp b/tests/unit-tests/dummy-forwarder.cpp
index 224dcd3..45a8cd6 100644
--- a/tests/unit-tests/dummy-forwarder.cpp
+++ b/tests/unit-tests/dummy-forwarder.cpp
@@ -1,6 +1,6 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
- * Copyright (c) 2012-2017 University of California, Los Angeles
+ * Copyright (c) 2012-2018 University of California, Los Angeles
*
* This file is part of ChronoSync, synchronization library for distributed realtime
* applications for NDN.
@@ -35,29 +35,30 @@
{
auto face = std::make_shared<util::DummyClientFace>(m_io, m_keyChain,
util::DummyClientFace::Options{true, true});
- face->onSendInterest.connect([this, face] (const Interest& interest) {
+ util::DummyClientFace* self = &*face; // to prevent memory leak
+ face->onSendInterest.connect([this, self] (const Interest& interest) {
Interest i(interest);
for (auto& otherFace : m_faces) {
- if (&*face == &*otherFace) {
+ if (self == &*otherFace) {
continue;
}
m_io.post([=] { otherFace->receive(i); });
}
});
- face->onSendData.connect([this, face] (const Data& data) {
+ face->onSendData.connect([this, self] (const Data& data) {
Data d(data);
for (auto& otherFace : m_faces) {
- if (&*face == &*otherFace) {
+ if (self == &*otherFace) {
continue;
}
m_io.post([=] { otherFace->receive(d); });
}
});
- face->onSendNack.connect([this, face] (const lp::Nack& nack) {
+ face->onSendNack.connect([this, self] (const lp::Nack& nack) {
lp::Nack n(nack);
for (auto& otherFace : m_faces) {
- if (&*face == &*otherFace) {
+ if (self == &*otherFace) {
continue;
}
m_io.post([=] { otherFace->receive(n); });
@@ -68,5 +69,11 @@
return *face;
}
+void
+DummyForwarder::removeFaces()
+{
+ m_faces.clear();
+}
+
} // namespace chronosync
} // namespace ndn