Added timeout support to analysers in validate mode
This commit is contained in:
parent
0c6cd9bfc6
commit
8c3b8d9666
2 changed files with 28 additions and 1 deletions
|
@ -6,6 +6,7 @@
|
||||||
Analyser::Analyser(Util::Config &conf){
|
Analyser::Analyser(Util::Config &conf){
|
||||||
validate = conf.getBool("validate");
|
validate = conf.getBool("validate");
|
||||||
detail = conf.getInteger("detail");
|
detail = conf.getInteger("detail");
|
||||||
|
timeOut = conf.getInteger("timeout");
|
||||||
mediaTime = 0;
|
mediaTime = 0;
|
||||||
upTime = Util::bootSecs();
|
upTime = Util::bootSecs();
|
||||||
isActive = &conf.is_active;
|
isActive = &conf.is_active;
|
||||||
|
@ -61,9 +62,26 @@ int Analyser::run(Util::Config &conf){
|
||||||
}
|
}
|
||||||
if (validate){
|
if (validate){
|
||||||
finTime = Util::bootSecs();
|
finTime = Util::bootSecs();
|
||||||
|
|
||||||
|
//slow down to realtime + 10s
|
||||||
|
if (validate && ((finTime - upTime + 10) * 1000 < mediaTime)){
|
||||||
|
uint32_t sleepMs = mediaTime - (Util::bootSecs() - upTime + 10) * 1000;
|
||||||
|
if ((finTime - upTime + sleepMs / 1000) >= timeOut){
|
||||||
|
WARN_MSG("Reached timeout of %llu seconds, stopping", timeOut);
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
INFO_MSG("Sleeping for %lums", sleepMs);
|
||||||
|
Util::sleep(sleepMs);
|
||||||
|
finTime = Util::bootSecs();
|
||||||
|
}
|
||||||
|
|
||||||
if ((finTime - upTime) > (mediaTime / 1000) + 2){
|
if ((finTime - upTime) > (mediaTime / 1000) + 2){
|
||||||
FAIL_MSG("Media time more than 2 seconds behind!");
|
FAIL_MSG("Media time more than 2 seconds behind!");
|
||||||
return 1;
|
return 4;
|
||||||
|
}
|
||||||
|
if ((finTime - upTime) >= timeOut){
|
||||||
|
WARN_MSG("Reached timeout of %llu seconds, stopping", timeOut);
|
||||||
|
return 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,6 +106,14 @@ void Analyser::init(Util::Config &conf){
|
||||||
conf.addOption("validate", opt);
|
conf.addOption("validate", opt);
|
||||||
opt.null();
|
opt.null();
|
||||||
|
|
||||||
|
opt["long"] = "timeout";
|
||||||
|
opt["short"] = "T";
|
||||||
|
opt["arg"] = "num";
|
||||||
|
opt["default"] = 0ll;
|
||||||
|
opt["help"] = "Time out after X seconds of processing/retrieving";
|
||||||
|
conf.addOption("timeout", opt);
|
||||||
|
opt.null();
|
||||||
|
|
||||||
opt["long"] = "detail";
|
opt["long"] = "detail";
|
||||||
opt["short"] = "D";
|
opt["short"] = "D";
|
||||||
opt["arg"] = "num";
|
opt["arg"] = "num";
|
||||||
|
|
|
@ -31,6 +31,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
// These hold the current state and/or config
|
// These hold the current state and/or config
|
||||||
bool validate; ///< True of validation mode is enabled
|
bool validate; ///< True of validation mode is enabled
|
||||||
|
uint64_t timeOut; ///< After how many seconds a timeout should trigger
|
||||||
int detail; ///< Detail level of analyser
|
int detail; ///< Detail level of analyser
|
||||||
uint64_t mediaTime; ///< Timestamp in ms of last media packet received
|
uint64_t mediaTime; ///< Timestamp in ms of last media packet received
|
||||||
uint64_t upTime; ///< Unix time of analyser start
|
uint64_t upTime; ///< Unix time of analyser start
|
||||||
|
|
Loading…
Add table
Reference in a new issue