Skip to content

Commit 720f4b5

Browse files
committed
Added configurable input timeout for all inputs
1 parent 72ce091 commit 720f4b5

3 files changed

Lines changed: 26 additions & 5 deletions

File tree

src/input/input.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ namespace Mist{
100100
config = cfg;
101101
standAlone = true;
102102
Util::Config::binaryType = Util::INPUT;
103+
inputTimeout = INPUT_TIMEOUT;
103104

104105
JSON::Value option;
105106
option["long"] = "json";
@@ -131,6 +132,19 @@ namespace Mist{
131132
option["value"].append(0u);
132133
option["help"] = "Generate .dtsh, then exit";
133134
config->addOption("headeronly", option);
135+
option.null();
136+
option["short"] = "i";
137+
option["arg"] = "integer";
138+
option["long"] = "inputtimeout";
139+
option["value"].append(inputTimeout);
140+
option["help"] = "Time in seconds to keep the input process loaded without activity";
141+
config->addOption("inputtimeout", option);
142+
capa["optional"]["inputtimeout"]["name"] = "Input inactivity timeout";
143+
capa["optional"]["inputtimeout"]["help"] = "How long the input should remain loaded without activity";
144+
capa["optional"]["inputtimeout"]["default"] = inputTimeout;
145+
capa["optional"]["inputtimeout"]["unit"] = "s";
146+
capa["optional"]["inputtimeout"]["type"] = "uint";
147+
capa["optional"]["inputtimeout"]["option"] = "--inputtimeout";
134148

135149
/*LTS-START*/
136150
/*
@@ -368,6 +382,7 @@ namespace Mist{
368382
int Input::boot(int argc, char *argv[]){
369383
if (!(config->parseArgs(argc, argv))){return 1;}
370384
streamName = config->getString("streamname");
385+
inputTimeout = config->getInteger("inputtimeout");
371386
Util::setStreamName(streamName);
372387

373388
if (config->getBool("json")){
@@ -923,7 +938,7 @@ namespace Mist{
923938
// We keep running in serve mode if the config is still active AND either
924939
// - INPUT_TIMEOUT seconds haven't passed yet,
925940
// - this is a live stream and at least two of the biggest fragment haven't passed yet,
926-
bool ret = config->is_active && ((Util::bootSecs() - activityCounter) < INPUT_TIMEOUT);
941+
bool ret = config->is_active && ((Util::bootSecs() - activityCounter) < inputTimeout);
927942
/*LTS-START*/
928943
if (!ret){
929944
if (Triggers::shouldTrigger("STREAM_UNLOAD", config->getString("streamname"))){
@@ -936,8 +951,8 @@ namespace Mist{
936951
}
937952
}
938953
/*LTS-END*/
939-
if (!ret && ((Util::bootSecs() - activityCounter) >= INPUT_TIMEOUT)){
940-
Util::logExitReason(ER_CLEAN_INACTIVE, "no activity for %u seconds", Util::bootSecs() - activityCounter);
954+
if (!ret && ((Util::bootSecs() - activityCounter) >= inputTimeout)){
955+
Util::logExitReason(ER_CLEAN_INACTIVE, "no activity for %us (> %" PRIu64 "s)", Util::bootSecs() - activityCounter, inputTimeout);
941956
}
942957
return ret;
943958
}

src/input/input.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ namespace Mist{
5757
Comms::Connections statComm;
5858
uint64_t startTime;
5959
uint64_t lastStats;
60+
uint64_t inputTimeout;
6061

6162
virtual bool checkArguments() = 0;
6263
virtual bool readHeader();

src/input/input_buffer.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,13 @@ namespace Mist{
557557
bufferTime = tmpNum;
558558
}
559559

560-
/*LTS-START*/
560+
//Check if input timeout setting is correct
561+
tmpNum = retrieveSetting(streamCfg, "inputtimeout");
562+
if (inputTimeout != tmpNum){
563+
DEVEL_MSG("Setting input timeout from %" PRIu64 " to new value of %" PRIu64, inputTimeout, tmpNum);
564+
inputTimeout = tmpNum;
565+
}
566+
561567
//Check if cutTime setting is correct
562568
tmpNum = retrieveSetting(streamCfg, "cut");
563569
// if the new value is different, print a message and apply it
@@ -594,7 +600,6 @@ namespace Mist{
594600
meta.setMaxKeepAway(tmpNum);
595601
}
596602

597-
/*LTS-END*/
598603
return true;
599604
}
600605

0 commit comments

Comments
 (0)