Change controller calls that use stream metadata to instantly time out if unavailable, rather than waiting for availability
This commit is contained in:
parent
f19899aed2
commit
f3ba13d6bb
4 changed files with 16 additions and 16 deletions
12
lib/dtsc.cpp
12
lib/dtsc.cpp
|
@ -901,13 +901,13 @@ namespace DTSC{
|
|||
|
||||
/// Initialize empty metadata, in master or slave mode.
|
||||
/// If stream name is empty, slave mode is enforced.
|
||||
Meta::Meta(const std::string &_streamName, bool master){
|
||||
Meta::Meta(const std::string &_streamName, bool master, bool autoBackOff){
|
||||
if (!_streamName.size()){master = false;}
|
||||
version = DTSH_VERSION;
|
||||
streamMemBuf = 0;
|
||||
isMemBuf = false;
|
||||
isMaster = master;
|
||||
reInit(_streamName, master);
|
||||
reInit(_streamName, master, autoBackOff);
|
||||
}
|
||||
|
||||
/// Initialize metadata from given DTSH file in master mode.
|
||||
|
@ -926,12 +926,12 @@ namespace DTSC{
|
|||
/// Calls clear(), then initializes freshly.
|
||||
/// If stream name is set, uses shared memory backing.
|
||||
/// If stream name is empty, uses non-shared memory backing.
|
||||
void Meta::reInit(const std::string &_streamName, bool master){
|
||||
void Meta::reInit(const std::string &_streamName, bool master, bool autoBackOff){
|
||||
clear();
|
||||
if (_streamName == ""){
|
||||
sBufMem();
|
||||
}else{
|
||||
sBufShm(_streamName, DEFAULT_TRACK_COUNT, master);
|
||||
sBufShm(_streamName, DEFAULT_TRACK_COUNT, master, autoBackOff);
|
||||
}
|
||||
streamInit();
|
||||
}
|
||||
|
@ -1118,7 +1118,7 @@ namespace DTSC{
|
|||
|
||||
/// Initializes shared memory backed mode, with enough room for the given track count.
|
||||
/// Should not be called repeatedly, nor to switch modes.
|
||||
void Meta::sBufShm(const std::string &_streamName, size_t trackCount, bool master){
|
||||
void Meta::sBufShm(const std::string &_streamName, size_t trackCount, bool master, bool autoBackOff){
|
||||
isMaster = master;
|
||||
if (isMaster){HIGH_MSG("Creating meta page for stream %s", _streamName.c_str());}
|
||||
|
||||
|
@ -1142,7 +1142,7 @@ namespace DTSC{
|
|||
streamPage.master = false;
|
||||
stream = Util::RelAccX(streamPage.mapped, false);
|
||||
}else{
|
||||
streamPage.init(pageName, bufferSize, false, true);
|
||||
streamPage.init(pageName, bufferSize, false, autoBackOff);
|
||||
if (!streamPage.mapped){
|
||||
INFO_MSG("Page %s not found", pageName);
|
||||
return;
|
||||
|
|
|
@ -284,11 +284,11 @@ namespace DTSC{
|
|||
class Meta{
|
||||
public:
|
||||
Meta(const std::string &_streamName, const DTSC::Scan &src);
|
||||
Meta(const std::string &_streamName = "", bool master = true);
|
||||
Meta(const std::string &_streamName = "", bool master = true, bool autoBackOff = true);
|
||||
Meta(const std::string &_streamName, const std::string &fileName);
|
||||
|
||||
~Meta();
|
||||
void reInit(const std::string &_streamName, bool master = true);
|
||||
void reInit(const std::string &_streamName, bool master = true, bool autoBackOff = true);
|
||||
void reInit(const std::string &_streamName, const std::string &fileName);
|
||||
void reInit(const std::string &_streamName, const DTSC::Scan &src);
|
||||
void addTrackFrom(const DTSC::Scan &src);
|
||||
|
@ -493,7 +493,7 @@ namespace DTSC{
|
|||
|
||||
protected:
|
||||
void sBufMem(size_t trackCount = DEFAULT_TRACK_COUNT);
|
||||
void sBufShm(const std::string &_streamName, size_t trackCount = DEFAULT_TRACK_COUNT, bool master = true);
|
||||
void sBufShm(const std::string &_streamName, size_t trackCount = DEFAULT_TRACK_COUNT, bool master = true, bool autoBackOff = true);
|
||||
void streamInit(size_t trackCount = DEFAULT_TRACK_COUNT);
|
||||
|
||||
std::string streamName;
|
||||
|
|
|
@ -1207,7 +1207,7 @@ void Controller::fillHasStats(JSON::Value &req, JSON::Value &rep){
|
|||
jsonForEach(req, j){
|
||||
if (j->asStringRef() == "clients"){rep[*it].append(clients[*it]);}
|
||||
if (j->asStringRef() == "lastms"){
|
||||
DTSC::Meta M(*it, false);
|
||||
DTSC::Meta M(*it, false, false);
|
||||
if (M){
|
||||
uint64_t lms = 0;
|
||||
std::set<size_t> validTracks = M.getValidTracks();
|
||||
|
@ -1325,7 +1325,7 @@ void Controller::fillActive(JSON::Value &req, JSON::Value &rep){
|
|||
}else if (j->asStringRef() == "packretrans"){
|
||||
F = it->second.packRetrans;
|
||||
}else if (j->asStringRef() == "firstms"){
|
||||
if (!M || M.getStreamName() != it->first){M.reInit(it->first, false);}
|
||||
if (!M || M.getStreamName() != it->first){M.reInit(it->first, false, false);}
|
||||
if (M){
|
||||
uint64_t fms = 0;
|
||||
std::set<size_t> validTracks = M.getValidTracks();
|
||||
|
@ -1335,7 +1335,7 @@ void Controller::fillActive(JSON::Value &req, JSON::Value &rep){
|
|||
F = fms;
|
||||
}
|
||||
}else if (j->asStringRef() == "lastms"){
|
||||
if (!M || M.getStreamName() != it->first){M.reInit(it->first, false);}
|
||||
if (!M || M.getStreamName() != it->first){M.reInit(it->first, false, false);}
|
||||
if (M){
|
||||
uint64_t lms = 0;
|
||||
std::set<size_t> validTracks = M.getValidTracks();
|
||||
|
@ -1345,15 +1345,15 @@ void Controller::fillActive(JSON::Value &req, JSON::Value &rep){
|
|||
F = lms;
|
||||
}
|
||||
}else if (j->asStringRef() == "zerounix"){
|
||||
if (!M || M.getStreamName() != it->first){M.reInit(it->first, false);}
|
||||
if (!M || M.getStreamName() != it->first){M.reInit(it->first, false, false);}
|
||||
if (M && M.getLive()){
|
||||
F = (M.getBootMsOffset() + (Util::unixMS() - Util::bootMS())) / 1000;
|
||||
}
|
||||
}else if (j->asStringRef() == "health"){
|
||||
if (!M || M.getStreamName() != it->first){M.reInit(it->first, false);}
|
||||
if (!M || M.getStreamName() != it->first){M.reInit(it->first, false, false);}
|
||||
if (M){M.getHealthJSON(F);}
|
||||
}else if (j->asStringRef() == "tracks"){
|
||||
if (!M || M.getStreamName() != it->first){M.reInit(it->first, false);}
|
||||
if (!M || M.getStreamName() != it->first){M.reInit(it->first, false, false);}
|
||||
if (M){
|
||||
F = (uint64_t)M.getValidTracks().size();
|
||||
}
|
||||
|
|
|
@ -353,7 +353,7 @@ namespace Controller{
|
|||
Util::sanitizeName(cleaned);
|
||||
std::string strmSource;
|
||||
if (Util::getStreamStatus(cleaned) != STRMSTAT_OFF){
|
||||
DTSC::Meta M(cleaned, false);
|
||||
DTSC::Meta M(cleaned, false, false);
|
||||
if (M && M.getSource().size()){strmSource = M.getSource();}
|
||||
}
|
||||
if (!strmSource.size()){
|
||||
|
|
Loading…
Add table
Reference in a new issue