Converted HTTP based outputs to new and improved mechanism, increasing robustness and efficiency.

This commit is contained in:
Thulinma 2014-10-31 00:38:25 +01:00
parent b325ca96ee
commit d457046420
32 changed files with 1113 additions and 1510 deletions

View file

@ -486,29 +486,33 @@ namespace Mist {
return false;
}
}
void Output::requestHandler(){
static bool firstData = true;//only the first time, we call onRequest if there's data buffered already.
if ((firstData && myConn.Received().size()) || myConn.spool()){
firstData = false;
DEBUG_MSG(DLVL_DONTEVEN, "onRequest");
onRequest();
}else{
if (!isBlocking && !parseData){
Util::sleep(500);
}
}
}
int Output::run() {
bool firstData = true;//only the first time, we call OnRequest if there's data buffered already.
DEBUG_MSG(DLVL_MEDIUM, "MistOut client handler started");
while (myConn.connected() && (wantRequest || parseData)){
stats();
if (wantRequest){
if ((firstData && myConn.Received().size()) || myConn.spool()){
firstData = false;
DEBUG_MSG(DLVL_DONTEVEN, "OnRequest");
onRequest();
}else{
if (!isBlocking && !parseData){
Util::sleep(500);
}
}
requestHandler();
}
if (parseData){
if (!isInitialized){
initialize();
}
if ( !sentHeader){
DEBUG_MSG(DLVL_DONTEVEN, "SendHeader");
DEBUG_MSG(DLVL_DONTEVEN, "sendHeader");
sendHeader();
}
prepareNext();