[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-1-9' - 5 commits - loolwsd/ClientSession.hpp loolwsd/common loolwsd/DocumentBroker.cpp loolwsd/LOOLWSD.cpp loolwsd/Makefile.am

Andras Timar andras.timar at collabora.com
Wed Nov 23 07:29:05 UTC 2016


 loolwsd/ClientSession.hpp   |    2 +-
 loolwsd/DocumentBroker.cpp  |    2 +-
 loolwsd/LOOLWSD.cpp         |   30 ++++++++++++++++++++++--------
 loolwsd/Makefile.am         |    1 +
 loolwsd/common/FileUtil.cpp |   23 +++++++++++++----------
 loolwsd/common/FileUtil.hpp |    2 +-
 6 files changed, 39 insertions(+), 21 deletions(-)

New commits:
commit eb31030f431f6d4ab4e9c5b48bcb8aaffe9ea792
Author: Andras Timar <andras.timar at collabora.com>
Date:   Wed Nov 23 08:20:55 2016 +0100

    loolwsd: add LibreOfficeKit.hxx to tarball

diff --git a/loolwsd/Makefile.am b/loolwsd/Makefile.am
index 865d3e7..6df3998 100644
--- a/loolwsd/Makefile.am
+++ b/loolwsd/Makefile.am
@@ -120,6 +120,7 @@ noinst_HEADERS = Admin.hpp \
                  UserMessages.hpp \
                  Util.hpp \
                  bundled/include/LibreOfficeKit/LibreOfficeKit.h \
+                 bundled/include/LibreOfficeKit/LibreOfficeKit.hxx \
                  bundled/include/LibreOfficeKit/LibreOfficeKitEnums.h \
                  bundled/include/LibreOfficeKit/LibreOfficeKitInit.h \
                  bundled/include/LibreOfficeKit/LibreOfficeKitTypes.h \
commit 4b04119a2e2def6af3adaa4941bf5211d3392d86
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Wed Nov 23 11:31:39 2016 +0530

    loolwsd: unused param
    
    Change-Id: If74ccb603337971076e93c03ac28a9d8b5115f61
    (cherry picked from commit 96952ceafd4de83093b4aed78320f673d599fda8)

diff --git a/loolwsd/ClientSession.hpp b/loolwsd/ClientSession.hpp
index 586b438..a8f2e51 100644
--- a/loolwsd/ClientSession.hpp
+++ b/loolwsd/ClientSession.hpp
@@ -40,7 +40,7 @@ public:
     const std::string getUserId() const { return _userId; }
     void setUserId(const std::string& userId) { _userId = userId; }
     void setUserName(const std::string& userName) { _userName = userName; }
-    void setDocumentOwner(const bool documentOwner) { _isDocumentOwner = isDocumentOwner; }
+    void setDocumentOwner(const bool documentOwner) { _isDocumentOwner = documentOwner; }
     bool isDocumentOwner() const { return _isDocumentOwner; }
 
     /**
commit f56ee6bd70505f5a710918a1b14ab2bc8f3f37f3
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Wed Nov 23 11:15:05 2016 +0530

    loolwsd: -Werror=shadow
    
    Change-Id: If346299e76e50eabde65a4c3aab7b529a8c09148
    (cherry picked from commit 81e4b052beda012219a5990dfed222f518b899a3)

diff --git a/loolwsd/ClientSession.hpp b/loolwsd/ClientSession.hpp
index 5349caa..586b438 100644
--- a/loolwsd/ClientSession.hpp
+++ b/loolwsd/ClientSession.hpp
@@ -40,7 +40,7 @@ public:
     const std::string getUserId() const { return _userId; }
     void setUserId(const std::string& userId) { _userId = userId; }
     void setUserName(const std::string& userName) { _userName = userName; }
-    void setDocumentOwner(const bool isDocumentOwner) { _isDocumentOwner = isDocumentOwner; }
+    void setDocumentOwner(const bool documentOwner) { _isDocumentOwner = isDocumentOwner; }
     bool isDocumentOwner() const { return _isDocumentOwner; }
 
     /**
commit d5393326957048b193935e40f658e345ed1c4789
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Tue Nov 22 22:06:50 2016 -0500

    loolwsd: avoid deadlocking when alerting all users
    
    Alerting all users is done from different contexts.
    One such is when loading a new document.
    
    Since both alerting all users and loading documents
    need to hold the same lock, this would deadlock.
    
    The solution here is to differentiate between
    external alerts and internal ones (to WSD).
    
    The internal one expects to be invoked while holding
    the lock, while the external one always takes the lock.
    
    Care should be taking when alerting from within WSD to
    avoid this deadlock.
    
    Change-Id: Idf0e952db1216a3d161f22c7da51af16701f685b
    Reviewed-on: https://gerrit.libreoffice.org/31102
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>
    (cherry picked from commit 51c88c5fb79c5db146a08f5ef2d9a4fe6d095caa)

diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 1f8644f..c253f51 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -228,6 +228,20 @@ void shutdownLimitReached(LOOLWebSocket& ws)
     }
 }
 
+/// Internal implementation to alert all clients
+/// connected to any document.
+void alertAllUsersInternal(const std::string& msg)
+{
+    Util::assertIsLocked(DocBrokersMutex);
+
+    LOG_INF("Alerting all users: [" << msg << "]");
+
+    for (auto& brokerIt : DocBrokers)
+    {
+        auto lock = brokerIt.second->getLock();
+        brokerIt.second->alertAllUsers(msg);
+    }
+}
 }
 
 /// Remove dead DocBrokers.
@@ -260,7 +274,13 @@ static void forkChildren(const int number)
 
     if (number > 0)
     {
-        FileUtil::checkDiskSpaceOnRegisteredFileSystems();
+        const std::string fs = FileUtil::checkDiskSpaceOnRegisteredFileSystems();
+        if (!fs.empty())
+        {
+            LOG_WRN("File system of " << fs << " dangerously low on disk space");
+            alertAllUsersInternal("error: cmd=internal kind=diskfull");
+        }
+
         const std::string aMessage = "spawn " + std::to_string(number) + "\n";
         LOG_DBG("MasterToForKit: " << aMessage.substr(0, aMessage.length() - 1));
 
@@ -2155,13 +2175,7 @@ void alertAllUsers(const std::string& msg)
 {
     std::lock_guard<std::mutex> DocBrokersLock(DocBrokersMutex);
 
-    LOG_INF("Alerting all users: [" << msg << "]");
-
-    for (auto& brokerIt : DocBrokers)
-    {
-        auto lock = brokerIt.second->getLock();
-        brokerIt.second->alertAllUsers(msg);
-    }
+    alertAllUsersInternal(msg);
 }
 
 }
diff --git a/loolwsd/common/FileUtil.cpp b/loolwsd/common/FileUtil.cpp
index 19e8e00..ea55548 100644
--- a/loolwsd/common/FileUtil.cpp
+++ b/loolwsd/common/FileUtil.cpp
@@ -163,7 +163,7 @@ namespace FileUtil
         }
     }
 
-    void checkDiskSpaceOnRegisteredFileSystems()
+    std::string checkDiskSpaceOnRegisteredFileSystems()
     {
         std::lock_guard<std::mutex> lock(fsmutex);
 
@@ -172,7 +172,7 @@ namespace FileUtil
 
         // Don't check more often that once a minute
         if (std::chrono::duration_cast<std::chrono::seconds>(now - lastCheck).count() < 60)
-            return;
+            return std::string();
 
         lastCheck = now;
 
@@ -180,10 +180,11 @@ namespace FileUtil
         {
             if (!checkDiskSpace(i.path))
             {
-                alertAllUsersAndLog("File system of " + i.path + " dangerously low on disk space", "internal", "diskfull");
-                break;
+                return i.path;
             }
         }
+
+        return std::string();
     }
 
     bool checkDiskSpace(const std::string& path)
diff --git a/loolwsd/common/FileUtil.hpp b/loolwsd/common/FileUtil.hpp
index aa6bba6..e0e9487 100644
--- a/loolwsd/common/FileUtil.hpp
+++ b/loolwsd/common/FileUtil.hpp
@@ -51,7 +51,7 @@ namespace FileUtil
     // Perform the check. If the free space on any of the registered file systems is below 5%, call
     // 'alertAllUsers("internal", "diskfull")'. The check will be made no more often than once a
     // minute.
-    void checkDiskSpaceOnRegisteredFileSystems();
+    std::string checkDiskSpaceOnRegisteredFileSystems();
 
     // Check disk space on a specific file system, the one where 'path' is located. This does not
     // add that file system to the list used by 'registerFileSystemForDiskSpaceChecks'. If the free
commit a3f6ad13a92dafd846478363375fed7e70867a96
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Tue Nov 22 22:06:05 2016 -0500

    loolwsd: minor cleanups
    
    Change-Id: I9f75b991e6f4bedcffe1dd86f2a5cff2a606bf89
    Reviewed-on: https://gerrit.libreoffice.org/31101
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>
    (cherry picked from commit 5d4aa362404eff5c5ed12ffcce2cefa8e5be409d)

diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp
index 949cec5..9fa56ae 100644
--- a/loolwsd/DocumentBroker.cpp
+++ b/loolwsd/DocumentBroker.cpp
@@ -598,7 +598,7 @@ void DocumentBroker::alertAllUsers(const std::string& msg)
 {
     Util::assertIsLocked(_mutex);
 
-    LOG_DBG("Alerting all users: " << msg);
+    LOG_DBG("Alerting all users of [" << _docKey << "]: " << msg);
     for (auto& it : _sessions)
     {
         try
diff --git a/loolwsd/common/FileUtil.cpp b/loolwsd/common/FileUtil.cpp
index 461513e..19e8e00 100644
--- a/loolwsd/common/FileUtil.cpp
+++ b/loolwsd/common/FileUtil.cpp
@@ -148,17 +148,18 @@ namespace FileUtil
     {
         std::lock_guard<std::mutex> lock(fsmutex);
 
-        if (path != "")
+        if (!path.empty())
         {
             std::string dirPath = path;
             std::string::size_type lastSlash = dirPath.rfind('/');
             assert(lastSlash != std::string::npos);
-            dirPath = dirPath.substr(0, lastSlash + 1) + ".";
+            dirPath = dirPath.substr(0, lastSlash + 1) + '.';
 
             struct stat s;
-            if (stat(dirPath.c_str(), &s) == -1)
-                return;
-            filesystems.insert(fs(dirPath, s.st_dev));
+            if (stat(dirPath.c_str(), &s) == 0)
+            {
+                filesystems.insert(fs(dirPath, s.st_dev));
+            }
         }
     }
 
@@ -187,7 +188,8 @@ namespace FileUtil
 
     bool checkDiskSpace(const std::string& path)
     {
-        assert(path != "");
+        assert(!path.empty());
+
         struct statfs sfs;
         if (statfs(path.c_str(), &sfs) == -1)
             return true;


More information about the Libreoffice-commits mailing list