Fixes for segfaults when the connection to the metadata gets lost

Set stream RelAccx pages to null pointers if we cannot reload those pages
This commit is contained in:
Marco van Dijk 2023-08-30 13:14:00 +02:00 committed by Thulinma
parent b61aab8719
commit 5af441d16b
3 changed files with 13 additions and 0 deletions

View file

@ -1298,6 +1298,8 @@ namespace DTSC{
streamPage.init(pageName, 0, false, true); streamPage.init(pageName, 0, false, true);
if (!streamPage.mapped){ if (!streamPage.mapped){
INFO_MSG("Page %s not found", pageName); INFO_MSG("Page %s not found", pageName);
stream = Util::RelAccX();
trackList = Util::RelAccX();
return true; return true;
} }
stream = Util::RelAccX(streamPage.mapped, true); stream = Util::RelAccX(streamPage.mapped, true);

View file

@ -846,6 +846,10 @@ namespace Mist{
// unload pages that haven't been used for a while // unload pages that haven't been used for a while
removeUnused(); removeUnused();
if (!M){
Util::logExitReason(ER_SHM_LOST, "Lost connection to metadata");
break;
}
if (M.getLive() && !internalOnly){ if (M.getLive() && !internalOnly){
uint64_t currLastUpdate = M.getLastUpdated(); uint64_t currLastUpdate = M.getLastUpdated();

View file

@ -187,6 +187,10 @@ namespace Mist{
/// Detected issues in string format, or empty string if no issues /// Detected issues in string format, or empty string if no issues
/// ~~~~~~~~~~~~~~~ /// ~~~~~~~~~~~~~~~
void inputBuffer::updateMeta(){ void inputBuffer::updateMeta(){
if (!M){
Util::logExitReason(ER_SHM_LOST, "Lost connection to metadata");
return;
}
static bool wentDry = false; static bool wentDry = false;
static uint64_t lastFragCount = 0xFFFFull; static uint64_t lastFragCount = 0xFFFFull;
static uint32_t lastBPS = 0; /*LTS*/ static uint32_t lastBPS = 0; /*LTS*/
@ -329,6 +333,9 @@ namespace Mist{
void inputBuffer::removeUnused(){ void inputBuffer::removeUnused(){
meta.reloadReplacedPagesIfNeeded(); meta.reloadReplacedPagesIfNeeded();
if (!meta){
return;
}
// first remove all tracks that have not been updated for too long // first remove all tracks that have not been updated for too long
bool changed = true; bool changed = true;
while (changed){ while (changed){