Fix two related bugs: rescheduling periodic task + fetch manager restart of failed fetches
Apparently, posix_time::seconds() returns just seconds from [0, 59]
range and to get total number of seconds, total_seconds() call is
necessary
Change-Id: Idbc3cbd6a33e72d7f573f9cc905b73022ddf4847
diff --git a/scheduler/periodic-task.cc b/scheduler/periodic-task.cc
index 32bae6a..947107c 100644
--- a/scheduler/periodic-task.cc
+++ b/scheduler/periodic-task.cc
@@ -20,8 +20,11 @@
*/
#include "periodic-task.h"
+#include "logging.h"
#include <utility>
+INIT_LOGGER ("Scheduler.PeriodicTask");
+
PeriodicTask::PeriodicTask(const Callback &callback, const Tag &tag, const SchedulerPtr &scheduler,
IntervalGeneratorPtr generator)
: Task(callback, tag, scheduler)
@@ -34,9 +37,14 @@
{
if (!m_invoked)
{
- m_callback();
m_invoked = true;
- m_scheduler->rescheduleTask(m_tag);
+ m_callback();
+
+ if (m_invoked)
+ {
+ // m_invoked getting back if it is rescheduled inside the callback
+ m_scheduler->rescheduleTask(m_tag);
+ }
}
}
diff --git a/src/fetch-manager.cc b/src/fetch-manager.cc
index e9463b7..af72e08 100644
--- a/src/fetch-manager.cc
+++ b/src/fetch-manager.cc
@@ -181,7 +181,7 @@
item->RestartPipeline ();
}
- m_scheduler->rescheduleTaskAt (m_scheduleFetchesTask, (nextSheduleCheck - currentTime).seconds ());
+ m_scheduler->rescheduleTaskAt (m_scheduleFetchesTask, (nextSheduleCheck - currentTime).total_seconds ());
}
void