From 17824b65d0dbf640f23507f1f983acfc4177da94 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 18 Jun 2015 01:34:03 +0100 Subject: Add an option to force performing a maintenance cycle on start-up --- p2pvr/daemon/maintenance.cpp | 11 +++++++---- p2pvr/daemon/maintenance.h | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/p2pvr/daemon/maintenance.cpp b/p2pvr/daemon/maintenance.cpp index 928e8d9..e3747b3 100644 --- a/p2pvr/daemon/maintenance.cpp +++ b/p2pvr/daemon/maintenance.cpp @@ -10,6 +10,7 @@ time_t Maintenance::periodUpdateNetwork; time_t Maintenance::periodUpdateServices; time_t Maintenance::periodUpdateEvents; +bool Maintenance::scanOnStart; DECLARE_OPTIONS(Maintenance, "P2PVR Maintenance options") ("p2pvr.maintenance.periodUpdateNetwork", Options::value(&periodUpdateNetwork, 86400 * 7), @@ -18,12 +19,14 @@ DECLARE_OPTIONS(Maintenance, "P2PVR Maintenance options") "Period between automated updates of DVB services (1 week)") ("p2pvr.maintenance.periodUpdateEvents", Options::value(&periodUpdateEvents, 3600 * 12), "Period between automated updates of DVB events (12 hours)") +("p2pvr.maintenance.scanOnStart", Options::value(&scanOnStart, false), + "Perform the maintenance circle on start-up (false)") END_OPTIONS(Maintenance); Maintenance::Maintenance(Ice::ObjectAdapterPtr a, IceUtil::TimerPtr t) : adapter(a), timer(t), - clientCheck(new BindTimerTask(boost::bind(&Maintenance::ScheduledUpdate, this))), + clientCheck(new BindTimerTask(boost::bind(&Maintenance::ScheduledUpdate, this))), lastUpdateNetwork(0), lastUpdateServices(0), lastUpdateEvents(0), @@ -32,9 +35,9 @@ Maintenance::Maintenance(Ice::ObjectAdapterPtr a, IceUtil::TimerPtr t) : if (timer) { timer->scheduleRepeated(clientCheck, IceUtil::Time::seconds(5 * 60)); } -#ifdef NDEBUG - ScheduledUpdate(); -#endif + if (scanOnStart) { + ScheduledUpdate(); + } } void diff --git a/p2pvr/daemon/maintenance.h b/p2pvr/daemon/maintenance.h index 5b663eb..7ec0541 100644 --- a/p2pvr/daemon/maintenance.h +++ b/p2pvr/daemon/maintenance.h @@ -31,6 +31,7 @@ class Maintenance : public P2PVR::Maintenance, public DatabaseClient { static time_t periodUpdateNetwork; static time_t periodUpdateServices; static time_t periodUpdateEvents; + static bool scanOnStart; }; #endif -- cgit v1.2.3