Skip to content

Commit 41cf557

Browse files
committed
TSSRT and TSRIST outputs in listen mode will now request not to be killed by the Comms library, since they handle multiple users
1 parent 22e0036 commit 41cf557

File tree

7 files changed

+11
-5
lines changed

7 files changed

+11
-5
lines changed

lib/comms.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace Comms{
1717
uint8_t sessionUnspecifiedMode = 0;
1818
uint8_t sessionStreamInfoMode = SESS_DEFAULT_STREAM_INFO_MODE;
1919
uint8_t tknMode = SESS_TKN_DEFAULT_MODE;
20+
uint8_t defaultCommFlags = 0;
2021

2122
/// \brief Refreshes the session configuration if the last update was more than 5 seconds ago
2223
void sessionConfigCache(){
@@ -103,7 +104,7 @@ namespace Comms{
103104
for (size_t i = 0; i < recordCount(); i++){
104105
if (getStatus(i) == COMM_STATUS_INVALID || (getStatus(i) & COMM_STATUS_DISCONNECT)){continue;}
105106
uint64_t cPid = getPid(i);
106-
if (cPid > 1){
107+
if (cPid > 1 && !(getStatus(i) & COMM_STATUS_NOKILL)){
107108
Util::Procs::Stop(cPid); // soft kill
108109
keepGoing = true;
109110
}
@@ -164,7 +165,7 @@ namespace Comms{
164165
IPC::semGuard G(&sem);
165166
if (getStatus() != COMM_STATUS_INVALID){continue;}
166167
nullFields();
167-
setStatus(COMM_STATUS_ACTIVE);
168+
setStatus(COMM_STATUS_ACTIVE | defaultCommFlags);
168169
break;
169170
}
170171
}
@@ -275,7 +276,7 @@ namespace Comms{
275276
if (dataPage){
276277
setTrack(idx);
277278
setKeyNum(0);
278-
setStatus(initialState);
279+
setStatus(initialState | defaultCommFlags);
279280
}
280281
}
281282

lib/comms.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ namespace Comms{
2626
extern uint8_t sessionUnspecifiedMode;
2727
extern uint8_t sessionStreamInfoMode;
2828
extern uint8_t tknMode;
29+
extern uint8_t defaultCommFlags;
2930
void sessionConfigCache();
3031

3132
class Comms{

lib/defines.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ static inline void show_stackframe(){}
291291
#define COMM_STATUS_DONOTTRACK 0x40
292292
#define COMM_STATUS_DISCONNECT 0x20
293293
#define COMM_STATUS_REQDISCONNECT 0x10
294+
#define COMM_STATUS_NOKILL 0x8
294295
#define COMM_STATUS_ACTIVE 0x1
295296
#define COMM_STATUS_INVALID 0x0
296297
#define SESS_BUNDLE_DEFAULT_VIEWER 14

src/output/output.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2221,7 +2221,7 @@ namespace Mist{
22212221
onFail("Shutting down since this session is not allowed to view this stream");
22222222
statComm.unload();
22232223
return;
2224-
}
2224+
}
22252225

22262226
lastStats = now;
22272227

src/output/output_tsrist.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ int main(int argc, char *argv[]){
446446
sigaction(SIGUSR1, &new_action, NULL);
447447
}
448448
if (conf.getInteger("port") && conf.getString("interface").size()){
449+
Comms::defaultCommFlags = COMM_STATUS_NOKILL;
449450

450451
if (rist_receiver_create(&rec_ctx, (rist_profile)conf.getInteger("profile"), &Mist::log_settings) != 0){
451452
FAIL_MSG("Failed to create receiver context");

src/output/output_tssrt.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ int main(int argc, char *argv[]){
501501
if (oldSignal){WARN_MSG("Multiple signal handlers! I can't deal with this.");}
502502
oldSignal = cur_action.sa_sigaction;
503503
}
504+
Comms::defaultCommFlags = COMM_STATUS_NOKILL;
504505
Util::Procs::socketList.insert(server_socket.getSocket());
505506
while (conf.is_active && server_socket.connected()){
506507
Socket::SRTConnection S = server_socket.accept(false, "output");

src/utils/util_nuke.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ int main(int argc, char **argv){
141141
cleanUsers.setStatus(COMM_STATUS_INVALID, i);
142142
if (status != COMM_STATUS_INVALID && !(status & COMM_STATUS_DISCONNECT)){
143143
pid_t pid = cleanUsers.getPid(i);
144-
if (pid > 1){
144+
if (pid > 1 && !(cleanUsers.getStatus(i) & COMM_STATUS_NOKILL)){
145145
Util::Procs::Stop(pid);
146146
checkPids.insert(pid);
147147
}
@@ -165,3 +165,4 @@ int main(int argc, char **argv){
165165
nukeSem("/MstPull_%s");
166166
nukeSem(SEM_TRACKLIST);
167167
}
168+

0 commit comments

Comments
 (0)