Robustify accesses to server config
This commit is contained in:
parent
d36faa340a
commit
ac92e09262
14 changed files with 238 additions and 192 deletions
|
@ -123,10 +123,8 @@ namespace Mist {
|
|||
}
|
||||
|
||||
//loop over the connectors
|
||||
IPC::semaphore configLock(SEM_CONF, O_CREAT | O_RDWR, ACCESSPERMS, 1);
|
||||
configLock.wait();
|
||||
IPC::sharedPage serverCfg(SHM_CONF, DEFAULT_CONF_PAGE_SIZE);
|
||||
DTSC::Scan capa = DTSC::Scan(serverCfg.mapped, serverCfg.len).getMember("capabilities").getMember("connectors");
|
||||
Util::DTSCShmReader rCapa(SHM_CAPA);
|
||||
DTSC::Scan capa = rCapa.getMember("connectors");
|
||||
unsigned int capa_ctr = capa.getSize();
|
||||
for (unsigned int i = 0; i < capa_ctr; ++i){
|
||||
DTSC::Scan c = capa.getIndice(i);
|
||||
|
@ -159,14 +157,10 @@ namespace Mist {
|
|||
Util::sanitizeName(streamname);
|
||||
H.SetVar("stream", streamname);
|
||||
}
|
||||
configLock.post();
|
||||
configLock.close();
|
||||
return capa.getIndiceName(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
configLock.post();
|
||||
configLock.close();
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -323,22 +317,16 @@ namespace Mist {
|
|||
char * argarr[20];
|
||||
for (int i=0; i<20; i++){argarr[i] = 0;}
|
||||
int id = -1;
|
||||
|
||||
IPC::semaphore configLock(SEM_CONF, O_CREAT | O_RDWR, ACCESSPERMS, 1);
|
||||
configLock.wait();
|
||||
IPC::sharedPage serverCfg(SHM_CONF, DEFAULT_CONF_PAGE_SIZE);
|
||||
DTSC::Scan prots = DTSC::Scan(serverCfg.mapped, serverCfg.len).getMember("config").getMember("protocols");
|
||||
unsigned int prots_ctr = prots.getSize();
|
||||
|
||||
JSON::Value pipedCapa;
|
||||
JSON::Value p;//properties of protocol
|
||||
for (unsigned int i=0; i < prots_ctr; ++i){
|
||||
if (prots.getIndice(i).getMember("connector").asString() == connector) {
|
||||
id = i;
|
||||
break; //pick the first protocol in the list that matches the connector
|
||||
}
|
||||
}
|
||||
if (id == -1) {
|
||||
connector = connector + ".exe";
|
||||
|
||||
|
||||
{
|
||||
Util::DTSCShmReader rProto(SHM_PROTO);
|
||||
DTSC::Scan prots = rProto.getScan();
|
||||
unsigned int prots_ctr = prots.getSize();
|
||||
|
||||
//find connector in config
|
||||
for (unsigned int i=0; i < prots_ctr; ++i){
|
||||
if (prots.getIndice(i).getMember("connector").asString() == connector) {
|
||||
id = i;
|
||||
|
@ -346,26 +334,32 @@ namespace Mist {
|
|||
}
|
||||
}
|
||||
if (id == -1) {
|
||||
connector = connector.substr(0, connector.size() - 4);
|
||||
DEBUG_MSG(DLVL_ERROR, "No connector found for: %s", connector.c_str());
|
||||
configLock.post();
|
||||
configLock.close();
|
||||
return;
|
||||
connector = connector + ".exe";
|
||||
for (unsigned int i=0; i < prots_ctr; ++i){
|
||||
if (prots.getIndice(i).getMember("connector").asString() == connector) {
|
||||
id = i;
|
||||
break; //pick the first protocol in the list that matches the connector
|
||||
}
|
||||
}
|
||||
if (id == -1) {
|
||||
connector = connector.substr(0, connector.size() - 4);
|
||||
ERROR_MSG("No connector found for: %s", connector.c_str());
|
||||
return;
|
||||
}
|
||||
}
|
||||
//read options from found connector
|
||||
p = prots.getIndice(id).asJSON();
|
||||
|
||||
HIGH_MSG("Connector found: %s", connector.c_str());
|
||||
Util::DTSCShmReader rCapa(SHM_CAPA);
|
||||
DTSC::Scan capa = rCapa.getMember("connectors");
|
||||
pipedCapa = capa.getMember(connector).asJSON();
|
||||
}
|
||||
//read options from found connector
|
||||
p = prots.getIndice(id).asJSON();
|
||||
|
||||
DEBUG_MSG(DLVL_HIGH, "Connector found: %s", connector.c_str());
|
||||
|
||||
//build arguments for starting output process
|
||||
|
||||
std::string tmparg = Util::getMyPath() + std::string("MistOut") + connector;
|
||||
|
||||
int argnum = 0;
|
||||
argarr[argnum++] = (char*)tmparg.c_str();
|
||||
JSON::Value pipedCapa = DTSC::Scan(serverCfg.mapped, serverCfg.len).getMember("capabilities").getMember("connectors").getMember(connector).asJSON();
|
||||
configLock.post();
|
||||
configLock.close();
|
||||
std::string temphost=getConnectedHost();
|
||||
std::string debuglevel = JSON::Value((long long)Util::Config::printDebugLevel).asString();
|
||||
argarr[argnum++] = (char*)"--ip";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue