fs-watcher: Fixed fs-watcher multiple onChange callback

Change-Id: Ied8c876e4fee238c960e091466e275823e83e899
diff --git a/test/test-fetch-manager.cc b/test/test-fetch-manager.cc
index 5abe47d..42d4b48 100644
--- a/test/test-fetch-manager.cc
+++ b/test/test-fetch-manager.cc
@@ -188,6 +188,45 @@
   executor->shutdown ();
 }
 
+
+BOOST_AUTO_TEST_CASE (TestFetcher2)
+{
+  INIT_LOGGERS ();
+
+  CcnxWrapperPtr ccnx = make_shared<CcnxWrapper> ();
+
+  Name baseName ("/base");
+  Name deviceName ("/device");
+  int i = 0;
+
+  ccnx->publishData (Name (baseName)(i), reinterpret_cast<const unsigned char*> (&i), sizeof(int), 30);
+
+
+  FetcherTestData data;
+  ExecutorPtr executor = make_shared<Executor>(1);
+  executor->start ();
+
+  Fetcher fetcher (ccnx,
+                   executor,
+                   bind (&FetcherTestData::onData, &data, _1, _2, _3, _4),
+                   bind (&FetcherTestData::finish, &data, _1, _2),
+                   bind (&FetcherTestData::onComplete, &data, _1),
+                   bind (&FetcherTestData::onFail, &data, _1),
+                   deviceName, Name ("/base"), 1, 1,
+                   boost::posix_time::seconds (5)); // this time is not precise
+
+  BOOST_CHECK_EQUAL (fetcher.IsActive (), false);
+  fetcher.RestartPipeline ();
+  BOOST_CHECK_EQUAL (fetcher.IsActive (), true);
+
+  usleep(7000000);
+  BOOST_CHECK_EQUAL (data.m_failed, true);
+
+  executor->shutdown ();
+}
+
+
+
 // BOOST_AUTO_TEST_CASE (CcnxWrapperSelector)
 // {
 
diff --git a/test/test-fs-watcher-delay.cc b/test/test-fs-watcher-delay.cc
index e658e2a..162d1d4 100644
--- a/test/test-fs-watcher-delay.cc
+++ b/test/test-fs-watcher-delay.cc
@@ -69,13 +69,15 @@
   
   
 
-  usleep(2000000);
+  usleep(10000000);
 
   // cleanup
   if (fs::exists(dir))
   {
     fs::remove_all(dir);
   }
+
+  usleep(1000000);
 }
 
 BOOST_AUTO_TEST_SUITE_END()