diff options
author | Dan Goodliffe <randomdan@akira.random.lan> | 2014-11-29 16:43:25 +0000 |
---|---|---|
committer | Dan Goodliffe <randomdan@akira.random.lan> | 2014-11-29 16:43:25 +0000 |
commit | b3fdd29f6ca5d2f43eed835a1b02723fc8d0fd53 (patch) | |
tree | ab08dd53d339ef10d0c9395d08c496af159040a4 /project2/sql | |
parent | Remove dependency on xml lib (functionality tested separately) (diff) | |
download | project2-b3fdd29f6ca5d2f43eed835a1b02723fc8d0fd53.tar.bz2 project2-b3fdd29f6ca5d2f43eed835a1b02723fc8d0fd53.tar.xz project2-b3fdd29f6ca5d2f43eed835a1b02723fc8d0fd53.zip |
Remove the continue on error options for plugables and add proper handling into implementations where errors can be ignored
Diffstat (limited to 'project2/sql')
-rw-r--r-- | project2/sql/rdbmsDataSource.cpp | 6 | ||||
-rw-r--r-- | project2/sql/sqlCache.cpp | 25 |
2 files changed, 17 insertions, 14 deletions
diff --git a/project2/sql/rdbmsDataSource.cpp b/project2/sql/rdbmsDataSource.cpp index 7965a29..86c6a6e 100644 --- a/project2/sql/rdbmsDataSource.cpp +++ b/project2/sql/rdbmsDataSource.cpp @@ -13,7 +13,7 @@ SimpleMessageException(UnknownConnectionProvider); /// Specialized ElementLoader for instances of RdbmsDataSource; handles persistent DB connections class RdbmsDataSourceLoader : public ElementLoader::For<RdbmsDataSource> { public: - void onIdle() + void onIdle() override { // Disconnect all cached database connections RdbmsDataSource::dbhosts.clear(); @@ -22,7 +22,7 @@ class RdbmsDataSourceLoader : public ElementLoader::For<RdbmsDataSource> { { return con.second->isExpired(); } - void onPeriodic() + void onPeriodic() override { // Disconnect expired database connections RdbmsDataSource::DBHosts::iterator i; @@ -30,7 +30,7 @@ class RdbmsDataSourceLoader : public ElementLoader::For<RdbmsDataSource> { RdbmsDataSource::dbhosts.erase(i); } } - void onIteration() + void onIteration() override { RdbmsDataSource::changedDSNs.clear(); } diff --git a/project2/sql/sqlCache.cpp b/project2/sql/sqlCache.cpp index c495528..f20bfe4 100644 --- a/project2/sql/sqlCache.cpp +++ b/project2/sql/sqlCache.cpp @@ -267,18 +267,21 @@ time_t SqlCache::CacheLife; class CustomSqlCacheLoader : public ElementLoader::For<SqlCache> { public: - void onIdle() + void onIdle() override { - if (!SqlCache::DataSource.empty()) { - boost::intrusive_ptr<CommonObjects> co = new CommonObjects(); - RdbmsDataSource * db = co->dataSource<RdbmsDataSource>(SqlCache::DataSource); - Buffer del; - del.appendf("DELETE FROM %s WHERE p2_time < ?", SqlCache::HeaderTable.c_str()); - auto con = db->getWritable(); - ModifyPtr m(con->newModifyCommand(del)); - m->bindParamT(0, boost::posix_time::microsec_clock::universal_time() - boost::posix_time::seconds(SqlCache::CacheLife)); - m->execute(); - db->commit(); + try { + if (!SqlCache::DataSource.empty()) { + boost::intrusive_ptr<CommonObjects> co = new CommonObjects(); + RdbmsDataSource * db = co->dataSource<RdbmsDataSource>(SqlCache::DataSource); + auto con = db->getWritable(); + ModifyPtr m(con->newModifyCommand(stringbf("DELETE FROM %s WHERE p2_time < ?", SqlCache::HeaderTable))); + m->bindParamT(0, boost::posix_time::microsec_clock::universal_time() - boost::posix_time::seconds(SqlCache::CacheLife)); + m->execute(); + db->commit(); + } + } + catch (...) { + Logger()->messagebf(LOG_WARNING, "Failed to purge expired caches from table %s", SqlCache::HeaderTable); } } }; |