loolwsd/LOOLBroker.cpp | 37 ++++++++++++++++++++++++++++++++++++- loolwsd/LOOLKit.cpp | 4 ++-- 2 files changed, 38 insertions(+), 3 deletions(-)
New commits: commit 584e68e6d1ff0c5e45eadf6dd8987f1c6714831e Author: Henry Castro <[email protected]> Date: Fri Jan 8 19:02:09 2016 -0400 loolwsd: remove expired session URL cached diff --git a/loolwsd/LOOLBroker.cpp b/loolwsd/LOOLBroker.cpp index dd90a47..5fdd28b 100644 --- a/loolwsd/LOOLBroker.cpp +++ b/loolwsd/LOOLBroker.cpp @@ -68,6 +68,7 @@ static int readerChild = -1; static int readerBroker = -1; static std::atomic<unsigned> forkCounter; +static std::atomic<std::chrono::seconds> maintenance; static unsigned int childCounter = 0; static unsigned int numPreSpawnedChildren = 0; @@ -236,6 +237,35 @@ public: return sendMessage(_childProcesses[nPID], aMessage); } + void verifyChilds() + { + std::string aMessage; + bool bError = false; + + // sanity cache + for (auto it =_cacheURL.cbegin(); it != _cacheURL.cend(); ) + { + aMessage = "search " + it->first + "\r\n"; + if (sendMessage(_childProcesses[it->second], aMessage) < 0) + { + bError = true; + break; + } + + if (!isOKResponse(it->second)) + { + Log::debug() << "Removed expired Kit [" + std::to_string(it->second) + "] hosts URL [" + it->first + "] -> " << Log::end; + _cacheURL.erase(it++); + continue; + } + + it++; + } + + if (bError) + _cacheURL.clear(); + } + Process::PID searchURL(const std::string& aURL) { const std::string aMessage = "search " + aURL + "\r\n"; @@ -404,6 +434,11 @@ public: pStart++; forkMutex.lock(); + if (maintenance.load() > std::chrono::seconds(10)) + { + maintenance = std::chrono::seconds::zero(); + verifyChilds(); + } handleInput(aMessage); aMessage.clear(); forkMutex.unlock(); @@ -819,7 +854,7 @@ int main(int argc, char** argv) { timeoutCounter = 0; sleep(MAINTENANCE_INTERVAL); - // TODO. lokit processes maintance + maintenance.store( ++maintenance.load() ); } } diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp index c46c260..32c8f4d 100644 --- a/loolwsd/LOOLKit.cpp +++ b/loolwsd/LOOLKit.cpp @@ -738,7 +738,7 @@ void lokit_main(const std::string &loSubPath, const std::string& jailId, const s } else { - aResponse += ( pDocument->getURL() == tokens[1] ? "ok \r\n" : "no \r\n"); + aResponse += (pDocument->getURL() == tokens[1] ? "ok \r\n" : "no \r\n"); } } else if (tokens[0] == "thread") @@ -746,7 +746,7 @@ void lokit_main(const std::string &loSubPath, const std::string& jailId, const s const std::string& sessionId = tokens[1]; const std::string& url = tokens[2]; - if ( !pDocument->hasConnections() || (pDocument->getURL() == url)) + if (!pDocument->hasConnections() || pDocument->getURL() == url) { Log::debug("Thread request for session [" + sessionId + "], url: [" + url + "]."); pDocument->createSession(sessionId, url); _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
