Made Util::streamName and exitReason thread-local
This commit is contained in:
parent
7c6da9d455
commit
7423868de4
11 changed files with 40 additions and 32 deletions
|
@ -310,7 +310,7 @@ namespace Mist{
|
|||
int Input::boot(int argc, char *argv[]){
|
||||
if (!(config->parseArgs(argc, argv))){return 1;}
|
||||
streamName = config->getString("streamname");
|
||||
Util::streamName = streamName;
|
||||
Util::setStreamName(streamName);
|
||||
|
||||
if (config->getBool("json")){
|
||||
capa["version"] = PACKAGE_VERSION;
|
||||
|
|
|
@ -87,7 +87,7 @@ namespace Mist{
|
|||
// If we have a streamname option, set internal streamname to that option
|
||||
if (!streamName.size() && config->hasOption("streamname")){
|
||||
streamName = config->getString("streamname");
|
||||
Util::streamName = streamName;
|
||||
Util::setStreamName(streamName);
|
||||
}
|
||||
|
||||
/*LTS-START*/
|
||||
|
@ -327,7 +327,7 @@ namespace Mist{
|
|||
JSON::Value strCnf = Util::getStreamConfig(streamName);
|
||||
if (strCnf && strCnf["fallback_stream"].asStringRef().size()){
|
||||
streamName = strCnf["fallback_stream"].asStringRef();
|
||||
Util::streamName = streamName;
|
||||
Util::setStreamName(streamName);
|
||||
INFO_MSG("Switching to configured fallback stream '%s'", streamName.c_str());
|
||||
reconnect();
|
||||
return;
|
||||
|
@ -358,7 +358,7 @@ namespace Mist{
|
|||
newStrm.c_str());
|
||||
std::string origStream = streamName;
|
||||
streamName = newStrm;
|
||||
Util::streamName = streamName;
|
||||
Util::setStreamName(streamName);
|
||||
if (!Util::startInput(streamName, "", true, isPushing())){
|
||||
onFail("Stream open failed (fallback stream for '" + origStream + "')", true);
|
||||
return;
|
||||
|
|
|
@ -450,7 +450,7 @@ namespace Mist{
|
|||
INFO_MSG("Falling back to default stream '%s' -> '%s'", defStrm.c_str(), newStrm.c_str());
|
||||
origStreamName = streamName;
|
||||
streamName = newStrm;
|
||||
Util::streamName = streamName;
|
||||
Util::setStreamName(streamName);
|
||||
reconnect();
|
||||
return getStatusJSON(reqHost, useragent);
|
||||
}
|
||||
|
|
|
@ -828,11 +828,11 @@ namespace Mist{
|
|||
if (streamName.find('?') != std::string::npos){
|
||||
std::string tmpVars = streamName.substr(streamName.find('?') + 1);
|
||||
streamName = streamName.substr(0, streamName.find('?'));
|
||||
Util::streamName = streamName;
|
||||
Util::setStreamName(streamName);
|
||||
HTTP::parseVars(tmpVars, targetParams);
|
||||
}
|
||||
|
||||
Util::streamName = streamName;
|
||||
Util::setStreamName(streamName);
|
||||
reqUrl += "/" + streamName; // LTS
|
||||
|
||||
/*LTS-START*/
|
||||
|
@ -850,17 +850,17 @@ namespace Mist{
|
|||
size_t lSlash = newUrl.rfind('/');
|
||||
if (lSlash != std::string::npos){
|
||||
streamName = newUrl.substr(lSlash + 1);
|
||||
Util::streamName = streamName;
|
||||
Util::setStreamName(streamName);
|
||||
}else{
|
||||
streamName = newUrl;
|
||||
Util::streamName = streamName;
|
||||
Util::setStreamName(streamName);
|
||||
}
|
||||
}
|
||||
/*LTS-END*/
|
||||
|
||||
if (streamName.find('/')){
|
||||
streamName = streamName.substr(0, streamName.find('/'));
|
||||
Util::streamName = streamName;
|
||||
Util::setStreamName(streamName);
|
||||
}
|
||||
|
||||
size_t colonPos = streamName.find(':');
|
||||
|
@ -871,7 +871,7 @@ namespace Mist{
|
|||
}else{
|
||||
streamName = oldName.substr(colonPos + 1) + std::string(".") + oldName.substr(0, colonPos);
|
||||
}
|
||||
Util::streamName = streamName;
|
||||
Util::setStreamName(streamName);
|
||||
}
|
||||
|
||||
Util::sanitizeName(streamName);
|
||||
|
@ -941,14 +941,14 @@ namespace Mist{
|
|||
int8_t playMessageType = messageType;
|
||||
int32_t playStreamId = streamId;
|
||||
streamName = Encodings::URL::decode(amfData.getContentP(3)->StrValue());
|
||||
Util::streamName = streamName;
|
||||
Util::setStreamName(streamName);
|
||||
reqUrl += "/" + streamName; // LTS
|
||||
|
||||
// handle variables
|
||||
if (streamName.find('?') != std::string::npos){
|
||||
std::string tmpVars = streamName.substr(streamName.find('?') + 1);
|
||||
streamName = streamName.substr(0, streamName.find('?'));
|
||||
Util::streamName = streamName;
|
||||
Util::setStreamName(streamName);
|
||||
HTTP::parseVars(tmpVars, targetParams);
|
||||
}
|
||||
|
||||
|
@ -960,7 +960,7 @@ namespace Mist{
|
|||
}else{
|
||||
streamName = oldName.substr(colonPos + 1) + std::string(".") + oldName.substr(0, colonPos);
|
||||
}
|
||||
Util::streamName = streamName;
|
||||
Util::setStreamName(streamName);
|
||||
}
|
||||
Util::sanitizeName(streamName);
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace Mist{
|
|||
streamName = opt["sink"].asString();
|
||||
if (!streamName.size()){streamName = opt["source"].asString();}
|
||||
Util::streamVariables(streamName, opt["source"].asString());
|
||||
Util::streamName = opt["source"].asString() + "→" + streamName;
|
||||
Util::setStreamName(opt["source"].asString() + "→" + streamName);
|
||||
}
|
||||
bool needsLock(){return false;}
|
||||
bool isSingular(){return false;}
|
||||
|
|
|
@ -389,7 +389,7 @@ namespace Mist{
|
|||
streamName = opt["sink"].asString();
|
||||
if (!streamName.size()){streamName = opt["source"].asString();}
|
||||
Util::streamVariables(streamName, opt["source"].asString());
|
||||
Util::streamName = opt["source"].asString() + "→" + streamName;
|
||||
Util::setStreamName(opt["source"].asString() + "→" + streamName);
|
||||
}
|
||||
|
||||
std::string EncodeOutputEBML::getTrackType(int tid){return M.getType(tid);}
|
||||
|
|
|
@ -227,7 +227,7 @@ namespace Mist{
|
|||
streamName = opt["sink"].asString();
|
||||
if (!streamName.size()){streamName = opt["source"].asString();}
|
||||
Util::streamVariables(streamName, opt["source"].asString());
|
||||
Util::streamName = opt["source"].asString() + "→" + streamName;
|
||||
Util::setStreamName(opt["source"].asString() + "→" + streamName);
|
||||
preRun();
|
||||
};
|
||||
virtual bool needsLock(){return false;}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <mist/stream.h>
|
||||
#include <mist/procs.h>
|
||||
#include <mist/comms.h>
|
||||
#include <mist/config.h>
|
||||
|
||||
const char * getStateString(uint8_t state){
|
||||
switch (state){
|
||||
|
@ -21,7 +22,7 @@ const char * getStateString(uint8_t state){
|
|||
/// Gets a PID from a shared memory page, if it exists
|
||||
uint64_t getPidFromPage(const char * pagePattern){
|
||||
char pageName[NAME_BUFFER_SIZE];
|
||||
snprintf(pageName, NAME_BUFFER_SIZE, pagePattern, Util::streamName.c_str());
|
||||
snprintf(pageName, NAME_BUFFER_SIZE, pagePattern, Util::streamName);
|
||||
IPC::sharedPage pidPage(pageName, 8, false, false);
|
||||
if (pidPage){
|
||||
return *(uint64_t*)(pidPage.mapped);
|
||||
|
@ -32,7 +33,7 @@ uint64_t getPidFromPage(const char * pagePattern){
|
|||
/// Deletes a shared memory page, if it exists
|
||||
void nukePage(const char * pagePattern){
|
||||
char pageName[NAME_BUFFER_SIZE];
|
||||
snprintf(pageName, NAME_BUFFER_SIZE, pagePattern, Util::streamName.c_str());
|
||||
snprintf(pageName, NAME_BUFFER_SIZE, pagePattern, Util::streamName);
|
||||
IPC::sharedPage page(pageName, 0, false, false);
|
||||
page.master = true;
|
||||
}
|
||||
|
@ -40,7 +41,7 @@ void nukePage(const char * pagePattern){
|
|||
/// Deletes a semaphore, if it exists
|
||||
void nukeSem(const char * pagePattern){
|
||||
char pageName[NAME_BUFFER_SIZE];
|
||||
snprintf(pageName, NAME_BUFFER_SIZE, pagePattern, Util::streamName.c_str());
|
||||
snprintf(pageName, NAME_BUFFER_SIZE, pagePattern, Util::streamName);
|
||||
IPC::semaphore sem(pageName, O_RDWR, ACCESSPERMS, 0, true);
|
||||
if (sem){sem.unlink();}
|
||||
}
|
||||
|
@ -51,7 +52,7 @@ int main(int argc, char **argv){
|
|||
FAIL_MSG("Usage: %s STREAM_NAME", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
Util::streamName = argv[1];
|
||||
Util::setStreamName(argv[1]);
|
||||
uint8_t state = Util::getStreamStatus(Util::streamName);
|
||||
INFO_MSG("Current stream status: %s", getStateString(state));
|
||||
size_t loops = 0;
|
||||
|
@ -73,7 +74,7 @@ int main(int argc, char **argv){
|
|||
// Scoping to clear up metadata and track providers
|
||||
{
|
||||
char pageName[NAME_BUFFER_SIZE];
|
||||
snprintf(pageName, NAME_BUFFER_SIZE, SHM_STREAM_META, Util::streamName.c_str());
|
||||
snprintf(pageName, NAME_BUFFER_SIZE, SHM_STREAM_META, Util::streamName);
|
||||
IPC::sharedPage streamPage(pageName, 0, false, false);
|
||||
if (streamPage.mapped){
|
||||
streamPage.master = true;
|
||||
|
@ -98,7 +99,7 @@ int main(int argc, char **argv){
|
|||
for (uint64_t j = pages.getDeleted(); j < pages.getEndPos(); j++){
|
||||
char thisPageName[NAME_BUFFER_SIZE];
|
||||
snprintf(thisPageName, NAME_BUFFER_SIZE, SHM_TRACK_DATA,
|
||||
Util::streamName.c_str(), i, pages.getInt("firstkey", j));
|
||||
Util::streamName, i, pages.getInt("firstkey", j));
|
||||
IPC::sharedPage p(thisPageName, 0);
|
||||
p.master = true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue