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

Ashod Nakashian ashod.nakashian at collabora.co.uk
Wed May 4 10:34:05 UTC 2016


 loolwsd/DocumentBroker.cpp |    1 +
 loolwsd/DocumentBroker.hpp |   21 ++++++++++++++++++++-
 loolwsd/LOOLWSD.cpp        |    1 +
 3 files changed, 22 insertions(+), 1 deletion(-)

New commits:
commit ff0d4a3a9119de9bd65ef03c7ae32ba54d532b14
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Mon May 2 07:21:30 2016 -0400

    Revert "Revert "loolwsd: establish communication with...
    
    ...child from DocumentBroker""
    
    Restore the communication with child from DocumentBroker.
    
    This reverts commit 20ab6e8ae70254557e5bff242dbb9d5861fa946c.
    
    Change-Id: I248bededff7074d8fb482b2cdd172048f80c02b2
    Reviewed-on: https://gerrit.libreoffice.org/24639
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp
index 5dbdf46..0cc1975 100644
--- a/loolwsd/DocumentBroker.cpp
+++ b/loolwsd/DocumentBroker.cpp
@@ -79,6 +79,7 @@ DocumentBroker::DocumentBroker(const Poco::URI& uriPublic,
 {
     assert(!_docKey.empty());
     assert(!_childRoot.empty());
+
     Log::info("DocumentBroker [" + _uriPublic.toString() + "] created. DocKey: [" + _docKey + "]");
 }
 
diff --git a/loolwsd/DocumentBroker.hpp b/loolwsd/DocumentBroker.hpp
index 965ced3..49b5d32 100644
--- a/loolwsd/DocumentBroker.hpp
+++ b/loolwsd/DocumentBroker.hpp
@@ -17,6 +17,7 @@
 #include <memory>
 #include <mutex>
 #include <string>
+#include <thread>
 #include <map>
 
 #include <Poco/URI.h>
@@ -39,8 +40,10 @@ public:
     /// @param ws is the control WebSocket to the child.
     ChildProcess(const Poco::Process::PID pid, const std::shared_ptr<Poco::Net::WebSocket>& ws) :
         _pid(pid),
-        _ws(ws)
+        _ws(ws),
+        _stop(false)
     {
+        _thread = std::thread([this]() { this->socketProcessor(); });
         Log::info("ChildProcess ctor [" + std::to_string(_pid) + "].");
     }
 
@@ -57,8 +60,16 @@ public:
         }
     }
 
+    void setDocumentBroker(const std::shared_ptr<DocumentBroker>& docBroker)
+    {
+        _docBroker = docBroker;
+    }
+
     void close(const bool rude)
     {
+        _stop = true;
+        IoUtil::shutdownWebSocket(_ws);
+        _thread.join();
         _ws.reset();
         if (_pid != -1)
         {
@@ -95,8 +106,14 @@ public:
     }
 
 private:
+    void socketProcessor();
+
+private:
     Poco::Process::PID _pid;
     std::shared_ptr<Poco::Net::WebSocket> _ws;
+    std::weak_ptr<DocumentBroker> _docBroker;
+    std::thread _thread;
+    std::atomic<bool> _stop;
 };
 
 /// DocumentBroker is responsible for setting up a document
@@ -184,6 +201,8 @@ public:
     bool canDestroy();
     bool isMarkedToDestroy() const { return _markToDestroy; }
 
+    bool handleInput(const std::vector<char>& payload);
+
 private:
 
     /// Sends the .uno:Save command to LoKit.
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index d4d8dcc..5af6964 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -558,6 +558,7 @@ private:
             // Set one we just created.
             Log::debug("New DocumentBroker for docKey [" + docKey + "].");
             docBroker = std::make_shared<DocumentBroker>(uriPublic, docKey, LOOLWSD::ChildRoot, child);
+            child->setDocumentBroker(docBroker);
         }
 
         // Validate the broker.


More information about the Libreoffice-commits mailing list