[Libreoffice-commits] online.git: wsd/LOOLWSD.cpp wsd/LOOLWSD.hpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Mon Jan 16 02:11:52 UTC 2017
wsd/LOOLWSD.cpp | 19 +++++++++++++------
wsd/LOOLWSD.hpp | 2 +-
2 files changed, 14 insertions(+), 7 deletions(-)
New commits:
commit e3aec0e6c4b7fefe65aff19e6eb1ac048f2c8306
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Sun Jan 15 12:57:22 2017 -0500
wsd: detect and fail child forking when forkit is down
Change-Id: I97ba133b0285403b7dfa4b6a6cbef26b818dcaf3
Reviewed-on: https://gerrit.libreoffice.org/33132
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 47a2fdc..7d55971 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -389,7 +389,7 @@ static bool rebalanceChildren(int balance)
return forkChildren(balance);
}
- return false;
+ return true;
}
/// Called on startup only.
@@ -473,7 +473,11 @@ static std::shared_ptr<ChildProcess> getNewChild()
LOG_DBG("getNewChild: Rebalancing children.");
int numPreSpawn = LOOLWSD::NumPreSpawnedChildren;
++numPreSpawn; // Replace the one we'll dispatch just now.
- rebalanceChildren(numPreSpawn);
+ if (!rebalanceChildren(numPreSpawn))
+ {
+ // Fatal. Let's fail and retry at a higher level.
+ return nullptr;
+ }
LOG_TRC("Waiting for a new child for a max of " << CHILD_TIMEOUT_MS << " ms.");
const auto timeout = chrono::milliseconds(CHILD_TIMEOUT_MS);
@@ -1673,7 +1677,7 @@ inline std::string getAdminURI(const Poco::Util::LayeredConfiguration &config)
} // anonymous namespace
std::atomic<unsigned> LOOLWSD::NextSessionId;
-int LOOLWSD::ForKitWritePipe = -1;
+std::atomic<int> LOOLWSD::ForKitWritePipe(-1);
bool LOOLWSD::NoCapsForKit = false;
std::string LOOLWSD::Cache = LOOLWSD_CACHEDIR;
std::string LOOLWSD::SysTemplate;
@@ -2073,8 +2077,13 @@ void LOOLWSD::displayHelp()
Process::PID LOOLWSD::createForKit()
{
- Process::Args args;
+ LOG_INF("Creating new forkit process.");
+
+ const int oldForKitWritePipe = ForKitWritePipe;
+ ForKitWritePipe = -1;
+ close(oldForKitWritePipe);
+ Process::Args args;
args.push_back("--losubpath=" + std::string(LO_JAIL_SUBPATH));
args.push_back("--systemplate=" + SysTemplate);
args.push_back("--lotemplate=" + LoTemplate);
@@ -2271,7 +2280,6 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
}
// Spawn a new forkit and try to dust it off and resume.
- close(ForKitWritePipe);
forKitPid = createForKit();
if (forKitPid < 0)
{
@@ -2306,7 +2314,6 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
{
// No child processes.
// Spawn a new forkit and try to dust it off and resume.
- close(ForKitWritePipe);
forKitPid = createForKit();
if (forKitPid < 0)
{
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index a8d364e..7728efa 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -36,7 +36,7 @@ public:
static std::atomic<unsigned> NextSessionId;
static unsigned int NumPreSpawnedChildren;
static bool NoCapsForKit;
- static int ForKitWritePipe;
+ static std::atomic<int> ForKitWritePipe;
static std::string Cache;
static std::string SysTemplate;
static std::string LoTemplate;
More information about the Libreoffice-commits
mailing list