face: Call Transport::connect within io_service thread
Previously, there was an indirect call to Transport::connect from within
Face constructor, causing in some cases false timeouts for connect operation.
Change-Id: I6358970e92ead94de977cfde94b5552c4fa24c63
Refs: #2742
diff --git a/src/face.cpp b/src/face.cpp
index 98581b3..1579ee5 100644
--- a/src/face.cpp
+++ b/src/face.cpp
@@ -128,7 +128,7 @@
m_transport = transport;
- m_impl->ensureConnected(false);
+ m_ioService.post([=] { m_impl->ensureConnected(false); });
}
Face::~Face() = default;
diff --git a/tests/integrated/face.cpp b/tests/integrated/face.cpp
index 3a5f071..2662365 100644
--- a/tests/integrated/face.cpp
+++ b/tests/integrated/face.cpp
@@ -511,6 +511,15 @@
// should not segfault
}
+BOOST_AUTO_TEST_CASE(LargeDelayBetweenFaceConstructorAndProcessEvents) // Bug #2742
+{
+ ndn::Face face;
+
+ ::sleep(5); // simulate setup workload
+
+ BOOST_CHECK_NO_THROW(face.processEvents(time::seconds(1)));
+}
+
BOOST_AUTO_TEST_SUITE_END()
} // tests