face: Reset io_service after io_service::poll()
In the case when after the io_service::poll call from the inside of
processEvents(<negative time>) there are no more handlers to dispatch,
io_service is moved to "stopped" state, which requires
io_service::reset() to be called in order for the future events to be
dispatched in subsequent poll/processEvents call.
Change-Id: I3dd4c44550a5cf6c6885f249ccfb7ba2fbf8198d
diff --git a/tests/unit-tests/test-faces.cpp b/tests/unit-tests/test-faces.cpp
index 3fcae2e..84982a0 100644
--- a/tests/unit-tests/test-faces.cpp
+++ b/tests/unit-tests/test-faces.cpp
@@ -367,6 +367,24 @@
BOOST_CHECK_EQUAL(nInInterests, 2);
}
+BOOST_AUTO_TEST_CASE(ProcessEvents)
+{
+ face->processEvents(time::milliseconds(-1)); // io_service::reset()/poll() inside
+
+ face->registerPrefix("/Hello/World",
+ bind(&FacesFixture::onRegSucceeded, this),
+ bind(&FacesFixture::onRegFailed, this));
+
+ // io_service::poll() without reset
+ face->getIoService().poll();
+ BOOST_CHECK_EQUAL(nRegFailures, 0);
+ BOOST_CHECK_EQUAL(nRegSuccesses, 0);
+
+ face->processEvents(time::milliseconds(-1)); // io_service::reset()/poll() inside
+ BOOST_CHECK_EQUAL(nRegFailures, 0);
+ BOOST_CHECK_EQUAL(nRegSuccesses, 1);
+}
+
BOOST_AUTO_TEST_SUITE_END()
} // tests