[Libreoffice-commits] online.git: loolwsd/ChildSession.cpp loolwsd/ClientSession.cpp loolwsd/ClientSession.hpp loolwsd/DocumentBroker.cpp loolwsd/DocumentBroker.hpp loolwsd/PrisonerSession.cpp loolwsd/protocol.txt loolwsd/test

Miklos Vajna vmiklos at collabora.co.uk
Tue Sep 20 07:47:49 UTC 2016


 loolwsd/ChildSession.cpp    |   14 +-------------
 loolwsd/ClientSession.cpp   |   15 +--------------
 loolwsd/ClientSession.hpp   |    1 -
 loolwsd/DocumentBroker.cpp  |   33 ---------------------------------
 loolwsd/DocumentBroker.hpp  |    5 -----
 loolwsd/PrisonerSession.cpp |    7 +------
 loolwsd/protocol.txt        |   18 ------------------
 loolwsd/test/httpwstest.cpp |   10 +---------
 8 files changed, 4 insertions(+), 99 deletions(-)

New commits:
commit ef4ca0507a81a58786f15841d11830e90d4d7644
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Sep 20 09:46:39 2016 +0200

    loolwsd: remove takeedit and editlock commands
    
    As a follow-up to commit 77e219ceff24dd4a566dfdf4f82a6929fe9a563e
    (loleaflet: Kill editlock code, completely, 2016-09-20).
    
    Change-Id: I48a58bb738c0939f99d220eca7a8fd3f4c3debe4

diff --git a/loolwsd/ChildSession.cpp b/loolwsd/ChildSession.cpp
index 17cf397..a8a1a26 100644
--- a/loolwsd/ChildSession.cpp
+++ b/loolwsd/ChildSession.cpp
@@ -199,8 +199,7 @@ bool ChildSession::_handleInput(const char *buffer, int length)
                tokens[0] == "resetselection" ||
                tokens[0] == "saveas" ||
                tokens[0] == "useractive" ||
-               tokens[0] == "userinactive" ||
-               tokens[0] == "editlock:");
+               tokens[0] == "userinactive");
 
         if (tokens[0] == "clientzoom")
         {
@@ -266,17 +265,6 @@ bool ChildSession::_handleInput(const char *buffer, int length)
         {
             setIsActive(false);
         }
-        else if (tokens[0] == "editlock:")
-        {
-            // Nothing for us to do but to let the
-            // client know about the edit lock state.
-            // Yes, this is echoed back because it's better
-            // to do this on each child's queue and thread
-            // than for WSD to potentially stall while notifying
-            // each client with the edit lock state.
-            Log::trace("Echoing back [" + firstLine + "].");
-            return sendTextFrame(firstLine);
-        }
         else
         {
             assert(false && "Unknown command token.");
diff --git a/loolwsd/ClientSession.cpp b/loolwsd/ClientSession.cpp
index b493c58..6465519 100644
--- a/loolwsd/ClientSession.cpp
+++ b/loolwsd/ClientSession.cpp
@@ -93,12 +93,7 @@ bool ClientSession::_handleInput(const char *buffer, int length)
         return true;
     }
 
-    if (!isReadOnly() && tokens[0] == "takeedit")
-    {
-        _docBroker->takeEditLock(getId());
-        return true;
-    }
-    else if (tokens[0] == "load")
+    if (tokens[0] == "load")
     {
         if (_docURL != "")
         {
@@ -257,14 +252,6 @@ bool ClientSession::getStatus(const char *buffer, int length)
     return forwardToPeer(_peer, buffer, length, false);
 }
 
-bool ClientSession::setEditLock()
-{
-    // Update the sate and forward to child.
-    const std::string msg = "editlock: 1";
-    Log::debug("Forwarding [" + msg + "] to set editlock to 1.");
-    return forwardToPeer(_peer, msg.data(), msg.size(), false);
-}
-
 bool ClientSession::getCommandValues(const char *buffer, int length, StringTokenizer& tokens)
 {
     std::string command;
diff --git a/loolwsd/ClientSession.hpp b/loolwsd/ClientSession.hpp
index a285efe..237fe13 100644
--- a/loolwsd/ClientSession.hpp
+++ b/loolwsd/ClientSession.hpp
@@ -27,7 +27,6 @@ public:
 
     virtual ~ClientSession();
 
-    bool setEditLock();
     bool isReadOnly() const { return _isReadOnly; }
 
     void setPeer(const std::shared_ptr<PrisonerSession>& peer) { _peer = peer; }
diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp
index 5ef3f60..6a1c037 100644
--- a/loolwsd/DocumentBroker.cpp
+++ b/loolwsd/DocumentBroker.cpp
@@ -112,7 +112,6 @@ DocumentBroker::DocumentBroker() :
     _cursorHeight(0),
     _isLoaded(false),
     _isModified(false),
-    _isEditLockHeld(false),
     _tileVersion(0)
 {
     Log::info("Empty DocumentBroker (marked to destroy) created.");
@@ -136,7 +135,6 @@ DocumentBroker::DocumentBroker(const Poco::URI& uriPublic,
     _cursorHeight(0),
     _isLoaded(false),
     _isModified(false),
-    _isEditLockHeld(false),
     _tileVersion(0)
 {
     assert(!_docKey.empty());
@@ -381,18 +379,6 @@ std::string DocumentBroker::getJailRoot() const
     return Poco::Path(_childRoot, _jailId).toString();
 }
 
-void DocumentBroker::takeEditLock(const std::string& id)
-{
-    Log::debug("Session " + id + " taking the editing lock.");
-    std::lock_guard<std::mutex> lock(_mutex);
-
-    // Forward to all children.
-    for (auto& it: _sessions)
-    {
-        it.second->setEditLock();
-    }
-}
-
 size_t DocumentBroker::addSession(std::shared_ptr<ClientSession>& session)
 {
     const auto id = session->getId();
@@ -414,11 +400,6 @@ size_t DocumentBroker::addSession(std::shared_ptr<ClientSession>& session)
     {
         Log::debug("Adding a readonly session [" + id + "]");
     }
-    else if (!_isEditLockHeld)
-    {
-        Log::debug("Giving editing lock to the first editable session [" + id + "].");
-        _isEditLockHeld = true;
-    }
 
     // Below values are recalculated when startDestroy() is called (before destroying the
     // document). It is safe to reset their values to their defaults whenever a new session is added
@@ -453,20 +434,6 @@ size_t DocumentBroker::removeSession(const std::string& id)
     if (it != _sessions.end())
     {
         _sessions.erase(it);
-
-        // pass the edit lock to first non-readonly session in map
-        bool editLockGiven = false;
-        for (auto& session: _sessions)
-        {
-            if (!session.second->isReadOnly())
-            {
-                session.second->setEditLock();
-                editLockGiven = true;
-                break;
-            }
-        }
-
-        _isEditLockHeld = editLockGiven;
     }
 
     return _sessions.size();
diff --git a/loolwsd/DocumentBroker.hpp b/loolwsd/DocumentBroker.hpp
index 301f896..c8a46b7 100644
--- a/loolwsd/DocumentBroker.hpp
+++ b/loolwsd/DocumentBroker.hpp
@@ -194,10 +194,6 @@ public:
 
     std::string getJailRoot() const;
 
-    /// Ignore input events from all web socket sessions
-    /// except this one
-    void takeEditLock(const std::string& id);
-
     /// Add a new session. Returns the new number of sessions.
     size_t addSession(std::shared_ptr<ClientSession>& session);
     /// Connect a prison session to its client peer.
@@ -264,7 +260,6 @@ private:
     mutable std::mutex _mutex;
     std::condition_variable _saveCV;
     std::mutex _saveMutex;
-    std::atomic<bool> _isEditLockHeld;
 
     /// Versioning is used to prevent races between
     /// painting and invalidation.
diff --git a/loolwsd/PrisonerSession.cpp b/loolwsd/PrisonerSession.cpp
index 5a924bc..3844974 100644
--- a/loolwsd/PrisonerSession.cpp
+++ b/loolwsd/PrisonerSession.cpp
@@ -185,12 +185,7 @@ bool PrisonerSession::_handleInput(const char *buffer, int length)
             _docBroker->setLoaded();
 
             // Forward the status response to the client.
-            forwardToPeer(_peer, buffer, length, isBinary);
-
-            // And let clients know if they hold the edit lock.
-            std::string message = "editlock: 1";
-            Log::debug("Forwarding [" + message + "] in response to status.");
-            return forwardToPeer(_peer, message.c_str(), message.size(), isBinary);
+            return forwardToPeer(_peer, buffer, length, isBinary);
         }
         else if (tokens[0] == "commandvalues:")
         {
diff --git a/loolwsd/protocol.txt b/loolwsd/protocol.txt
index 3639484..bf1a8ea 100644
--- a/loolwsd/protocol.txt
+++ b/loolwsd/protocol.txt
@@ -143,13 +143,6 @@ clientvisiblearea x=<x> y=<y> width=<width> height=<height>
 
     Invokes lok::Document::setClientVisibleArea().
 
-takeedit
-
-    Request for an edit lock. If successful, client will receive an 'editlock: 1'
-    message meaning editlock is granted.
-
-    See 'editlock:' message in server -> client.
-
 useractive
 
     Sent when the user regains focus or clicks within the active area to
@@ -210,17 +203,6 @@ downloadas: jail=<jail directory> dir=<a tmp dir> name=<name> port=<port>
     The client should then request http://server:port/jail/dir/name in order to download
     the document
 
-editlock: <1 or 0>
-
-    Informs the client of any change in ownership of edit lock. A value of '1'
-    means client can edit the document, and '0' means that client can only view
-    the document. This message always follows the 'status:' message after a
-    document is loaded, so that client has this information as soon as it loads
-    the document.
-
-    Note that only one client can have the editlock at a time and
-    others can only view.
-
 error: cmd=<command> kind=<kind> [code=<error_code>]
 <freeErrorText>
 
diff --git a/loolwsd/test/httpwstest.cpp b/loolwsd/test/httpwstest.cpp
index bf4eee1..e1096da 100644
--- a/loolwsd/test/httpwstest.cpp
+++ b/loolwsd/test/httpwstest.cpp
@@ -361,12 +361,6 @@ void HTTPWSTest::loadDoc(const std::string& documentURL)
                         // Might be too strict, consider something flexible instread.
                         CPPUNIT_ASSERT_EQUAL(std::string("type=text parts=1 current=0 width=12808 height=16408 viewid=0"), status);
                     }
-                    else if (msg.find("editlock") == 0)
-                    {
-                        // First session always gets the lock.
-                        CPPUNIT_ASSERT_EQUAL(std::string("editlock: 1"), msg);
-                        return false;
-                    }
 
                     return true;
                 });
@@ -439,8 +433,7 @@ void HTTPWSTest::testBadLoad()
 
                 // For some reason the server claims a client has the 'edit lock' even if no
                 // document has been successfully loaded
-                if (LOOLProtocol::getFirstToken(buffer, n) == "editlock:" ||
-                    LOOLProtocol::getFirstToken(buffer, n) == "statusindicator:")
+                if (LOOLProtocol::getFirstToken(buffer, n) == "statusindicator:")
                     continue;
 
                 CPPUNIT_ASSERT_EQUAL(std::string("error: cmd=status kind=nodocloaded"), line);
@@ -1019,7 +1012,6 @@ void HTTPWSTest::testInactiveClient()
                     CPPUNIT_ASSERT_MESSAGE("unexpected message: " + msg,
                                             token == "addview:" ||
                                             token == "cursorvisible:" ||
-                                            token == "editlock:" ||
                                             token == "graphicselection:" ||
                                             token == "graphicviewselection:" ||
                                             token == "invalidatecursor:" ||


More information about the Libreoffice-commits mailing list