From ea03f86900b1d2ccda9ce0b539ed69a6d3b27122 Mon Sep 17 00:00:00 2001 From: randomdan Date: Sat, 4 Jan 2014 20:59:40 +0000 Subject: Do reschudule automatically after events have been updated --- p2pvr/.p2config | 2 +- p2pvr/lib/dbClient.cpp | 7 +++++++ p2pvr/lib/dbClient.h | 3 +++ p2pvr/lib/maintenance.cpp | 2 ++ p2pvr/lib/maintenance/events.cpp | 5 +++++ 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/p2pvr/.p2config b/p2pvr/.p2config index 723dd2e..ddf998e 100644 --- a/p2pvr/.p2config +++ b/p2pvr/.p2config @@ -4,5 +4,5 @@ common.filelog.level = 9 common.filelog.path = /tmp/p2daemon.log common.filelog.openmode = w common.consolelogLevel = 9 -p2pvr.globaldevices.carddaemon = Devices:default -h defiant -p 10001 +p2pvr.globaldevices.carddaemon = Devices:default -h defiant -p 10000 p2pvr.storage.root = /tmp/p2pvr/recordings diff --git a/p2pvr/lib/dbClient.cpp b/p2pvr/lib/dbClient.cpp index c12cb6c..8267584 100644 --- a/p2pvr/lib/dbClient.cpp +++ b/p2pvr/lib/dbClient.cpp @@ -20,12 +20,19 @@ DatabaseClient::onAllDatasources(const DataSourceCall & call) const } DatabaseClient::TxHelper::TxHelper(const DatabaseClient * dbc) : + client(dbc), so(NULL, boost::bind(&DatabaseClient::onAllDatasources, dbc, DataSourceCall(boost::bind(&DataSource::commit, _1))), boost::bind(&DatabaseClient::onAllDatasources, dbc, DataSourceCall(boost::bind(&DataSource::rollback, _1)))) { } +void +DatabaseClient::TxHelper::Commit() const +{ + client->onAllDatasources(boost::bind(&DataSource::commit, _1)); +} + DatabaseClient::NoRowsFoundException::NoRowsFoundException() : std::runtime_error("No rows found") { diff --git a/p2pvr/lib/dbClient.h b/p2pvr/lib/dbClient.h index cf18669..84cf5e7 100644 --- a/p2pvr/lib/dbClient.h +++ b/p2pvr/lib/dbClient.h @@ -24,7 +24,10 @@ class DatabaseClient : public virtual CommonObjects { class TxHelper { public: TxHelper(const DatabaseClient *); + void Commit() const; + private: + const DatabaseClient * client; ScopeObject so; }; diff --git a/p2pvr/lib/maintenance.cpp b/p2pvr/lib/maintenance.cpp index b31998b..3475544 100644 --- a/p2pvr/lib/maintenance.cpp +++ b/p2pvr/lib/maintenance.cpp @@ -30,7 +30,9 @@ Maintenance::Maintenance(Ice::ObjectAdapterPtr a, IceUtil::TimerPtr t) : updateRunning(false) { timer->scheduleRepeated(clientCheck, IceUtil::Time::seconds(5 * 60)); +#ifdef NDEBUG ScheduledUpdate(); +#endif } void diff --git a/p2pvr/lib/maintenance/events.cpp b/p2pvr/lib/maintenance/events.cpp index 0327ec8..308b726 100644 --- a/p2pvr/lib/maintenance/events.cpp +++ b/p2pvr/lib/maintenance/events.cpp @@ -82,6 +82,11 @@ Maintenance::UpdateEvents(short type, const Ice::Current & ice) mergeEvents.sources.insert(new SiEventsMerger(type, ice)); mergeEvents.loadComplete(this); mergeEvents.execute(NULL); + tx.Commit(); Logger()->messagebf(LOG_INFO, "%s: Updated events", __PRETTY_FUNCTION__); + + auto ic = ice.adapter->getCommunicator(); + auto sch = P2PVR::SchedulesPrx::checkedCast(ice.adapter->createProxy(ic->stringToIdentity("Schedules"))); + sch->DoReschedule(); } -- cgit v1.2.3