[Libreoffice-commits] online.git: loolwsd/LOOLWSD.cpp loolwsd/LOOLWSD.hpp loolwsd/MasterProcessSession.cpp

Henry Castro hcastro at collabora.com
Wed Dec 23 09:05:55 PST 2015


 loolwsd/LOOLWSD.cpp              |   18 +++++++++++++++---
 loolwsd/LOOLWSD.hpp              |    2 ++
 loolwsd/MasterProcessSession.cpp |    6 +++++-
 3 files changed, 22 insertions(+), 4 deletions(-)

New commits:
commit 2d375f3eba9695e2f0debefbf283553e9fd825e8
Author: Henry Castro <hcastro at collabora.com>
Date:   Sun Dec 13 13:28:01 2015 -0500

    loolwsd: FIFO
    
    Change-Id: I4694e45ab8006e8287011000bc5e2797bc9ecd48
    Reviewed-on: https://gerrit.libreoffice.org/20898
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index b89fb9c..8bdc377 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -101,7 +101,7 @@ DEALINGS IN THE SOFTWARE.
 #include <Poco/TemporaryFile.h>
 #include <Poco/StreamCopier.h>
 #include <Poco/URI.h>
-
+#include <Poco/Environment.h>
 
 #include "LOOLProtocol.hpp"
 #include "LOOLSession.hpp"
@@ -579,6 +579,7 @@ private:
 
 int LOOLWSD::portNumber = DEFAULT_CLIENT_PORT_NUMBER;
 int LOOLWSD::timeoutCounter = 0;
+int LOOLWSD::writerBroker = -1;
 Poco::UInt64 LOOLWSD::_childId = 0;
 std::string LOOLWSD::cache = LOOLWSD_CACHEDIR;
 std::string LOOLWSD::sysTemplate;
@@ -601,6 +602,7 @@ int LOOLWSD::uid = 0;
 const std::string LOOLWSD::CHILD_URI = "/loolws/child/";
 const std::string LOOLWSD::PIDLOG = "/tmp/loolwsd.pid";
 const std::string LOOLWSD::LOKIT_PIDLOG = "/tmp/lokit.pid";
+const std::string LOOLWSD::FIFO_FILE = "/tmp/loolwsdfifo";
 
 LOOLWSD::LOOLWSD()
 {
@@ -1150,7 +1152,7 @@ void LOOLWSD::desktopMain()
                 }
 
                 if ( WCOREDUMP(status) )
-                    std::cout << Util::logPrefix() << "The child produced a core dump." << std::endl;
+                    std::cout << Util::logPrefix() << "The child process [" << pid << "] produced a core dump." << std::endl;
 
                 if ( WIFSTOPPED(status) )
                     std::cout << Util::logPrefix() << "The child process was stopped by delivery of a signal." << std::endl;
@@ -1222,6 +1224,9 @@ void LOOLWSD::startupDesktop(int nDesktops)
 
 int LOOLWSD::main(const std::vector<std::string>& /*args*/)
 {
+    Poco::Environment::set("LD_BIND_NOW", "1");
+    Poco::Environment::set("LOK_VIEW_CALLBACK", "1");
+
     int status;
 #ifdef __linux
     char *locale = setlocale(LC_ALL, NULL);
@@ -1233,7 +1238,7 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
 
     if (access(cache.c_str(), R_OK | W_OK | X_OK) != 0)
     {
-        std::cout << "Unable to access " << cache <<
+        std::cout << Util::logPrefix() << "Unable to access " << cache <<
             ", please make sure it exists, and has write permission for this user." << std::endl;
         return Application::EXIT_UNAVAILABLE;
     }
@@ -1266,6 +1271,12 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
             filePID << Process::id();
     }
 
+    if (!File(FIFO_FILE).exists() && mkfifo(FIFO_FILE.c_str(), 0666) == -1)
+    {
+        std::cout << Util::logPrefix() << "Fail to create pipe FIFO" << std::endl;
+        return Application::EXIT_UNAVAILABLE;
+    }
+
     _namedMutexLOOL.lock();
 
     startupDesktop(1);
@@ -1362,6 +1373,7 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
     // wait broker process finish
     waitpid(-1, &status, WUNTRACED);
 
+    std::cout << Util::logPrefix() << "loolwsd finished OK!" << std::endl;
     return Application::EXIT_OK;
 }
 
diff --git a/loolwsd/LOOLWSD.hpp b/loolwsd/LOOLWSD.hpp
index 62e4c32..9771e4c 100644
--- a/loolwsd/LOOLWSD.hpp
+++ b/loolwsd/LOOLWSD.hpp
@@ -33,6 +33,7 @@ public:
     static int portNumber;
     static int timeoutCounter;
     static int _numPreSpawnedChildren;
+    static int writerBroker;
     static bool doTest;
     static bool volatile isShutDown;
     static std::string cache;
@@ -53,6 +54,7 @@ public:
     static const int POLL_TIMEOUT = 1000000;
     static const std::string CHILD_URI;
     static const std::string PIDLOG;
+    static const std::string FIFO_FILE;
     static const std::string LOKIT_PIDLOG;
 
 protected:
diff --git a/loolwsd/MasterProcessSession.cpp b/loolwsd/MasterProcessSession.cpp
index ac39c92..21f8caf 100644
--- a/loolwsd/MasterProcessSession.cpp
+++ b/loolwsd/MasterProcessSession.cpp
@@ -373,6 +373,10 @@ bool MasterProcessSession::loadDocument(const char* /*buffer*/, int /*length*/,
     try
     {
         URI aUri(_docURL);
+
+        // request new URL session
+        std::string aMessage = "request " + std::to_string(Thread::currentTid()) + " " + _docURL + "\r\n";
+        Util::writeFIFO(LOOLWSD::writerBroker, aMessage.c_str(), aMessage.length());
     }
     catch(Poco::SyntaxException&)
     {
@@ -598,7 +602,7 @@ void MasterProcessSession::dispatchChild()
 
 #ifdef __linux
         Application::instance().logger().information(Util::logPrefix() + "Linking " + aSrcFile.toString() + " to " + aDstFile.toString());
-        if (link(aSrcFile.toString().c_str(), aDstFile.toString().c_str()) == -1)
+        if (!File(aDstFile).exists() && link(aSrcFile.toString().c_str(), aDstFile.toString().c_str()) == -1)
         {
             // Failed
             Application::instance().logger().error( Util::logPrefix() +


More information about the Libreoffice-commits mailing list