diff --git a/lib/comms.cpp b/lib/comms.cpp index dabea8f0..5c76925b 100644 --- a/lib/comms.cpp +++ b/lib/comms.cpp @@ -17,6 +17,7 @@ namespace Comms{ uint8_t sessionUnspecifiedMode = 0; uint8_t sessionStreamInfoMode = SESS_DEFAULT_STREAM_INFO_MODE; uint8_t tknMode = SESS_TKN_DEFAULT_MODE; + uint8_t defaultCommFlags = 0; /// \brief Refreshes the session configuration if the last update was more than 5 seconds ago void sessionConfigCache(){ @@ -103,7 +104,7 @@ namespace Comms{ for (size_t i = 0; i < recordCount(); i++){ if (getStatus(i) == COMM_STATUS_INVALID || (getStatus(i) & COMM_STATUS_DISCONNECT)){continue;} uint64_t cPid = getPid(i); - if (cPid > 1){ + if (cPid > 1 && !(getStatus(i) & COMM_STATUS_NOKILL)){ Util::Procs::Stop(cPid); // soft kill keepGoing = true; } @@ -164,7 +165,7 @@ namespace Comms{ IPC::semGuard G(&sem); if (getStatus() != COMM_STATUS_INVALID){continue;} nullFields(); - setStatus(COMM_STATUS_ACTIVE); + setStatus(COMM_STATUS_ACTIVE | defaultCommFlags); break; } } @@ -275,7 +276,7 @@ namespace Comms{ if (dataPage){ setTrack(idx); setKeyNum(0); - setStatus(initialState); + setStatus(initialState | defaultCommFlags); } } diff --git a/lib/comms.h b/lib/comms.h index 8dfed832..491bda9b 100644 --- a/lib/comms.h +++ b/lib/comms.h @@ -26,6 +26,7 @@ namespace Comms{ extern uint8_t sessionUnspecifiedMode; extern uint8_t sessionStreamInfoMode; extern uint8_t tknMode; + extern uint8_t defaultCommFlags; void sessionConfigCache(); class Comms{ diff --git a/lib/defines.h b/lib/defines.h index 9337a0b6..be68782f 100644 --- a/lib/defines.h +++ b/lib/defines.h @@ -291,6 +291,7 @@ static inline void show_stackframe(){} #define COMM_STATUS_DONOTTRACK 0x40 #define COMM_STATUS_DISCONNECT 0x20 #define COMM_STATUS_REQDISCONNECT 0x10 +#define COMM_STATUS_NOKILL 0x8 #define COMM_STATUS_ACTIVE 0x1 #define COMM_STATUS_INVALID 0x0 #define SESS_BUNDLE_DEFAULT_VIEWER 14 diff --git a/src/output/output.cpp b/src/output/output.cpp index ee79aa9f..78800d38 100644 --- a/src/output/output.cpp +++ b/src/output/output.cpp @@ -2221,7 +2221,7 @@ namespace Mist{ onFail("Shutting down since this session is not allowed to view this stream"); statComm.unload(); return; - } + } lastStats = now; diff --git a/src/output/output_tsrist.cpp b/src/output/output_tsrist.cpp index 894b091b..578ddae0 100644 --- a/src/output/output_tsrist.cpp +++ b/src/output/output_tsrist.cpp @@ -446,6 +446,7 @@ int main(int argc, char *argv[]){ sigaction(SIGUSR1, &new_action, NULL); } if (conf.getInteger("port") && conf.getString("interface").size()){ + Comms::defaultCommFlags = COMM_STATUS_NOKILL; if (rist_receiver_create(&rec_ctx, (rist_profile)conf.getInteger("profile"), &Mist::log_settings) != 0){ FAIL_MSG("Failed to create receiver context"); diff --git a/src/output/output_tssrt.cpp b/src/output/output_tssrt.cpp index 3e8ba276..d172d2a5 100644 --- a/src/output/output_tssrt.cpp +++ b/src/output/output_tssrt.cpp @@ -501,6 +501,7 @@ int main(int argc, char *argv[]){ if (oldSignal){WARN_MSG("Multiple signal handlers! I can't deal with this.");} oldSignal = cur_action.sa_sigaction; } + Comms::defaultCommFlags = COMM_STATUS_NOKILL; Util::Procs::socketList.insert(server_socket.getSocket()); while (conf.is_active && server_socket.connected()){ Socket::SRTConnection S = server_socket.accept(false, "output"); diff --git a/src/utils/util_nuke.cpp b/src/utils/util_nuke.cpp index 083a204f..a2858cf6 100644 --- a/src/utils/util_nuke.cpp +++ b/src/utils/util_nuke.cpp @@ -141,7 +141,7 @@ int main(int argc, char **argv){ cleanUsers.setStatus(COMM_STATUS_INVALID, i); if (status != COMM_STATUS_INVALID && !(status & COMM_STATUS_DISCONNECT)){ pid_t pid = cleanUsers.getPid(i); - if (pid > 1){ + if (pid > 1 && !(cleanUsers.getStatus(i) & COMM_STATUS_NOKILL)){ Util::Procs::Stop(pid); checkPids.insert(pid); } @@ -165,3 +165,4 @@ int main(int argc, char **argv){ nukeSem("/MstPull_%s"); nukeSem(SEM_TRACKLIST); } +