[Libreoffice-commits] online.git: Branch 'private/hcvcastro/forking' - loolwsd/LOOLBroker.cpp

Henry Castro hcastro at collabora.com
Sun Aug 2 18:33:11 PDT 2015


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

New commits:
commit 71d75571c3b758b584cafc522e3309a7d37b0f9b
Author: Henry Castro <hcastro at collabora.com>
Date:   Sun Aug 2 21:32:04 2015 -0400

    loolwsd: test case #1
    
    lok_init_2 is initialized in loolbroker process.

diff --git a/loolwsd/LOOLBroker.cpp b/loolwsd/LOOLBroker.cpp
index c0a09f0..2ba22f4 100644
--- a/loolwsd/LOOLBroker.cpp
+++ b/loolwsd/LOOLBroker.cpp
@@ -21,6 +21,10 @@
 #include <Poco/Process.h>
 #include <Poco/Thread.h>
 #include <Poco/SharedMemory.h>
+#include <Poco/NamedMutex.h>
+
+#define LOK_USE_UNSTABLE_API
+#include <LibreOfficeKit/LibreOfficeKitInit.h>
 
 #include "Util.hpp"
 
@@ -239,6 +243,7 @@ static void startupLibreOfficeKit(int nLOKits, std::string loSubPath, Poco::UInt
 }
 
 static int timeoutCounter = 0;
+Poco::NamedMutex _namedMutexLOOL("loolwsd");
 
 // Broker process
 int main(int argc, char** argv)
@@ -399,7 +404,21 @@ int main(int argc, char** argv)
         Thread::sleep(std::stoul(std::getenv("SLEEPFORDEBUGGER")) * 1000);
     }
 
-    void* dlOffice = dlopen(Path("/"+ loSubPath + "/program", LIB_SOFFICEAPP).toString().c_str(), RTLD_NOW);
+    _namedMutexLOOL.lock();
+#ifdef __APPLE__
+    LibreOfficeKit *loKit(lok_init_2(("/" + loSubPath + "/Frameworks").c_str(), "file:///user"));
+#else
+    LibreOfficeKit *loKit(lok_init_2(("/" + loSubPath + "/program").c_str(), "file:///user"));
+#endif
+
+    if (!loKit)
+    {
+        std::cout << Util::logPrefix() + "LibreOfficeKit initialization failed" << std::endl;
+        exit(-1);
+    }
+    _namedMutexLOOL.unlock();
+
+    /*void* dlOffice = dlopen(Path("/"+ loSubPath + "/program", LIB_SOFFICEAPP).toString().c_str(), RTLD_NOW);
     if ( !dlOffice )
     {
         std::cout << Util::logPrefix() << " Failed to load library :" << LIB_SOFFICEAPP << std::endl;
@@ -425,7 +444,7 @@ int main(int argc, char** argv)
     {
         std::cout << Util::logPrefix() << " Failed to load library :" << LIB_SDLO << std::endl;
         exit(-1);
-    }
+    }*/
 
     startupLibreOfficeKit(_numPreSpawnedChildren, loSubPath, _childId);
 
@@ -486,10 +505,10 @@ int main(int argc, char** argv)
         Process::requestTermination(i.first);
     }
     
-    dlclose(dlOffice);
-    dlclose(dlSC);
-    dlclose(dlSW);
-    dlclose(dlSD);
+    //dlclose(dlOffice);
+    //dlclose(dlSC);
+    //dlclose(dlSW);
+    //dlclose(dlSD);
 
     std::cout << Util::logPrefix() << "loolbroker finished OK!" << std::endl;
     return 0;


More information about the Libreoffice-commits mailing list