TSSRT and TSRIST outputs in listen mode will now request not to be killed by the Comms library, since they handle multiple users

This commit is contained in:
Thulinma 2023-07-24 10:37:42 +02:00
parent 22e0036b8b
commit 41cf557b48
7 changed files with 11 additions and 5 deletions

View file

@ -17,6 +17,7 @@ namespace Comms{
uint8_t sessionUnspecifiedMode = 0; uint8_t sessionUnspecifiedMode = 0;
uint8_t sessionStreamInfoMode = SESS_DEFAULT_STREAM_INFO_MODE; uint8_t sessionStreamInfoMode = SESS_DEFAULT_STREAM_INFO_MODE;
uint8_t tknMode = SESS_TKN_DEFAULT_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 /// \brief Refreshes the session configuration if the last update was more than 5 seconds ago
void sessionConfigCache(){ void sessionConfigCache(){
@ -103,7 +104,7 @@ namespace Comms{
for (size_t i = 0; i < recordCount(); i++){ for (size_t i = 0; i < recordCount(); i++){
if (getStatus(i) == COMM_STATUS_INVALID || (getStatus(i) & COMM_STATUS_DISCONNECT)){continue;} if (getStatus(i) == COMM_STATUS_INVALID || (getStatus(i) & COMM_STATUS_DISCONNECT)){continue;}
uint64_t cPid = getPid(i); uint64_t cPid = getPid(i);
if (cPid > 1){ if (cPid > 1 && !(getStatus(i) & COMM_STATUS_NOKILL)){
Util::Procs::Stop(cPid); // soft kill Util::Procs::Stop(cPid); // soft kill
keepGoing = true; keepGoing = true;
} }
@ -164,7 +165,7 @@ namespace Comms{
IPC::semGuard G(&sem); IPC::semGuard G(&sem);
if (getStatus() != COMM_STATUS_INVALID){continue;} if (getStatus() != COMM_STATUS_INVALID){continue;}
nullFields(); nullFields();
setStatus(COMM_STATUS_ACTIVE); setStatus(COMM_STATUS_ACTIVE | defaultCommFlags);
break; break;
} }
} }
@ -275,7 +276,7 @@ namespace Comms{
if (dataPage){ if (dataPage){
setTrack(idx); setTrack(idx);
setKeyNum(0); setKeyNum(0);
setStatus(initialState); setStatus(initialState | defaultCommFlags);
} }
} }

View file

@ -26,6 +26,7 @@ namespace Comms{
extern uint8_t sessionUnspecifiedMode; extern uint8_t sessionUnspecifiedMode;
extern uint8_t sessionStreamInfoMode; extern uint8_t sessionStreamInfoMode;
extern uint8_t tknMode; extern uint8_t tknMode;
extern uint8_t defaultCommFlags;
void sessionConfigCache(); void sessionConfigCache();
class Comms{ class Comms{

View file

@ -291,6 +291,7 @@ static inline void show_stackframe(){}
#define COMM_STATUS_DONOTTRACK 0x40 #define COMM_STATUS_DONOTTRACK 0x40
#define COMM_STATUS_DISCONNECT 0x20 #define COMM_STATUS_DISCONNECT 0x20
#define COMM_STATUS_REQDISCONNECT 0x10 #define COMM_STATUS_REQDISCONNECT 0x10
#define COMM_STATUS_NOKILL 0x8
#define COMM_STATUS_ACTIVE 0x1 #define COMM_STATUS_ACTIVE 0x1
#define COMM_STATUS_INVALID 0x0 #define COMM_STATUS_INVALID 0x0
#define SESS_BUNDLE_DEFAULT_VIEWER 14 #define SESS_BUNDLE_DEFAULT_VIEWER 14

View file

@ -446,6 +446,7 @@ int main(int argc, char *argv[]){
sigaction(SIGUSR1, &new_action, NULL); sigaction(SIGUSR1, &new_action, NULL);
} }
if (conf.getInteger("port") && conf.getString("interface").size()){ 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){ if (rist_receiver_create(&rec_ctx, (rist_profile)conf.getInteger("profile"), &Mist::log_settings) != 0){
FAIL_MSG("Failed to create receiver context"); FAIL_MSG("Failed to create receiver context");

View file

@ -501,6 +501,7 @@ int main(int argc, char *argv[]){
if (oldSignal){WARN_MSG("Multiple signal handlers! I can't deal with this.");} if (oldSignal){WARN_MSG("Multiple signal handlers! I can't deal with this.");}
oldSignal = cur_action.sa_sigaction; oldSignal = cur_action.sa_sigaction;
} }
Comms::defaultCommFlags = COMM_STATUS_NOKILL;
Util::Procs::socketList.insert(server_socket.getSocket()); Util::Procs::socketList.insert(server_socket.getSocket());
while (conf.is_active && server_socket.connected()){ while (conf.is_active && server_socket.connected()){
Socket::SRTConnection S = server_socket.accept(false, "output"); Socket::SRTConnection S = server_socket.accept(false, "output");

View file

@ -141,7 +141,7 @@ int main(int argc, char **argv){
cleanUsers.setStatus(COMM_STATUS_INVALID, i); cleanUsers.setStatus(COMM_STATUS_INVALID, i);
if (status != COMM_STATUS_INVALID && !(status & COMM_STATUS_DISCONNECT)){ if (status != COMM_STATUS_INVALID && !(status & COMM_STATUS_DISCONNECT)){
pid_t pid = cleanUsers.getPid(i); pid_t pid = cleanUsers.getPid(i);
if (pid > 1){ if (pid > 1 && !(cleanUsers.getStatus(i) & COMM_STATUS_NOKILL)){
Util::Procs::Stop(pid); Util::Procs::Stop(pid);
checkPids.insert(pid); checkPids.insert(pid);
} }
@ -165,3 +165,4 @@ int main(int argc, char **argv){
nukeSem("/MstPull_%s"); nukeSem("/MstPull_%s");
nukeSem(SEM_TRACKLIST); nukeSem(SEM_TRACKLIST);
} }