[Libreoffice-commits] online.git: wsd/AdminModel.cpp wsd/AdminModel.hpp

Michael Meeks (via logerrit) logerrit at kemper.freedesktop.org
Mon May 4 09:17:01 UTC 2020


 wsd/AdminModel.cpp |   24 +++++++++++++-----------
 wsd/AdminModel.hpp |    2 ++
 2 files changed, 15 insertions(+), 11 deletions(-)

New commits:
commit afcca641e560d7beef7331af5d3204ec19f3da1c
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Mon May 4 09:11:00 2020 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon May 4 11:16:44 2020 +0200

    AdminModel::removeDocument: fix the other key issue by code sharing.
    
    Change-Id: I0f841b0b54f44827f397e57e22c0d845cfb121ba
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/93401
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/wsd/AdminModel.cpp b/wsd/AdminModel.cpp
index dca1c7bc0..9579a4e51 100644
--- a/wsd/AdminModel.cpp
+++ b/wsd/AdminModel.cpp
@@ -543,6 +543,17 @@ void AdminModel::addDocument(const std::string& docKey, pid_t pid,
     notify(oss.str());
 }
 
+void AdminModel::doRemove(std::map<std::string, std::unique_ptr<Document>>::iterator &docIt)
+{
+    std::unique_ptr<Document> doc;
+    std::swap(doc, docIt->second);
+    std::string docItKey = docIt->first;
+    _documents.erase(docIt);
+    _expiredDocuments.emplace(docItKey + std::to_string(std::chrono::duration_cast<std::chrono::nanoseconds>(
+                                                            std::chrono::steady_clock::now().time_since_epoch()).count()),
+                              std::move(doc));
+}
+
 void AdminModel::removeDocument(const std::string& docKey, const std::string& sessionId)
 {
     assertCorrectThread();
@@ -561,13 +572,7 @@ void AdminModel::removeDocument(const std::string& docKey, const std::string& se
         // of documents open and close, to be able to give a detailed summary
         // to the admin console with views.
         if (docIt->second->expireView(sessionId) == 0)
-        {
-            std::unique_ptr<Document> doc;
-            std::swap(doc, docIt->second);
-            std::string docItKey = docIt->first;
-            _documents.erase(docIt);
-            _expiredDocuments.emplace(docItKey + std::to_string(std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::steady_clock::now().time_since_epoch()).count()), std::move(doc));
-        }
+            doRemove(docIt);
     }
 }
 
@@ -591,10 +596,7 @@ void AdminModel::removeDocument(const std::string& docKey)
         }
 
         LOG_DBG("Removed admin document [" << docKey << "].");
-        std::unique_ptr<Document> doc;
-        std::swap(doc, docIt->second);
-        _documents.erase(docIt);
-        _expiredDocuments.emplace(docIt->first + std::to_string(std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::steady_clock::now().time_since_epoch()).count()), std::move(doc));
+        doRemove(docIt);
     }
 }
 
diff --git a/wsd/AdminModel.hpp b/wsd/AdminModel.hpp
index 63f61d5c9..8faceb5f3 100644
--- a/wsd/AdminModel.hpp
+++ b/wsd/AdminModel.hpp
@@ -341,6 +341,8 @@ public:
     static int getPidsFromProcName(const std::regex& procNameRegEx, std::vector<int> *pids);
 
 private:
+    void doRemove(std::map<std::string, std::unique_ptr<Document>>::iterator &docIt);
+
     std::string getMemStats();
 
     std::string getSentActivity();


More information about the Libreoffice-commits mailing list