Speed up MistInBuffer shutdown time

This commit is contained in:
Thulinma 2021-01-06 15:33:16 +01:00
parent 97b28bebda
commit f862263354
3 changed files with 6 additions and 1 deletions

View file

@ -29,6 +29,9 @@ bool Util::Procs::thread_handler = false;
tthread::mutex Util::Procs::plistMutex; tthread::mutex Util::Procs::plistMutex;
tthread::thread *Util::Procs::reaper_thread = 0; tthread::thread *Util::Procs::reaper_thread = 0;
/// How many seconds to wait when shutting down child processes. Defaults to 10
int Util::Procs::kill_timeout = 10;
/// Local-only function. Attempts to reap child and returns current running status. /// Local-only function. Attempts to reap child and returns current running status.
bool Util::Procs::childRunning(pid_t p){ bool Util::Procs::childRunning(pid_t p){
int status; int status;
@ -98,7 +101,7 @@ void Util::Procs::exit_handler(){
(int)listcopy.size()); (int)listcopy.size());
waiting = 0; waiting = 0;
// wait up to 10 seconds for applications to shut down // wait up to 10 seconds for applications to shut down
while (!listcopy.empty() && waiting <= 500){ while (!listcopy.empty() && waiting <= 50*Util::Procs::kill_timeout){
bool doWait = true; bool doWait = true;
for (it = listcopy.begin(); it != listcopy.end(); it++){ for (it = listcopy.begin(); it != listcopy.end(); it++){
if (!childRunning(*it)){ if (!childRunning(*it)){

View file

@ -42,5 +42,6 @@ namespace Util{
static void forget(pid_t pid); static void forget(pid_t pid);
static void remember(pid_t pid); static void remember(pid_t pid);
static std::set<int> socketList; ///< Holds sockets that should be closed before forking static std::set<int> socketList; ///< Holds sockets that should be closed before forking
static int kill_timeout;
}; };
}// namespace Util }// namespace Util

View file

@ -573,6 +573,7 @@ namespace Mist{
bool inputBuffer::preRun(){ bool inputBuffer::preRun(){
// This function gets run periodically to make sure runtime updates of the config get parsed. // This function gets run periodically to make sure runtime updates of the config get parsed.
Util::Procs::kill_timeout = 5;
std::string strName = config->getString("streamname"); std::string strName = config->getString("streamname");
Util::sanitizeName(strName); Util::sanitizeName(strName);
strName = strName.substr(0, (strName.find_first_of("+ "))); strName = strName.substr(0, (strName.find_first_of("+ ")));