From 7f3b61978fda79895fc3a2a76661f60476e11d0e Mon Sep 17 00:00:00 2001 From: Thulinma Date: Sun, 6 Jan 2019 13:51:58 +0100 Subject: [PATCH] Shared memory logic fix for quick disconnecting users, small tweak to sync byte reporting --- src/controller/controller_statistics.cpp | 2 +- src/output/output.cpp | 36 +++++++++++++----------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/controller/controller_statistics.cpp b/src/controller/controller_statistics.cpp index 55b6f79b..0d7df85e 100644 --- a/src/controller/controller_statistics.cpp +++ b/src/controller/controller_statistics.cpp @@ -516,7 +516,7 @@ uint32_t Controller::statSession::kill(){ /// Updates the given active connection with new stats data. void Controller::statSession::update(unsigned long index, IPC::statExchange & data){ - //update the sync byte: 0 = requesting fill, 2 = requesting refill, 1 = needs checking, > 1 = state known (100=denied, 10=accepted) + //update the sync byte: 0 = requesting fill, 2 = requesting refill, 1 = needs checking, > 2 = state known (100=denied, 10=accepted) if (!data.getSync()){ sessIndex tmpidx(data); std::string myHost = tmpidx.host; diff --git a/src/output/output.cpp b/src/output/output.cpp index 577954c0..fba8c7a8 100644 --- a/src/output/output.cpp +++ b/src/output/output.cpp @@ -282,25 +282,27 @@ namespace Mist{ stats(true); tmpEx = IPC::statExchange(statsPage.getData()); } - HIGH_MSG("USER_NEW sync achieved: %u", (unsigned int)tmpEx.getSync()); - //1 = check requested (connection is new) - if (tmpEx.getSync() == 1){ - std::string payload = streamName+"\n" + getConnectedHost() +"\n" + JSON::Value((long long)crc).asString() + "\n"+capa["name"].asStringRef()+"\n"+reqUrl+"\n"+tmpEx.getSessId(); - if (!Triggers::doTrigger("USER_NEW", payload, streamName)){ - onFail("Not allowed to play (USER_NEW)"); - tmpEx.setSync(100);//100 = denied - }else{ - tmpEx.setSync(10);//10 = accepted + //If we aren't online, skip any further checks. + //We don't immediately return, so the recursing = false line only + //needs to be written once and will always be executed. + if (keepGoing()){ + HIGH_MSG("USER_NEW sync achieved: %u", (unsigned int)tmpEx.getSync()); + //1 = check requested (connection is new) + if (tmpEx.getSync() == 1){ + std::string payload = streamName+"\n" + getConnectedHost() +"\n" + JSON::Value((long long)crc).asString() + "\n"+capa["name"].asStringRef()+"\n"+reqUrl+"\n"+tmpEx.getSessId(); + if (!Triggers::doTrigger("USER_NEW", payload, streamName)){ + onFail("Not allowed to play (USER_NEW)"); + tmpEx.setSync(100);//100 = denied + }else{ + tmpEx.setSync(10);//10 = accepted + } } + //100 = denied + if (tmpEx.getSync() == 100){onFail("Not allowed to play (USER_NEW cache)");} + if (tmpEx.getSync() == 0){onFail("Not allowed to play (USER_NEW init timeout)", true);} + if (tmpEx.getSync() == 2){onFail("Not allowed to play (USER_NEW re-init timeout)", true);} + //anything else = accepted } - //100 = denied - if (tmpEx.getSync() == 100){ - onFail("Not allowed to play (USER_NEW cache)"); - } - if (tmpEx.getSync() == 0 || tmpEx.getSync() == 2){ - onFail("Not allowed to play (USER_NEW timeout)", true); - } - //anything else = accepted }else{ tmpEx.setSync(10);//auto-accept if no trigger }