Keep capabilities and protocol config around after close, retry opening pages for ~50ms, no longer warn in save situations of SHM re-use
This commit is contained in:
parent
e8388b2a89
commit
b7d5964512
4 changed files with 58 additions and 11 deletions
|
@ -919,7 +919,12 @@ bool Util::checkException(const JSON::Value &ex, const std::string &useragent){
|
||||||
}
|
}
|
||||||
|
|
||||||
Util::DTSCShmReader::DTSCShmReader(const std::string &pageName){
|
Util::DTSCShmReader::DTSCShmReader(const std::string &pageName){
|
||||||
|
size_t attempts = 0;
|
||||||
|
do {
|
||||||
rPage.init(pageName, 0, false, false);
|
rPage.init(pageName, 0, false, false);
|
||||||
|
++attempts;
|
||||||
|
if (!rPage && attempts < 5){Util::sleep(10);}
|
||||||
|
} while (!rPage && attempts < 5);
|
||||||
if (rPage){rAcc = Util::RelAccX(rPage.mapped);}
|
if (rPage){rAcc = Util::RelAccX(rPage.mapped);}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@ namespace Controller{
|
||||||
JSON::Value Storage; ///< Global storage of data.
|
JSON::Value Storage; ///< Global storage of data.
|
||||||
tthread::mutex configMutex;
|
tthread::mutex configMutex;
|
||||||
tthread::mutex logMutex;
|
tthread::mutex logMutex;
|
||||||
|
std::set<std::string> shmList;
|
||||||
|
tthread::mutex shmListMutex;
|
||||||
uint64_t logCounter = 0;
|
uint64_t logCounter = 0;
|
||||||
uint64_t lastConfigChange = 0;
|
uint64_t lastConfigChange = 0;
|
||||||
uint64_t lastConfigWrite = 0;
|
uint64_t lastConfigWrite = 0;
|
||||||
|
@ -217,6 +219,7 @@ namespace Controller{
|
||||||
if (shmAccs){shmAccs->master = true;}
|
if (shmAccs){shmAccs->master = true;}
|
||||||
if (rlxStrm){rlxStrm->setExit();}
|
if (rlxStrm){rlxStrm->setExit();}
|
||||||
if (shmStrm){shmStrm->master = true;}
|
if (shmStrm){shmStrm->master = true;}
|
||||||
|
wipeShmPages();
|
||||||
}else{
|
}else{
|
||||||
if (shmLogs){shmLogs->master = false;}
|
if (shmLogs){shmLogs->master = false;}
|
||||||
if (shmAccs){shmAccs->master = false;}
|
if (shmAccs){shmAccs->master = false;}
|
||||||
|
@ -442,6 +445,7 @@ namespace Controller{
|
||||||
mistCapaOut.close();
|
mistCapaOut.close();
|
||||||
}
|
}
|
||||||
mistCapaOut.init(SHM_CAPA, temp.size() + 100, true, false);
|
mistCapaOut.init(SHM_CAPA, temp.size() + 100, true, false);
|
||||||
|
addShmPage(SHM_CAPA);
|
||||||
if (!mistCapaOut.mapped){
|
if (!mistCapaOut.mapped){
|
||||||
FAIL_MSG("Could not open capabilities config for writing! Is shared memory enabled on your "
|
FAIL_MSG("Could not open capabilities config for writing! Is shared memory enabled on your "
|
||||||
"system?");
|
"system?");
|
||||||
|
@ -454,6 +458,7 @@ namespace Controller{
|
||||||
A.setRCount(1);
|
A.setRCount(1);
|
||||||
A.setEndPos(1);
|
A.setEndPos(1);
|
||||||
A.setReady();
|
A.setReady();
|
||||||
|
mistCapaOut.master = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeProtocols(){
|
void writeProtocols(){
|
||||||
|
@ -473,6 +478,7 @@ namespace Controller{
|
||||||
if (proxy_written != tmpProxy){
|
if (proxy_written != tmpProxy){
|
||||||
proxy_written = tmpProxy;
|
proxy_written = tmpProxy;
|
||||||
static IPC::sharedPage mistProxOut(SHM_PROXY, proxy_written.size() + 100, true, false);
|
static IPC::sharedPage mistProxOut(SHM_PROXY, proxy_written.size() + 100, true, false);
|
||||||
|
addShmPage(SHM_PROXY);
|
||||||
mistProxOut.close();
|
mistProxOut.close();
|
||||||
mistProxOut.init(SHM_PROXY, proxy_written.size() + 100, false, false);
|
mistProxOut.init(SHM_PROXY, proxy_written.size() + 100, false, false);
|
||||||
if (mistProxOut){
|
if (mistProxOut){
|
||||||
|
@ -511,6 +517,7 @@ namespace Controller{
|
||||||
mistProtoOut.close();
|
mistProtoOut.close();
|
||||||
}
|
}
|
||||||
mistProtoOut.init(SHM_PROTO, temp.size() + 100, true, false);
|
mistProtoOut.init(SHM_PROTO, temp.size() + 100, true, false);
|
||||||
|
addShmPage(SHM_PROTO);
|
||||||
if (!mistProtoOut.mapped){
|
if (!mistProtoOut.mapped){
|
||||||
FAIL_MSG(
|
FAIL_MSG(
|
||||||
"Could not open protocol config for writing! Is shared memory enabled on your system?");
|
"Could not open protocol config for writing! Is shared memory enabled on your system?");
|
||||||
|
@ -526,6 +533,7 @@ namespace Controller{
|
||||||
A.setEndPos(1);
|
A.setEndPos(1);
|
||||||
A.setReady();
|
A.setReady();
|
||||||
}
|
}
|
||||||
|
mistProtoOut.master = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeStream(const std::string &sName, const JSON::Value &sConf){
|
void writeStream(const std::string &sName, const JSON::Value &sConf){
|
||||||
|
@ -640,6 +648,7 @@ namespace Controller{
|
||||||
globAccX.setString("udpApi", udpApiBindAddr);
|
globAccX.setString("udpApi", udpApiBindAddr);
|
||||||
globAccX.setInt("systemBoot", systemBoot);
|
globAccX.setInt("systemBoot", systemBoot);
|
||||||
globCfg.master = false; // leave the page after closing
|
globCfg.master = false; // leave the page after closing
|
||||||
|
addShmPage(SHM_GLOBAL_CONF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -752,4 +761,23 @@ namespace Controller{
|
||||||
}
|
}
|
||||||
/*LTS-END*/
|
/*LTS-END*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void addShmPage(const std::string & page){
|
||||||
|
tthread::lock_guard<tthread::mutex> guard(shmListMutex);
|
||||||
|
shmList.insert(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wipeShmPages(){
|
||||||
|
tthread::lock_guard<tthread::mutex> guard(shmListMutex);
|
||||||
|
if (!shmList.size()){return;}
|
||||||
|
std::set<std::string>::iterator it;
|
||||||
|
for (it = shmList.begin(); it != shmList.end(); ++it){
|
||||||
|
IPC::sharedPage page(*it, 0, false, false);
|
||||||
|
if (page){page.master = true;}
|
||||||
|
}
|
||||||
|
shmList.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}// namespace Controller
|
}// namespace Controller
|
||||||
|
|
|
@ -50,4 +50,7 @@ namespace Controller{
|
||||||
void writeCapabilities();
|
void writeCapabilities();
|
||||||
void writeProtocols();
|
void writeProtocols();
|
||||||
|
|
||||||
|
void addShmPage(const std::string & page);
|
||||||
|
void wipeShmPages();
|
||||||
|
|
||||||
}// namespace Controller
|
}// namespace Controller
|
||||||
|
|
|
@ -423,7 +423,8 @@ namespace Mist{
|
||||||
//Set stream status to STRMSTAT_INIT, then close the page in non-master mode to keep it around
|
//Set stream status to STRMSTAT_INIT, then close the page in non-master mode to keep it around
|
||||||
char pageName[NAME_BUFFER_SIZE];
|
char pageName[NAME_BUFFER_SIZE];
|
||||||
snprintf(pageName, NAME_BUFFER_SIZE, SHM_STREAM_STATE, streamName.c_str());
|
snprintf(pageName, NAME_BUFFER_SIZE, SHM_STREAM_STATE, streamName.c_str());
|
||||||
streamStatus.init(pageName, 2, true, false);
|
streamStatus.init(pageName, 2, false, false);
|
||||||
|
if (!streamStatus){streamStatus.init(pageName, 2, true, false);}
|
||||||
if (streamStatus){streamStatus.mapped[0] = STRMSTAT_INIT;}
|
if (streamStatus){streamStatus.mapped[0] = STRMSTAT_INIT;}
|
||||||
streamStatus.master = false;
|
streamStatus.master = false;
|
||||||
streamStatus.close();
|
streamStatus.close();
|
||||||
|
@ -470,7 +471,8 @@ namespace Mist{
|
||||||
// Re-init streamStatus, previously closed
|
// Re-init streamStatus, previously closed
|
||||||
char pageName[NAME_BUFFER_SIZE];
|
char pageName[NAME_BUFFER_SIZE];
|
||||||
snprintf(pageName, NAME_BUFFER_SIZE, SHM_STREAM_STATE, streamName.c_str());
|
snprintf(pageName, NAME_BUFFER_SIZE, SHM_STREAM_STATE, streamName.c_str());
|
||||||
streamStatus.init(pageName, 2, true, false);
|
streamStatus.init(pageName, 2, false, false);
|
||||||
|
if (!streamStatus){streamStatus.init(pageName, 2, true, false);}
|
||||||
streamStatus.master = false;
|
streamStatus.master = false;
|
||||||
if (streamStatus){streamStatus.mapped[0] = STRMSTAT_INIT;}
|
if (streamStatus){streamStatus.mapped[0] = STRMSTAT_INIT;}
|
||||||
}
|
}
|
||||||
|
@ -480,9 +482,12 @@ namespace Mist{
|
||||||
playerLock.unlink();
|
playerLock.unlink();
|
||||||
char pageName[NAME_BUFFER_SIZE];
|
char pageName[NAME_BUFFER_SIZE];
|
||||||
snprintf(pageName, NAME_BUFFER_SIZE, SHM_STREAM_STATE, streamName.c_str());
|
snprintf(pageName, NAME_BUFFER_SIZE, SHM_STREAM_STATE, streamName.c_str());
|
||||||
streamStatus.init(pageName, 2, true, false);
|
streamStatus.init(pageName, 2, false, false);
|
||||||
|
if (streamStatus){
|
||||||
|
streamStatus.master = true;
|
||||||
streamStatus.close();
|
streamStatus.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
playerLock.unlink();
|
playerLock.unlink();
|
||||||
pullLock.unlink();
|
pullLock.unlink();
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -501,7 +506,8 @@ namespace Mist{
|
||||||
// Re-init streamStatus, previously closed
|
// Re-init streamStatus, previously closed
|
||||||
char pageName[NAME_BUFFER_SIZE];
|
char pageName[NAME_BUFFER_SIZE];
|
||||||
snprintf(pageName, NAME_BUFFER_SIZE, SHM_STREAM_STATE, streamName.c_str());
|
snprintf(pageName, NAME_BUFFER_SIZE, SHM_STREAM_STATE, streamName.c_str());
|
||||||
streamStatus.init(pageName, 2, true, false);
|
streamStatus.init(pageName, 2, false, false);
|
||||||
|
if (!streamStatus){streamStatus.init(pageName, 2, true, false);}
|
||||||
streamStatus.master = false;
|
streamStatus.master = false;
|
||||||
if (streamStatus){streamStatus.mapped[0] = STRMSTAT_INIT;}
|
if (streamStatus){streamStatus.mapped[0] = STRMSTAT_INIT;}
|
||||||
}
|
}
|
||||||
|
@ -539,7 +545,7 @@ namespace Mist{
|
||||||
if (playerLock){
|
if (playerLock){
|
||||||
char pageName[NAME_BUFFER_SIZE];
|
char pageName[NAME_BUFFER_SIZE];
|
||||||
snprintf(pageName, NAME_BUFFER_SIZE, SHM_STREAM_STATE, streamName.c_str());
|
snprintf(pageName, NAME_BUFFER_SIZE, SHM_STREAM_STATE, streamName.c_str());
|
||||||
streamStatus.init(pageName, 2, true, false);
|
streamStatus.init(pageName, 2, false, false);
|
||||||
if (streamStatus){streamStatus.mapped[0] = STRMSTAT_INVALID;}
|
if (streamStatus){streamStatus.mapped[0] = STRMSTAT_INVALID;}
|
||||||
}
|
}
|
||||||
#if DEBUG >= DLVL_DEVEL
|
#if DEBUG >= DLVL_DEVEL
|
||||||
|
@ -566,12 +572,17 @@ namespace Mist{
|
||||||
char pageName[NAME_BUFFER_SIZE];
|
char pageName[NAME_BUFFER_SIZE];
|
||||||
snprintf(pageName, NAME_BUFFER_SIZE, SHM_STREAM_IPID, streamName.c_str());
|
snprintf(pageName, NAME_BUFFER_SIZE, SHM_STREAM_IPID, streamName.c_str());
|
||||||
pidPage.init(pageName, 8, false, false);
|
pidPage.init(pageName, 8, false, false);
|
||||||
|
if (pidPage){
|
||||||
pidPage.master = true;
|
pidPage.master = true;
|
||||||
pidPage.close();
|
pidPage.close();
|
||||||
|
}
|
||||||
//Clear stream state
|
//Clear stream state
|
||||||
snprintf(pageName, NAME_BUFFER_SIZE, SHM_STREAM_STATE, streamName.c_str());
|
snprintf(pageName, NAME_BUFFER_SIZE, SHM_STREAM_STATE, streamName.c_str());
|
||||||
streamStatus.init(pageName, 2, true, false);
|
streamStatus.init(pageName, 2, false, false);
|
||||||
|
if (streamStatus){
|
||||||
|
streamStatus.master = true;
|
||||||
streamStatus.close();
|
streamStatus.close();
|
||||||
|
}
|
||||||
//Delete lock
|
//Delete lock
|
||||||
playerLock.unlink();
|
playerLock.unlink();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue