Change VoD data page logic to use wallclock seconds rather than loop iterations for timeouts
This commit is contained in:
parent
44c2809733
commit
747438746c
2 changed files with 24 additions and 10 deletions
|
@ -1022,28 +1022,42 @@ namespace Mist{
|
|||
}
|
||||
|
||||
void Input::removeUnused(){
|
||||
uint64_t cTime = Util::bootSecs();
|
||||
std::set<size_t> validTracks = M.getValidTracks();
|
||||
std::map<size_t, std::set<uint32_t> > checkedPages;
|
||||
for (std::set<size_t>::iterator it = validTracks.begin(); it != validTracks.end(); ++it){
|
||||
Util::RelAccX &tPages = meta.pages(*it);
|
||||
for (size_t i = tPages.getDeleted(); i < tPages.getEndPos(); i++){
|
||||
uint64_t pageNum = tPages.getInt("firstkey", i);
|
||||
checkedPages[*it].insert(pageNum);
|
||||
if (pageCounter[*it].count(pageNum)){
|
||||
// If the page is still being written to, reset the counter rather than potentially unloading it
|
||||
if (isCurrentLivePage(*it, pageNum)){
|
||||
pageCounter[*it][pageNum] = DEFAULT_PAGE_TIMEOUT;
|
||||
pageCounter[*it][pageNum] = cTime;
|
||||
continue;
|
||||
}
|
||||
--pageCounter[*it][pageNum];
|
||||
if (!pageCounter[*it][pageNum]){
|
||||
if (cTime > pageCounter[*it][pageNum] + DEFAULT_PAGE_TIMEOUT){
|
||||
pageCounter[*it].erase(pageNum);
|
||||
bufferRemove(*it, pageNum);
|
||||
}
|
||||
}
|
||||
else{
|
||||
pageCounter[*it][pageNum] = DEFAULT_PAGE_TIMEOUT;
|
||||
}else{
|
||||
pageCounter[*it][pageNum] = cTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
//Check pages we buffered but forgot about
|
||||
for (std::map<size_t, std::map<uint32_t, size_t> >::iterator it = pageCounter.begin();
|
||||
it != pageCounter.end(); it++){
|
||||
for (std::map<uint32_t, size_t>::iterator it2 = it->second.begin(); it2 != it->second.end(); it2++){
|
||||
if (!checkedPages.count(it->first) || !checkedPages[it->first].count(it2->first)){
|
||||
INFO_MSG("Deleting forgotten page %zu:%" PRIu32, it->first, it2->first);
|
||||
bufferRemove(it->first, it2->first);
|
||||
it->second.erase(it2);
|
||||
it2 = it->second.begin();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string formatGUID(const std::string &val){
|
||||
|
@ -1290,8 +1304,8 @@ namespace Mist{
|
|||
}
|
||||
uint32_t pageNumber = tPages.getInt("firstkey", pageIdx);
|
||||
if (isBuffered(idx, pageNumber, meta)){
|
||||
// Mark the page for removal after 15 seconds of no one watching it
|
||||
pageCounter[idx][pageNumber] = DEFAULT_PAGE_TIMEOUT;
|
||||
// Mark the page as still actively requested
|
||||
pageCounter[idx][pageNumber] = Util::bootSecs();
|
||||
DONTEVEN_MSG("Track %zu, key %" PRIu32 " is already buffered in page %" PRIu32
|
||||
". Cancelling bufferFrame",
|
||||
idx, keyNum, pageNumber);
|
||||
|
@ -1432,7 +1446,7 @@ namespace Mist{
|
|||
idx, pageNumber, tPages.getInt("firsttime", pageIdx), thisTime, bufferTimer);
|
||||
INFO_MSG(" (%" PRIu32 "/%" PRIu64 " parts, %" PRIu64 " bytes)", packCounter,
|
||||
tPages.getInt("parts", pageIdx), byteCounter);
|
||||
pageCounter[idx][pageNumber] = DEFAULT_PAGE_TIMEOUT;
|
||||
pageCounter[idx][pageNumber] = Util::bootSecs();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ namespace Mist{
|
|||
|
||||
IPC::sharedPage streamStatus;
|
||||
|
||||
std::map<size_t, std::map<uint32_t, size_t> > pageCounter;
|
||||
std::map<size_t, std::map<uint32_t, uint64_t> > pageCounter;
|
||||
|
||||
static Input *singleton;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue