Added crazy thing in CcnxWrapper
Now CcnxWrapperTest succeeds every four seconds, but fails if it
executed with period less than 4 seconds (I guess there is some kind of
interests/filter suppression)
diff --git a/model/sync-ccnx-wrapper.cc b/model/sync-ccnx-wrapper.cc
index aa7ab8c..d531971 100644
--- a/model/sync-ccnx-wrapper.cc
+++ b/model/sync-ccnx-wrapper.cc
@@ -31,12 +31,19 @@
namespace Sync {
+#ifdef _DEBUG_WRAPPER_
+CcnxWrapper::CcnxWrapper(char c)
+#else
CcnxWrapper::CcnxWrapper()
+#endif
: m_handle (0)
, m_keyStore (0)
, m_keyLoactor (0)
, m_running (true)
{
+#ifdef _DEBUG_WRAPPER_
+ m_c = c;
+#endif
m_handle = ccn_create ();
initKeyStore ();
createKeyLocator ();
@@ -106,17 +113,17 @@
void
CcnxWrapper::ccnLoop ()
{
- pollfd pfds[1];
-
- pfds[0].fd = ccn_get_connection_fd (m_handle);
- pfds[0].events = POLLIN;
while (m_running)
{
+#ifdef _DEBUG_WRAPPER_
+ std::cout << m_c << flush;
+#endif
int res = 0;
{
recursive_mutex::scoped_lock lock (m_mutex);
res = ccn_run (m_handle, 0);
+
}
if (!m_running) break;
@@ -125,12 +132,22 @@
BOOST_THROW_EXCEPTION (CcnxOperationException()
<< errmsg_info_str("ccn_run returned error"));
- int ret = poll(pfds, 1, 10);
+
+ pollfd pfds[1];
+ {
+ recursive_mutex::scoped_lock lock (m_mutex);
+
+ pfds[0].fd = ccn_get_connection_fd (m_handle);
+ pfds[0].events = POLLIN;
+ if (ccn_output_is_pending (m_handle))
+ pfds[0].events |= POLLOUT;
+ }
+
+ int ret = poll (pfds, 1, 1);
if (ret < 0)
{
BOOST_THROW_EXCEPTION (CcnxOperationException() << errmsg_info_str("ccnd socket failed (probably ccnd got stopped)"));
}
-
}
}
diff --git a/model/sync-ccnx-wrapper.h b/model/sync-ccnx-wrapper.h
index ecfeee3..e7a1a64 100644
--- a/model/sync-ccnx-wrapper.h
+++ b/model/sync-ccnx-wrapper.h
@@ -61,7 +61,12 @@
* keystore 2) init keylocator 3) start a thread to hold a loop of ccn_run
*
*/
+#ifdef _DEBUG_WRAPPER_
+ CcnxWrapper(char c='.');
+ char m_c;
+#else
CcnxWrapper();
+#endif
~CcnxWrapper();
/**