Fixed removing pages at the right points.
This commit is contained in:
parent
049e9babe0
commit
926dd01995
2 changed files with 144 additions and 113 deletions
|
@ -88,7 +88,9 @@ namespace Mist {
|
||||||
DEBUG_MSG(DLVL_DEVEL, "Cleaning up, removing last keyframes");
|
DEBUG_MSG(DLVL_DEVEL, "Cleaning up, removing last keyframes");
|
||||||
for (std::map<unsigned int, DTSC::Track>::iterator it = myMeta.tracks.begin(); it != myMeta.tracks.end(); it++){
|
for (std::map<unsigned int, DTSC::Track>::iterator it = myMeta.tracks.begin(); it != myMeta.tracks.end(); it++){
|
||||||
std::map<unsigned long, DTSCPageData> & locations = bufferLocations[it->first];
|
std::map<unsigned long, DTSCPageData> & locations = bufferLocations[it->first];
|
||||||
|
if (!metaPages.count(it->first) || !metaPages[it->first].mapped){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
//First detect all entries on metaPage
|
//First detect all entries on metaPage
|
||||||
for (int i = 0; i < 8192; i += 8){
|
for (int i = 0; i < 8192; i += 8){
|
||||||
int * tmpOffset = (int *)(metaPages[it->first].mapped + i);
|
int * tmpOffset = (int *)(metaPages[it->first].mapped + i);
|
||||||
|
@ -253,16 +255,27 @@ namespace Mist {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void inputBuffer::eraseTrackDataPages(unsigned long tid){
|
||||||
|
if (!bufferLocations.count(tid)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (std::map<unsigned long, DTSCPageData>::iterator it = bufferLocations[tid].begin(); it != bufferLocations[tid].end(); it++){
|
||||||
|
char thisPageName[NAME_BUFFER_SIZE];
|
||||||
|
snprintf(thisPageName, NAME_BUFFER_SIZE, SHM_TRACK_DATA, config->getString("streamname").c_str(), tid, it->first);
|
||||||
|
curPage[tid].init(thisPageName, 20971520, false, false);
|
||||||
|
curPage[tid].master = true;
|
||||||
|
curPage.erase(tid);
|
||||||
|
}
|
||||||
|
bufferLocations.erase(tid);
|
||||||
|
metaPages[tid].master = true;
|
||||||
|
metaPages.erase(tid);
|
||||||
|
}
|
||||||
|
|
||||||
void inputBuffer::finish(){
|
void inputBuffer::finish(){
|
||||||
Input::finish();
|
Input::finish();
|
||||||
|
updateMeta();
|
||||||
for (std::map<unsigned long, std::map<unsigned long, DTSCPageData> >::iterator it = bufferLocations.begin(); it != bufferLocations.end(); it++){
|
for (std::map<unsigned long, std::map<unsigned long, DTSCPageData> >::iterator it = bufferLocations.begin(); it != bufferLocations.end(); it++){
|
||||||
for (std::map<unsigned long, DTSCPageData>::iterator it2 = it->second.begin(); it2 != it->second.end(); it2++) {
|
eraseTrackDataPages(it->first);
|
||||||
char thisPageName[NAME_BUFFER_SIZE];
|
|
||||||
snprintf(thisPageName, NAME_BUFFER_SIZE, SHM_TRACK_DATA, config->getString("streamname").c_str(), it->first, it2->first);
|
|
||||||
curPage[it->first].init(thisPageName, 20971520, false, false);
|
|
||||||
curPage[it->first].master = true;
|
|
||||||
curPage.erase(it->first);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,13 +389,15 @@ namespace Mist {
|
||||||
pushLocation.erase(value);
|
pushLocation.erase(value);
|
||||||
if (negotiatingTracks.count(value)){
|
if (negotiatingTracks.count(value)){
|
||||||
negotiatingTracks.erase(value);
|
negotiatingTracks.erase(value);
|
||||||
metaPages[value].master = true;
|
|
||||||
metaPages.erase(value);
|
|
||||||
}
|
}
|
||||||
if (activeTracks.count(value)){
|
if (activeTracks.count(value)){
|
||||||
|
updateMeta();
|
||||||
|
eraseTrackDataPages(value);
|
||||||
activeTracks.erase(value);
|
activeTracks.erase(value);
|
||||||
bufferLocations.erase(value);
|
bufferLocations.erase(value);
|
||||||
}
|
}
|
||||||
|
metaPages[value].master = true;
|
||||||
|
metaPages.erase(value);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -416,7 +431,11 @@ namespace Mist {
|
||||||
}
|
}
|
||||||
//If this tracks metdata page is not initialize, skip the entire element for now. It will be instantiated later
|
//If this tracks metdata page is not initialize, skip the entire element for now. It will be instantiated later
|
||||||
if (!metaPages[value].mapped){
|
if (!metaPages[value].mapped){
|
||||||
///\todo Maybe add a timeout counter here, for when we dont expect the track to appear anymore
|
//remove the negotiation if it has timed out
|
||||||
|
if (++negotiationTimeout[value] >= 1000){
|
||||||
|
negotiatingTracks.erase(value);
|
||||||
|
negotiationTimeout.erase(value);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -434,6 +453,14 @@ namespace Mist {
|
||||||
DTSC::Meta trackMeta(tempJSONForMeta);
|
DTSC::Meta trackMeta(tempJSONForMeta);
|
||||||
//If the track metadata does not contain the negotiated track, assume the metadata is currently being written, and skip the element for now. It will be instantiated in the next call.
|
//If the track metadata does not contain the negotiated track, assume the metadata is currently being written, and skip the element for now. It will be instantiated in the next call.
|
||||||
if (!trackMeta.tracks.count(value)){
|
if (!trackMeta.tracks.count(value)){
|
||||||
|
//remove the negotiation if it has timed out
|
||||||
|
if (++negotiationTimeout[value] >= 1000){
|
||||||
|
negotiatingTracks.erase(value);
|
||||||
|
//Set master to true before erasing the page, because we are responsible for cleaning up unused pages
|
||||||
|
metaPages[value].master = true;
|
||||||
|
metaPages.erase(value);
|
||||||
|
negotiationTimeout.erase(value);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -485,6 +512,8 @@ namespace Mist {
|
||||||
INFO_MSG("Replacement of track %lu detected, coming from temporary track %lu of user %u", finalMap, value, id);
|
INFO_MSG("Replacement of track %lu detected, coming from temporary track %lu of user %u", finalMap, value, id);
|
||||||
myMeta.tracks.erase(finalMap);
|
myMeta.tracks.erase(finalMap);
|
||||||
//Set master to true before erasing the page, because we are responsible for cleaning up unused pages
|
//Set master to true before erasing the page, because we are responsible for cleaning up unused pages
|
||||||
|
updateMeta();
|
||||||
|
eraseTrackDataPages(value);
|
||||||
metaPages[finalMap].master = true;
|
metaPages[finalMap].master = true;
|
||||||
metaPages.erase(finalMap);
|
metaPages.erase(finalMap);
|
||||||
bufferLocations.erase(finalMap);
|
bufferLocations.erase(finalMap);
|
||||||
|
|
|
@ -26,11 +26,13 @@ namespace Mist {
|
||||||
void trackSelect(std::string trackSpec);
|
void trackSelect(std::string trackSpec);
|
||||||
bool removeKey(unsigned int tid);
|
bool removeKey(unsigned int tid);
|
||||||
void removeUnused();
|
void removeUnused();
|
||||||
|
void eraseTrackDataPages(unsigned long tid);
|
||||||
void finish();
|
void finish();
|
||||||
void userCallback(char * data, size_t len, unsigned int id);
|
void userCallback(char * data, size_t len, unsigned int id);
|
||||||
std::set<unsigned long> negotiatingTracks;
|
std::set<unsigned long> negotiatingTracks;
|
||||||
std::set<unsigned long> activeTracks;
|
std::set<unsigned long> activeTracks;
|
||||||
std::map<unsigned long, unsigned long long> lastUpdated;
|
std::map<unsigned long, unsigned long long> lastUpdated;
|
||||||
|
std::map<unsigned long, unsigned long long> negotiationTimeout;
|
||||||
///Maps trackid to a pagenum->pageData map
|
///Maps trackid to a pagenum->pageData map
|
||||||
std::map<unsigned long, std::map<unsigned long, DTSCPageData> > bufferLocations;
|
std::map<unsigned long, std::map<unsigned long, DTSCPageData> > bufferLocations;
|
||||||
std::map<unsigned long, char *> pushLocation;
|
std::map<unsigned long, char *> pushLocation;
|
||||||
|
|
Loading…
Add table
Reference in a new issue