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();
 
   /**
diff --git a/test/test_ccnx_wrapper.cc b/test/test_ccnx_wrapper.cc
index 1cd1394..ad69262 100644
--- a/test/test_ccnx_wrapper.cc
+++ b/test/test_ccnx_wrapper.cc
@@ -35,52 +35,50 @@
 string echoStr = "";
 
 void echo(string str) {
-	echoStr = str;
+  echoStr = str;
 }
 
 struct TestStruct {
-	string s_str1, s_str2;
-	void set(string str1, string str2) {
-		s_str1 = str1;
-		s_str2 = str2;
-	}
+  string s_str1, s_str2;
+  void set(string str1, string str2) {
+    s_str1 = str1;
+    s_str2 = str2;
+  }
 };
 
 BOOST_AUTO_TEST_CASE (CcnxWrapperTest)
 {
-
-	CcnxWrapper ha;
-	CcnxWrapper hb;
+  CcnxWrapper ha;
+  CcnxWrapper hb;
 	
-	TestStruct foo;
+  TestStruct foo;
 	
-	boost::function<void (string)> globalFunc = echo;
-	boost::function<void (string, string)> memberFunc =
-	bind(&TestStruct::set, &foo, _1, _2);
+  boost::function<void (string)> globalFunc = echo;
+  boost::function<void (string, string)> memberFunc =
+    bind(&TestStruct::set, &foo, _1, _2);
 
-	string prefix = "/ucla.edu";
-	ha.setInterestFilter(prefix, globalFunc);
+  string prefix = "/ucla.edu";
+  ha.setInterestFilter(prefix, globalFunc);
+  this_thread::sleep (posix_time::milliseconds (10));
 
-	string interest = "/ucla.edu/0";
-	hb.sendInterest(interest, memberFunc);
+  string interest = "/ucla.edu/0";
+  hb.sendInterest(interest, memberFunc);
 
-	// give time for ccnd to react
-	sleep(1);
+  // give time for ccnd to react
+  // sleep(1);
+  this_thread::sleep (posix_time::milliseconds (5));
+  BOOST_CHECK_EQUAL(echoStr, interest);
 
-	BOOST_CHECK_EQUAL(echoStr, interest);
+  string name = "/ucla.edu/0";
+  string data = "random bits: !#$!@#$!";
+  ha.publishData(name, data, 5);
 
+  hb.sendInterest(interest, memberFunc);
 
-	string name = "/ucla.edu/0";
-	string data = "random bits: !#$!@#$!";
-	ha.publishData(name, data, 5);
-
-	hb.sendInterest(interest, memberFunc);
-
-	// give time for ccnd to react
-	sleep(1);
-	BOOST_CHECK_EQUAL(foo.s_str1, name);
-	BOOST_CHECK_EQUAL(foo.s_str2, data);
-
+  // give time for ccnd to react
+  this_thread::sleep (posix_time::milliseconds (5));
+  BOOST_CHECK_EQUAL(foo.s_str1, name);
+  BOOST_CHECK_EQUAL(foo.s_str2, data);
 }