diff --git a/lib/GeneralServer/GeneralCommTask.h b/lib/GeneralServer/GeneralCommTask.h index 2eda6e63d9..82cb8fd13a 100644 --- a/lib/GeneralServer/GeneralCommTask.h +++ b/lib/GeneralServer/GeneralCommTask.h @@ -225,10 +225,18 @@ namespace triagens { //////////////////////////////////////////////////////////////////////////////// bool handleRead (bool& closed) { - bool res = fillReadBuffer(closed); + bool res; - // process as much data as we got - processRead(); + if (! this->_closeRequested) { + res = fillReadBuffer(closed); + + // process as much data as we got + while (processRead()) { + if (this->_closeRequested) { + break; + } + } + } if (closed) { res = false; diff --git a/lib/HttpServer/HttpCommTask.h b/lib/HttpServer/HttpCommTask.h index f4a3807310..193952ff47 100644 --- a/lib/HttpServer/HttpCommTask.h +++ b/lib/HttpServer/HttpCommTask.h @@ -321,7 +321,7 @@ namespace triagens { bool processRead () { if (this->_requestPending || this->_readBuffer->c_str() == nullptr) { - return true; + return false; } bool handleRequest = false; @@ -373,7 +373,7 @@ namespace triagens { this->resetState(true); this->handleResponse(&response); - return true; + return false; } // header is complete @@ -403,7 +403,7 @@ namespace triagens { this->resetState(true); this->handleResponse(&response); - return true; + return false; } TRI_ASSERT(this->_request != nullptr); @@ -421,7 +421,7 @@ namespace triagens { this->resetState(true); this->handleResponse(&response); - return true; + return false; } // check max URL length @@ -435,7 +435,7 @@ namespace triagens { this->resetState(true); this->handleResponse(&response); - return true; + return false; } // update the connection information, i. e. client and server addresses and ports @@ -489,7 +489,7 @@ namespace triagens { || this->_requestType == HttpRequest::HTTP_REQUEST_DELETE); if (! checkContentLength(expectContentLength)) { - return true; + return false; } if (this->_bodyLength == 0) { @@ -520,7 +520,7 @@ namespace triagens { // force a socket close, response will be ignored! TRI_CLOSE_SOCKET(this->_commSocket); - return true; + return false; } } @@ -541,7 +541,7 @@ namespace triagens { this->resetState(true); this->handleResponse(&response); - return true; + return false; } // check for a 100-continue @@ -588,7 +588,7 @@ namespace triagens { } // let client send more - return true; + return false; } // read "bodyLength" from read buffer and add this body to "httpRequest" @@ -609,7 +609,7 @@ namespace triagens { // ............................................................................. if (! handleRequest) { - return true; + return false; } RequestStatisticsAgentSetReadEnd(this); @@ -799,9 +799,6 @@ namespace triagens { // start output this->fillWriteBuffer(); - - // and process any remaining input - processRead(); } ////////////////////////////////////////////////////////////////////////////////