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

Henry Castro hcastro at collabora.com
Wed Feb 3 21:10:23 UTC 2016


 loolwsd/LOOLBroker.cpp |   25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

New commits:
commit 3cda7993289b3b97e5ea5714e6ff16f5c892f8b5
Author: Henry Castro <hcastro at collabora.com>
Date:   Wed Feb 3 17:07:36 2016 -0400

    loolwsd: avoid the loolbroker block forever before lokit launch

diff --git a/loolwsd/LOOLBroker.cpp b/loolwsd/LOOLBroker.cpp
index d824eb7..181c52c 100644
--- a/loolwsd/LOOLBroker.cpp
+++ b/loolwsd/LOOLBroker.cpp
@@ -898,12 +898,32 @@ int main(int argc, char** argv)
     dropCapability();
 #endif
 
+    int nFlags = O_RDONLY | O_NONBLOCK;
     if (mkfifo(FIFO_BROKER.c_str(), 0666) == -1)
     {
         Log::error("Error: Failed to create pipe FIFO [" + FIFO_BROKER + "].");
         exit(Application::EXIT_SOFTWARE);
     }
 
+    if ((readerChild = open(FIFO_BROKER.c_str(), nFlags) ) < 0)
+    {
+        Log::error("Error: pipe opened for reading.");
+        exit(Application::EXIT_SOFTWARE);
+    }
+
+    if ((nFlags = fcntl(readerChild, F_GETFL, 0)) < 0)
+    {
+        Log::error("Error: failed to get pipe flags [" + FIFO_BROKER + "].");
+        exit(Application::EXIT_SOFTWARE);
+    }
+
+    nFlags &= ~O_NONBLOCK;
+    if (fcntl(readerChild, F_SETFL, nFlags) < 0)
+    {
+        Log::error("Error: failed to set pipe flags [" + FIFO_BROKER + "].");
+        exit(Application::EXIT_SOFTWARE);
+    }
+
     // Initialize LoKit and hope we can fork and save memory by sharing pages.
     const bool sharePages = globalPreinit(loSubPath);
 
@@ -917,11 +937,6 @@ int main(int argc, char** argv)
     if (numPreSpawnedChildren > 1)
         forkCounter = numPreSpawnedChildren - 1;
 
-    if ( (readerChild = open(FIFO_BROKER.c_str(), O_RDONLY) ) < 0 )
-    {
-        Log::error("Error: pipe opened for reading.");
-        exit(Application::EXIT_SOFTWARE);
-    }
 
     PipeRunnable pipeHandler;
     Poco::Thread aPipe;


More information about the Libreoffice-commits mailing list