loolwsd/LOOLWSD.cpp |   14 ++++++++++++++
 loolwsd/LOOLWSD.hpp |    2 ++
 2 files changed, 16 insertions(+)

New commits:
commit d621a49ffee698473283d56d88d00651b62ae116
Author: Henry Castro <[email protected]>
Date:   Sun Sep 27 18:21:15 2015 -0400

    loolwsd: create writer pipe to send messages to broker process

diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 0684285..1010efa 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -424,6 +424,7 @@ public:
 
 int LOOLWSD::portNumber = DEFAULT_CLIENT_PORT_NUMBER;
 int LOOLWSD::timeoutCounter = 0;
+int LOOLWSD::writerBroker = -1;
 std::string LOOLWSD::cache = LOOLWSD_CACHEDIR;
 std::string LOOLWSD::sysTemplate;
 std::string LOOLWSD::loTemplate;
@@ -443,6 +444,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() :
     _childId(0)
@@ -640,6 +642,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;
+    }
+
     std::unique_lock<std::mutex> rngLock(_rngMutex);
     _childId = (((Poco::UInt64)_rng.next()) << 32) | _rng.next() | 1;
     rngLock.unlock();
@@ -669,6 +677,12 @@ int LOOLWSD::main(const std::vector<std::string>& args)
 
     srv2.start();
 
+    if ( (writerBroker = open(FIFO_FILE.c_str(), O_WRONLY) ) < 0 )
+    {
+        std::cout << Util::logPrefix() << "Pipe opened for writing" << 
strerror(errno) << std::endl;
+        return Application::EXIT_UNAVAILABLE;
+    }
+
     _namedMutexLOOL.unlock();
 
     while (MasterProcessSession::_childProcesses.size() > 0)
diff --git a/loolwsd/LOOLWSD.hpp b/loolwsd/LOOLWSD.hpp
index 4470968..6e58e4d 100644
--- a/loolwsd/LOOLWSD.hpp
+++ b/loolwsd/LOOLWSD.hpp
@@ -31,6 +31,7 @@ public:
     // statics
     static int portNumber;
     static int timeoutCounter;
+    static int writerBroker;
     static bool doTest;
     static std::string cache;
     static std::string sysTemplate;
@@ -45,6 +46,7 @@ public:
     static const int MAINTENANCE_INTERVAL = 1;
     static const std::string CHILD_URI;
     static const std::string PIDLOG;
+    static const std::string FIFO_FILE;
     static const std::string LOKIT_PIDLOG;
     static Poco::NamedMutex _namedMutexLOOL;
 
_______________________________________________
Libreoffice-commits mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to