face: Avoid resuming transport after connect if the transmission queue empty
Change-Id: I53763b62a8fc12d1d2613daa8d4f9d2b5109b7aa
Refs: #3957
diff --git a/tests/integrated/face.cpp b/tests/integrated/face.cpp
index 9d358a5..12e7a99 100644
--- a/tests/integrated/face.cpp
+++ b/tests/integrated/face.cpp
@@ -30,6 +30,9 @@
#include "boost-test.hpp"
#include <stdio.h>
+#include <thread>
+#include <mutex>
+#include <condition_variable>
namespace ndn {
namespace tests {
@@ -565,6 +568,33 @@
BOOST_CHECK_NO_THROW(face.processEvents(time::seconds(1)));
}
+BOOST_AUTO_TEST_CASE(ProcessEventsBlocksForeverWhenNothingScheduled) // Bug #3957
+{
+ ndn::Face face;
+ std::mutex m;
+ std::condition_variable cv;
+ bool processEventsFinished = false;
+
+ std::thread faceThread([&] {
+ face.processEvents();
+
+ processEventsFinished = true;
+ std::lock_guard<std::mutex> lk(m);
+ cv.notify_one();
+ });
+
+ {
+ std::unique_lock<std::mutex> lk(m);
+ cv.wait_for(lk, std::chrono::seconds(5), [&] { return processEventsFinished; });
+ }
+
+ BOOST_CHECK_EQUAL(processEventsFinished, true);
+ if (!processEventsFinished) {
+ face.shutdown();
+ }
+ faceThread.join();
+}
+
BOOST_AUTO_TEST_SUITE_END()
} // namespace tests