fix sync interest sending in sync-core
diff --git a/src/sync-core.cc b/src/sync-core.cc
index 6c9df52..29f8664 100644
--- a/src/sync-core.cc
+++ b/src/sync-core.cc
@@ -23,8 +23,10 @@
 #include "sync-state-helper.h"
 #include "logging.h"
 #include "random-interval-generator.h"
+#include "one-time-task.h"
 
 #include <boost/lexical_cast.hpp>
+#include <boost/make_shared.hpp>
 
 INIT_LOGGER ("Sync.Core");
 
@@ -51,6 +53,8 @@
   m_log->UpdateLocalLocator (localPrefix);
 
   m_scheduler->start();
+  string tag = userName.toString() + "send-sync-interest";
+  m_sendSyncInterestTask = make_shared<OneTimeTask>(bind(&SyncCore::sendSyncInterest, this), tag, m_scheduler, 4.0);
   sendSyncInterest();
 }
 
@@ -180,8 +184,7 @@
 Closure::TimeoutCallbackReturnValue
 SyncCore::handleSyncInterestTimeout(const Name &name)
 {
-  // sendInterestInterest with the current root hash;
-  sendSyncInterest();
+  // sync interest will be resent by scheduler
   return Closure::RESULT_OK;
 }
 
@@ -283,6 +286,12 @@
   m_ccnx->sendInterest(syncInterest,
                          Closure (boost::bind(&SyncCore::handleSyncData, this, _1, _2),
                                   boost::bind(&SyncCore::handleSyncInterestTimeout, this, _1)));
+
+  // if there is a pending syncSyncInterest task, reschedule it to be 4 seconds from now
+  // if no such task exists, it will be added
+  _LOG_DEBUG("[" << m_log->GetLocalName () << "] >>> Attempt to schedule sendSyncInterest ");
+  m_scheduler->rescheduleTask(m_sendSyncInterestTask);
+  _LOG_DEBUG("[" << m_log->GetLocalName () << "] >>> Scheduled sendSyncInterest ");
 }
 
 void
diff --git a/src/sync-core.h b/src/sync-core.h
index db20bbb..b0d8af0 100644
--- a/src/sync-core.h
+++ b/src/sync-core.h
@@ -25,6 +25,7 @@
 #include "sync-log.h"
 #include "ccnx-wrapper.h"
 #include "scheduler.h"
+#include "task.h"
 
 #include <boost/function.hpp>
 
@@ -110,6 +111,8 @@
   HashPtr m_rootHash;
 
   IntervalGeneratorPtr m_recoverWaitGenerator;
+
+  TaskPtr m_sendSyncInterestTask;
 };
 
 #endif // SYNC_CORE_H