face: Issuing Transport::connect() within the same thread as Transport::send()
In certain cases, previous version caused connect() to fail (stopped
io_service due to exception) before send() is dispatched. This could
have resulted in incorrectly calling Transport::send with old buffer
when io_service resumes.
Change-Id: Ib6ba0f1d87ec321da0c489eb41850b5b401e5521
Refs: #1759
diff --git a/src/detail/face-impl.hpp b/src/detail/face-impl.hpp
index bcb290f..7c259aa 100644
--- a/src/detail/face-impl.hpp
+++ b/src/detail/face-impl.hpp
@@ -103,6 +103,10 @@
asyncExpressInterest(const shared_ptr<const Interest>& interest,
const OnData& onData, const OnTimeout& onTimeout)
{
+ if (!m_face.m_transport->isConnected())
+ m_face.m_transport->connect(*m_face.m_ioService,
+ bind(&Face::onReceiveElement, &m_face, _1));
+
if (!m_face.m_transport->isExpectingData())
m_face.m_transport->resume();
diff --git a/src/face.cpp b/src/face.cpp
index 9f52acd..6f13570 100644
--- a/src/face.cpp
+++ b/src/face.cpp
@@ -142,10 +142,6 @@
const PendingInterestId*
Face::expressInterest(const Interest& interest, const OnData& onData, const OnTimeout& onTimeout)
{
- if (!m_transport->isConnected())
- m_transport->connect(*m_ioService,
- bind(&Face::onReceiveElement, this, _1));
-
shared_ptr<Interest> interestToExpress = make_shared<Interest>(interest);
// If the same ioService thread, dispatch directly calls the method