[Libreoffice-commits] online.git: 2 commits - loolwsd/LOOLForKit.cpp loolwsd/LOOLWSD.cpp

2016-11-15 Thread Ashod Nakashian
 loolwsd/LOOLForKit.cpp |   20 +++-
 loolwsd/LOOLWSD.cpp|9 +
 2 files changed, 16 insertions(+), 13 deletions(-)

New commits:
commit cf2f4ed712d87ba46055f9a0666447fdd727d8e4
Author: Ashod Nakashian 
Date:   Tue Nov 15 22:03:49 2016 -0500

loolwsd: improve interrupted pipe-reading handling in forkit

Change-Id: Iabaadee064bb1178cc6b1bd3482608a758d65506
Reviewed-on: https://gerrit.libreoffice.org/30892
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLForKit.cpp b/loolwsd/LOOLForKit.cpp
index 8509446..ab3d2c3 100644
--- a/loolwsd/LOOLForKit.cpp
+++ b/loolwsd/LOOLForKit.cpp
@@ -72,20 +72,22 @@ public:
 {
 std::string message;
 const auto ready = readLine(message, [](){ return 
TerminationFlag.load(); });
-if (ready == 0)
-{
-// Timeout.
-return true;
-}
-else if (ready < 0)
+if (ready <= 0)
 {
 // Termination is done via SIGTERM, which breaks the wait.
-if (!TerminationFlag)
+if (TerminationFlag)
 {
-Log::error("Error reading from pipe [" + getName() + "].");
+if (ready < 0)
+{
+LOG_INF("Poll interrupted in " << getName() << " and 
Termination flag set.");
+}
+
+// Break.
+return false;
 }
 
-return false;
+// Timeout.
+return true;
 }
 
 LOG_INF("ForKit command: [" << message << "].");
commit 4c9a2e821d5f32005be3a10ceecb107ea20ecc29
Author: Ashod Nakashian 
Date:   Tue Nov 15 22:03:11 2016 -0500

loolwsd: don't set TerminationFlag unnecessarily

Change-Id: I993e1c5bfdb5b4a5d9a421bc61fa90fdfd1ba00b
Reviewed-on: https://gerrit.libreoffice.org/30891
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 94be625..c0d19aa 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -2032,7 +2032,6 @@ int LOOLWSD::main(const std::vector& 
/*args*/)
 {
 // No child processes.
 LOG_FTL("No Forkit instance. Terminating.");
-TerminationFlag = true;
 break;
 }
 }
@@ -2072,7 +2071,6 @@ int LOOLWSD::main(const std::vector& 
/*args*/)
 if (careerSpanSeconds > 0 && time(nullptr) > startTimeSpan + 
careerSpanSeconds)
 {
 LOG_INF((time(nullptr) - startTimeSpan) << " seconds gone, 
finishing as requested.");
-TerminationFlag = true;
 break;
 }
 #endif
@@ -2080,8 +2078,10 @@ int LOOLWSD::main(const std::vector& 
/*args*/)
 
 // Stop the listening to new connections
 // and wait until sockets close.
-LOG_INF("Stopping server socket listening.");
+LOG_INF("Stopping server socket listening. ShutdownFlag: " <<
+ShutdownFlag << ", TerminationFlag: " << TerminationFlag);
 Util::alertAllUsers("internal", "shutdown");
+
 srv.stop();
 srv2.stop();
 threadPool.joinAll();
@@ -2094,10 +2094,11 @@ int LOOLWSD::main(const std::vector& 
/*args*/)
 child->close(true);
 }
 
-// Wait for forkit process finish
+// Wait for forkit process finish.
 waitpid(forKitPid, , WUNTRACED);
 close(ForKitWritePipe);
 
+// In case forkit didn't cleanup fully.'
 LOG_INF("Cleaning up childroot directory [" << ChildRoot << "].");
 std::vector jails;
 File(ChildRoot).list(jails);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: 2 commits - loolwsd/LOOLForKit.cpp

2016-10-12 Thread Tor Lillqvist
 loolwsd/LOOLForKit.cpp |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit d658a35c039b7b231594bd72c85a9dd8bc81ae42
Author: Tor Lillqvist 
Date:   Wed Oct 12 15:15:39 2016 +0300

Fix copy-paste error

diff --git a/loolwsd/LOOLForKit.cpp b/loolwsd/LOOLForKit.cpp
index 1ee1998..2122444 100644
--- a/loolwsd/LOOLForKit.cpp
+++ b/loolwsd/LOOLForKit.cpp
@@ -172,7 +172,7 @@ static bool haveCorrectCapabilities()
 result = false;
 if (!haveCapability(CAP_MKNOD))
 result = false;
-if (!haveCapability(CAP_SYS_CHROOT))
+if (!haveCapability(CAP_FOWNER))
 result = false;
 
 return result;
commit 7872c5f0837bd204add78615c358186cea7f7726
Author: Tor Lillqvist 
Date:   Wed Oct 12 15:13:26 2016 +0300

I mean loolforkit, not loolkit

diff --git a/loolwsd/LOOLForKit.cpp b/loolwsd/LOOLForKit.cpp
index fa03aaa..1ee1998 100644
--- a/loolwsd/LOOLForKit.cpp
+++ b/loolwsd/LOOLForKit.cpp
@@ -140,12 +140,12 @@ static bool haveCapability(cap_value_t capability)
 {
 if (cap_name)
 {
-Log::error("Capability " + std::string(cap_name) + " is not set 
for the loolkit program.");
+Log::error("Capability " + std::string(cap_name) + " is not set 
for the loolforkit program.");
 cap_free(cap_name);
 }
 else
 {
-Log::error("Capability " + std::to_string(capability) + " is not 
set for the loolkit program.");
+Log::error("Capability " + std::to_string(capability) + " is not 
set for the loolforkit program.");
 }
 return false;
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: 2 commits - loolwsd/LOOLForKit.cpp loolwsd/LOOLWSD.cpp loolwsd/PROBLEMS

2016-04-12 Thread Tor Lillqvist
 loolwsd/LOOLForKit.cpp |1 +
 loolwsd/LOOLWSD.cpp|   10 +++---
 loolwsd/PROBLEMS   |8 
 3 files changed, 8 insertions(+), 11 deletions(-)

New commits:
commit 5c6e2095675028816131628b6ffc3d33b5eff5c3
Author: Tor Lillqvist 
Date:   Tue Apr 12 17:49:20 2016 +0300

Log creation and opening of fifos in more detail

diff --git a/loolwsd/LOOLForKit.cpp b/loolwsd/LOOLForKit.cpp
index dd74a2c..23f43da 100644
--- a/loolwsd/LOOLForKit.cpp
+++ b/loolwsd/LOOLForKit.cpp
@@ -226,6 +226,7 @@ int main(int argc, char** argv)
 Log::syserror("Failed to open pipe [" + pipeLoolwsd + "] for reading. 
Exiting.");
 std::exit(Application::EXIT_SOFTWARE);
 }
+Log::debug("open(" + pipeLoolwsd + ", RDONLY) = " + 
std::to_string(pipeFd));
 
 // Initialize LoKit
 if (!globalPreinit(loTemplate))
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index ffbfeb2..4b1a1ed 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -1316,6 +1316,7 @@ int LOOLWSD::main(const std::vector& 
/*args*/)
 }
 
 const std::string pipeLoolwsd = Path(pipePath, FIFO_LOOLWSD).toString();
+Log::debug("mkfifo(" + pipeLoolwsd + ")");
 if (mkfifo(pipeLoolwsd.c_str(), 0666) < 0 && errno != EEXIST)
 {
 Log::syserror("Failed to create pipe FIFO [" + pipeLoolwsd + "].");
@@ -1326,6 +1327,7 @@ int LOOLWSD::main(const std::vector& 
/*args*/)
 int pipeFlags = O_RDONLY | O_NONBLOCK;
 int notifyPipe = -1;
 const std::string pipeNotify = Path(pipePath, 
FIFO_ADMIN_NOTIFY).toString();
+Log::debug("mkfifo(" + pipeNotify + ")");
 if (mkfifo(pipeNotify.c_str(), 0666) < 0 && errno != EEXIST)
 {
 Log::syserror("Failed to create pipe FIFO [" + 
std::string(FIFO_ADMIN_NOTIFY) + "].");
@@ -1334,20 +1336,21 @@ int LOOLWSD::main(const std::vector& 
/*args*/)
 
 if ((notifyPipe = open(pipeNotify.c_str(), pipeFlags) ) < 0)
 {
-Log::syserror("Failed to open pipe for reading.");
+Log::syserror("Failed to open pipe [" + pipeNotify + "] for reading.");
 std::exit(Application::EXIT_SOFTWARE);
 }
+Log::debug("open(" + pipeNotify + ", RDONLY) = " + 
std::to_string(notifyPipe));
 
 if ((pipeFlags = fcntl(notifyPipe, F_GETFL, 0)) < 0)
 {
-Log::syserror("Failed to get pipe flags [" + 
std::string(FIFO_ADMIN_NOTIFY) + "].");
+Log::syserror("Failed to get pipe flags [" + pipeNotify + "].");
 std::exit(Application::EXIT_SOFTWARE);
 }
 
 pipeFlags &= ~O_NONBLOCK;
 if (fcntl(notifyPipe, F_SETFL, pipeFlags) < 0)
 {
-Log::syserror("Failed to set pipe flags [" + 
std::string(FIFO_ADMIN_NOTIFY) + "].");
+Log::syserror("Failed to set pipe flags [" + pipeNotify + "].");
 std::exit(Application::EXIT_SOFTWARE);
 }
 
@@ -1400,6 +1403,7 @@ int LOOLWSD::main(const std::vector& 
/*args*/)
 Log::syserror("Failed to open pipe [" + pipeLoolwsd + "] for 
writing.");
 return Application::EXIT_SOFTWARE;
 }
+Log::debug("open(" + pipeLoolwsd + ", WRONLY) = " + 
std::to_string(ForKitWritePipe));
 
 threadPool.start(Admin::instance());
 
commit 6342c33dda0d6a609307a6d4b519e5284fc1a8fb
Author: Tor Lillqvist 
Date:   Tue Apr 12 16:04:59 2016 +0300

ClientPortNumber is not static any longer

diff --git a/loolwsd/PROBLEMS b/loolwsd/PROBLEMS
index edc151a..89ed2c7 100644
--- a/loolwsd/PROBLEMS
+++ b/loolwsd/PROBLEMS
@@ -1,14 +1,6 @@
 - There is way too much of busy waiting for fairly arbitrarily chosen
   timeout periods in the code.
 
-- The --clientport= option to a lookit process (when spawning them,
-  not forking) can not work as intended. The ClientPortNumber variable
-  is declared *static* in ChildProcessSession.hpp and thus is a
-  separate variable in each compilation unit (object file) that
-  includes ChildProcessSession.hpp. The variable that is assigned in
-  main() in LOOLBroker.cpp is not the variable used in
-  ChildProcessSession::downloadAs() in ChildProcessSession.cpp.
-
 - Recursive mutexes are evil. In general, I think the consensus is
   that recursive mutexes should be avoided. One should use them only
   when absolutely necessary because the code-base is so complex that
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits