[Libreoffice-commits] online.git: 2 commits - loolwsd/Common.hpp loolwsd/DocumentBroker.cpp loolwsd/IoUtil.cpp loolwsd/LOOLWSD.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Sun Oct 16 22:08:19 UTC 2016
loolwsd/Common.hpp | 9 +++++----
loolwsd/DocumentBroker.cpp | 2 +-
loolwsd/IoUtil.cpp | 2 +-
loolwsd/LOOLWSD.cpp | 13 +++++++------
4 files changed, 14 insertions(+), 12 deletions(-)
New commits:
commit c1ee1f5102d29182af95e273686272f70b9c210d
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Fri Oct 14 23:01:14 2016 -0400
loolwsd: stop ChildProcess WS on TerminationFlag
Change-Id: I303dedb8254a9b815dd0b2c5d0a62cc5345af062
Reviewed-on: https://gerrit.libreoffice.org/29943
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp
index 77aa6ba..0d36497 100644
--- a/loolwsd/DocumentBroker.cpp
+++ b/loolwsd/DocumentBroker.cpp
@@ -52,7 +52,7 @@ void ChildProcess::socketProcessor()
return true;
},
[]() { },
- [this]() { return !!this->_stop; });
+ [this]() { return TerminationFlag || this->_stop; });
}
namespace
commit 67437c607668f2534f73fb6947dbc90f73876771
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Fri Oct 14 23:00:33 2016 -0400
loolwsd: all timeouts in milliseconds
Change-Id: Ic5db4e13b2caba53fcbeea0bfdb10d112f2d5a18
Reviewed-on: https://gerrit.libreoffice.org/29942
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/Common.hpp b/loolwsd/Common.hpp
index 68530e8..13028b7 100644
--- a/loolwsd/Common.hpp
+++ b/loolwsd/Common.hpp
@@ -16,11 +16,12 @@ constexpr int MAX_SESSIONS = 1024;
constexpr int DEFAULT_CLIENT_PORT_NUMBER = 9980;
constexpr int DEFAULT_MASTER_PORT_NUMBER = 9981;
-constexpr int WSD_SLEEP_SECS = 2;
-constexpr int CHILD_TIMEOUT_SECS = 4;
-constexpr int POLL_TIMEOUT_MS = 1000;
+
constexpr int COMMAND_TIMEOUT_MS = 5000;
-constexpr int WS_SEND_TIMEOUT_MICROSECS = 1000000; // 1 second.
+constexpr int CHILD_TIMEOUT_MS = COMMAND_TIMEOUT_MS;
+constexpr int CHILD_REBALANCE_INTERVAL_MS = CHILD_TIMEOUT_MS / 10;
+constexpr int POLL_TIMEOUT_MS = COMMAND_TIMEOUT_MS / 10;
+constexpr int WS_SEND_TIMEOUT_MS = 1000;
/// Pipe and Socket read buffer size.
/// Should be large enough for ethernet packets
diff --git a/loolwsd/IoUtil.cpp b/loolwsd/IoUtil.cpp
index 1160b15..ca6002b 100644
--- a/loolwsd/IoUtil.cpp
+++ b/loolwsd/IoUtil.cpp
@@ -275,7 +275,7 @@ int PipeReader::readLine(std::string& line,
// Poll in short intervals to check for stop condition.
const auto pollTimeoutMs = 500;
- auto maxPollCount = POLL_TIMEOUT_MS / pollTimeoutMs;
+ auto maxPollCount = std::max<int>(POLL_TIMEOUT_MS / pollTimeoutMs, 1);
while (maxPollCount-- > 0)
{
if (stopPredicate())
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index a9d08d2..ee2c931 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -260,7 +260,7 @@ static void prespawnChildren()
}
const auto duration = (std::chrono::steady_clock::now() - lastForkRequestTime);
- if (std::chrono::duration_cast<std::chrono::milliseconds>(duration).count() <= static_cast<int64_t>(CHILD_TIMEOUT_SECS) * 1000)
+ if (std::chrono::duration_cast<std::chrono::milliseconds>(duration).count() <= CHILD_TIMEOUT_MS)
{
// Not enough time passed to balance children.
return;
@@ -308,7 +308,7 @@ static std::shared_ptr<ChildProcess> getNewChild()
Log::debug("getNewChild: Have " + std::to_string(available) + " children, forking " + std::to_string(balance));
forkChildren(balance);
- const auto timeout = chrono::milliseconds(CHILD_TIMEOUT_SECS * 1000);
+ const auto timeout = chrono::milliseconds(CHILD_TIMEOUT_MS);
if (newChildrenCV.wait_for(lock, timeout, [](){ return !newChildren.empty(); }))
{
auto child = newChildren.back();
@@ -324,7 +324,8 @@ static std::shared_ptr<ChildProcess> getNewChild()
Log::debug("getNewChild: No live child, forking more.");
}
- while (chrono::duration_cast<chrono::milliseconds>(chrono::steady_clock::now() - startTime).count() < static_cast<int64_t>(CHILD_TIMEOUT_SECS) * 4000);
+ while (chrono::duration_cast<chrono::milliseconds>(chrono::steady_clock::now() - startTime).count() <
+ CHILD_TIMEOUT_MS * 4);
Log::debug("getNewChild: Timed out while waiting for new child.");
return nullptr;
@@ -669,7 +670,7 @@ private:
// If this document is going out, wait.
Log::debug("Document [" + docKey + "] is marked to destroy, waiting to reload.");
- const auto timeout = POLL_TIMEOUT_MS / 2;
+ const auto timeout = POLL_TIMEOUT_MS;
bool timedOut = true;
for (size_t i = 0; i < COMMAND_TIMEOUT_MS / timeout; ++i)
{
@@ -1029,7 +1030,7 @@ public:
{
// First, setup WS options.
ws->setBlocking(false);
- ws->setSendTimeout(WS_SEND_TIMEOUT_MICROSECS);
+ ws->setSendTimeout(WS_SEND_TIMEOUT_MS * 1000);
std::string decodedUri;
URI::decode(reqPathTokens[1], decodedUri);
handleGetRequest(decodedUri, ws, id);
@@ -1884,7 +1885,7 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
}
}
- std::this_thread::sleep_for(std::chrono::seconds(WSD_SLEEP_SECS));
+ std::this_thread::sleep_for(std::chrono::milliseconds(CHILD_REBALANCE_INTERVAL_MS));
// Make sure we have sufficient reserves.
prespawnChildren();
More information about the Libreoffice-commits
mailing list