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

2020-05-02 Thread Michael Meeks (via logerrit)
 wsd/DocumentBroker.cpp |2 +-
 wsd/LOOLWSD.cpp|7 ++-
 wsd/LOOLWSD.hpp|8 ++--
 3 files changed, 5 insertions(+), 12 deletions(-)

New commits:
commit fdd4b4f63ddd16679a5a7035aa14d6e02fd57fdd
Author: Michael Meeks 
AuthorDate: Sat May 2 19:14:05 2020 +0100
Commit: Michael Meeks 
CommitDate: Sat May 2 21:31:25 2020 +0200

mobile: remove a few conditionals.

Change-Id: I5f306904b0b0533290d5533bbc3452217689eaec
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/93324
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index b6defa9d5..801343c63 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -228,7 +228,7 @@ void DocumentBroker::pollThread()
 do
 {
 static const int timeoutMs = COMMAND_TIMEOUT_MS * 5;
-_childProcess = getNewChild_Blocks();
+_childProcess = getNewChild_Blocks(getPublicUri().getPath());
 if (_childProcess ||
 
std::chrono::duration_cast(std::chrono::steady_clock::now()
 -
   
_threadStart).count() > timeoutMs)
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index f4812ff30..dbe119067 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -491,17 +491,14 @@ static size_t addNewChild(const 
std::shared_ptr& child)
 std::mutex LOOLWSD::lokit_main_mutex;
 #endif
 
-std::shared_ptr getNewChild_Blocks(
-#if MOBILEAPP
- const std::string& uri
-#endif
- )
+std::shared_ptr getNewChild_Blocks(const std::string& uri)
 {
 std::unique_lock lock(NewChildrenMutex);
 
 const auto startTime = std::chrono::steady_clock::now();
 
 #if !MOBILEAPP
+(void)uri;
 LOG_DBG("getNewChild: Rebalancing children.");
 int numPreSpawn = LOOLWSD::NumPreSpawnedChildren;
 ++numPreSpawn; // Replace the one we'll dispatch just now.
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index f2f7e0abc..dc0a68e06 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -32,15 +32,11 @@ class TraceFileWriter;
 class DocumentBroker;
 class ClipboardCache;
 
-std::shared_ptr getNewChild_Blocks(
-#if MOBILEAPP
- const std::string& uri
-#endif
- );
+std::shared_ptr getNewChild_Blocks(const std::string& uri);
+
 // A WSProcess object in the WSD process represents a descendant process, 
either the direct child
 // process FORKIT or a grandchild KIT process, with which the WSD process 
communicates through a
 // WebSocket.
-
 class WSProcess
 {
 public:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-04-16 Thread Ashod Nakashian (via logerrit)
 wsd/DocumentBroker.cpp |8 
 wsd/LOOLWSD.cpp|3 ++-
 wsd/LOOLWSD.hpp|4 ++--
 3 files changed, 8 insertions(+), 7 deletions(-)

New commits:
commit 40684c46872899f9ef705f267b8597007f3703d1
Author: Ashod Nakashian 
AuthorDate: Fri Apr 10 09:37:29 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Fri Apr 17 02:35:52 2020 +0200

wsd: const correctness and cosmetics

Change-Id: I46751dc0a6d7c693fd9ab371c1e9a12bac309611
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92098
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Ashod Nakashian 

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index bbe3b7937..8c342c4c3 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -75,7 +75,7 @@ void sendLastModificationTime(const std::shared_ptr& 
session,
 
 std::stringstream stream;
 stream << "lastmodtime: " << documentLastModifiedTime;
-std::string message = stream.str();
+const std::string message = stream.str();
 session->sendTextFrame(message);
 if (documentBroker)
 documentBroker->broadcastMessage(message);
@@ -982,7 +982,7 @@ bool DocumentBroker::saveToStorageInternal(const 
std::string& sessionId, bool su
 if (!isSaveAs && newFileModifiedTime == _lastFileModifiedTime && !isRename)
 {
 // Nothing to do.
-auto timeInSec = std::chrono::duration_cast
+const auto timeInSec = std::chrono::duration_cast
 (std::chrono::system_clock::now() 
- _lastFileModifiedTime);
 LOG_DBG("Skipping unnecessary saving to URI [" << uriAnonym << "] with 
docKey [" << _docKey <<
 "]. File last modified " << timeInSec.count() << " seconds 
ago.");
@@ -1140,7 +1140,7 @@ void DocumentBroker::refreshLock()
 {
 assertCorrectThread();
 
-std::string savingSessionId = getWriteableSessionId();
+const std::string savingSessionId = getWriteableSessionId();
 LOG_TRC("Refresh lock " << _lockCtx->_lockToken << " with session " << 
savingSessionId);
 
 auto it = _sessions.find(savingSessionId);
@@ -1171,7 +1171,7 @@ bool DocumentBroker::autoSave(const bool force, const 
bool dontSaveIfUnmodified)
 LOG_TRC("Checking to autosave [" << _docKey << "].");
 
 // Which session to use when auto saving ?
-std::string savingSessionId = getWriteableSessionId();
+const std::string savingSessionId = getWriteableSessionId();
 
 bool sent = false;
 if (force)
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index e40ec7a47..0796b53dd 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1755,7 +1755,7 @@ bool LOOLWSD::createForKit()
 // Below line will be executed by PrisonerPoll thread.
 ForKitProc = nullptr;
 PrisonerPoll.setForKitProcess(ForKitProc);
-
+
 // ForKit always spawns one.
 ++OutstandingForks;
 
@@ -3691,6 +3691,7 @@ int LOOLWSD::innerMain()
 LOG_INF("Removing jail [" << path << "].");
 FileUtil::removeFile(path, true);
 }
+
 if (UnitBase::isUnitTesting())
 {
 LOG_TRC("Removing sub-childroot: of " + ChildRoot);
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index 4470e8871..821a7e5e4 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -48,7 +48,7 @@ class WSProcess
 public:
 /// @param pid is the process ID.
 /// @param socket is the underlying Sockeet to the process.
-WSProcess(const std::string& name, 
+WSProcess(const std::string& name,
   const Poco::Process::PID pid,
   const std::shared_ptr& socket,
   std::shared_ptr handler) :
@@ -369,7 +369,7 @@ public:
 /// Close document with @docKey and a @message
 static void closeDocument(const std::string& docKey, const std::string& 
message);
 
-/// Autosave a given document
+/// Autosave a given document (currently only called from Admin).
 static void autoSave(const std::string& docKey);
 
 /// Anonymize the basename of filenames, preserving the path and extension.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-06-06 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |3 ++-
 wsd/LOOLWSD.cpp|8 +++-
 wsd/LOOLWSD.hpp|7 +++
 wsd/Storage.hpp|4 +++-
 4 files changed, 19 insertions(+), 3 deletions(-)

New commits:
commit 194faa6d693416ece2e17da34871b109e5243a6f
Author: Ashod Nakashian 
Date:   Tue Jun 6 23:43:48 2017 -0400

wsd: force readonly for view file types per discovery.xml

File extensions marked as view (as opposed to edit)
in discovery.xml are now forced to be read-only,
regardless of what the client tries to request.

Change-Id: I3eb00c33ff716800dc317f7377281c6d5f0909d7
Reviewed-on: https://gerrit.libreoffice.org/38480
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index a80b9395..d2c44b63 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -431,7 +431,8 @@ bool DocumentBroker::load(const 
std::shared_ptr& session, const s
 username = wopifileinfo->_username;
 userExtraInfo = wopifileinfo->_userExtraInfo;
 
-if (!wopifileinfo->_userCanWrite)
+if (!wopifileinfo->_userCanWrite ||
+LOOLWSD::IsViewFileExtension(wopiStorage->getFileExtension()))
 {
 LOG_DBG("Setting the session as readonly");
 session->setReadOnly();
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 445027e2..07d371c8 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -550,6 +550,7 @@ std::string LOOLWSD::LOKitVersion;
 std::string LOOLWSD::ConfigFile = LOOLWSD_CONFIGDIR "/loolwsd.xml";
 Util::RuntimeConstant LOOLWSD::SSLEnabled;
 Util::RuntimeConstant LOOLWSD::SSLTermination;
+std::set LOOLWSD::ViewFileExtensions;
 
 static std::string UnitTestLibrary;
 
@@ -2176,7 +2177,12 @@ private:
 
 for (unsigned long it = 0; it < listNodes->length(); ++it)
 {
-static_cast(listNodes->item(it))->setAttribute(urlsrc, 
uriValue);
+Element* elem = static_cast(listNodes->item(it));
+elem->setAttribute(urlsrc, uriValue);
+
+// Set the View extensions cache as well.
+if (elem->getAttribute("name") == "view")
+LOOLWSD::ViewFileExtensions.insert(elem->getAttribute("ext"));
 }
 
 std::ostringstream ostrXML;
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index 46538dc0..a608c6c1 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -55,6 +55,7 @@ public:
 static std::atomic NumConnections;
 static bool TileCachePersistent;
 static std::unique_ptr TraceDumper;
+static std::set ViewFileExtensions;
 
 /// Flag to shutdown the server.
 std::atomic ShutdownFlag;
@@ -81,6 +82,12 @@ public:
 return LOOLWSD::SSLTermination.get();
 }
 
+/// Return truee iff extension is marked as view action in discovery.xml.
+static bool IsViewFileExtension(const std::string& extension)
+{
+return ViewFileExtensions.find(extension) != ViewFileExtensions.end();
+}
+
 /// Returns the value of the specified application configuration,
 /// of the default, if one doesn't exist.
 template
diff --git a/wsd/Storage.hpp b/wsd/Storage.hpp
index 60c73275..09002bde 100644
--- a/wsd/Storage.hpp
+++ b/wsd/Storage.hpp
@@ -95,7 +95,9 @@ public:
 void forceSave() { _forceSave = true; }
 
 /// Returns the basic information about the file.
-FileInfo getFileInfo() { return _fileInfo; }
+const FileInfo& getFileInfo() const { return _fileInfo; }
+
+std::string getFileExtension() const { return 
Poco::Path(_fileInfo._filename).getExtension(); }
 
 /// Returns a local file path for the given URI.
 /// If necessary copies the file locally first.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-04-02 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |3 +++
 wsd/LOOLWSD.cpp|   16 
 wsd/LOOLWSD.hpp|4 +++-
 3 files changed, 14 insertions(+), 9 deletions(-)

New commits:
commit c81db872352443cb0c3ac0f7c0d68f27fcd34963
Author: Ashod Nakashian 
Date:   Sun Apr 2 19:56:42 2017 -0400

wsd: do child housekeeping on finishing DocBroker thread

Change-Id: I109737b79759986cb2a1cbfc6d711ee2f19ff59d
Reviewed-on: https://gerrit.libreoffice.org/36034
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index ae7f6e71..a89e3862 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -260,6 +260,9 @@ void DocumentBroker::pollThread()
 _poll->poll(std::min(flushTimeoutMs - elapsedMs, POLL_TIMEOUT_MS / 5));
 }
 
+// Cleanup.
+LOOLWSD::doHousekeeping();
+
 LOG_INF("Finished docBroker polling thread for docKey [" << _docKey << 
"].");
 }
 
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 2cc7bf51..6b2d633b 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1101,6 +1101,11 @@ bool LOOLWSD::checkAndRestoreForKit()
 
 void PrisonerPoll::wakeupHook()
 {
+LOOLWSD::doHousekeeping();
+}
+
+void LOOLWSD::doHousekeeping()
+{
 if (!LOOLWSD::checkAndRestoreForKit())
 {
 // No children have died.
@@ -1136,11 +1141,6 @@ void PrisonerPoll::wakeupHook()
 cleanupDocBrokers();
 }
 
-void LOOLWSD::triggerChildAndDocHousekeeping()
-{
-PrisonerPoll.wakeup();
-}
-
 bool LOOLWSD::createForKit()
 {
 #ifdef KIT_IN_PROCESS
@@ -2428,9 +2428,9 @@ int LOOLWSD::innerMain()
 UnitWSD::get().invokeTest();
 
 // This timeout affects the recovery time of prespawned children.
-int msWait = UnitWSD::isUnitTesting() ?
-UnitWSD::get().getTimeoutMilliSeconds() / 4 :
-SocketPoll::DefaultPollTimeoutMs * 4;
+const int msWait = UnitWSD::isUnitTesting() ?
+   UnitWSD::get().getTimeoutMilliSeconds() / 4 :
+   SocketPoll::DefaultPollTimeoutMs * 4;
 mainWait.poll(msWait);
 
 // Wake the prisoner poll to spawn some children, if necessary.
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index b86b23ac..072a4a88 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -100,7 +100,9 @@ public:
 /// Return true when successfull.
 static bool createForKit();
 
-static void triggerChildAndDocHousekeeping();
+/// Checks forkit (and respawns), rebalances
+/// child kit processes and cleans up DocBrokers.
+static void doHousekeeping();
 
 protected:
 void initialize(Poco::Util::Application& self) override;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-03-27 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |3 +++
 wsd/LOOLWSD.cpp|   23 +--
 wsd/LOOLWSD.hpp|2 ++
 3 files changed, 18 insertions(+), 10 deletions(-)

New commits:
commit 1a6f6e9a65559756ead5c61804744e520ea749d3
Author: Ashod Nakashian 
Date:   Mon Mar 27 21:46:16 2017 -0400

wsd: trigger child and doc housekeeping upon terminating kit

Change-Id: I7ffbadb40221c19b24fd172d1b9aabcaa8c581e5
Reviewed-on: https://gerrit.libreoffice.org/35787
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 384e66cf..32f55aae 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1304,6 +1304,9 @@ void 
DocumentBroker::terminateChild(std::unique_lock& lock, const st
 // Stop the polling thread.
 _poll->stop();
 _stop = true;
+
+// Trigger cleanup.
+LOOLWSD::triggerChildAndDocHousekeeping();
 }
 
 void DocumentBroker::closeDocument(const std::string& reason)
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 4e2c923a..f8d6aa03 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1112,9 +1112,6 @@ bool LOOLWSD::checkAndRestoreForKit()
 
 void PrisonerPoll::wakeupHook()
 {
-/// FIXME: we should do this less frequently
-/// currently the prisoner poll wakes up quite
-/// a lot.
 if (!LOOLWSD::checkAndRestoreForKit())
 {
 // No children have died.
@@ -1144,6 +1141,18 @@ void PrisonerPoll::wakeupHook()
 #endif
 }
 }
+
+std::unique_lock docBrokersLock(DocBrokersMutex, 
std::defer_lock);
+if (docBrokersLock.try_lock())
+{
+cleanupDocBrokers();
+}
+}
+
+void LOOLWSD::triggerChildAndDocHousekeeping()
+{
+PrisonerPoll.wakeup();
+
 }
 
 bool LOOLWSD::createForKit()
@@ -2451,7 +2460,7 @@ int LOOLWSD::innerMain()
 UnitWSD::get().invokeTest();
 
 // This timeout affects the recovery time of prespawned children.
-mainWait.poll(SocketPoll::DefaultPollTimeoutMs);
+mainWait.poll(SocketPoll::DefaultPollTimeoutMs * 4);
 
 // Wake the prisoner poll to spawn some children, if necessary.
 PrisonerPoll.wakeup();
@@ -2462,12 +2471,6 @@ int LOOLWSD::innerMain()
 UnitWSD::get().getTimeoutMilliSeconds())
 UnitWSD::get().timeout();
 
-std::unique_lock docBrokersLock(DocBrokersMutex, 
std::defer_lock);
-if (docBrokersLock.try_lock())
-{
-cleanupDocBrokers();
-}
-
 #if ENABLE_DEBUG
 if (careerSpanSeconds > 0 && time(nullptr) > startTimeSpan + 
careerSpanSeconds)
 {
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index 2461a0d5..d20314c1 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -99,6 +99,8 @@ public:
 /// Return true when successfull.
 static bool createForKit();
 
+static void triggerChildAndDocHousekeeping();
+
 protected:
 void initialize(Poco::Util::Application& self) override;
 void defineOptions(Poco::Util::OptionSet& options) override;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits