diff --git a/mythtv/libs/libmythtv/eitcache.cpp b/mythtv/libs/libmythtv/eitcache.cpp
index 79ec796..959b196 100644
|
a
|
b
|
|
| 19 | 19 | const uint EITCache::kVersionMax = 31; |
| 20 | 20 | |
| 21 | 21 | EITCache::EITCache() |
| 22 | | : accessCnt(0), hitCnt(0), tblChgCnt(0), verChgCnt(0), |
| 23 | | entryCnt(0), pruneCnt(0), prunedHitCnt(0), wrongChannelHitCnt(0) |
| | 22 | : accessCnt(0), hitCnt(0), tblChgCnt(0), verChgCnt(0), endChgCnt(0), |
| | 23 | entryCnt(0), pruneCnt(0), prunedHitCnt(0), futureHitCnt(0), wrongChannelHitCnt(0) |
| 24 | 24 | { |
| 25 | 25 | // 24 hours ago |
| 26 | 26 | lastPruneTime = MythDate::current().toUTC().toTime_t() - 86400; |
| … |
… |
void EITCache::ResetStatistics(void)
|
| 37 | 37 | hitCnt = 0; |
| 38 | 38 | tblChgCnt = 0; |
| 39 | 39 | verChgCnt = 0; |
| | 40 | endChgCnt = 0; |
| 40 | 41 | entryCnt = 0; |
| 41 | 42 | pruneCnt = 0; |
| 42 | 43 | prunedHitCnt = 0; |
| | 44 | futureHitCnt = 0; |
| 43 | 45 | wrongChannelHitCnt = 0; |
| 44 | 46 | } |
| 45 | 47 | |
| … |
… |
QString EITCache::GetStatistics(void) const
|
| 48 | 50 | QMutexLocker locker(&eventMapLock); |
| 49 | 51 | return QString( |
| 50 | 52 | "EITCache::statistics: Accesses: %1, Hits: %2, " |
| 51 | | "Table Upgrades %3, New Versions: %4, Entries: %5 " |
| 52 | | "Pruned entries: %6, pruned Hits: %7 Discard channel Hit %8 " |
| 53 | | "Hit Ratio %9.") |
| 54 | | .arg(accessCnt).arg(hitCnt).arg(tblChgCnt).arg(verChgCnt) |
| 55 | | .arg(entryCnt).arg(pruneCnt).arg(prunedHitCnt) |
| | 53 | "Table Upgrades %3, New Versions: %4, New Endtimes: %5, Entries: %6, " |
| | 54 | "Pruned Entries: %7, Pruned Hits: %8, Future Hits: %9, Wrong Channel Hits %10, " |
| | 55 | "Hit Ratio %11.") |
| | 56 | .arg(accessCnt).arg(hitCnt).arg(tblChgCnt).arg(verChgCnt).arg(endChgCnt) |
| | 57 | .arg(entryCnt).arg(pruneCnt).arg(prunedHitCnt).arg(futureHitCnt) |
| 56 | 58 | .arg(wrongChannelHitCnt) |
| 57 | | .arg((hitCnt+prunedHitCnt+wrongChannelHitCnt)/(double)accessCnt); |
| | 59 | .arg((hitCnt+prunedHitCnt+futureHitCnt+wrongChannelHitCnt)/(double)accessCnt); |
| 58 | 60 | } |
| 59 | 61 | |
| 60 | 62 | static inline uint64_t construct_sig(uint tableid, uint version, |
| … |
… |
static void delete_in_db(uint endtime)
|
| 125 | 127 | return; |
| 126 | 128 | } |
| 127 | 129 | |
| | 130 | |
| 128 | 131 | #define EITDATA 0 |
| 129 | 132 | #define CHANNEL_LOCK 1 |
| 130 | 133 | #define STATISTIC 2 |
| 131 | 134 | |
| 132 | | static bool lock_channel(uint chanid, uint lastPruneTime) |
| | 135 | static bool lock_channel(uint chanid, uint endtime) |
| 133 | 136 | { |
| 134 | 137 | int lock = 1; |
| 135 | 138 | MSqlQuery query(MSqlQuery::InitCon()); |
| … |
… |
static bool lock_channel(uint chanid, uint lastPruneTime)
|
| 142 | 145 | |
| 143 | 146 | query.prepare(qstr); |
| 144 | 147 | query.bindValue(":CHANID", chanid); |
| 145 | | query.bindValue(":ENDTIME", lastPruneTime); |
| | 148 | query.bindValue(":ENDTIME", endtime); |
| 146 | 149 | query.bindValue(":STATUS", CHANNEL_LOCK); |
| 147 | 150 | |
| 148 | 151 | if (!query.exec() || !query.isActive()) |
| … |
… |
event_map_t * EITCache::LoadChannel(uint chanid)
|
| 235 | 238 | query.bindValue(":ENDTIME", lastPruneTime); |
| 236 | 239 | query.bindValue(":STATUS", EITDATA); |
| 237 | 240 | |
| 238 | | |
| 239 | 241 | if (!query.exec() || !query.isActive()) |
| 240 | 242 | { |
| 241 | 243 | MythDB::DBError("Error loading eitcache", query); |
| … |
… |
void EITCache::WriteChannelToDB(uint chanid)
|
| 274 | 276 | |
| 275 | 277 | uint size = eventMap->size(); |
| 276 | 278 | uint updated = 0; |
| | 279 | uint removed = 0; |
| 277 | 280 | |
| 278 | 281 | event_map_t::iterator it = eventMap->begin(); |
| 279 | 282 | while (it != eventMap->end()) |
| 280 | 283 | { |
| 281 | | if (modified(*it) && extract_endtime(*it) > lastPruneTime) |
| | 284 | if (extract_endtime(*it) > lastPruneTime) |
| 282 | 285 | { |
| 283 | | replace_in_db(chanid, it.key(), *it); |
| 284 | | updated++; |
| 285 | | *it &= ~(uint64_t)0 >> 1; // mark as synced |
| | 286 | if (modified(*it)) |
| | 287 | { |
| | 288 | replace_in_db(chanid, it.key(), *it); |
| | 289 | updated++; |
| | 290 | *it &= ~(uint64_t)0 >> 1; // mark as synced |
| | 291 | } |
| | 292 | } |
| | 293 | else |
| | 294 | { |
| | 295 | // Event is too old; remove from eit cache in memory |
| | 296 | eventMap->remove(it.key()); |
| | 297 | removed++; |
| 286 | 298 | } |
| 287 | 299 | ++it; |
| 288 | 300 | } |
| … |
… |
void EITCache::WriteChannelToDB(uint chanid)
|
| 292 | 304 | LOG(VB_EIT, LOG_INFO, LOC + QString("Wrote %1 modified entries of %2 " |
| 293 | 305 | "for channel %3 to database.") |
| 294 | 306 | .arg(updated).arg(size).arg(chanid)); |
| | 307 | if (removed) |
| | 308 | LOG(VB_EIT, LOG_INFO, LOC + QString("Removed %1 old entries of %2 " |
| | 309 | "for channel %3 from cache.") |
| | 310 | .arg(removed).arg(size).arg(chanid)); |
| | 311 | pruneCnt += removed; |
| 295 | 312 | } |
| 296 | 313 | |
| 297 | 314 | void EITCache::WriteToDB(void) |
| … |
… |
void EITCache::WriteToDB(void)
|
| 306 | 323 | } |
| 307 | 324 | } |
| 308 | 325 | |
| 309 | | |
| 310 | | |
| 311 | 326 | bool EITCache::IsNewEIT(uint chanid, uint tableid, uint version, |
| 312 | 327 | uint eventid, uint endtime) |
| 313 | 328 | { |
| … |
… |
bool EITCache::IsNewEIT(uint chanid, uint tableid, uint version,
|
| 319 | 334 | WriteToDB(); |
| 320 | 335 | } |
| 321 | 336 | |
| 322 | | // don't readd pruned entries |
| | 337 | // don't read pruned entries |
| 323 | 338 | if (endtime < lastPruneTime) |
| 324 | 339 | { |
| 325 | 340 | prunedHitCnt++; |
| 326 | 341 | return false; |
| 327 | 342 | } |
| | 343 | |
| 328 | 344 | // validity check, reject events with endtime over 7 weeks in the future |
| 329 | 345 | if (endtime > lastPruneTime + 50 * 86400) |
| | 346 | { |
| | 347 | futureHitCnt++; |
| 330 | 348 | return false; |
| | 349 | } |
| 331 | 350 | |
| 332 | 351 | QMutexLocker locker(&eventMapLock); |
| 333 | 352 | if (!channelMap.contains(chanid)) |
| … |
… |
bool EITCache::IsNewEIT(uint chanid, uint tableid, uint version,
|
| 358 | 377 | // EIT updated version on current table |
| 359 | 378 | verChgCnt++; |
| 360 | 379 | } |
| | 380 | else if (extract_endtime(*it) != endtime) |
| | 381 | { |
| | 382 | // Endtime (starttime + duration) changed |
| | 383 | endChgCnt++; |
| | 384 | } |
| 361 | 385 | else |
| 362 | 386 | { |
| 363 | 387 | // EIT data previously seen |