Shared memory logic fix for quick disconnecting users, small tweak to sync byte reporting

This commit is contained in:
Thulinma 2019-01-06 13:51:58 +01:00
parent 5c074757f1
commit 7f3b61978f
2 changed files with 20 additions and 18 deletions

View file

@ -516,7 +516,7 @@ uint32_t Controller::statSession::kill(){
/// Updates the given active connection with new stats data. /// Updates the given active connection with new stats data.
void Controller::statSession::update(unsigned long index, IPC::statExchange & 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()){ if (!data.getSync()){
sessIndex tmpidx(data); sessIndex tmpidx(data);
std::string myHost = tmpidx.host; std::string myHost = tmpidx.host;

View file

@ -282,25 +282,27 @@ namespace Mist{
stats(true); stats(true);
tmpEx = IPC::statExchange(statsPage.getData()); tmpEx = IPC::statExchange(statsPage.getData());
} }
HIGH_MSG("USER_NEW sync achieved: %u", (unsigned int)tmpEx.getSync()); //If we aren't online, skip any further checks.
//1 = check requested (connection is new) //We don't immediately return, so the recursing = false line only
if (tmpEx.getSync() == 1){ //needs to be written once and will always be executed.
std::string payload = streamName+"\n" + getConnectedHost() +"\n" + JSON::Value((long long)crc).asString() + "\n"+capa["name"].asStringRef()+"\n"+reqUrl+"\n"+tmpEx.getSessId(); if (keepGoing()){
if (!Triggers::doTrigger("USER_NEW", payload, streamName)){ HIGH_MSG("USER_NEW sync achieved: %u", (unsigned int)tmpEx.getSync());
onFail("Not allowed to play (USER_NEW)"); //1 = check requested (connection is new)
tmpEx.setSync(100);//100 = denied if (tmpEx.getSync() == 1){
}else{ std::string payload = streamName+"\n" + getConnectedHost() +"\n" + JSON::Value((long long)crc).asString() + "\n"+capa["name"].asStringRef()+"\n"+reqUrl+"\n"+tmpEx.getSessId();
tmpEx.setSync(10);//10 = accepted 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{ }else{
tmpEx.setSync(10);//auto-accept if no trigger tmpEx.setSync(10);//auto-accept if no trigger
} }