Converted comms system entirely to being bitflag-based instead of integer state based

This commit is contained in:
Thulinma 2020-12-04 16:26:57 +01:00
parent 6e316663fc
commit 974380ab30
10 changed files with 28 additions and 24 deletions

View file

@ -860,7 +860,7 @@ namespace Mist{
userSelect[idx].reload(streamName, idx, COMM_STATUS_ACTIVE | COMM_STATUS_SOURCE | COMM_STATUS_DONOTTRACK);
}
while (thisPacket && config->is_active && userSelect[idx]){
if (userSelect[idx].getStatus() == COMM_STATUS_REQDISCONNECT){
if (userSelect[idx].getStatus() & COMM_STATUS_REQDISCONNECT){
Util::logExitReason("buffer requested shutdown");
break;
}
@ -933,7 +933,7 @@ namespace Mist{
// Connect to stats for INPUT detection
if (!statComm){statComm.reload();}
if (statComm){
if (statComm.getStatus() == COMM_STATUS_REQDISCONNECT){
if (statComm.getStatus() & COMM_STATUS_REQDISCONNECT){
config->is_active = false;
Util::logExitReason("received shutdown request from controller");
return;

View file

@ -393,7 +393,7 @@ namespace Mist{
if (!(users.getStatus(i) & COMM_STATUS_SOURCE)){continue;}
if (users.getTrack(i) != tid){continue;}
// We have found the right track here (pid matches, and COMM_STATUS_SOURCE set)
users.setStatus(COMM_STATUS_REQDISCONNECT, i);
users.setStatus(COMM_STATUS_REQDISCONNECT | users.getStatus(i), i);
break;
}
@ -518,7 +518,7 @@ namespace Mist{
void inputBuffer::userOnActive(size_t id){
///\todo Add tracing of earliest watched keys, to prevent data going out of memory for
/// still-watching viewers
if (users.getStatus(id) != COMM_STATUS_DISCONNECT && users.getStatus(id) & COMM_STATUS_SOURCE){
if (!(users.getStatus(id) & COMM_STATUS_DISCONNECT) && (users.getStatus(id) & COMM_STATUS_SOURCE)){
sourcePids[users.getPid(id)].insert(users.getTrack(id));
// GeneratePids holds the pids of the process that generate data, so ignore those for determining if a push is ingested.
if (M.trackValid(users.getTrack(id)) && !generatePids.count(users.getPid(id))){hasPush = true;}

View file

@ -212,7 +212,7 @@ namespace Mist{
// Connect to stats for INPUT detection
statComm.reload();
if (statComm){
if (statComm.getStatus() == COMM_STATUS_REQDISCONNECT){
if (statComm.getStatus() & COMM_STATUS_REQDISCONNECT){
config->is_active = false;
Util::logExitReason("received shutdown request from controller");
return;
@ -403,7 +403,7 @@ namespace Mist{
WARN_MSG("Reloading track %zu, index %zu", pkt.getTrackId(), idx);
userSelect[idx].reload(streamName, idx, COMM_STATUS_ACTIVE | COMM_STATUS_SOURCE | COMM_STATUS_DONOTTRACK);
}
if (userSelect[idx].getStatus() == COMM_STATUS_REQDISCONNECT){
if (userSelect[idx].getStatus() & COMM_STATUS_REQDISCONNECT){
Util::logExitReason("buffer requested shutdown");
tcpCon.close();
}

View file

@ -146,7 +146,7 @@ void parseThread(void *mistIn){
threadTimer.erase(tid);
}
liveStream.eraseTrack(tid);
if (dataTrack && userConn){userConn.setStatus(COMM_STATUS_DISCONNECT);}
if (dataTrack && userConn){userConn.setStatus(COMM_STATUS_DISCONNECT | userConn.getStatus());}
}
namespace Mist{