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

2020-07-16 Thread Miklos Vajna (via logerrit)
 wsd/DocumentBroker.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 7b38cf9fce5f5d868d8aaf42a5679bfbd595e767
Author: Miklos Vajna 
AuthorDate: Thu Jul 16 09:24:47 2020 +0200
Commit: Miklos Vajna 
CommitDate: Thu Jul 16 15:45:05 2020 +0200

wsd: fix log order in DocumentBroker::sendRequestedTiles()

First log then modify the container.

Change-Id: Ia2bae55562ec6e158c5622cfd25197b6e65584a5
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98872
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Miklos Vajna 

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 137ba25b5..c4f80aa61 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1907,10 +1907,10 @@ void DocumentBroker::sendRequestedTiles(const 
std::shared_ptr& se
 // until we get a tileprocessed message for this specific tile.
 if (session->countIdenticalTilesOnFly(tile) >= 2)
 {
+LOG_DBG("Requested tile " << tile.getWireId() << " was delayed 
(already sent a version)!");
 requestedTiles.push_back(requestedTiles.front());
 requestedTiles.pop_front();
 delayedTiles += 1;
-LOG_DBG("Requested tile " << tile.getWireId() << " was delayed 
(already sent a version)!");
 continue;
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-07-09 Thread Samuel Mehrbrodt (via logerrit)
 wsd/DocumentBroker.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 20eaab272069226485c194d639388b6b7038c211
Author: Samuel Mehrbrodt 
AuthorDate: Tue Jul 7 21:07:21 2020 +0200
Commit: Samuel Mehrbrodt 
CommitDate: Thu Jul 9 10:25:36 2020 +0200

Log number of active sessions

Change-Id: Id161f09bc637e5dcf5ea0beaf11e360de7aa1fa2
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98298
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Samuel Mehrbrodt 

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index f198bb8e3..fe9cdb7f0 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -2257,7 +2257,7 @@ void DocumentBroker::broadcastMessage(const std::string& 
message)
 {
 assertCorrectThread();
 
-LOG_DBG("Broadcasting message [" << message << "] to all sessions.");
+LOG_DBG("Broadcasting message [" << message << "] to all " << 
_sessions.size() <<  " sessions.");
 for (const auto& sessionIt : _sessions)
 {
 sessionIt.second->sendTextFrame(message);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-07-08 Thread Tor Lillqvist (via logerrit)
 wsd/DocumentBroker.cpp |5 -
 1 file changed, 5 deletions(-)

New commits:
commit 0a2033d68800f3ed7346b43b344982bf929fbbcf
Author: Tor Lillqvist 
AuthorDate: Wed Jul 8 15:12:26 2020 +0300
Commit: Tor Lillqvist 
CommitDate: Wed Jul 8 16:30:13 2020 +0200

Bin pointless virtual function that only calls the base class function

Pointless since my own 7f25109f72738706359a63c9062764699f00f568, so
yeah, I should have noticed then.

Change-Id: Ic34584134ef840b33b874952e0bba8d14d3fde2f
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98374
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Tor Lillqvist 

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index a6b8c62e2..009de809d 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -155,11 +155,6 @@ public:
 {
 }
 
-bool continuePolling() override
-{
-return TerminatingPoll::continuePolling();
-}
-
 void pollingThread() override
 {
 // Delegate to the docBroker.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-07-07 Thread Samuel Mehrbrodt (via logerrit)
 wsd/DocumentBroker.cpp |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit e71e37bcec84068e92434357df6172b9cf457e7e
Author: Samuel Mehrbrodt 
AuthorDate: Thu Jul 2 08:16:00 2020 +0200
Commit: Samuel Mehrbrodt 
CommitDate: Tue Jul 7 15:06:25 2020 +0200

Improve reporting save results

Change-Id: I3f2f96f4b8f196e6e9268bed24695f739f679124
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97699
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Samuel Mehrbrodt 

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index e64c0f8e1..a6b8c62e2 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -970,8 +970,8 @@ bool DocumentBroker::saveToStorageInternal(const 
std::string& sessionId, bool su
 {
 LOG_DBG("Save skipped as document [" << _docKey << "] was not 
modified.");
 _lastSaveTime = std::chrono::steady_clock::now();
-_poll->wakeup();
 broadcastSaveResult(true, "unmodified");
+_poll->wakeup();
 return true;
 }
 
@@ -1116,7 +1116,7 @@ bool DocumentBroker::saveToStorageInternal(const 
std::string& sessionId, bool su
 LOG_ERR("Cannot save docKey [" << _docKey << "] to storage URI [" << 
uriAnonym <<
 "]. Invalid or expired access token. Notifying client.");
 it->second->sendTextFrameAndLogError("error: cmd=storage 
kind=saveunauthorized");
-broadcastSaveResult(false, "Invalid or expired access token", 
storageSaveResult.getErrorMsg());
+broadcastSaveResult(false, "Invalid or expired access token");
 }
 else if (storageSaveResult.getResult() == StorageBase::SaveResult::FAILED)
 {
@@ -1144,9 +1144,9 @@ bool DocumentBroker::saveToStorageInternal(const 
std::string& sessionId, bool su
 
 void DocumentBroker::broadcastSaveResult(bool success, const std::string& 
result, const std::string& errorMsg)
 {
-std::string resultstr = success ? "true" : "false";
+const std::string resultstr = success ? "true" : "false";
 // Some sane limit, otherwise we get problems transfering this to the 
client with large strings (can be a whole webpage)
-std::string errorMsgFormatted = errorMsg.substr(0, 1000);
+std::string errorMsgFormatted = 
LOOLProtocol::getAbbreviatedMessage(errorMsg);
 // Replace reserverd characters
 errorMsgFormatted = Poco::translate(errorMsgFormatted, "\"", "'");
 broadcastMessage("commandresult: { \"command\": \"save\", \"success\": " + 
resultstr +
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-07-02 Thread Mike Kaganski (via logerrit)
 wsd/DocumentBroker.cpp |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit 35f8788e1cae3d94ae9a39074aca83dddaea43d3
Author: Mike Kaganski 
AuthorDate: Wed Jul 1 13:38:06 2020 +0300
Commit: Mike Kaganski 
CommitDate: Thu Jul 2 14:21:30 2020 +0200

Only lock documents in editing sessions

Change-Id: I97753541a944bb299b04c032790d6af7a9ee0f63
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97609
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Mike Kaganski 

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 7753d87ac..e64c0f8e1 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -786,7 +786,9 @@ bool DocumentBroker::load(const 
std::shared_ptr& session, const s
 std::string localPath = _storage->loadStorageFileToLocal(
 session->getAuthorization(), session->getCookies(), *_lockCtx, 
templateSource);
 
-if (!_storage->updateLockState(session->getAuthorization(), 
session->getCookies(), *_lockCtx, true))
+// Only lock the document on storage for editing sessions
+if (!session->isReadOnly() &&
+!_storage->updateLockState(session->getAuthorization(), 
session->getCookies(), *_lockCtx, true))
 LOG_ERR("Failed to lock!");
 
 #if !MOBILEAPP
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-06-30 Thread Ashod Nakashian (via logerrit)
 wsd/DocumentBroker.cpp |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

New commits:
commit e93f7039c13d2b5326d22eaf14a6e801eba0cb9a
Author: Ashod Nakashian 
AuthorDate: Thu Jun 25 21:55:30 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Wed Jul 1 07:42:46 2020 +0200

wsd: anonymize the filename only when anonymization is enabled

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 4b3a61d39..8a41a6dd9 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1002,9 +1002,13 @@ bool DocumentBroker::saveToStorageInternal(const 
std::string& sessionId, bool su
 const std::string newFilename = Util::getFilenameFromURL(uri);
 const std::string fileId = Util::getFilenameFromURL(_docKey);
 if (LOOLWSD::AnonymizeUserData)
-LOG_DBG("New filename [" << LOOLWSD::anonymizeUrl(newFilename) << "] 
will be known by its fileId [" << fileId << ']');
+{
+LOG_DBG("New filename [" << LOOLWSD::anonymizeUrl(newFilename)
+ << "] will be known by its fileId [" << 
fileId << ']');
+
+Util::mapAnonymized(newFilename, fileId);
+}
 
-Util::mapAnonymized(newFilename, fileId);
 const std::string uriAnonym = LOOLWSD::anonymizeUrl(uri);
 
 // If the file timestamp hasn't changed, skip saving.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-06-30 Thread Jan Holesovsky (via logerrit)
 wsd/DocumentBroker.cpp |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 2c4e4f2e6e98998d566c2445a2f34ec92b851dc0
Author: Jan Holesovsky 
AuthorDate: Tue Jun 30 10:30:27 2020 +0200
Commit: Jan Holesovsky 
CommitDate: Tue Jun 30 10:54:29 2020 +0200

android: This assert is iOS-only, ifdef it out.

Change-Id: I2a0dab7069721175983fa426f30422f5fd00e6b8
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/97474
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Jan Holesovsky 

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index f062e0145..4b3a61d39 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -255,7 +255,9 @@ void DocumentBroker::pollThread()
 }
 while (!_stop && _poll->continuePolling() && 
!SigUtil::getTerminationFlag() && !SigUtil::getShutdownRequestFlag());
 #else
+#ifdef IOS
 assert(_mobileAppDocId > 0);
+#endif
 _childProcess = getNewChild_Blocks(_mobileAppDocId);
 #endif
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-06-23 Thread Tor Lillqvist (via logerrit)
 wsd/DocumentBroker.cpp |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

New commits:
commit a541dc5bcbb089f8ffbf977e8c62d39065dc2d24
Author: Tor Lillqvist 
AuthorDate: Tue Jun 23 13:44:28 2020 +0300
Commit: Tor Lillqvist 
CommitDate: Tue Jun 23 13:26:37 2020 +0200

No need for this 'if (false)'

Change-Id: I552ee8873d398b428aa2c54d7d762c13144b8b75
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/96931
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Tor Lillqvist 

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index c242da586..da71968f6 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -432,10 +432,8 @@ void DocumentBroker::pollThread()
 lastClipboardHashUpdateTime = now;
 }
 
-if (false)
-;
 // Remove idle documents after 1 hour.
-else if (isLoaded() && getIdleTimeSecs() >= IdleDocTimeoutSecs)
+if (isLoaded() && getIdleTimeSecs() >= IdleDocTimeoutSecs)
 {
 // Stop if there is nothing to save.
 LOG_INF("Autosaving idle DocumentBroker for docKey [" << 
getDocKey() << "] to kill.");
___
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/DocumentBroker.hpp

2020-06-22 Thread Ashod Nakashian (via logerrit)
 wsd/DocumentBroker.cpp |2 ++
 wsd/DocumentBroker.hpp |2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

New commits:
commit 17044ade27ec94f135b95350a8a96ae7696049a2
Author: Ashod Nakashian 
AuthorDate: Wed Jun 3 12:30:40 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Tue Jun 23 06:42:53 2020 +0200

wsd: fix: call to virtual function during destruction

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index f62241808..c242da586 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -2325,6 +2325,8 @@ void ConvertToBroker::dispose()
 
 ConvertToBroker::~ConvertToBroker()
 {
+// Calling a virtual function from a dtor
+// is only valid if there are no inheritors.
 dispose();
 }
 
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 17300d0cb..42d506629 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -442,7 +442,7 @@ private:
 };
 
 #if !MOBILEAPP
-class ConvertToBroker : public DocumentBroker
+class ConvertToBroker final : public DocumentBroker
 {
 const std::string _format;
 const std::string _sOptions;
___
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/ProxyProtocol.cpp wsd/ProxyProtocol.hpp

2020-06-04 Thread Michael Meeks (via logerrit)
 wsd/DocumentBroker.cpp |   14 +-
 wsd/ProxyProtocol.cpp  |2 +-
 wsd/ProxyProtocol.hpp  |5 -
 3 files changed, 18 insertions(+), 3 deletions(-)

New commits:
commit 36a4b5ad05c527fa38baf85e4f8bd65ed8d11e2f
Author: Michael Meeks 
AuthorDate: Wed Jun 3 17:14:03 2020 +0100
Commit: Michael Meeks 
CommitDate: Thu Jun 4 15:49:46 2020 +0200

Proxy: dump ProxyProtocolHandler state separately

Somewhat inelegant - nasty extra header & dynamic cast.

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index d13a5d1a3..55e921295 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -32,6 +32,7 @@
 #include "SenderQueue.hpp"
 #include "Storage.hpp"
 #include "TileCache.hpp"
+#include "ProxyProtocol.hpp"
 #include 
 #include 
 #include 
@@ -216,7 +217,7 @@ void DocumentBroker::setupPriorities()
 int prio = LOOLWSD::getConfigValue("per_document.batch_priority", 
5);
 Util::setProcessAndThreadPriorities(_childProcess->getPid(), prio);
 }
-#endif // !MOBILE
+#endif
 }
 
 void DocumentBroker::startThread()
@@ -2420,6 +2421,17 @@ void DocumentBroker::dumpState(std::ostream& os)
 _tileCache->dumpState(os);
 
 _poll->dumpState(os);
+
+#if !MOBILEAPP
+// Bit nasty - need a cleaner way to dump state.
+for (auto  : _sessions)
+{
+auto proto = it.second->getProtocol();
+auto proxy = dynamic_cast(proto.get());
+if (proxy)
+proxy->dumpProxyState(os);
+}
+#endif
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/wsd/ProxyProtocol.cpp b/wsd/ProxyProtocol.cpp
index 4b6950a10..8e7b8a631 100644
--- a/wsd/ProxyProtocol.cpp
+++ b/wsd/ProxyProtocol.cpp
@@ -277,7 +277,7 @@ void ProxyProtocolHandler::getIOStats(uint64_t , 
uint64_t )
 sent = recv = 0;
 }
 
-void ProxyProtocolHandler::dumpState(std::ostream& os)
+void ProxyProtocolHandler::dumpProxyState(std::ostream& os)
 {
 os << "proxy protocol sockets: " << _outSockets.size() << " writeQueue: " 
<< _writeQueue.size() << ":\n";
 os << '\t';
diff --git a/wsd/ProxyProtocol.hpp b/wsd/ProxyProtocol.hpp
index 7a342912b..d20377b30 100644
--- a/wsd/ProxyProtocol.hpp
+++ b/wsd/ProxyProtocol.hpp
@@ -57,7 +57,10 @@ public:
 int sendBinaryMessage(const char *data, const size_t len, bool flush = 
false) const override;
 void shutdown(bool goingAway = false, const std::string  = 
"") override;
 void getIOStats(uint64_t , uint64_t ) override;
-void dumpState(std::ostream& os) override;
+// don't duplicate ourselves for every socket
+void dumpState(std::ostream&) override {}
+// instead do it centrally.
+void dumpProxyState(std::ostream& os);
 bool parseEmitIncoming(const std::shared_ptr );
 
 void handleRequest(bool isWaiting, const std::shared_ptr );
___
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-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

2020-04-27 Thread Ashod Nakashian (via logerrit)
 wsd/DocumentBroker.cpp |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 762ca3d3ed613da7a3132192fe535233e1547a9e
Author: Ashod Nakashian 
AuthorDate: Fri Apr 10 09:36:43 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Tue Apr 28 03:53:22 2020 +0200

wsd: don't reset modified flag on storing the doc

The modified flag should only be changed by Core,
otherwise, we suffer a race and really make the
significance of this flag ambiguous.

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index d9fc339c9..fd1dc7f46 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -984,7 +984,7 @@ bool DocumentBroker::saveToStorageInternal(const 
std::string& sessionId, bool su
 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.");
+"]. File last modified " << timeInSec.count() << " seconds 
ago, timestamp unchanged.");
 _poll->wakeup();
 return true;
 }
@@ -1005,7 +1005,6 @@ bool DocumentBroker::saveToStorageInternal(const 
std::string& sessionId, bool su
 if (!isSaveAs && !isRename)
 {
 // Saved and stored; update flags.
-setModified(false);
 _lastFileModifiedTime = newFileModifiedTime;
 _lastSaveTime = std::chrono::steady_clock::now();
 
@@ -2013,6 +2012,7 @@ void DocumentBroker::setModified(const bool value)
 #endif
 }
 
+// Set the X-LOOL-WOPI-IsModifiedByUser header flag sent to storage.
 _storage->setUserModified(value);
 }
 
___
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/DocumentBroker.hpp

2020-04-16 Thread Ashod Nakashian (via logerrit)
 wsd/DocumentBroker.cpp |   18 --
 wsd/DocumentBroker.hpp |2 +-
 2 files changed, 9 insertions(+), 11 deletions(-)

New commits:
commit 2f703dc5ae14875910053b22bf8d806a18257a65
Author: Ashod Nakashian 
AuthorDate: Thu Apr 9 10:37:33 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Fri Apr 17 02:36:39 2020 +0200

wsd: _isModified -> isModified()

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 8c342c4c3..f79cbbbd4 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -432,7 +432,7 @@ void DocumentBroker::pollThread()
 _poll->continuePolling() << ", ShutdownRequestFlag: " << 
SigUtil::getShutdownRequestFlag() <<
 ", TerminationFlag: " << SigUtil::getTerminationFlag() << ", 
closeReason: " << _closeReason << ". Flushing socket.");
 
-if (_isModified)
+if (isModified())
 {
 std::stringstream state;
 dumpState(state);
@@ -739,9 +739,8 @@ bool DocumentBroker::load(const 
std::shared_ptr& session, const s
 ", Actual: " << fileInfo.getModifiedTime());
 
 _documentChangedInStorage = true;
-std::string message = "close: documentconflict";
-if (_isModified)
-message = "error: cmd=storage kind=documentconflict";
+const std::string message = isModified() ? "error: cmd=storage 
kind=documentconflict"
+ : "close: 
documentconflict";
 
 session->sendTextFrame(message);
 broadcastMessage(message);
@@ -1090,9 +1089,8 @@ bool DocumentBroker::saveToStorageInternal(const 
std::string& sessionId, bool su
 {
 LOG_ERR("PutFile says that Document changed in storage");
 _documentChangedInStorage = true;
-std::string message = "close: documentconflict";
-if (_isModified)
-message = "error: cmd=storage kind=documentconflict";
+const std::string message
+= isModified() ? "error: cmd=storage kind=documentconflict" : 
"close: documentconflict";
 
 broadcastMessage(message);
 }
@@ -1160,7 +1158,7 @@ bool DocumentBroker::autoSave(const bool force, const 
bool dontSaveIfUnmodified)
 
 LOG_TRC("autoSave(): forceful? " << force);
 if (_sessions.empty() || _storage == nullptr || !_isLoaded ||
-!_childProcess->isAlive() || (!_isModified && !force))
+!_childProcess->isAlive() || (!isModified() && !force))
 {
 // Nothing to do.
 LOG_TRC("Nothing to autosave [" << _docKey << "].");
@@ -1186,7 +1184,7 @@ bool DocumentBroker::autoSave(const bool force, const 
bool dontSaveIfUnmodified)
dontSaveIfUnmodified, /*isAutosave=*/false,
/*isExitSave=*/true);
 }
-else if (_isModified)
+else if (isModified())
 {
 const std::chrono::steady_clock::time_point now = 
std::chrono::steady_clock::now();
 const std::chrono::milliseconds::rep inactivityTimeMs = 
std::chrono::duration_cast(now - 
_lastActivityTime).count();
@@ -2377,7 +2375,7 @@ void DocumentBroker::dumpState(std::ostream& os)
 now - _threadStart).count() << "s";
 os << "\n  sent: " << sent;
 os << "\n  recv: " << recv;
-os << "\n  modified?: " << _isModified;
+os << "\n  modified?: " << isModified();
 os << "\n  jail id: " << _jailId;
 os << "\n  filename: " << LOOLWSD::anonymizeUrl(_filename);
 os << "\n  public uri: " << _uriPublic.toString();
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index d270f53b0..42fc82bbb 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -313,7 +313,7 @@ private:
 /// True if we know the doc is modified or
 /// if there has been activity from a client after we last *requested* 
saving,
 /// since there are race conditions vis-a-vis user activity while saving.
-bool isPossiblyModified() const { return _isModified || 
(_lastSaveRequestTime < _lastActivityTime); }
+bool isPossiblyModified() const { return isModified() || 
(_lastSaveRequestTime < _lastActivityTime); }
 
 /// True iff there is at least one non-readonly session other than the 
given.
 /// Since only editable sessions can save, we need to use the last to
___
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

2020-04-06 Thread Tor Lillqvist (via logerrit)
 wsd/DocumentBroker.cpp |   15 +++
 1 file changed, 15 insertions(+)

New commits:
commit 293f4913d2cdfe5385e2cdc0e3bebde281da1578
Author: Tor Lillqvist 
AuthorDate: Mon Apr 6 12:37:12 2020 +0300
Commit: Tor Lillqvist 
CommitDate: Mon Apr 6 20:52:47 2020 +0200

On iOS, make the document show up as modified also after auto or explicit 
save

It is not enough to just have the core code rewrite the document file.
We need to do the same dance as in -[DocumentViewController bye].

I wonder if it would be cleaner to copy the document file to some
temporary location when opening it, and use only that copy in Online
and core, and then after core has saved it (either for an auto-save,
an explicit save, or when closing the document) do the -[UIDocument
saveToURL:forSaveOperation:completionHandler] thing?

Change-Id: I78fec08a90424780dc6e794347a0acf2c64e1dab
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91741
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Tor Lillqvist 

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 0c28b94bd..0d5ce909d 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -39,6 +39,10 @@
 #include 
 #include 
 
+#ifdef IOS
+#import "DocumentViewController.h"
+#endif
+
 #include 
 #include 
 
@@ -1284,6 +1288,17 @@ bool DocumentBroker::sendUnoSave(const std::string& 
sessionId, bool dontTerminat
 const auto command = "uno .uno:Save " + saveArgs;
 forwardToChild(sessionId, command);
 _lastSaveRequestTime = std::chrono::steady_clock::now();
+#ifdef IOS
+// We need to do this so that file provider extensions notice. Just 
like in
+// -[DocumentViewController bye] I suspect that will read the file and 
then overwrite it
+// with the same contents, but oh well.
+CODocument *document = [[DocumentViewController singleton] document];
+[document saveToURL:[[[DocumentViewController singleton] document] 
fileURL]
+   forSaveOperation:UIDocumentSaveForOverwriting
+  completionHandler:^(BOOL success) {
+LOG_TRC("save completion handler gets " << 
(success?"YES":"NO"));
+}];
+#endif
 return true;
 }
 
___
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/DocumentBroker.hpp wsd/LOOLWSD.cpp

2020-03-05 Thread Michael Meeks (via logerrit)
 wsd/DocumentBroker.cpp |   32 
 wsd/DocumentBroker.hpp |7 +++
 wsd/LOOLWSD.cpp|   38 ++
 3 files changed, 41 insertions(+), 36 deletions(-)

New commits:
commit da944760a62a82c21a32017b9c04526ea00d3cbd
Author: Michael Meeks 
AuthorDate: Wed Mar 4 21:56:48 2020 +
Commit: Michael Meeks 
CommitDate: Thu Mar 5 17:10:36 2020 +0100

re-factor: move createNewSession into DocumentBroker.

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 74b827678..18bcdce63 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1497,6 +1497,38 @@ void DocumentBroker::finalRemoveSession(const 
std::string& id)
 }
 }
 
+std::shared_ptr DocumentBroker::createNewClientSession(const 
WebSocketHandler* ws,
+  const 
std::string& id,
+  const 
Poco::URI& uriPublic,
+  const 
bool isReadOnly,
+  const 
std::string& hostNoTrust)
+{
+try
+{
+// Now we have a DocumentBroker and we're ready to process client 
commands.
+if (ws)
+{
+const std::string statusReady = "statusindicator: ready";
+LOG_TRC("Sending to Client [" << statusReady << "].");
+ws->sendMessage(statusReady);
+}
+
+// In case of WOPI, if this session is not set as readonly, it might 
be set so
+// later after making a call to WOPI host which tells us the 
permission on files
+// (UserCanWrite param).
+auto session = std::make_shared(id, shared_from_this(), 
uriPublic, isReadOnly, hostNoTrust);
+session->construct();
+
+return session;
+}
+catch (const std::exception& exc)
+{
+LOG_WRN("Exception while preparing session [" << id << "]: " << 
exc.what());
+}
+
+return nullptr;
+}
+
 void DocumentBroker::addCallback(const SocketPoll::CallbackFn& fn)
 {
 _poll->addCallback(fn);
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 5e3bea9aa..f56bd1e3f 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -243,6 +243,13 @@ public:
 /// Hard removes a session by ID, only for ClientSession.
 void finalRemoveSession(const std::string& id);
 
+/// Create new client session
+std::shared_ptr createNewClientSession(const 
WebSocketHandler* ws,
+  const std::string& 
id,
+  const Poco::URI& 
uriPublic,
+  const bool 
isReadOnly,
+  const std::string& 
hostNoTrust);
+
 /// Thread safe termination of this broker if it has a lingering thread
 void joinThread();
 
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 61b9d8f09..eb35d601c 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1780,40 +1780,6 @@ static std::shared_ptr 
findOrCreateDocBroker(WebSocketHandler& w
 return docBroker;
 }
 
-static std::shared_ptr createNewClientSession(const 
WebSocketHandler* ws,
- const 
std::string& id,
- const Poco::URI& 
uriPublic,
- const 
std::shared_ptr& docBroker,
- const bool 
isReadOnly,
- const 
std::string& hostNoTrust)
-{
-LOG_CHECK_RET(docBroker && "Null docBroker instance", nullptr);
-try
-{
-// Now we have a DocumentBroker and we're ready to process client 
commands.
-if (ws)
-{
-const std::string statusReady = "statusindicator: ready";
-LOG_TRC("Sending to Client [" << statusReady << "].");
-ws->sendMessage(statusReady);
-}
-
-// In case of WOPI, if this session is not set as readonly, it might 
be set so
-// later after making a call to WOPI host which tells us the 
permission on files
-// (UserCanWrite param).
-auto session = std::make_shared(id, docBroker, 
uriPublic, isReadOnly, hostNoTrust);
-session->construct();
-
-return session;
-}
-catch (const std::exception& exc)
-{
-LOG_WRN("Exception while preparing session [" << id << "]: " << 
exc.what());
-}
-
-return nullptr;
-}
-
 /// Handles the socket that the 

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

2019-12-13 Thread Andras Timar (via logerrit)
 wsd/DocumentBroker.cpp |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 97ee22a8ffb17030fea9b094f13ffdc7d5a3b4e5
Author: Andras Timar 
AuthorDate: Fri Dec 13 16:03:26 2019 +0100
Commit: Andras Timar 
CommitDate: Fri Dec 13 16:05:52 2019 +0100

fix error: declaration of ‘load’ shadows a member of 'this' [-Werror=shadow]

Change-Id: I4bd4fb3ae6f01c0d03d622f90e1dfb872c396494

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 77204dd69..fecea32bc 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -2244,8 +2244,8 @@ bool ConvertToBroker::startConversion(SocketDisposition 
, const std:
  // Load the document manually and request saving in the 
target format.
  std::string encodedFrom;
  Poco::URI::encode(docBroker->getPublicUri().getPath(), 
"", encodedFrom);
- const std::string load = "load url=" + encodedFrom;
- std::vector loadRequest(load.begin(), load.end());
+ const std::string _load = "load url=" + encodedFrom;
+ std::vector loadRequest(_load.begin(), _load.end());
  docBroker->_clientSession->handleMessage(true, 
WSOpCode::Text, loadRequest);
 
  // Save is done in the setLoaded
___
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/DocumentBroker.hpp

2019-12-12 Thread Jan Holesovsky (via logerrit)
 wsd/DocumentBroker.cpp |2 ++
 wsd/DocumentBroker.hpp |2 ++
 2 files changed, 4 insertions(+)

New commits:
commit 863111c952300efd3a3b13b9dcc4d41c8dc85405
Author: Jan Holesovsky 
AuthorDate: Thu Dec 12 09:56:43 2019 +0100
Commit: Jan Holesovsky 
CommitDate: Thu Dec 12 09:57:44 2019 +0100

mobile: Fix build.

Change-Id: Ie0f08a984b9333ca65d0fd52c71e358b7fd5f771
Reviewed-on: https://gerrit.libreoffice.org/85018
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 700a56fbf..77204dd69 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -2207,6 +2207,7 @@ ConvertToBroker::ConvertToBroker(const std::string& uri,
 _limitLifeSeconds = limit_convert_secs;
 }
 
+#if !MOBILEAPP
 bool ConvertToBroker::startConversion(SocketDisposition , const 
std::string )
 {
 std::shared_ptr docBroker = 
std::static_pointer_cast(shared_from_this());
@@ -2252,6 +2253,7 @@ bool ConvertToBroker::startConversion(SocketDisposition 
, const std:
 });
 return true;
 }
+#endif
 
 void ConvertToBroker::dispose()
 {
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 5632c56b6..07f967579 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -532,8 +532,10 @@ public:
 const std::string& sOptions);
 virtual ~ConvertToBroker();
 
+#if !MOBILEAPP
 /// Move socket to this broker for response & do conversion
 bool startConversion(SocketDisposition , const std::string 
);
+#endif
 
 /// Called when removed from the DocBrokers list
 void dispose() 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/DocumentBroker.hpp wsd/LOOLWSD.cpp

2019-12-11 Thread Michael Meeks (via logerrit)
 wsd/DocumentBroker.cpp |   74 +++--
 wsd/DocumentBroker.hpp |   17 +--
 wsd/LOOLWSD.cpp|   63 +
 3 files changed, 89 insertions(+), 65 deletions(-)

New commits:
commit 948b424abbb3ee493d148896492d18186e3507f2
Author: Michael Meeks 
AuthorDate: Thu Dec 12 05:09:35 2019 +
Commit: Michael Meeks 
CommitDate: Thu Dec 12 07:42:42 2019 +0100

convert-to: wait for load to complete before attempting the save.

Change-Id: Iee3a8a6720bbc29fc4e113bf705f405b840e1e45
Reviewed-on: https://gerrit.libreoffice.org/85009
Reviewed-by: Michael Meeks 
Tested-by: Michael Meeks 

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index af756c676..700a56fbf 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -2195,14 +2195,64 @@ size_t ConvertToBroker::getInstanceCount()
 
 ConvertToBroker::ConvertToBroker(const std::string& uri,
  const Poco::URI& uriPublic,
- const std::string& docKey)
-: DocumentBroker(uri, uriPublic, docKey)
+ const std::string& docKey,
+ const std::string& format,
+ const std::string& sOptions) :
+DocumentBroker(uri, uriPublic, docKey),
+_format(format),
+_sOptions(sOptions)
 {
 static const int limit_convert_secs = 
LOOLWSD::getConfigValue("per_document.limit_convert_secs", 100);
 NumConverters++;
 _limitLifeSeconds = limit_convert_secs;
 }
 
+bool ConvertToBroker::startConversion(SocketDisposition , const 
std::string )
+{
+std::shared_ptr docBroker = 
std::static_pointer_cast(shared_from_this());
+
+// Create a session to load the document.
+const bool isReadOnly = true;
+_clientSession = std::make_shared(id, docBroker, 
getPublicUri(), isReadOnly, "nocliphost");
+_clientSession->construct();
+
+if (!_clientSession)
+return false;
+
+disposition.setMove([docBroker] (const std::shared_ptr )
+{
+// Perform all of this after removing the socket
+
+// Make sure the thread is running before adding callback.
+docBroker->startThread();
+
+// We no longer own this socket.
+moveSocket->setThreadOwner(std::thread::id(0));
+
+docBroker->addCallback([docBroker, moveSocket]()
+ {
+ auto streamSocket = 
std::static_pointer_cast(moveSocket);
+ docBroker->_clientSession->setSaveAsSocket(streamSocket);
+
+ // Move the socket into DocBroker.
+ docBroker->addSocketToPoll(moveSocket);
+
+ // First add and load the session.
+ docBroker->addSession(docBroker->_clientSession);
+
+ // Load the document manually and request saving in the 
target format.
+ std::string encodedFrom;
+ Poco::URI::encode(docBroker->getPublicUri().getPath(), 
"", encodedFrom);
+ const std::string load = "load url=" + encodedFrom;
+ std::vector loadRequest(load.begin(), load.end());
+ docBroker->_clientSession->handleMessage(true, 
WSOpCode::Text, loadRequest);
+
+ // Save is done in the setLoaded
+ });
+});
+return true;
+}
+
 void ConvertToBroker::dispose()
 {
 if (!_uriOrig.empty())
@@ -2233,6 +2283,26 @@ void ConvertToBroker::removeFile(const std::string 
)
 }
 }
 
+void ConvertToBroker::setLoaded()
+{
+DocumentBroker::setLoaded();
+
+// FIXME: Check for security violations.
+Poco::Path toPath(getPublicUri().getPath());
+toPath.setExtension(_format);
+const std::string toJailURL = "file://" + 
std::string(JAILED_DOCUMENT_ROOT) + toPath.getFileName();
+std::string encodedTo;
+Poco::URI::encode(toJailURL, "", encodedTo);
+
+// Convert it to the requested format.
+const std::string saveAsCmd = "saveas url=" + encodedTo + " format=" + 
_format + " options=" + _sOptions;
+
+// Send the save request ...
+std::vector saveasRequest(saveAsCmd.begin(), saveAsCmd.end());
+
+_clientSession->handleMessage(true, WSOpCode::Text, saveasRequest);
+}
+
 std::vector> 
DocumentBroker::getSessionsTestOnlyUnsafe()
 {
 std::vector> result;
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 3b8f6e844..5632c56b6 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -245,7 +245,8 @@ public:
 /// Thread safe termination of this broker if it has a lingering thread
 void joinThread();
 
-void setLoaded();
+/// Notify that the load has completed
+virtual void setLoaded();
 
 bool isDocumentChangedInStorage() { return _documentChangedInStorage; }
 
@@ -518,16 +519,28 @@ private:
 
 class ConvertToBroker : 

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

2019-11-28 Thread Michael Meeks (via logerrit)
 wsd/DocumentBroker.cpp |6 ++
 wsd/LOOLWSD.cpp|3 +--
 2 files changed, 7 insertions(+), 2 deletions(-)

New commits:
commit 039ca3540e84498e24da33cdea51c70163aafca8
Author: Michael Meeks 
AuthorDate: Thu Nov 28 18:05:04 2019 +
Commit: Michael Meeks 
CommitDate: Thu Nov 28 18:05:04 2019 +

tdf#125755: specialize reduced decoding for mobile apps.

The WOPI multiple encoding magic is unpleasant; best not to try to
unwind it all now.

This fixes Download-As and SllideShow pieces.

cf. c806acb157fa501a8be872042b534a2f49641e62

Change-Id: Ie06ad386c7a30e0f572e299e50fc949ce41b09f5

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index ddfaa922d..177da0618 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -86,7 +86,13 @@ void sendLastModificationTime(const 
std::shared_ptr& session,
 Poco::URI DocumentBroker::sanitizeURI(const std::string& uri)
 {
 // The URI of the document should be url-encoded.
+#if !MOBILEAPP
+std::string decodedUri;
+Poco::URI::decode(uri, decodedUri);
+Poco::URI uriPublic(decodedUri);
+#else
 Poco::URI uriPublic(uri);
+#endif
 
 if (uriPublic.isRelative() || uriPublic.getScheme() == "file")
 {
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 221d179ef..f76aaabc1 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2430,8 +2430,7 @@ private:
 }
 LOG_TRC("Clipboard request for us: " << serverId << " with tag " << 
tag);
 
-const auto uriPublic = DocumentBroker::sanitizeURI(WOPISrc);
-const auto docKey = DocumentBroker::getDocKey(uriPublic);
+const auto docKey = 
DocumentBroker::getDocKey(DocumentBroker::sanitizeURI(WOPISrc));
 
 std::shared_ptr docBroker;
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-11-25 Thread Tor Lillqvist (via logerrit)
 wsd/DocumentBroker.cpp |7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

New commits:
commit c806acb157fa501a8be872042b534a2f49641e62
Author: Tor Lillqvist 
AuthorDate: Thu Nov 21 15:29:51 2019 +0200
Commit: Tor Lillqvist 
CommitDate: Mon Nov 25 18:10:42 2019 +0100

tdf#125755: Fix some URI encoding issues

Now the iOS app is able to open a document called A#B?C\D❤️FG%AAHÖ.doc.
That is, with ‘#’, ‘?’, and ‘&’ that can mess things up when parsing URIs,
non-ASCII and even non-BMP characters, and an actual percent
character in the file name. Is that a complete enough test case? Will see.

Change-Id: I7fc53eaf8188f633d442d14a7f42814553169c71
Reviewed-on: https://gerrit.libreoffice.org/83395
Reviewed-by: Tor Lillqvist 
Tested-by: Tor Lillqvist 
(cherry picked from commit b60ccd60c59efb5a03ea698c0205a8543846d9e2)
Reviewed-on: https://gerrit.libreoffice.org/83664
Tested-by: Aron Budea 

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index d243a338c..7d669e00c 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -86,9 +86,7 @@ void sendLastModificationTime(const std::shared_ptr& 
session,
 Poco::URI DocumentBroker::sanitizeURI(const std::string& uri)
 {
 // The URI of the document should be url-encoded.
-std::string decodedUri;
-Poco::URI::decode(uri, decodedUri);
-Poco::URI uriPublic(decodedUri);
+Poco::URI uriPublic(uri);
 
 if (uriPublic.isRelative() || uriPublic.getScheme() == "file")
 {
@@ -805,9 +803,8 @@ bool DocumentBroker::load(const 
std::shared_ptr& session, const s
 LOG_INF("SHA1 for DocKey [" << _docKey << "] of [" << 
LOOLWSD::anonymizeUrl(localPath) << "]: " <<
 Poco::DigestEngine::digestToHex(sha1.digest()));
 
-// LibreOffice can't open files with '#' in the name
 std::string localPathEncoded;
-Poco::URI::encode(localPath, "#", localPathEncoded);
+Poco::URI::encode(localPath, "#?", localPathEncoded);
 _uriJailed = Poco::URI(Poco::URI("file://"), 
localPathEncoded).toString();
 _uriJailedAnonym = Poco::URI(Poco::URI("file://"), 
LOOLWSD::anonymizeUrl(localPathEncoded)).toString();
 
___
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/DocumentBroker.hpp wsd/Storage.cpp wsd/Storage.hpp

2019-11-21 Thread Michael Meeks (via logerrit)
 wsd/DocumentBroker.cpp |   33 
 wsd/DocumentBroker.hpp |2 +
 wsd/Storage.cpp|   96 -
 wsd/Storage.hpp|   48 +++-
 4 files changed, 154 insertions(+), 25 deletions(-)

New commits:
commit cabd30a1b83c5abea913dcbe8ce869d6b12ea404
Author: Michael Meeks 
AuthorDate: Tue Nov 19 22:51:45 2019 +
Commit: Michael Meeks 
CommitDate: Thu Nov 21 14:24:58 2019 +

Initial wopi-like locking implementation.

Change-Id: I3e16cfc40dbd29a24016b09e62afc9ec488300c7

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 6b393d277..ef1ad7ed6 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -189,6 +189,7 @@ DocumentBroker::DocumentBroker(const std::string& uri,
 _poll(new DocumentBrokerPoll("docbroker_" + _docId, *this)),
 _stop(false),
 _closeReason("stopped"),
+_lockCtx(new LockContext()),
 _tileVersion(0),
 _debugRenderedTileCount(0)
 {
@@ -563,7 +564,8 @@ bool DocumentBroker::load(const 
std::shared_ptr& session, const s
 WopiStorage* wopiStorage = dynamic_cast(_storage.get());
 if (wopiStorage != nullptr)
 {
-std::unique_ptr wopifileinfo = 
wopiStorage->getWOPIFileInfo(session->getAuthorization());
+std::unique_ptr wopifileinfo =
+wopiStorage->getWOPIFileInfo(session->getAuthorization(), 
*_lockCtx);
 userId = wopifileinfo->getUserId();
 username = wopifileinfo->getUsername();
 userExtraInfo = wopifileinfo->getUserExtraInfo();
@@ -722,7 +724,11 @@ bool DocumentBroker::load(const 
std::shared_ptr& session, const s
 // Let's load the document now, if not loaded.
 if (!_storage->isLoaded())
 {
-std::string localPath = 
_storage->loadStorageFileToLocal(session->getAuthorization(), templateSource);
+std::string localPath = _storage->loadStorageFileToLocal(
+session->getAuthorization(), *_lockCtx, templateSource);
+
+if (!_storage->updateLockState(session->getAuthorization(), *_lockCtx, 
true))
+LOG_ERR("Failed to lock!");
 
 #if !MOBILEAPP
 // Check if we have a prefilter "plugin" for this document format
@@ -955,7 +961,8 @@ bool DocumentBroker::saveToStorageInternal(const 
std::string& sessionId, bool su
 LOG_DBG("Persisting [" << _docKey << "] after saving to URI [" << 
uriAnonym << "].");
 
 assert(_storage && _tileCache);
-StorageBase::SaveResult storageSaveResult = 
_storage->saveLocalFileToStorage(auth, saveAsPath, saveAsFilename, isRename);
+StorageBase::SaveResult storageSaveResult = 
_storage->saveLocalFileToStorage(
+auth, *_lockCtx, saveAsPath, saveAsFilename, isRename);
 if (storageSaveResult.getResult() == StorageBase::SaveResult::OK)
 {
 if (!isSaveAs && !isRename)
@@ -1299,18 +1306,19 @@ size_t DocumentBroker::removeSession(const std::string& 
id)
 LOG_ERR("Invalid or unknown session [" << id << "] to remove.");
 return _sessions.size();
 }
+std::shared_ptr session = it->second;
 
 // Last view going away, can destroy.
 _markToDestroy = (_sessions.size() <= 1);
 
-const bool lastEditableSession = !it->second->isReadOnly() && 
!haveAnotherEditableSession(id);
+const bool lastEditableSession = !session->isReadOnly() && 
!haveAnotherEditableSession(id);
 static const bool dontSaveIfUnmodified = 
!LOOLWSD::getConfigValue("per_document.always_save_on_exit", false);
 
 LOG_INF("Removing session ["
 << id << "] on docKey [" << _docKey << "]. Have " << 
_sessions.size()
-<< " sessions. IsReadOnly: " << it->second->isReadOnly()
-<< ", IsViewLoaded: " << it->second->isViewLoaded() << ", 
IsWaitDisconnected: "
-<< it->second->inWaitDisconnected() << ", MarkToDestroy: " << 
_markToDestroy
+<< " sessions. IsReadOnly: " << session->isReadOnly()
+<< ", IsViewLoaded: " << session->isViewLoaded() << ", 
IsWaitDisconnected: "
+<< session->inWaitDisconnected() << ", MarkToDestroy: " << 
_markToDestroy
 << ", LastEditableSession: " << lastEditableSession
 << ", dontSaveIfUnmodified: " << dontSaveIfUnmodified);
 
@@ -1341,7 +1349,16 @@ void DocumentBroker::disconnectSessionInternal(const 
std::string& id)
 LOOLWSD::dumpEndSessionTrace(getJailId(), id, _uriOrig);
 #endif
 
-LOG_TRC("Disconnect session internal " << id);
+LOG_TRC("Disconnect session internal " << id <<
+" destroy? " << _markToDestroy <<
+" locked? " << _lockCtx->_isLocked);
+
+if (_markToDestroy && // last session to remove; FIXME: Editable?
+_lockCtx->_isLocked && _storage)
+{
+if (!_storage->updateLockState(it->second->getAuthorization(), 
*_lockCtx, 

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

2019-11-19 Thread Ashod Nakashian (via logerrit)
 wsd/DocumentBroker.cpp |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit eb6508061dbd03becec66e8d927c9439b10c1a43
Author: Ashod Nakashian 
AuthorDate: Tue Nov 19 09:19:21 2019 -0500
Commit: Michael Meeks 
CommitDate: Tue Nov 19 16:07:18 2019 +0100

wsd: notify clients of WOPI CONFLICT response

Change-Id: I7ad7d88066af7f2bba7fd3307c688ab85ba561eb
Reviewed-on: https://gerrit.libreoffice.org/83216
Reviewed-by: Michael Meeks 
Tested-by: Michael Meeks 

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index c8b0e811d..6b393d277 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1040,7 +1040,8 @@ bool DocumentBroker::saveToStorageInternal(const 
std::string& sessionId, bool su
 oss << "error: cmd=storage kind=" << (isRename ? "renamefailed" : 
"savefailed");
 it->second->sendTextFrame(oss.str());
 }
-else if (storageSaveResult.getResult() == 
StorageBase::SaveResult::DOC_CHANGED)
+else if (storageSaveResult.getResult() == 
StorageBase::SaveResult::DOC_CHANGED
+ || storageSaveResult.getResult() == 
StorageBase::SaveResult::CONFLICT)
 {
 LOG_ERR("PutFile says that Document changed in storage");
 _documentChangedInStorage = true;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-11-08 Thread Jan Holesovsky (via logerrit)
 wsd/DocumentBroker.cpp |   33 ++---
 1 file changed, 22 insertions(+), 11 deletions(-)

New commits:
commit 15dcf613d86a8b96e975b6b6c52420f76a26a60c
Author: Jan Holesovsky 
AuthorDate: Fri Nov 8 20:52:35 2019 +0100
Commit: Jan Holesovsky 
CommitDate: Fri Nov 8 22:23:25 2019 +0100

killpoco: More complicated StringTokenizer removal in DocumentBroker.

Change-Id: I55688bfdd5aef49e27dddf56cc47c2ec5834768c
Reviewed-on: https://gerrit.libreoffice.org/82324
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index fd77b83ae..c8b0e811d 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -24,7 +24,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include "Admin.hpp"
 #include "ClientSession.hpp"
@@ -743,19 +742,31 @@ bool DocumentBroker::load(const 
std::shared_ptr& session, const s
 
 const std::string newRootPath = 
_storage->getRootFilePath() + "." + newExtension;
 
+std::vector 
args(LOOLProtocol::tokenize(commandLine, ' '));
+std::string command(args[0]);
+args.erase(args.begin()); // strip the commmand
+
 // The commandline must contain the space-separated 
substring @INPUT@ that is
 // replaced with the input file name, and @OUTPUT@ for the 
output file name.
-Poco::StringTokenizer tokenizer(commandLine, " ");
-if (tokenizer.replace("@INPUT@", 
_storage->getRootFilePath()) != 1 ||
-tokenizer.replace("@OUTPUT@", newRootPath) != 1)
-throw Poco::NotFoundException();
-
+int inputs(0), outputs(0);
+for (auto it = args.begin(); it != args.end(); ++it)
+{
+if (*it == "@INPUT@")
+{
+*it = _storage->getRootFilePath();
+++inputs;
+}
+else if (*it == "@OUTPUT@")
+{
+*it = newRootPath;
+++outputs;
+}
+}
 
-std::vector args;
-for (std::size_t i = 1; i < tokenizer.count(); ++i)
-args.emplace_back(tokenizer[i]);
+if (inputs != 1 || outputs != 1)
+throw std::exception();
 
-int process = Util::spawnProcess(tokenizer[0], args);
+int process = Util::spawnProcess(command, args);
 int status = -1;
 const int rc = ::waitpid(process, , 0);
 if (rc != 0)
@@ -772,7 +783,7 @@ bool DocumentBroker::load(const 
std::shared_ptr& session, const s
 // loop.
 break;
 }
-catch (const Poco::NotFoundException&)
+catch (const std::exception&)
 {
 // This plugin is not a proper prefilter one
 }
___
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/DocumentBroker.hpp wsd/LOOLWSD.cpp

2019-11-05 Thread Ashod Nakashian (via logerrit)
 wsd/DocumentBroker.cpp |   55 +++--
 wsd/DocumentBroker.hpp |6 -
 wsd/LOOLWSD.cpp|1 
 3 files changed, 41 insertions(+), 21 deletions(-)

New commits:
commit 35fdc48e28f915e446bf6d78109368414335fcb9
Author: Ashod Nakashian 
AuthorDate: Tue Oct 22 10:28:57 2019 -0400
Commit: Ashod Nakashian 
CommitDate: Wed Nov 6 03:41:44 2019 +0100

wsd: upload to storage when per_document.always_save_on_exit is set

Saving the document on exit is not enough, we also need
to send it to the storage. We now force doing that,
even when there is no modifiction to the document
(i.e. a new version wasn't really saved).

Reviewed-on: https://gerrit.libreoffice.org/81336
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 
(cherry picked from commit f2913f20b03e916ce8a70f927ca3f5655a3768a8)

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 5a0926a2d..fd77b83ae 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -677,7 +677,6 @@ bool DocumentBroker::load(const 
std::shared_ptr& session, const s
 session->setUserName(username);
 session->setUserExtraInfo(userExtraInfo);
 session->setWatermarkText(watermarkText);
-
 if(!watermarkText.empty())
 session->setHash(watermarkText);
 else
@@ -834,13 +833,21 @@ bool DocumentBroker::saveToStorage(const std::string& 
sessionId,
 {
 assertCorrectThread();
 
-if (force)
+// Force saving on exit, if enabled.
+if (!force && isMarkedToDestroy())
 {
-LOG_TRC("Document will be saved forcefully to storage.");
-_storage->forceSave();
+static const bool always_save = 
LOOLWSD::getConfigValue("per_document.always_save_on_exit", false);
+if (always_save)
+{
+LOG_TRC("Enabling forced saving to storage per always_save_on_exit 
config.");
+_storage->forceSave();
+force = true;
+}
 }
 
-const bool res = saveToStorageInternal(sessionId, success, result);
+constexpr bool isRename = false;
+const bool res = saveToStorageInternal(sessionId, success, result, 
/*saveAsPath*/ std::string(),
+   /*saveAsFilename*/ std::string(), 
isRename, force);
 
 // If marked to destroy, or session is disconnected, remove.
 const auto it = _sessions.find(sessionId);
@@ -864,22 +871,21 @@ bool DocumentBroker::saveAsToStorage(const std::string& 
sessionId, const std::st
 return saveToStorageInternal(sessionId, true, "", saveAsPath, 
saveAsFilename, isRename);
 }
 
-bool DocumentBroker::saveToStorageInternal(const std::string& sessionId,
-   bool success, const std::string& 
result,
-   const std::string& saveAsPath, 
const std::string& saveAsFilename, const bool isRename)
+bool DocumentBroker::saveToStorageInternal(const std::string& sessionId, bool 
success,
+   const std::string& result, const 
std::string& saveAsPath,
+   const std::string& saveAsFilename, 
const bool isRename,
+   const bool force)
 {
 assertCorrectThread();
 
 // Record that we got a response to avoid timing out on saving.
 _lastSaveResponseTime = std::chrono::steady_clock::now();
 
-const bool isSaveAs = !saveAsPath.empty();
-
 // If save requested, but core didn't save because document was unmodified
 // notify the waiting thread, if any.
-LOG_TRC("Saving to storage docKey [" << _docKey << "] for session [" << 
sessionId <<
-"]. Success: " << success << ", result: " << result);
-if (!success && result == "unmodified" && !isRename)
+LOG_TRC("Uploading to storage docKey [" << _docKey << "] for session [" << 
sessionId <<
+"]. Success: " << success << ", result: " << result << ", force: " 
<< force);
+if (!success && result == "unmodified" && !isRename && !force)
 {
 LOG_DBG("Save skipped as document [" << _docKey << "] was not 
modified.");
 _lastSaveTime = std::chrono::steady_clock::now();
@@ -890,18 +896,26 @@ bool DocumentBroker::saveToStorageInternal(const 
std::string& sessionId,
 const auto it = _sessions.find(sessionId);
 if (it == _sessions.end())
 {
-LOG_ERR("Session with sessionId [" << sessionId << "] not found while 
saving docKey [" << _docKey << "].");
+LOG_ERR("Session with sessionId ["
+<< sessionId << "] not found while storing document docKey [" 
<< _docKey
+<< "]. The document will not be uploaded to storage at this 
time.");
 return false;
 }
 
 // Check that we 

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

2019-11-05 Thread Michael Meeks (via logerrit)
 wsd/DocumentBroker.cpp |9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

New commits:
commit a8924e6e6f0cfa88b2ef96a73f0de2686c26508e
Author: Michael Meeks 
AuthorDate: Wed Nov 6 00:33:37 2019 +
Commit: Michael Meeks 
CommitDate: Wed Nov 6 00:33:37 2019 +

avoid crash prior to load when _tileCache is not yet created.

Change-Id: Ic8b3b25af23df7638f0ccf48740f2267612e4e8b

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 754844e89..5a0926a2d 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -291,7 +291,8 @@ void DocumentBroker::pollThread()
 
 #if !MOBILEAPP
 // a tile's data is ~8k, a 4k screen is ~128 256x256 tiles
-_tileCache->setMaxCacheSize(8 * 1024 * 128 * _sessions.size());
+if (_tileCache)
+_tileCache->setMaxCacheSize(8 * 1024 * 128 * _sessions.size());
 
 if (!_isLoaded && (limit_load_secs > 0) && (now > loadDeadline))
 {
@@ -1474,7 +1475,8 @@ bool DocumentBroker::handleInput(const std::vector& 
payload)
 
 size_t DocumentBroker::getMemorySize() const
 {
-return sizeof(DocumentBroker) + _tileCache->getMemorySize() +
+return sizeof(DocumentBroker) +
+(!!_tileCache ? _tileCache->getMemorySize() : 0) +
 _sessions.size() * sizeof(ClientSession);
 }
 
@@ -2171,7 +2173,8 @@ void DocumentBroker::dumpState(std::ostream& os)
 os << "\n  last saved: " << std::ctime();
 os << "\n  cursor " << _cursorPosX << ", " << _cursorPosY
   << "( " << _cursorWidth << "," << _cursorHeight << ")\n";
-_tileCache->dumpState(os);
+if (_tileCache)
+_tileCache->dumpState(os);
 
 _poll->dumpState(os);
 }
___
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

2019-11-04 Thread Ashod Nakashian (via logerrit)
 wsd/DocumentBroker.cpp |2 -
 wsd/LOOLWSD.cpp|   64 +++--
 2 files changed, 42 insertions(+), 24 deletions(-)

New commits:
commit f18cd4c45855c84659af59afad8b936f5c087a0e
Author: Ashod Nakashian 
AuthorDate: Sun Nov 3 15:03:11 2019 -0500
Commit: Andras Timar 
CommitDate: Mon Nov 4 09:36:24 2019 +0100

wsd: improved shutdown cleanup

(cherry picked from commit 5eb58d4e13ed43156115d25482dffa96d7768bfe)

Change-Id: Ibdb822575c376af6065080070bf6b89c240ce67b
Reviewed-on: https://gerrit.libreoffice.org/81977
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index d3b0c654f..754844e89 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -485,7 +485,7 @@ void DocumentBroker::joinThread()
 
 void DocumentBroker::stop(const std::string& reason)
 {
-LOG_DBG("Closing DocumentBroker for docKey [" << _docKey << "] with 
reason: " << reason);
+LOG_DBG("Stopping DocumentBroker for docKey [" << _docKey << "] with 
reason: " << reason);
 _closeReason = reason; // used later in the polling loop
 _stop = true;
 _poll->wakeup();
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index f6d5132dc..0a66ac719 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3488,8 +3488,8 @@ int LOOLWSD::innerMain()
 #if ENABLE_DEBUG
 if (careerSpanMs > 0 && timeSinceStartMs > careerSpanMs)
 {
-LOG_INF(timeSinceStartMs << " milliseconds gone, finishing as 
requested.");
-break;
+LOG_INF(timeSinceStartMs << " milliseconds gone, finishing as 
requested. Setting ShutdownRequestFlag.");
+SigUtil::requestShutdown();
 }
 #endif
 }
@@ -3502,36 +3502,54 @@ int LOOLWSD::innerMain()
 srv.stop();
 
 // atexit handlers tend to free Admin before Documents
-LOG_INF("Cleaning up lingering documents.");
-if (SigUtil::getShutdownRequestFlag() || SigUtil::getTerminationFlag())
+LOG_INF("Exiting. Cleaning up lingering documents.");
+if (!SigUtil::getShutdownRequestFlag())
 {
-// Don't stop the DocBroker, they will exit.
-const size_t sleepMs = 300;
-const size_t count = std::max(COMMAND_TIMEOUT_MS, 2000) / 
sleepMs;
-for (size_t i = 0; i < count; ++i)
-{
-std::unique_lock docBrokersLock(DocBrokersMutex);
-cleanupDocBrokers();
-if (DocBrokers.empty())
-break;
-docBrokersLock.unlock();
-
-// Give them time to save and cleanup.
-std::this_thread::sleep_for(std::chrono::milliseconds(sleepMs));
-}
+// This shouldn't happen, but it's fail safe to always cleanup 
properly.
+LOG_WRN("Exiting WSD without ShutdownRequestFlag. Setting it now.");
+SigUtil::requestShutdown();
 }
-else
+
+// Don't stop the DocBroker, they will exit.
+constexpr size_t sleepMs = 500;
+constexpr size_t count = (COMMAND_TIMEOUT_MS * 4) / sleepMs;
+for (size_t i = 0; i < count; ++i)
 {
-// Stop and join.
-for (auto& docBrokerIt : DocBrokers)
-docBrokerIt.second->joinThread();
+std::unique_lock docBrokersLock(DocBrokersMutex);
+if (DocBrokers.empty())
+break;
+
+LOG_DBG("Waiting for " << DocBrokers.size() << " documents to stop.");
+cleanupDocBrokers();
+docBrokersLock.unlock();
+
+// Give them time to save and cleanup.
+std::this_thread::sleep_for(std::chrono::milliseconds(sleepMs));
 }
 
 // Disable thread checking - we'll now cleanup lots of things if we can
 Socket::InhibitThreadChecks = true;
 SocketPoll::InhibitThreadChecks = true;
 
-DocBrokers.clear();
+// Wait for the DocumentBrokers. They must be saving/uploading now.
+// Do not stop them! Otherwise they might not save/upload the document.
+// We block until they finish, or the service stopping times out.
+{
+std::unique_lock docBrokersLock(DocBrokersMutex);
+for (auto& docBrokerIt : DocBrokers)
+{
+std::shared_ptr docBroker = docBrokerIt.second;
+if (docBroker && docBroker->isAlive())
+{
+LOG_DBG("Joining docBroker [" << docBrokerIt.first << "].");
+docBroker->joinThread();
+}
+}
+
+// Now should be safe to destroy what's left.
+cleanupDocBrokers();
+DocBrokers.clear();
+}
 
 #if !defined(KIT_IN_PROCESS) && !MOBILEAPP
 // Terminate child processes
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-10-28 Thread Ashod Nakashian (via logerrit)
 wsd/DocumentBroker.cpp |   14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

New commits:
commit 8a06ad83e473e3f0b34e83a7ba4e45bebd0bdaeb
Author: Ashod Nakashian 
AuthorDate: Wed Oct 16 09:05:04 2019 -0400
Commit: Ashod Nakashian 
CommitDate: Tue Oct 29 01:42:05 2019 +0100

wsd: save using a fully-loaded view

Using a view that hasn't finished loading
for saving the document will fail, and there
is no recovery from that (by using a loaded
view as fallback, for example).

This can happen when a new view is being loaded
while the last one is closing. We might in this
case end up using the new view to save the document
before closing it, however this will fail if
the new view hasn't loaded yet, potentially
losing some late modifications.

We avoid this by always picking a loaded view
for saving, or the first.

Reviewed-on: https://gerrit.libreoffice.org/80896
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Andras Timar 
(cherry picked from commit 77cbe4e376649dee87dbe37f95a48e9bb6403a0b)

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 081a07c55..18568b53b 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1054,8 +1054,9 @@ bool DocumentBroker::autoSave(const bool force, const 
bool dontSaveIfUnmodified)
 for (auto& sessionIt : _sessions)
 {
 // Save the document using an editable session, or first ...
-if (savingSessionId.empty() ||
-(!sessionIt.second->isReadOnly() && 
!sessionIt.second->inWaitDisconnected()))
+if (savingSessionId.empty()
+|| (!sessionIt.second->isReadOnly() && 
sessionIt.second->isViewLoaded()
+&& !sessionIt.second->inWaitDisconnected()))
 {
 savingSessionId = sessionIt.second->getId();
 }
@@ -1271,9 +1272,12 @@ size_t DocumentBroker::removeSession(const std::string& 
id)
 
 const bool lastEditableSession = !it->second->isReadOnly() && 
!haveAnotherEditableSession(id);
 
-LOG_INF("Removing session [" << id << "] on docKey [" << _docKey <<
-"]. Have " << _sessions.size() << " sessions. markToDestroy: " 
<< _markToDestroy <<
-", LastEditableSession: " << lastEditableSession);
+LOG_INF("Removing session ["
+<< id << "] on docKey [" << _docKey << "]. Have " << 
_sessions.size()
+<< " sessions. IsReadOnly: " << it->second->isReadOnly()
+<< ", IsViewLoaded: " << it->second->isViewLoaded() << ", 
IsWaitDisconnected: "
+<< it->second->inWaitDisconnected() << ", MarkToDestroy: " << 
_markToDestroy
+<< ", LastEditableSession: " << lastEditableSession);
 
 const auto dontSaveIfUnmodified = 
!LOOLWSD::getConfigValue("per_document.always_save_on_exit", false);
 
___
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/DocumentBroker.hpp wsd/LOOLWSD.cpp

2019-10-04 Thread Michael Meeks (via logerrit)
 wsd/DocumentBroker.cpp |   13 +++--
 wsd/DocumentBroker.hpp |8 +++-
 wsd/LOOLWSD.cpp|6 --
 3 files changed, 22 insertions(+), 5 deletions(-)

New commits:
commit 5e7cac28fa74131461f6d9e25334e9cc7568f444
Author: Michael Meeks 
AuthorDate: Fri Oct 4 10:30:49 2019 +0100
Commit: Michael Meeks 
CommitDate: Fri Oct 4 11:01:45 2019 +0100

belt & braces fix erroneous popup of limit dialog

The shared_ptr allows the DocumentBroker's and ConvertToBroker to linger
after they are removed from the list, making 
ConvertToBroker::getInstanceCount
potentially larger than the number of documents transiently. Fix this
with a dispose method called on list removal.
Also make the arithmetic signed, to avoid unfortunate wrapping.
Also when the limit is large, don't show a message whatever happens.

Change-Id: Id2571429de48ae75e851c3fdc49e24a02aaaf6e9

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index ab71fe5ba..c332f7c52 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -2072,10 +2072,19 @@ ConvertToBroker::ConvertToBroker(const std::string& uri,
 NumConverters++;
 }
 
+void ConvertToBroker::dispose()
+{
+if (!_uriOrig.empty())
+{
+NumConverters--;
+removeFile(_uriOrig);
+_uriOrig.clear();
+}
+}
+
 ConvertToBroker::~ConvertToBroker()
 {
-NumConverters--;
-removeFile(_uriOrig);
+dispose();
 }
 
 void ConvertToBroker::removeFile(const std::string )
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 576906d9e..7c66832a5 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -225,6 +225,9 @@ public:
 
 virtual ~DocumentBroker();
 
+/// Called when removed from the DocBrokers list
+virtual void dispose() {}
+
 /// Start processing events
 void startThread();
 
@@ -420,7 +423,7 @@ private:
 void getIOStats(uint64_t , uint64_t );
 
 protected:
-const std::string _uriOrig;
+std::string _uriOrig;
 private:
 const Poco::URI _uriPublic;
 /// URL-based key. May be repeated during the lifetime of WSD.
@@ -498,6 +501,9 @@ public:
 const std::string& docKey);
 virtual ~ConvertToBroker();
 
+/// Called when removed from the DocBrokers list
+void dispose() override;
+
 /// How many live conversions are running.
 static size_t getInstanceCount();
 
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index f404798d0..b460d75d8 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -258,8 +258,9 @@ inline void shutdownLimitReached(WebSocketHandler& ws)
 inline void checkSessionLimitsAndWarnClients()
 {
 #if !MOBILEAPP
-size_t docBrokerCount = DocBrokers.size() - 
ConvertToBroker::getInstanceCount();
-if (docBrokerCount > LOOLWSD::MaxDocuments || LOOLWSD::NumConnections >= 
LOOLWSD::MaxConnections)
+ssize_t docBrokerCount = DocBrokers.size() - 
ConvertToBroker::getInstanceCount();
+if (LOOLWSD::MaxDocuments < 1 &&
+(docBrokerCount > LOOLWSD::MaxDocuments || LOOLWSD::NumConnections >= 
LOOLWSD::MaxConnections))
 {
 const std::string info = Poco::format(PAYLOAD_INFO_LIMIT_REACHED, 
LOOLWSD::MaxDocuments, LOOLWSD::MaxConnections);
 LOG_INF("Sending client 'limitreached' message: " << info);
@@ -333,6 +334,7 @@ void cleanupDocBrokers()
 if (!docBroker->isAlive())
 {
 LOG_INF("Removing DocumentBroker for docKey [" << it->first << 
"].");
+docBroker->dispose();
 it = DocBrokers.erase(it);
 continue;
 } else {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-09-22 Thread Ashod Nakashian (via logerrit)
 wsd/DocumentBroker.cpp |   11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

New commits:
commit fd5581e7a314d343e628315d054aaaf5efd9795c
Author: Ashod Nakashian 
AuthorDate: Thu Sep 19 23:42:13 2019 -0400
Commit: Ashod Nakashian 
CommitDate: Sun Sep 22 20:19:41 2019 +0200

wsd: log before killing slow-loading docs

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index dffe5ea7f..ab71fe5ba 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -277,8 +277,8 @@ void DocumentBroker::pollThread()
 auto lastBWUpdateTime = std::chrono::steady_clock::now();
 auto lastClipboardHashUpdateTime = std::chrono::steady_clock::now();
 
-int limit_load_secs = 
LOOLWSD::getConfigValue("per_document.limit_load_secs", 100);
-auto loadDeadline = std::chrono::steady_clock::now() + 
std::chrono::seconds(limit_load_secs);
+const int limit_load_secs = 
LOOLWSD::getConfigValue("per_document.limit_load_secs", 100);
+const auto loadDeadline = std::chrono::steady_clock::now() + 
std::chrono::seconds(limit_load_secs);
 #endif
 auto last30SecCheckTime = std::chrono::steady_clock::now();
 
@@ -294,7 +294,14 @@ void DocumentBroker::pollThread()
 {
 // Brutal but effective.
 if (_childProcess)
+{
+LOG_WRN("Doc [" << _docKey << "] is taking too long to load. 
Will kill process ["
+<< _childProcess->getPid()
+<< "]. per_document.limit_load_secs set to " 
<< limit_load_secs
+<< " secs.");
 _childProcess->terminate();
+}
+
 stop("Load timed out");
 continue;
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-05-30 Thread Libreoffice Gerrit user
 wsd/DocumentBroker.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 2827d50ee7e6e9fb35bc32fdeddd193d20e54158
Author: Miklos Vajna 
AuthorDate: Thu May 30 08:43:39 2019 +0200
Commit: Miklos Vajna 
CommitDate: Thu May 30 08:43:45 2019 +0200

wsd: avoid unnecessary copy initialization in DocumentBroker

'filename' was copy-constructed from a const reference, no need to make a
copy.

Change-Id: I2ad86a1a524359c3bd50975484d7742558e88dfd

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 51ca64927..fefe15ccd 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -902,7 +902,7 @@ bool DocumentBroker::saveToStorageInternal(const 
std::string& sessionId,
 else if (isRename)
 {
 // encode the name
-const std::string filename = storageSaveResult.getSaveAsName();
+const std::string& filename = storageSaveResult.getSaveAsName();
 const std::string url = 
Poco::URI(storageSaveResult.getSaveAsUrl()).toString();
 std::string encodedName;
 Poco::URI::encode(filename, "", encodedName);
___
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/DocumentBroker.hpp

2019-05-24 Thread Libreoffice Gerrit user
 wsd/DocumentBroker.cpp |3 +++
 wsd/DocumentBroker.hpp |1 +
 2 files changed, 4 insertions(+)

New commits:
commit 1a41e368add6d95ecd866cba1f2262fdfb329fe5
Author: Miklos Vajna 
AuthorDate: Fri May 24 09:04:07 2019 +0200
Commit: Miklos Vajna 
CommitDate: Fri May 24 09:04:16 2019 +0200

wsd: avoid UB in DocumentBroker::cancelTileRequests()

With this, it's possible to open a document and type keys with
sanitizers enabled.


/home/vmiklos/lode/opt_private/gcc-7.3.0/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../include/c++/7.3.0/bits/unique_ptr.h:323:9:
 runtime error: reference binding to null pointer of type 'TileCache'
#0 0x911996 in std::unique_ptr >::operator*() const 
/home/vmiklos/lode/opt_private/gcc-7.3.0/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../include/c++/7.3.0/bits/unique_ptr.h:323:2
#1 0x8ecb2a in DocumentBroker::tileCache() 
/home/vmiklos/lode/dev/online/./wsd/DocumentBroker.hpp:265:37
#2 0x8c6a63 in 
DocumentBroker::cancelTileRequests(std::shared_ptr const&) 
/home/vmiklos/lode/dev/online/wsd/DocumentBroker.cpp:1586:37
#3 0xb32b0e in ClientSession::_handleInput(char const*, int) 
/home/vmiklos/lode/dev/online/wsd/ClientSession.cpp:194:20
#4 0xd45d3c in Session::handleMessage(bool, WSOpCode, std::vector >&) /home/vmiklos/lode/dev/online/common/Session.cpp:219:13
#5 0x768080 in 
WebSocketHandler::handleTCPStream(std::shared_ptr const&) 
/home/vmiklos/lode/dev/online/./net/WebSocketHandler.hpp:368:13
#6 0x6f800d in 
WebSocketHandler::handleIncomingMessage(SocketDisposition&) 
/home/vmiklos/lode/dev/online/./net/WebSocketHandler.hpp:419:20
#7 0xb2c644 in ClientSession::handleIncomingMessage(SocketDisposition&) 
/home/vmiklos/lode/dev/online/wsd/ClientSession.cpp:74:14
#8 0xa6f641 in StreamSocket::handlePoll(SocketDisposition&, 
std::chrono::time_point > >, int) 
/home/vmiklos/lode/dev/online/./net/Socket.hpp:1037:29
#9 0x6ec63d in SocketPoll::poll(int) 
/home/vmiklos/lode/dev/online/./net/Socket.hpp:570:34
#10 0x83af99 in DocumentBroker::pollThread() 
/home/vmiklos/lode/dev/online/wsd/DocumentBroker.cpp:387:16
#11 0x8fc778 in DocumentBroker::DocumentBrokerPoll::pollingThread() 
/home/vmiklos/lode/dev/online/wsd/DocumentBroker.cpp:165:20
#12 0xdff935 in SocketPoll::pollingThreadEntry() 
/home/vmiklos/lode/dev/online/net/Socket.cpp:184:9
#13 0xe487bd in void std::__invoke_impl(std::__invoke_memfun_deref, void (SocketPoll::*&&)(), 
SocketPoll*&&) 
/home/vmiklos/lode/opt_private/gcc-7.3.0/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../include/c++/7.3.0/bits/invoke.h:73:14
#14 0xe482ca in std::__invoke_result::type std::__invoke(void 
(SocketPoll::*&&)(), SocketPoll*&&) 
/home/vmiklos/lode/opt_private/gcc-7.3.0/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../include/c++/7.3.0/bits/invoke.h:95:14
#15 0xe4817d in decltype(std::__invoke(_S_declval<0ul>(), 
_S_declval<1ul>())) std::thread::_Invoker >::_M_invoke<0ul, 1ul>(std::_Index_tuple<0ul, 1ul>) 
/home/vmiklos/lode/opt_private/gcc-7.3.0/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../include/c++/7.3.0/thread:234:13
#16 0xe47f87 in std::thread::_Invoker >::operator()() 
/home/vmiklos/lode/opt_private/gcc-7.3.0/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../include/c++/7.3.0/thread:243:11
#17 0xe4734a in 
std::thread::_State_impl > >::_M_run() 
/home/vmiklos/lode/opt_private/gcc-7.3.0/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../include/c++/7.3.0/thread:186:13
#18 0x7f5c2ce55e2e in execute_native_thread_routine 
/home/vmiklos/lode/packages/gccbuild/x86_64-pc-linux-gnu/libstdc++-v3/src/c++11/../../../../../gcc-7.3.0/libstdc++-v3/src/c++11/thread.cc:83
#19 0x7f5c2c832558 in start_thread (/lib64/libpthread.so.0+0x7558)
#20 0x7f5c2bf4682e in clone (/lib64/libc.so.6+0xf882e)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior 
/home/vmiklos/lode/opt_private/gcc-7.3.0/lib/gcc/x86_64-pc-linux-gnu/7.3.0/../../../../include/c++/7.3.0/bits/unique_ptr.h:323:9
 in

Change-Id: Ief574a11c838c77f7f159b1133beeef0deada201

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 30f0619c6..51ca64927 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1588,6 +1588,9 @@ void DocumentBroker::cancelTileRequests(const 
std::shared_ptr& se
 
 session->resetWireIdMap();
 
+if (!hasTileCache())
+return;
+
 const std::string canceltiles = tileCache().cancelTiles(session);
 if (!canceltiles.empty())
 {
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index c56ced733..1923d3b93 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -263,6 +263,7 @@ public:
 const std::string& getDocKey() const { return _docKey; }
 const std::string& getFilename() const { return _filename; };
 TileCache& tileCache() { return *_tileCache; }
+bool hasTileCache() { return _tileCache 

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

2019-05-21 Thread Libreoffice Gerrit user
 wsd/DocumentBroker.cpp |   11 ---
 wsd/DocumentBroker.hpp |3 +++
 wsd/LOOLWSD.cpp|9 +
 3 files changed, 20 insertions(+), 3 deletions(-)

New commits:
commit 1845ed42af661dbb7b10a2fb4686ce2c8ef7e521
Author: Michael Meeks 
AuthorDate: Tue May 21 19:50:17 2019 +0100
Commit: Michael Meeks 
CommitDate: Wed May 22 01:57:48 2019 +0200

tdf#123482 - cleanup convert-to folder even more reliably.

Problems could occur if exceptiosn thrown when parsing the input stream.

Change-Id: Id82b3816450194164fc2093554c730b4a94acef1
Reviewed-on: https://gerrit.libreoffice.org/72695
Reviewed-by: Michael Meeks 
Tested-by: Michael Meeks 

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 6779473a4..698f3dd98 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1908,13 +1908,18 @@ ConvertToBroker::ConvertToBroker(const std::string& uri,
 ConvertToBroker::~ConvertToBroker()
 {
 NumConverters--;
-if (!_uriOrig.empty())
+removeFile(_uriOrig);
+}
+
+void ConvertToBroker::removeFile(const std::string )
+{
+if (!uriOrig.empty())
 {
 // Remove source file and directory
-Poco::Path path = _uriOrig;
+Poco::Path path = uriOrig;
 Poco::File(path).remove();
 Poco::File(path.makeParent()).remove();
-FileUtil::removeFile(_uriOrig);
+FileUtil::removeFile(uriOrig);
 }
 }
 
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 0642599c2..c56ced733 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -481,6 +481,9 @@ public:
 
 /// How many live conversions are running.
 static size_t getInstanceCount();
+
+/// Cleanup path and its parent
+static void removeFile(const std::string );
 };
 
 #endif
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 69e74114a..25877811a 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -572,6 +572,9 @@ class ConvertToPartHandler : public PartHandler
 public:
 std::string getFilename() const { return _filename; }
 
+/// Afterwards someone else is responsible for cleaning that up.
+void takeFile() { _filename.clear(); }
+
 ConvertToPartHandler(bool convertTo = false)
 : _convertTo(convertTo)
 {
@@ -579,6 +582,11 @@ public:
 
 virtual ~ConvertToPartHandler()
 {
+if (!_filename.empty())
+{
+LOG_TRC("Remove un-handled temporary file '" << _filename << "'");
+ConvertToBroker::removeFile(_filename);
+}
 }
 
 virtual void handlePart(const MessageHeader& header, std::istream& stream) 
override
@@ -2377,6 +2385,7 @@ private:
 
 LOG_DBG("New DocumentBroker for docKey [" << docKey << 
"].");
 auto docBroker = 
std::make_shared(fromPath, uriPublic, docKey);
+handler.takeFile();
 
 cleanupDocBrokers();
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-05-21 Thread Libreoffice Gerrit user
 wsd/DocumentBroker.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 73108db91330d049afa5520e9f82a99846737d4d
Author: Miklos Vajna 
AuthorDate: Tue May 21 09:13:13 2019 +0200
Commit: Miklos Vajna 
CommitDate: Tue May 21 09:13:13 2019 +0200

wsd: fix -Werror,-Winconsistent-missing-override

Change-Id: Ide9921e410a8e1401a25b85fda04de1b5a45617a

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index a2fb6f2ab..6779473a4 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -159,7 +159,7 @@ public:
 return TerminatingPoll::continuePolling();
 }
 
-virtual void pollingThread()
+void pollingThread() override
 {
 // Delegate to the docBroker.
 _docBroker.pollThread();
___
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/TileCache.cpp

2019-04-22 Thread Libreoffice Gerrit user
 wsd/DocumentBroker.cpp |4 ++--
 wsd/TileCache.cpp  |2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

New commits:
commit ca1a83f96b013e171130596dd1486b1416ddbea3
Author: Ashod Nakashian 
AuthorDate: Mon Apr 22 12:03:49 2019 -0400
Commit: Ashod Nakashian 
CommitDate: Tue Apr 23 03:02:36 2019 +0200

wsd: reduce tile logging from debug to trace level

These are very frequent and not very useful without
the ability to trace them across the system, which
are all done at trace level. So it's highly unlikely
that these would be used at debug.

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 53d3e2dbe..40465c0ce 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1395,7 +1395,7 @@ void 
DocumentBroker::handleTileCombinedRequest(TileCombined& tileCombined,
 
 // Forward to child to render.
 const std::string req = newTileCombined.serialize("tilecombine");
-LOG_DBG("Sending residual tilecombine: " << req);
+LOG_TRC("Sending uncached residual tilecombine request to Kit: " << 
req);
 _childProcess->sendTextFrame(req);
 }
 
@@ -1527,7 +1527,7 @@ void DocumentBroker::sendRequestedTiles(const 
std::shared_ptr& se
 
 // Forward to child to render.
 const std::string req = newTileCombined.serialize("tilecombine");
-LOG_DBG("Some of the tiles were not prerendered. Sending residual 
tilecombine: " << req);
+LOG_TRC("Some of the tiles were not prerendered. Sending residual 
tilecombine: " << req);
 _childProcess->sendTextFrame(req);
 }
 }
diff --git a/wsd/TileCache.cpp b/wsd/TileCache.cpp
index 287e0ba77..a4f16a5f0 100644
--- a/wsd/TileCache.cpp
+++ b/wsd/TileCache.cpp
@@ -311,7 +311,7 @@ void TileCache::invalidateTiles(int part, int x, int y, int 
width, int height)
 {
 if (intersectsTile(it->first, part, x, y, width, height))
 {
-LOG_DBG("Removing tile: " << it->first.serialize());
+LOG_TRC("Removing tile: " << it->first.serialize());
 it = _cache.erase(it);
 }
 else
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-03-21 Thread Libreoffice Gerrit user
 wsd/DocumentBroker.cpp |   10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

New commits:
commit c459ad77a1f278dc51d947f6b2a5fa559f279612
Author: Tor Lillqvist 
AuthorDate: Thu Mar 21 14:25:15 2019 +0200
Commit: Tor Lillqvist 
CommitDate: Thu Mar 21 14:36:46 2019 +0200

tdf#124055: Idle timeout is pointless in mobile apps

We don't want to unload the document and show any "Idle document -
please click to reload and resume editing" overlay.

What the iOS (and presumably Android) app *would* need, though, is
proper restore functionality. I.e. if you have a document open, and
the app is put in the background (i.e. the user does something else),
and the OS kills it (as is perfectly normal for iOS or Android to do
to idle background apps), then when the user returs to the app, it
should reopen the same document and restore the view location and zoom
level.

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index cc4068bc3..8524725ff 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -246,10 +246,11 @@ void DocumentBroker::pollThread()
 LOG_INF("Doc [" << _docKey << "] attached to child [" << 
_childProcess->getPid() << "].");
 
 static const bool AutoSaveEnabled = !std::getenv("LOOL_NO_AUTOSAVE");
+
+#if !MOBILEAPP
 static const size_t IdleDocTimeoutSecs = LOOLWSD::getConfigValue(
   
"per_document.idle_timeout_secs", 3600);
 
-#if !MOBILEAPP
 // Used to accumulate B/W deltas.
 uint64_t adminSent = 0;
 uint64_t adminRecv = 0;
@@ -320,9 +321,11 @@ void DocumentBroker::pollThread()
 last30SecCheckTime = std::chrono::steady_clock::now();
 }
 
+if (false)
+;
+#if !MOBILEAPP
 // Remove idle documents after 1 hour.
-const bool idle = (isLoaded() && getIdleTimeSecs() >= 
IdleDocTimeoutSecs);
-if (idle)
+else if (isLoaded() && getIdleTimeSecs() >= IdleDocTimeoutSecs)
 {
 // Stop if there is nothing to save.
 LOG_INF("Autosaving idle DocumentBroker for docKey [" << 
getDocKey() << "] to kill.");
@@ -332,6 +335,7 @@ void DocumentBroker::pollThread()
 stop("idle");
 }
 }
+#endif
 else if (_sessions.empty() && (isLoaded() || _markToDestroy))
 {
 // If all sessions have been removed, no reason to linger.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-02-26 Thread Libreoffice Gerrit user
 wsd/DocumentBroker.cpp |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 406a7dd59e09dfdffbb9d1516f4a10df6e0dff9c
Author: Ashod Nakashian 
AuthorDate: Wed Feb 13 17:42:05 2019 -0500
Commit: Szymon Kłos 
CommitDate: Tue Feb 26 14:23:00 2019 +0100

Fix PostMessageOrigin typo in log

Change-Id: I3d41c832561f9de1b46ef1444d8d0b1d633c7b63
Reviewed-on: https://gerrit.libreoffice.org/68249
Reviewed-by: Szymon Kłos 
Tested-by: Szymon Kłos 
(cherry picked from commit 9bc70150c856e8d671ade99e1d2024a8f0f45d9d)
Reviewed-on: https://gerrit.libreoffice.org/68390

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index e615b6d04..8f86c0398 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -208,6 +208,7 @@ void DocumentBroker::pollThread()
 
std::chrono::duration_cast(std::chrono::steady_clock::now()
 -
   
_threadStart).count() > timeoutMs)
 break;
+
 // Nominal time between retries, lest we busy-loop. getNewChild could 
also wait, so don't double that here.
 
std::this_thread::sleep_for(std::chrono::milliseconds(CHILD_REBALANCE_INTERVAL_MS
 / 10));
 }
@@ -489,7 +490,6 @@ bool DocumentBroker::load(const 
std::shared_ptr& session, const s
 
 #if !MOBILEAPP
 std::chrono::duration getInfoCallDuration(0);
-
 WopiStorage* wopiStorage = dynamic_cast(_storage.get());
 if (wopiStorage != nullptr)
 {
@@ -515,7 +515,7 @@ bool DocumentBroker::load(const 
std::shared_ptr& session, const s
 (LOOLWSD::isSSLEnabled() || LOOLWSD::isSSLTermination()))
 {
 wopifileinfo->getPostMessageOrigin().replace(0, 4, "https");
-LOG_DBG("Updating PostMessageOrgin scheme to HTTPS. Updated 
origin is [" << wopifileinfo->getPostMessageOrigin() << "].");
+LOG_DBG("Updating PostMessageOrigin scheme to HTTPS. Updated 
origin is [" << wopifileinfo->getPostMessageOrigin() << "].");
 }
 
 wopiInfo->set("PostMessageOrigin", 
wopifileinfo->getPostMessageOrigin());
___
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/TileCache.cpp wsd/TileCache.hpp

2019-02-15 Thread Libreoffice Gerrit user
 wsd/DocumentBroker.cpp |1 +
 wsd/TileCache.cpp  |   14 ++
 wsd/TileCache.hpp  |4 ++--
 3 files changed, 17 insertions(+), 2 deletions(-)

New commits:
commit 150d20cf37b2aa6112b13f73cf67b466f8a64975
Author: Michael Meeks 
AuthorDate: Fri Feb 15 20:42:00 2019 +0100
Commit: Michael Meeks 
CommitDate: Fri Feb 15 21:36:28 2019 +0100

TileCache: dumpState.

Change-Id: I6289f0b77eb0649be8254aa8c9647c47d4db3008

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 2239079e6..e615b6d04 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1888,6 +1888,7 @@ void DocumentBroker::dumpState(std::ostream& os)
 os << "\n  last saved: " << std::ctime();
 os << "\n  cursor " << _cursorPosX << ", " << _cursorPosY
   << "( " << _cursorWidth << "," << _cursorHeight << ")\n";
+_tileCache->dumpState(os);
 
 _poll->dumpState(os);
 }
diff --git a/wsd/TileCache.cpp b/wsd/TileCache.cpp
index e87fe9214..a5dae27c6 100644
--- a/wsd/TileCache.cpp
+++ b/wsd/TileCache.cpp
@@ -559,4 +559,18 @@ TileCache::Tile TileCache::loadTile(const std::string 
)
 return TileCache::Tile();
 }
 
+void TileCache::dumpState(std::ostream& os)
+{
+size_t num = 0, size = 0;
+for (auto it : _cache)
+{
+num++; size += it.second->size();
+}
+os << "  tile cache: num: " << num << " size: " << size << " bytes\n";
+for (auto it : _cache)
+{
+os << "" /* << std::setw(4) << it.first->getWireId() */ << " - '" 
<< it.first << "' - " << it.second->size() << " bytes\n";
+}
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/wsd/TileCache.hpp b/wsd/TileCache.hpp
index 9f847fc5d..fe5a7ca34 100644
--- a/wsd/TileCache.hpp
+++ b/wsd/TileCache.hpp
@@ -91,11 +91,11 @@ public:
 bool hasTileBeingRendered(const TileDesc& tile);
 int getTileBeingRenderedVersion(const TileDesc& tile);
 
+// Debugging bits ...
+void dumpState(std::ostream& os);
 void setThreadOwner(const std::thread::id ) { _owner = id; }
 void assertCorrectThread();
 
-
-
 private:
 void invalidateTiles(int part, int x, int y, int width, int height);
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-01-02 Thread Libreoffice Gerrit user
 wsd/DocumentBroker.cpp |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 3d38a71d77f4a089b1ffdae251a9e595f0afe29d
Author: Miklos Vajna 
AuthorDate: Wed Jan 2 09:07:06 2019 +0100
Commit: Miklos Vajna 
CommitDate: Wed Jan 2 09:07:06 2019 +0100

Minor cleanups in DocumentBroker

documentLastModifiedTime was an unnecessary value parameter, filename
was copy-initialized without a reason.

Change-Id: I5e5a2fe9d9fcde61db539e30689492b8c191b598

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 4199ece0c..c21177af1 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -61,7 +61,7 @@ namespace
 
 void sendLastModificationTime(const std::shared_ptr& session,
   DocumentBroker* documentBroker,
-  Poco::Timestamp documentLastModifiedTime)
+  const Poco::Timestamp& documentLastModifiedTime)
 {
 if (!session)
 return;
@@ -878,7 +878,7 @@ bool DocumentBroker::saveToStorageInternal(const 
std::string& sessionId,
 // normalize the url (mainly to " " -> "%20")
 const std::string url = 
Poco::URI(storageSaveResult.getSaveAsUrl()).toString();
 
-const std::string filename = storageSaveResult.getSaveAsName();
+const std::string& filename = storageSaveResult.getSaveAsName();
 
 // encode the name
 std::string encodedName;
___
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/Storage.hpp

2018-12-15 Thread Libreoffice Gerrit user
 wsd/DocumentBroker.cpp |2 +-
 wsd/Storage.hpp|2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

New commits:
commit 892117eb37b86f87c7b4f52ecc1ea8655e839564
Author: Andras Timar 
AuthorDate: Sat Dec 15 15:23:58 2018 +0100
Commit: Andras Timar 
CommitDate: Sat Dec 15 15:23:58 2018 +0100

_hideUserList is private

Change-Id: I1cded189783d897fa7aa1c65853dc506518b125e

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 2ea017bc2..631f95a39 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -552,7 +552,7 @@ bool DocumentBroker::load(const 
std::shared_ptr& session, const s
 wopiInfo->set("UserCanNotWriteRelative", 
wopifileinfo->getUserCanNotWriteRelative());
 wopiInfo->set("EnableInsertRemoteImage", 
wopifileinfo->getEnableInsertRemoteImage());
 wopiInfo->set("EnableShare", wopifileinfo->getEnableShare());
-wopiInfo->set("HideUserList", wopifileinfo->_hideUserList);
+wopiInfo->set("HideUserList", wopifileinfo->getHideUserList());
 if (wopifileinfo->getHideChangeTrackingControls() != 
WopiStorage::WOPIFileInfo::TriState::Unset)
 wopiInfo->set("HideChangeTrackingControls", 
wopifileinfo->getHideChangeTrackingControls() == 
WopiStorage::WOPIFileInfo::TriState::True);
 
diff --git a/wsd/Storage.hpp b/wsd/Storage.hpp
index fd70515c4..467deea40 100644
--- a/wsd/Storage.hpp
+++ b/wsd/Storage.hpp
@@ -393,6 +393,8 @@ public:
 
 bool getEnableShare() const { return _enableShare; }
 
+std::string& getHideUserList() const { return _hideUserList; }
+
 TriState getDisableChangeTrackingShow() const { return 
_disableChangeTrackingShow; }
 
 TriState getDisableChangeTrackingRecord() const { return 
_disableChangeTrackingRecord; }
___
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/DocumentBroker.hpp wsd/reference.md wsd/Storage.cpp wsd/Storage.hpp

2018-12-05 Thread Libreoffice Gerrit user
 wsd/DocumentBroker.cpp |   12 +---
 wsd/DocumentBroker.hpp |4 +++-
 wsd/Storage.cpp|1 +
 wsd/Storage.hpp|7 +--
 wsd/reference.md   |4 
 5 files changed, 22 insertions(+), 6 deletions(-)

New commits:
commit 2e9af9da16a7ed42bde4b6294f7970c00be9c566
Author: Samuel Mehrbrodt 
AuthorDate: Tue Dec 4 08:49:49 2018 +0100
Commit: Samuel Mehrbrodt 
CommitDate: Wed Dec 5 11:50:59 2018 +0100

Add custom http header when saving before document is cleaned up from memory

Change-Id: I3ac417d83a79a665ae6575097835542f43d40cef
Reviewed-on: https://gerrit.libreoffice.org/64499
Reviewed-by: Samuel Mehrbrodt 
Tested-by: Samuel Mehrbrodt 

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index c2dda9221..3b4de7ee6 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -962,7 +962,9 @@ bool DocumentBroker::autoSave(const bool force)
 {
 LOG_TRC("Sending forced save command for [" << _docKey << "].");
 // Don't terminate editing as this can be invoked by the admin OOM, 
but otherwise force saving anyway.
-sent = sendUnoSave(savingSessionId, /*dontTerminateEdit=*/ true, 
/*dontSaveIfUnmodified=*/ true, /*isAutosave=*/ false);
+sent = sendUnoSave(savingSessionId, /*dontTerminateEdit=*/true,
+   /*dontSaveIfUnmodified=*/true, /*isAutosave=*/false,
+   /*isExitSave=*/true);
 }
 else if (_isModified)
 {
@@ -979,14 +981,17 @@ bool DocumentBroker::autoSave(const bool force)
 timeSinceLastSaveMs >= autoSaveDurationMs)
 {
 LOG_TRC("Sending timed save command for [" << _docKey << "].");
-sent = sendUnoSave(savingSessionId, /*dontTerminateEdit=*/ true, 
/*dontSaveIfUnmodified=*/ true, /*isAutosave=*/ true);
+sent = sendUnoSave(savingSessionId, /*dontTerminateEdit=*/true,
+   /*dontSaveIfUnmodified=*/true, 
/*isAutosave=*/true,
+   /*isExitSave=*/false);
 }
 }
 
 return sent;
 }
 
-bool DocumentBroker::sendUnoSave(const std::string& sessionId, bool 
dontTerminateEdit, bool dontSaveIfUnmodified, bool isAutosave)
+bool DocumentBroker::sendUnoSave(const std::string& sessionId, bool 
dontTerminateEdit,
+ bool dontSaveIfUnmodified, bool isAutosave, 
bool isExitSave)
 {
 assertCorrectThread();
 
@@ -1029,6 +1034,7 @@ bool DocumentBroker::sendUnoSave(const std::string& 
sessionId, bool dontTerminat
 
 assert(_storage);
 _storage->setIsAutosave(isAutosave || UnitWSD::get().isAutosave());
+_storage->setIsExitSave(isExitSave);
 
 const std::string saveArgs = oss.str();
 LOG_TRC(".uno:Save arguments: " << saveArgs);
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 09ee0e9d6..3d47c722d 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -348,7 +348,9 @@ public:
 }
 
 /// Sends the .uno:Save command to LoKit.
-bool sendUnoSave(const std::string& sessionId, bool dontTerminateEdit = 
true, bool dontSaveIfUnmodified = true, bool isAutosave = false);
+bool sendUnoSave(const std::string& sessionId, bool dontTerminateEdit = 
true,
+ bool dontSaveIfUnmodified = true, bool isAutosave = false,
+ bool isExitSave = false);
 
 /// Sends a message to all sessions
 void broadcastMessage(const std::string& message);
diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index b40bebfb3..11c658b65 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -717,6 +717,7 @@ StorageBase::SaveResult 
WopiStorage::saveLocalFileToStorage(const Authorization&
 request.set("X-WOPI-Override", "PUT");
 request.set("X-LOOL-WOPI-IsModifiedByUser", isUserModified()? 
"true": "false");
 request.set("X-LOOL-WOPI-IsAutosave", getIsAutosave()? "true": 
"false");
+request.set("X-LOOL-WOPI-IsExitSave", isExitSave()? "true": 
"false");
 
 if (!getForceSave())
 {
diff --git a/wsd/Storage.hpp b/wsd/Storage.hpp
index 893fa9e35..6d56c64b0 100644
--- a/wsd/Storage.hpp
+++ b/wsd/Storage.hpp
@@ -174,10 +174,11 @@ public:
 
 bool isUserModified() const { return _isUserModified; }
 
-/// To be able to set the WOPI 'is autosave?' header appropriately.
+/// To be able to set the WOPI 'is autosave/is exitsave?' headers 
appropriately.
 void setIsAutosave(bool isAutosave) { _isAutosave = isAutosave; }
-
 bool getIsAutosave() const { return _isAutosave; }
+void setIsExitSave(bool isExitSave) { _isExitSave = isExitSave; }
+bool isExitSave() const { return _isExitSave; }
 
 void setFileInfo(const FileInfo& fileInfo) { _fileInfo = fileInfo; }
 
@@ -225,6 +226,8 @@ private:
 
 /// This save operation is an autosave.
 bool _isAutosave;
+/// Saving on exit (when the document is cleaned up from memory)
+

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

2018-11-28 Thread Libreoffice Gerrit user
 wsd/DocumentBroker.cpp |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit dc4712c3f9e3ad541f5d4348a47604665050596f
Author: Miklos Vajna 
AuthorDate: Thu Nov 29 08:52:57 2018 +0100
Commit: Miklos Vajna 
CommitDate: Thu Nov 29 08:52:57 2018 +0100

wsd: limit_load_secs is not interesting for the mobile case, either

Change-Id: I92ad4bea80c261cc802ccdbebc1ce2990260853e

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 87eff69b6..c2dda9221 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -250,12 +250,12 @@ void DocumentBroker::pollThread()
 uint64_t adminSent = 0;
 uint64_t adminRecv = 0;
 auto lastBWUpdateTime = std::chrono::steady_clock::now();
+
+int limit_load_secs = 
LOOLWSD::getConfigValue("per_document.limit_load_secs", 100);
 auto loadDeadline = std::chrono::steady_clock::now() + 
std::chrono::seconds(limit_load_secs);
 #endif
 auto last30SecCheckTime = std::chrono::steady_clock::now();
 
-int limit_load_secs = 
LOOLWSD::getConfigValue("per_document.limit_load_secs", 100);
-
 // Main polling loop goodness.
 while (!_stop && _poll->continuePolling() && !TerminationFlag)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-11-28 Thread Libreoffice Gerrit user
 wsd/DocumentBroker.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 0e312f90169b35a0ad7db48252a9d6d8c526140a
Author: Miklos Vajna 
AuthorDate: Thu Nov 29 08:51:26 2018 +0100
Commit: Miklos Vajna 
CommitDate: Thu Nov 29 08:51:26 2018 +0100

Fix gtk build: -Werror=unused-but-set-variable

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 8235c073c..87eff69b6 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -250,11 +250,11 @@ void DocumentBroker::pollThread()
 uint64_t adminSent = 0;
 uint64_t adminRecv = 0;
 auto lastBWUpdateTime = std::chrono::steady_clock::now();
+auto loadDeadline = std::chrono::steady_clock::now() + 
std::chrono::seconds(limit_load_secs);
 #endif
 auto last30SecCheckTime = std::chrono::steady_clock::now();
 
 int limit_load_secs = 
LOOLWSD::getConfigValue("per_document.limit_load_secs", 100);
-auto loadDeadline = std::chrono::steady_clock::now() + 
std::chrono::seconds(limit_load_secs);
 
 // Main polling loop goodness.
 while (!_stop && _poll->continuePolling() && !TerminationFlag)
___
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/Storage.cpp wsd/Storage.hpp

2018-11-28 Thread Libreoffice Gerrit user
 wsd/DocumentBroker.cpp |   18 +-
 wsd/Storage.cpp|   12 ++--
 wsd/Storage.hpp|   17 -
 3 files changed, 27 insertions(+), 20 deletions(-)

New commits:
commit ae3fec55d41bde6c8e7e50986ae30a58d87a
Author: Miklos Vajna 
AuthorDate: Thu Nov 29 08:42:43 2018 +0100
Commit: Miklos Vajna 
CommitDate: Thu Nov 29 08:43:02 2018 +0100

StorageBase::FileInfo: make members private

Which shows that the _size member was unused.

Change-Id: Ic6e74659050b86cd9057971ec21623fad75f0c39

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index fed34213e..8235c073c 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -526,7 +526,7 @@ bool DocumentBroker::load(const 
std::shared_ptr& session, const s
 if (wopifileinfo->getDisableExport())
 wopifileinfo->setHideExportOption(true);
 
-wopiInfo->set("BaseFileName", wopiStorage->getFileInfo()._filename);
+wopiInfo->set("BaseFileName", 
wopiStorage->getFileInfo().getFilename());
 wopiInfo->set("HidePrintOption", wopifileinfo->getHidePrintOption());
 wopiInfo->set("HideSaveOption", wopifileinfo->getHideSaveOption());
 wopiInfo->set("HideExportOption", wopifileinfo->getHideExportOption());
@@ -551,7 +551,7 @@ bool DocumentBroker::load(const 
std::shared_ptr& session, const s
 session->sendMessage("wopi: " + wopiInfoString);
 
 // Mark the session as 'Document owner' if WOPI hosts supports it
-if (userId == _storage->getFileInfo()._ownerId)
+if (userId == _storage->getFileInfo().getOwnerId())
 {
 LOG_DBG("Session [" << sessionId << "] is the document owner");
 session->setDocumentOwner(true);
@@ -604,21 +604,21 @@ bool DocumentBroker::load(const 
std::shared_ptr& session, const s
 
 if (firstInstance)
 {
-_documentLastModifiedTime = fileInfo._modifiedTime;
+_documentLastModifiedTime = fileInfo.getModifiedTime();
 LOG_DBG("Document timestamp: " << _documentLastModifiedTime);
 }
 else
 {
 // Check if document has been modified by some external action
-LOG_TRC("Document modified time: " << fileInfo._modifiedTime);
+LOG_TRC("Document modified time: " << fileInfo.getModifiedTime());
 static const Poco::Timestamp Zero(Poco::Timestamp::fromEpochTime(0));
 if (_documentLastModifiedTime != Zero &&
-fileInfo._modifiedTime != Zero &&
-_documentLastModifiedTime != fileInfo._modifiedTime)
+fileInfo.getModifiedTime() != Zero &&
+_documentLastModifiedTime != fileInfo.getModifiedTime())
 {
 LOG_DBG("Document " << _docKey << "] has been modified behind our 
back. " <<
 "Informing all clients. Expected: " << 
_documentLastModifiedTime <<
-", Actual: " << fileInfo._modifiedTime);
+", Actual: " << fileInfo.getModifiedTime());
 
 _documentChangedInStorage = true;
 std::string message = "close: documentconflict";
@@ -703,7 +703,7 @@ bool DocumentBroker::load(const 
std::shared_ptr& session, const s
 _uriJailed = Poco::URI(Poco::URI("file://"), 
localPathEncoded).toString();
 _uriJailedAnonym = Poco::URI(Poco::URI("file://"), 
LOOLWSD::anonymizeUrl(localPath)).toString();
 
-_filename = fileInfo._filename;
+_filename = fileInfo.getFilename();
 
 // Use the local temp file's timestamp.
 _lastFileModifiedTime = 
Poco::File(_storage->getRootFilePath()).getLastModified();
@@ -840,7 +840,7 @@ bool DocumentBroker::saveToStorageInternal(const 
std::string& sessionId,
 _lastSaveTime = std::chrono::steady_clock::now();
 
 // Save the storage timestamp.
-_documentLastModifiedTime = _storage->getFileInfo()._modifiedTime;
+_documentLastModifiedTime = 
_storage->getFileInfo().getModifiedTime();
 
 // After a successful save, we are sure that document in the 
storage is same as ours
 _documentChangedInStorage = false;
diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 7ed86bc3c..b40bebfb3 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -350,8 +350,8 @@ StorageBase::SaveResult 
LocalStorage::saveLocalFileToStorage(const Authorization
 
 // update its fileinfo object. This is used later to check if someone 
else changed the
 // document while we are/were editing it
-getFileInfo()._modifiedTime = 
Poco::File(getUri().getPath()).getLastModified();
-LOG_TRC("New FileInfo modified time in storage " << 
getFileInfo()._modifiedTime);
+
getFileInfo().setModifiedTime(Poco::File(getUri().getPath()).getLastModified());
+LOG_TRC("New FileInfo modified time in storage " << 
getFileInfo().getModifiedTime());
 }
 catch (const Poco::Exception& exc)
 {
@@ -660,7 +660,7 @@ std::string 

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

2018-11-28 Thread Libreoffice Gerrit user
 wsd/DocumentBroker.cpp |2 
 wsd/Storage.cpp|  102 -
 wsd/Storage.hpp|   29 -
 3 files changed, 77 insertions(+), 56 deletions(-)

New commits:
commit ed9c756c9ed9150f361340a2eb4dade9ec405935
Author: Miklos Vajna 
AuthorDate: Wed Nov 28 09:07:29 2018 +0100
Commit: Miklos Vajna 
CommitDate: Wed Nov 28 09:07:35 2018 +0100

StorageBase: make members private

Rename getUri() to getUriString(), so getUri() can expose a const
reference to _uri.

Change-Id: I0cd0faf08ba31bdf6a605be657e7ca2cf5fb33a6

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 9a2df5053..5b45a84d9 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -707,7 +707,7 @@ bool DocumentBroker::load(const 
std::shared_ptr& session, const s
 
 // Use the local temp file's timestamp.
 _lastFileModifiedTime = 
Poco::File(_storage->getRootFilePath()).getLastModified();
-_tileCache.reset(new TileCache(_storage->getUri(), 
_lastFileModifiedTime, _cacheRoot, LOOLWSD::TileCachePersistent));
+_tileCache.reset(new TileCache(_storage->getUriString(), 
_lastFileModifiedTime, _cacheRoot, LOOLWSD::TileCachePersistent));
 _tileCache->setThreadOwner(std::this_thread::get_id());
 }
 
diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index a3f86e743..a42534eaa 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -258,15 +258,15 @@ std::atomic LocalStorage::LastLocalStorageId;
 
 std::unique_ptr LocalStorage::getLocalFileInfo()
 {
-const Poco::Path path = Poco::Path(_uri.getPath());
-LOG_DBG("Getting info for local uri [" << 
LOOLWSD::anonymizeUrl(_uri.toString()) << "], path [" << 
LOOLWSD::anonymizeUrl(path.toString()) << "].");
+const Poco::Path path = Poco::Path(getUri().getPath());
+LOG_DBG("Getting info for local uri [" << 
LOOLWSD::anonymizeUrl(getUri().toString()) << "], path [" << 
LOOLWSD::anonymizeUrl(path.toString()) << "].");
 
 const auto& filename = path.getFileName();
 const Poco::File file = Poco::File(path);
 const Poco::Timestamp lastModified = file.getLastModified();
 const size_t size = file.getSize();
 
-_fileInfo = FileInfo({filename, "localhost", lastModified, size});
+setFileInfo(FileInfo({filename, "localhost", lastModified, size}));
 
 // Set automatic userid and username
 return std::unique_ptr(new 
LocalFileInfo({"localhost" + std::to_string(LastLocalStorageId), "LocalHost#" + 
std::to_string(LastLocalStorageId++)}));
@@ -276,53 +276,53 @@ std::string LocalStorage::loadStorageFileToLocal(const 
Authorization& /*auth*/)
 {
 #ifndef MOBILEAPP
 // /chroot/jailId/user/doc/childId/file.ext
-const std::string filename = Poco::Path(_uri.getPath()).getFileName();
-_jailedFilePath = Poco::Path(getLocalRootPath(), filename).toString();
-_jailedFilePathAnonym = LOOLWSD::anonymizeUrl(_jailedFilePath);
-LOG_INF("Public URI [" << LOOLWSD::anonymizeUrl(_uri.getPath()) <<
-"] jailed to [" << _jailedFilePathAnonym << "].");
+const std::string filename = Poco::Path(getUri().getPath()).getFileName();
+setRootFilePath(Poco::Path(getLocalRootPath(), filename).toString());
+setRootFilePathAnonym(LOOLWSD::anonymizeUrl(getRootFilePath()));
+LOG_INF("Public URI [" << LOOLWSD::anonymizeUrl(getUri().getPath()) <<
+"] jailed to [" << getRootFilePathAnonym() << "].");
 
 // Despite the talk about URIs it seems that _uri is actually just a 
pathname here
-const std::string publicFilePath = _uri.getPath();
+const std::string publicFilePath = getUri().getPath();
 
-if (!FileUtil::checkDiskSpace(_jailedFilePath))
+if (!FileUtil::checkDiskSpace(getRootFilePath()))
 {
-throw StorageSpaceLowException("Low disk space for " + 
_jailedFilePathAnonym);
+throw StorageSpaceLowException("Low disk space for " + 
getRootFilePathAnonym());
 }
 
-LOG_INF("Linking " << LOOLWSD::anonymizeUrl(publicFilePath) << " to " << 
_jailedFilePathAnonym);
-if (!Poco::File(_jailedFilePath).exists() && link(publicFilePath.c_str(), 
_jailedFilePath.c_str()) == -1)
+LOG_INF("Linking " << LOOLWSD::anonymizeUrl(publicFilePath) << " to " << 
getRootFilePathAnonym());
+if (!Poco::File(getRootFilePath()).exists() && 
link(publicFilePath.c_str(), getRootFilePath().c_str()) == -1)
 {
 // Failed
-LOG_WRN("link(\"" << LOOLWSD::anonymizeUrl(publicFilePath) << "\", \"" 
<< _jailedFilePathAnonym << "\") failed. Will copy. "
+LOG_WRN("link(\"" << LOOLWSD::anonymizeUrl(publicFilePath) << "\", \"" 
<< getRootFilePathAnonym() << "\") failed. Will copy. "
 "Linking error: " << Util::symbolicErrno(errno) << " " << 
strerror(errno));
 }
 
 try
 {
 // Fallback to copying.
-if (!Poco::File(_jailedFilePath).exists())
+if (!Poco::File(getRootFilePath()).exists())
 {
-

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

2018-11-27 Thread Libreoffice Gerrit user
 wsd/DocumentBroker.cpp |4 ++--
 wsd/Storage.hpp|4 
 2 files changed, 6 insertions(+), 2 deletions(-)

New commits:
commit 0f2fa202c04c0d06d3b0ac3ca237c9388d782143
Author: Miklos Vajna 
AuthorDate: Tue Nov 27 09:09:21 2018 +0100
Commit: Miklos Vajna 
CommitDate: Tue Nov 27 09:09:29 2018 +0100

LocalStorage::LocalFileInfo: make members private

Change-Id: Ibdbf35275e2b2f0b935a301fe77a54aef51e4514

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 2b51934e1..9a2df5053 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -569,8 +569,8 @@ bool DocumentBroker::load(const 
std::shared_ptr& session, const s
 if (localStorage != nullptr)
 {
 std::unique_ptr localfileinfo = 
localStorage->getLocalFileInfo();
-userId = localfileinfo->_userId;
-username = localfileinfo->_username;
+userId = localfileinfo->getUserId();
+username = localfileinfo->getUsername();
 
 if (LOOLWSD::IsViewFileExtension(localStorage->getFileExtension()))
 {
diff --git a/wsd/Storage.hpp b/wsd/Storage.hpp
index 4d546725b..bccaa66a6 100644
--- a/wsd/Storage.hpp
+++ b/wsd/Storage.hpp
@@ -227,6 +227,10 @@ public:
 {
 }
 
+const std::string& getUserId() const { return _userId; }
+const std::string& getUsername() const { return _username; }
+
+private:
 std::string _userId;
 std::string _username;
 };
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-11-07 Thread Libreoffice Gerrit user
 wsd/DocumentBroker.cpp |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 802cb3bd24605fc479f2bbd9967a40ee51e6f757
Author: Tor Lillqvist 
AuthorDate: Thu Nov 8 00:11:21 2018 +0200
Commit: Michael Meeks 
CommitDate: Wed Nov 7 23:16:49 2018 +0100

Move initailisation of 'now' variable back after the poll where it should be

Was moved before the poll in my
75438baa70a0d15b18c5ca829b3e3b1307a27c08.

Change-Id: I0ec99c0c1433d2e5d631720f003905cbd18206aa
Reviewed-on: https://gerrit.libreoffice.org/63052
Reviewed-by: Michael Meeks 
Tested-by: Michael Meeks 

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index dcef3df3e..7b56fc651 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -256,10 +256,10 @@ void DocumentBroker::pollThread()
 // Main polling loop goodness.
 while (!_stop && _poll->continuePolling() && !TerminationFlag)
 {
-const auto now = std::chrono::steady_clock::now();
-
 _poll->poll(SocketPoll::DefaultPollTimeoutMs);
 
+const auto now = std::chrono::steady_clock::now();
+
 #ifndef MOBILEAPP
 if (std::chrono::duration_cast
 (now - lastBWUpdateTime).count() >= 5 * 1000)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-09-04 Thread Libreoffice Gerrit user
 wsd/DocumentBroker.cpp |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 10c302f04781b1607f6500ba56c35195aca03ce0
Author: Tor Lillqvist 
AuthorDate: Tue Sep 4 11:55:31 2018 +0300
Commit: Tor Lillqvist 
CommitDate: Tue Sep 4 12:12:35 2018 +0300

Make std::chrono usage more portable

Add a std::chrono::time_point_cast to get it to compile against libc++
(for iOS).

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 8de6a9779..48671a0dc 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1785,9 +1785,9 @@ void DocumentBroker::dumpState(std::ostream& os)
 os << "\n  doc key: " << _docKey;
 os << "\n  doc id: " << _docId;
 os << "\n  num sessions: " << _sessions.size();
-const std::time_t t = std::chrono::system_clock::to_time_t(
+const std::time_t t = 
std::chrono::system_clock::to_time_t(std::chrono::time_point_cast(
 std::chrono::system_clock::now()
-+ (_lastSaveTime - std::chrono::steady_clock::now()));
++ (_lastSaveTime - std::chrono::steady_clock::now(;
 os << "\n  last saved: " << std::ctime();
 os << "\n  cursor " << _cursorPosX << ", " << _cursorPosY
   << "( " << _cursorWidth << "," << _cursorHeight << ")\n";
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-09-03 Thread Libreoffice Gerrit user
 wsd/DocumentBroker.cpp |   22 --
 1 file changed, 16 insertions(+), 6 deletions(-)

New commits:
commit 14537846a8891adaa2a56ae05edbe288a9469f43
Author: Tamás Zolnai 
AuthorDate: Mon Sep 3 16:35:00 2018 +0200
Commit: Tamás Zolnai 
CommitDate: Mon Sep 3 16:35:00 2018 +0200

Handle unset client visible area case while calculating tiles-on-fly limit

Change-Id: I25ea6f1efdc8115304d5449cfccdbb5c0c15fb1f

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 59ce6d0b8..8de6a9779 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1370,13 +1370,23 @@ void DocumentBroker::sendRequestedTiles(const 
std::shared_ptr& se
 // How many tiles we have on the visible area, set the upper limit 
accordingly
 Util::Rectangle normalizedVisArea = session->getNormalizedVisibleArea();
 
-const int tilesFitOnWidth = std::ceil(normalizedVisArea._x2 / 
session->getTileWidthInTwips()) -
-std::ceil(normalizedVisArea._x1 / 
session->getTileWidthInTwips()) + 1;
-const int tilesFitOnHeight = std::ceil(normalizedVisArea._y2 / 
session->getTileHeightInTwips()) -
- std::ceil(normalizedVisArea._y1 / 
session->getTileHeightInTwips()) + 1;
-const int tilesInVisArea = tilesFitOnWidth * tilesFitOnHeight;
+float tilesOnFlyUpperLimit = 0;
+if (normalizedVisArea.hasSurface() && session->getTileWidthInTwips() != 0 
&& session->getTileHeightInTwips() != 0)
+{
+
+const int tilesFitOnWidth = std::ceil(normalizedVisArea._x2 / 
session->getTileWidthInTwips()) -
+std::ceil(normalizedVisArea._x1 / 
session->getTileWidthInTwips()) + 1;
+const int tilesFitOnHeight = std::ceil(normalizedVisArea._y2 / 
session->getTileHeightInTwips()) -
+ std::ceil(normalizedVisArea._y1 / 
session->getTileHeightInTwips()) + 1;
+const int tilesInVisArea = tilesFitOnWidth * tilesFitOnHeight;
+
+tilesOnFlyUpperLimit = std::max(TILES_ON_FLY_MIN_UPPER_LIMIT, 
tilesInVisArea * 1.5f);
+}
+else
+{
+tilesOnFlyUpperLimit = 200; // Have a big number here to get all tiles 
requested by file openning
+}
 
-const float tilesOnFlyUpperLimit = std::max(TILES_ON_FLY_MIN_UPPER_LIMIT, 
tilesInVisArea * 1.5f);
 
 // Update client's tilesBeingRendered list
 session->removeOutdatedTileSubscriptions();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-08-20 Thread Libreoffice Gerrit user
 wsd/DocumentBroker.cpp |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit fd87e1e315fad5c3017f79f832d639bc5ea9dc29
Author: Tamás Zolnai 
AuthorDate: Mon Aug 20 18:07:16 2018 +0200
Commit: Aron Budea 
CommitDate: Mon Aug 20 18:19:54 2018 +0200

Crash: Check whether we still have requested tiles

Change-Id: I2a8b9ced09ff624ce925b52a60352e6fa50af25e
Reviewed-on: https://gerrit.libreoffice.org/59334
Reviewed-by: Aron Budea 
Tested-by: Aron Budea 

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 2bd5b5d02..cfd288507 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1385,7 +1385,8 @@ void DocumentBroker::sendRequestedTiles(const 
std::shared_ptr& se
 if (!requestedTiles.empty())
 {
 std::vector tilesNeedsRendering;
-while(session->getTilesOnFlyCount() + 
session->getTilesBeingRenderedCount() < tilesOnFlyUpperLimit)
+while(session->getTilesOnFlyCount() + 
session->getTilesBeingRenderedCount() < tilesOnFlyUpperLimit &&
+  !requestedTiles.empty())
 {
 TileDesc& tile = *(requestedTiles.begin());
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-02-19 Thread Andras Timar
 wsd/DocumentBroker.cpp |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

New commits:
commit dde84d17064926f457b6ef7c6ebd9d595ac837b9
Author: Andras Timar 
Date:   Sun Feb 18 00:24:08 2018 +0100

wsd: encode '#' character in file name

Change-Id: I4d10f38c9025f18a0d0f0f5599892b436b9d002c
Reviewed-on: https://gerrit.libreoffice.org/49919
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index beafe29e..25a495e2 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -657,7 +657,11 @@ bool DocumentBroker::load(const 
std::shared_ptr& session, const s
 LOG_INF("SHA1 for DocKey [" << _docKey << "] of [" << localPath << "]: 
" <<
 Poco::DigestEngine::digestToHex(sha1.digest()));
 
-_uriJailed = Poco::URI(Poco::URI("file://"), localPath);
+// LibreOffice can't open files with '#' in the name
+std::string localPathEncoded;
+Poco::URI::encode(localPath,"#",localPathEncoded);
+_uriJailed = Poco::URI(Poco::URI("file://"), localPathEncoded);
+
 _filename = fileInfo._filename;
 
 // Use the local temp file's timestamp.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-02-01 Thread Pranav Kant
 wsd/DocumentBroker.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 28ea409a4570be4edfd57aec8a0c779c5d1bd240
Author: Pranav Kant 
Date:   Thu Feb 1 23:58:43 2018 +0530

wsd: Don't save if document is unmodified

This also prevents saving the document back to storage.

Without this patch, in case of document conflict (when the document is
changed behind our back in the storage), the unmodified document end up
being saved to storage, hence overwriting the document which was changed
behind our back.

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index c499b6e4..a985fe36 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -899,7 +899,7 @@ bool DocumentBroker::autoSave(const bool force)
 {
 LOG_TRC("Sending forced save command for [" << _docKey << "].");
 // Don't terminate editing as this can be invoked by the admin OOM, 
but otherwise force saving anyway.
-sent = sendUnoSave(savingSessionId, /*dontTerminateEdit=*/ true, 
/*dontSaveIfUnmodified=*/ false, /*isAutosave=*/ false);
+sent = sendUnoSave(savingSessionId, /*dontTerminateEdit=*/ true, 
/*dontSaveIfUnmodified=*/ true, /*isAutosave=*/ false);
 }
 else if (_isModified)
 {
___
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/DocumentBroker.hpp

2018-01-15 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |   36 
 wsd/DocumentBroker.hpp |5 +
 2 files changed, 29 insertions(+), 12 deletions(-)

New commits:
commit f7fc3f494ca824253a2af6ad604622bcd1340b81
Author: Ashod Nakashian 
Date:   Mon Jan 15 00:49:14 2018 -0500

wsd: save before stopping

We don't force saving unconditionally now. Only
when the doc is reasonably expected to be modified
do we force saving (to circumvent the minimum duration
between auto-saves).

We invoke auto-saving before stopping the DocBroker
polling loop, whether due to idleness or server recycling.

Change-Id: I257d55f190d3df6a3ba82f2666c7602da0581d0c
Reviewed-on: https://gerrit.libreoffice.org/47887
Reviewed-by: Michael Meeks 
Tested-by: Michael Meeks 

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 28a4920d..476ad544 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -275,8 +275,12 @@ void DocumentBroker::pollThread()
 
 if (ShutdownRequestFlag)
 {
-autoSave(true);
-stop("recycling");
+LOG_INF("Autosaving DocumentBroker for docKey [" << getDocKey() << 
"] to recycle server.");
+if (!autoSave(isPossiblyModified()))
+{
+LOG_INF("Terminating DocumentBroker for docKey [" << 
getDocKey() << "] to recycle server.");
+stop("recycling");
+}
 }
 else if (AutoSaveEnabled && !_stop &&
  std::chrono::duration_cast(now - 
last30SecCheckTime).count() >= 30)
@@ -287,14 +291,22 @@ void DocumentBroker::pollThread()
 }
 
 // Remove idle documents after 1 hour.
-const bool idle = (getIdleTimeSecs() >= IdleDocTimeoutSecs);
-
-// If all sessions have been removed, no reason to linger.
-if ((isLoaded() || _markToDestroy) && (_sessions.empty() || idle))
+const bool idle = (isLoaded() && getIdleTimeSecs() >= 
IdleDocTimeoutSecs);
+if (idle)
+{
+// Stop if there is nothing to save.
+LOG_INF("Autosaving idle DocumentBroker for docKey [" << 
getDocKey() << "] to kill.");
+if (!autoSave(isPossiblyModified()))
+{
+LOG_INF("Terminating idle DocumentBroker for docKey [" << 
getDocKey() << "].");
+stop("idle");
+}
+}
+else if (_sessions.empty() && (isLoaded() || _markToDestroy))
 {
-LOG_INF("Terminating " << (idle ? "idle" : "dead") <<
-" DocumentBroker for docKey [" << getDocKey() << "].");
-stop(idle ? "idle" : "dead");
+// If all sessions have been removed, no reason to linger.
+LOG_INF("Terminating dead DocumentBroker for docKey [" << 
getDocKey() << "].");
+stop("dead");
 }
 }
 
@@ -864,8 +876,8 @@ bool DocumentBroker::autoSave(const bool force)
 std::string savingSessionId;
 for (auto& sessionIt : _sessions)
 {
-// Save the document using first session available ...
-if (savingSessionId.empty())
+// Save the document using an editable session, or first ...
+if (savingSessionId.empty() || !sessionIt.second->isReadOnly())
 {
 savingSessionId = sessionIt.second->getId();
 }
@@ -1058,7 +1070,7 @@ size_t DocumentBroker::removeSession(const std::string& 
id)
 ", LastEditableSession: " << lastEditableSession);
 
 // If last editable, save and don't remove until after uploading to 
storage.
-if (!lastEditableSession || !autoSave(true))
+if (!lastEditableSession || !autoSave(isPossiblyModified()))
 removeSessionInternal(id);
 }
 catch (const std::exception& ex)
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 1e8e0746..1571e426 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -367,6 +367,11 @@ private:
 /// True iff a save is in progress (requested but not completed).
 bool isSaving() const { return _lastSaveResponseTime < 
_lastSaveRequestTime; }
 
+/// True if we know the doc is modified or
+/// if there has been activity from a client after we last *requested* 
saving,
+/// since there are race conditions vis-a-vis user activity while saving.
+bool isPossiblyModified() const { return _isModified || 
(_lastSaveRequestTime < _lastActivityTime); }
+
 /// True iff there is at least one non-readonly session other than the 
given.
 /// Since only editable sessions can save, we need to use the last to
 /// save modified documents, otherwise we'll potentially have to save on
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org

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

2018-01-12 Thread Michael Meeks
 wsd/DocumentBroker.cpp |7 +++
 1 file changed, 7 insertions(+)

New commits:
commit 9335f6ff128b56876f5e7ef37b7983baa4d5b152
Author: Michael Meeks 
Date:   Fri Jan 12 16:16:56 2018 +

Warn if we exit with a modified document around.

Change-Id: Ie38ab49c66358f674e14820a6ffa993c25aa9e92

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index d2d627a3..97ef771f 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -298,6 +298,13 @@ void DocumentBroker::pollThread()
 _poll->continuePolling() << ", ShutdownRequestFlag: " << 
ShutdownRequestFlag <<
 ", TerminationFlag: " << TerminationFlag << ", closeReason: " << 
_closeReason << ". Flushing socket.");
 
+if (_isModified)
+{
+std::stringstream state;
+dumpState(state);
+LOG_ERR("DocumentBroker stopping although modified " << state.str());
+}
+
 // Flush socket data first.
 const int flushTimeoutMs = POLL_TIMEOUT_MS * 2; // ~1000ms
 const auto flushStartTime = std::chrono::steady_clock::now();
___
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/DocumentBroker.hpp

2018-01-06 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |2 +-
 wsd/DocumentBroker.hpp |1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 040a211d60c6eab8695cad4bee78b22f38428b77
Author: Ashod Nakashian 
Date:   Wed Jan 3 23:15:44 2018 -0500

wsd: set modified flag on the storage when set on the DocumentBroker

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 53e0ae61..6a164533 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1401,7 +1401,7 @@ void DocumentBroker::destroyIfLastEditor(const 
std::string& id)
 
 void DocumentBroker::setModified(const bool value)
 {
-if(_isModified != value)
+if (_isModified != value)
 {
 _isModified = value;
 Admin::instance().modificationAlert(_docKey, getPid(), value);
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index a56d3332..0e278150 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -248,6 +248,7 @@ public:
 
 bool isModified() const { return _isModified; }
 void setModified(const bool value);
+
 /// Save the document if the document is modified.
 /// @param force when true, will force saving if there
 /// has been any recent activity after the last save.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-01-05 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

New commits:
commit d96cb94d023ac31459c64f60dd659f37d3239bdb
Author: Ashod Nakashian 
Date:   Thu Jan 4 00:16:40 2018 -0500

wsd: set modified flag on the storage when set on the DocumentBroker

Reviewed-on: https://gerrit.libreoffice.org/47367
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 
(cherry picked from commit 752e3b7002f2199438aa81d5b660088da3faac44)

Change-Id: I13e25b2edff33d6fddec5eb34d7847fbbd2e
Reviewed-on: https://gerrit.libreoffice.org/47400
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 
(cherry picked from commit e9ce36f26ea3f007e00efbf9012bbbe8f93ccc9d)

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index e74c22f5..53e0ae61 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -416,7 +416,6 @@ bool DocumentBroker::load(const 
std::shared_ptr& session, const s
 LOG_ERR("Failed to create Storage instance for [" << _docKey << "] 
in " << jailPath.toString());
 return false;
 }
-
 firstInstance = true;
 }
 
@@ -926,7 +925,6 @@ bool DocumentBroker::sendUnoSave(const std::string& 
sessionId, bool dontTerminat
 oss << "}";
 
 assert(_storage);
-_storage->setUserModified(_isModified);
 _storage->setIsAutosave(isAutosave || UnitWSD::get().isAutosave());
 
 const auto saveArgs = oss.str();
@@ -1409,6 +1407,7 @@ void DocumentBroker::setModified(const bool value)
 Admin::instance().modificationAlert(_docKey, getPid(), value);
 }
 
+_storage->setUserModified(value);
 _tileCache->setUnsavedChanges(value);
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-09-18 Thread Pranav Kant
 wsd/DocumentBroker.cpp |   14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

New commits:
commit 7b4f734b32afc40efb1ecfa9db1a55b08541e46b
Author: Pranav Kant 
Date:   Mon Sep 18 23:00:19 2017 +0530

Broadcast closing documents in same thread

... instead of handing it over the Document broker polling thread which
can lead to race conditions, and hence not giving desired behavior when
document is changed externally.

Change-Id: Ib0821d4ae931c357bc4d4c526865eefc090ddc23

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 9154abab..91d61c57 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -540,16 +540,12 @@ bool DocumentBroker::load(const 
std::shared_ptr& session, const s
  << "Actual: " << fileInfo._modifiedTime << Log::end;
 
 _documentChangedInStorage = true;
+std::string message = "close: documentconflict";
 if (_isModified)
-{
-const std::string errorMsg = "error: cmd=storage 
kind=documentconflict";
-session->sendTextFrame(errorMsg);
-broadcastMessage(errorMsg);
-}
-else
-{
-closeDocument("documentconflict");
-}
+message = "error: cmd=storage kind=documentconflict";
+
+session->sendTextFrame(message);
+broadcastMessage(message);
 }
 }
 
___
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/Storage.cpp wsd/Storage.hpp

2017-08-17 Thread Pranav Kant
 wsd/DocumentBroker.cpp |2 +-
 wsd/Storage.cpp|5 +++--
 wsd/Storage.hpp|2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)

New commits:
commit 769e41dfb21a17a50cb0d768451d0838bc30f2f3
Author: Pranav Kant 
Date:   Fri Aug 18 07:14:33 2017 +0530

Fix build

Mismerge. There is no session->getAccessToken now

Change-Id: I4d8f2cc612cbd39b3163bcdbba5df8ea5d732774

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 016d251d..77035837 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -729,7 +729,7 @@ void DocumentBroker::saveFileAs(const std::string& 
sessionId, const std::string&
 WopiStorage* wopiStorage = dynamic_cast(_storage.get());
 if (wopiStorage != nullptr)
 {
-const std::string newUrl = 
wopiStorage->createCopyFile(it->second->getAccessToken(), newFileName, path);
+const std::string newUrl = 
wopiStorage->createCopyFile(it->second->getAuthorization(), newFileName, path);
 if (!newUrl.empty())
 {
 it->second->sendTextFrame("saveas: " + newUrl + " " + newFileName);
diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 1472faa6..db047aba 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -585,12 +585,12 @@ std::unique_ptr 
WopiStorage::getWOPIFileInfo(const Au
 }
 
 /// PutRelativeFile - uri format: http://server/<...>/wopi*/files//
-std::string WopiStorage::createCopyFile(const std::string& accessToken, const 
std::string& newFileName, const std::string& path)
+std::string WopiStorage::createCopyFile(const Authorization& auth, const 
std::string& newFileName, const std::string& path)
 {
 const auto size = getFileSize(_jailedFilePath);
 std::ostringstream oss;
 Poco::URI uriObject(_uri);
-setQueryParameter(uriObject, "access_token", accessToken);
+auth.authorizeURI(uriObject);
 
 LOG_DBG("Wopi PutRelativeFile(save as) request for : " << 
uriObject.toString());
 
@@ -600,6 +600,7 @@ std::string WopiStorage::createCopyFile(const std::string& 
accessToken, const st
 
 Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_POST, 
uriObject.getPathAndQuery(), Poco::Net::HTTPMessage::HTTP_1_1);
 request.set("User-Agent", WOPI_AGENT_STRING);
+auth.authorizeRequest(request);
 request.set("X-WOPI-Override", "PUT_RELATIVE");
 request.set("X-WOPI-RelativeTarget", newFileName + "." + 
getFileExtension());
 request.set("X-WOPI-Size", std::to_string(size));
diff --git a/wsd/Storage.hpp b/wsd/Storage.hpp
index da30b1b9..827a8fa7 100644
--- a/wsd/Storage.hpp
+++ b/wsd/Storage.hpp
@@ -259,7 +259,7 @@ public:
 std::unique_ptr getWOPIFileInfo(const Authorization& auth);
 
 /// returns
-std::string createCopyFile(const std::string& accessToken, const 
std::string& newFileName, const std::string& path);
+std::string createCopyFile(const Authorization& auth, const std::string& 
newFileName, const std::string& path);
 
 /// uri format: http://server/<...>/wopi*/files//content
 std::string loadStorageFileToLocal(const Authorization& auth) 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

2017-06-26 Thread Pranav Kant
 wsd/DocumentBroker.cpp |8 
 1 file changed, 8 insertions(+)

New commits:
commit a03f69a16a05aba90de600f0f92e2b89af2bf591
Author: Pranav Kant 
Date:   Thu Jun 22 17:04:59 2017 +0530

Update PostMessageOrigin if SSL termination is on too

Change-Id: I887ab368fec62a5efefde4da3762c47dd0bf66d7
Reviewed-on: https://gerrit.libreoffice.org/39100
Reviewed-by: pranavk 
Tested-by: pranavk 

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 4adfcd89..3be3375c 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -445,6 +445,14 @@ bool DocumentBroker::load(const 
std::shared_ptr& session, const s
 Object::Ptr wopiInfo = new Object();
 if (!wopifileinfo->_postMessageOrigin.empty())
 {
+// Update the scheme to https if ssl or ssl termination is on
+if (wopifileinfo->_postMessageOrigin.substr(0, 7) == "http://; &&
+(LOOLWSD::isSSLEnabled() || LOOLWSD::isSSLTermination()))
+{
+wopifileinfo->_postMessageOrigin.replace(0, 4, "https");
+LOG_DBG("Updating PostMessageOrgin scheme to HTTPS. Updated 
origin is [" << wopifileinfo->_postMessageOrigin << "].");
+}
+
 wopiInfo->set("PostMessageOrigin", 
wopifileinfo->_postMessageOrigin);
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-06-25 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit 8689d11f5cb27f84ec8c49ad7b87abae4b48bee0
Author: Ashod Nakashian 
Date:   Wed Jun 21 21:49:08 2017 -0400

wsd: don't busy wait when getNewChild fails fast

If Forkit is dead, getNewChild will fail fast.

Try not to busy loop in that case and yield
the CPU for a nominal duration, which currently
is the tenth of the normal getNewChild timeout.

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index c9c61d4c..4adfcd89 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -196,6 +196,9 @@ void DocumentBroker::pollThread()
 
std::chrono::duration_cast(std::chrono::steady_clock::now()
 -
   
_threadStart).count() > timeoutMs)
 break;
+
+// Nominal time between retries, lest we  busy-loop. getNewChild could 
also wait, so don't double that here.
+
std::this_thread::sleep_for(std::chrono::milliseconds(CHILD_REBALANCE_INTERVAL_MS
 / 10));
 }
 while (!_stop && _poll->continuePolling() && !TerminationFlag && 
!ShutdownRequestFlag);
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-06-22 Thread Pranav Kant
 wsd/DocumentBroker.cpp |3 ---
 1 file changed, 3 deletions(-)

New commits:
commit d192fa4944305d8488391b76b7994b8ea4596be4
Author: Pranav Kant 
Date:   Wed Jun 21 17:27:55 2017 +0530

Obsolete comment

Change-Id: I30b1bcbb5c4bd040ab1205030d16867fa488bdb4

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index ff5e2b61..2e37ccf7 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -646,9 +646,6 @@ bool DocumentBroker::saveToStorageInternal(const 
std::string& sessionId,
 
 LOG_DBG("Persisting [" << _docKey << "] after saving to URI [" << uri << 
"].");
 
-// FIXME: We should check before persisting the document that it hasn't 
been updated in its
-// storage behind our backs.
-
 assert(_storage && _tileCache);
 StorageBase::SaveResult storageSaveResult = 
_storage->saveLocalFileToStorage(accessToken);
 if (storageSaveResult == StorageBase::SaveResult::OK)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-06-19 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |   14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

New commits:
commit 7ae37aff0d2d6a337551b8b5a3d9daadc93d128c
Author: Ashod Nakashian 
Date:   Mon Jun 19 21:53:58 2017 -0400

wsd: fix access-after-free error

Valgrind spotted one case, and the other is possible but
not common it seems.

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 240c1d40..ff5e2b61 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -949,9 +949,8 @@ size_t DocumentBroker::removeSessionInternal(const 
std::string& id)
 
 const auto readonly = (it->second ? it->second->isReadOnly() : 
false);
 
-//FIXME: We might be called from the session we are removing,
-//FIXME: and if this is the last/only reference, we destroy it.
-//FIXME: Should flag and remove from the poll thread.
+// Remove. The caller must have a reference to the session
+// in question, lest we destroy from underneith them.
 _sessions.erase(it);
 
 const auto count = _sessions.size();
@@ -1355,7 +1354,9 @@ bool DocumentBroker::forwardToClient(const 
std::shared_ptr& payload)
 if (sid == "all")
 {
 // Broadcast to all.
-for (const auto& pair : _sessions)
+// Events could cause the removal of sessions.
+std::map 
sessions(_sessions);
+for (const auto& pair : sessions)
 {
 pair.second->handleKitToClientMessage(data, size);
 }
@@ -1365,7 +1366,10 @@ bool DocumentBroker::forwardToClient(const 
std::shared_ptr& payload)
 const auto it = _sessions.find(sid);
 if (it != _sessions.end())
 {
-return it->second->handleKitToClientMessage(data, size);
+// Take a ref as the session could be removed from _sessions
+// if it's the save confirmation keeping a stopped session 
alive.
+std::shared_ptr session = it->second;
+return session->handleKitToClientMessage(data, size);
 }
 else
 {
___
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/DocumentBroker.hpp wsd/LOOLWSD.cpp

2017-05-22 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |   29 -
 wsd/DocumentBroker.hpp |3 +++
 wsd/LOOLWSD.cpp|3 ---
 3 files changed, 27 insertions(+), 8 deletions(-)

New commits:
commit e877adc84bc6f90bcfa52f9f63666358e6614885
Author: Ashod Nakashian 
Date:   Mon May 22 15:04:35 2017 -0400

wsd: don't stop doc on unauthorized loading

When a client connects with expired/invalid
access_token, the document should remain
active for other/existing clients, if any.

However, if no clients exists (i.e. the
first client has invalid access_token),
then the document should be unloaded and
cleaned up.

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 73178103..17ce1be2 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -785,6 +785,25 @@ std::string DocumentBroker::getJailRoot() const
 
 size_t DocumentBroker::addSession(const std::shared_ptr& 
session)
 {
+try
+{
+return addSessionInternal(session);
+}
+catch (const std::exception& exc)
+{
+LOG_ERR("Failed to add session to [" << _docKey << "] with URI [" << 
session->getPublicUri().toString() << "]: " << exc.what());
+if (_sessions.empty())
+{
+LOG_INF("Doc [" << _docKey << "] has no more sessions. Marking to 
destroy.");
+_markToDestroy = true;
+}
+
+throw;
+}
+}
+
+size_t DocumentBroker::addSessionInternal(const 
std::shared_ptr& session)
+{
 assertCorrectThread();
 
 try
@@ -815,12 +834,7 @@ size_t DocumentBroker::addSession(const 
std::shared_ptr& session)
 _markToDestroy = false;
 _stop = false;
 
-// Add and attach the session.
-_sessions.emplace(session->getId(), session);
-session->setAttached();
-
 const auto id = session->getId();
-const auto count = _sessions.size();
 
 // Request a new session from the child kit.
 const std::string aMessage = "session " + id + ' ' + _docKey + ' ' + 
_docId;
@@ -829,6 +843,11 @@ size_t DocumentBroker::addSession(const 
std::shared_ptr& session)
 // Tell the admin console about this new doc
 Admin::instance().addDoc(_docKey, getPid(), getFilename(), id, 
session->getUserName());
 
+// Add and attach the session.
+_sessions.emplace(session->getId(), session);
+session->setAttached();
+
+const auto count = _sessions.size();
 LOG_TRC("Added " << (session->isReadOnly() ? "readonly" : "non-readonly") 
<<
 " session [" << id << "] to docKey [" <<
 _docKey << "] to have " << count << " sessions.");
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 14fe17e0..23b699e4 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -350,6 +350,9 @@ private:
 /// Saves the doc to the storage.
 bool saveToStorageInternal(const std::string& sesionId, bool success, 
const std::string& result = "");
 
+/// Loads a new session and adds to the sessions container.
+size_t addSessionInternal(const std::shared_ptr& session);
+
 /// Removes a session by ID. Returns the new number of sessions.
 size_t removeSessionInternal(const std::string& id);
 
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 3a877242..7c188f17 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2127,19 +2127,16 @@ private:
 LOG_ERR("Unauthorized Request while loading 
session for " << docBroker->getDocKey() << ": " << exc.what());
 const std::string msg = "error: cmd=internal 
kind=unauthorized";
 clientSession->sendMessage(msg);
-docBroker->stop();
 }
 catch (const StorageConnectionException& exc)
 {
 // Alert user about failed load
 const std::string msg = "error: cmd=storage 
kind=loadfailed";
 clientSession->sendMessage(msg);
-docBroker->stop();
 }
 catch (const std::exception& exc)
 {
 LOG_ERR("Error while loading : " << 
exc.what());
-docBroker->stop();
 }
 });
 });
___
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

2017-05-21 Thread Pranav Kant
 wsd/DocumentBroker.cpp |6 --
 wsd/LOOLWSD.cpp|   18 --
 2 files changed, 8 insertions(+), 16 deletions(-)

New commits:
commit 1ea87b627e077590c6eefa455ce3c8f7d0564068
Author: Pranav Kant 
Date:   Mon May 22 11:04:26 2017 +0530

wsd: Arrange exception handling a bit

Remove incorrect usage of std::uncaught_exception and handle
StorageConnectionException later.

Change-Id: I15ecd46b51e8ed33649fe876d46ce3d5fbae07cc

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 7d807acb..73178103 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -797,12 +797,6 @@ size_t DocumentBroker::addSession(const 
std::shared_ptr& session)
 throw std::runtime_error(msg);
 }
 }
-catch (const StorageConnectionException& exc)
-{
-// Alert user about failed load
-session->sendMessage("error: cmd=storage kind=loadfailed");
-throw;
-}
 catch (const StorageSpaceLowException&)
 {
 LOG_ERR("Out of storage while loading document with URI [" << 
session->getPublicUri().toString() << "].");
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index a2e868d9..3a877242 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2129,18 +2129,16 @@ private:
 clientSession->sendMessage(msg);
 docBroker->stop();
 }
+catch (const StorageConnectionException& exc)
+{
+// Alert user about failed load
+const std::string msg = "error: cmd=storage 
kind=loadfailed";
+clientSession->sendMessage(msg);
+docBroker->stop();
+}
 catch (const std::exception& exc)
 {
-LOG_ERR("Error while handling loading : " << 
exc.what());
-// only send our default error message if we 
haven't handled the
-// exception already up the stack
-if (std::uncaught_exception())
-{
-// FIXME: Are we sure we want to say that 
all other failures due
-// to an 'unauthorized' WOPI host ?
-const std::string msg = "error: 
cmd=internal kind=unauthorized";
-clientSession->sendMessage(msg);
-}
+LOG_ERR("Error while loading : " << 
exc.what());
 docBroker->stop();
 }
 });
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-05-10 Thread Pranav Kant
 wsd/DocumentBroker.cpp |9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

New commits:
commit e8ff26899203b6994579afacdd5f89aa68c8a696
Author: Pranav Kant 
Date:   Mon May 8 23:40:46 2017 +0530

wsd: Use hostname and port in doc key too

... to avoid different WOPI hosts using same loolwsd instance sharing a
file because the path of the file (file id etc.) is same in both of
WOPI hosts.

Though, having hosts + port in doc key engenders the possibility of
opening the same file as two if the WOPI host is accessed using
different aliases but that is much less of a concern than security bug
mentioned in previous paragraph.

Change-Id: Iaa2f880edce952925a85e56ed8eba99514e19751
Reviewed-on: https://gerrit.libreoffice.org/37400
Reviewed-by: Michael Meeks 
Tested-by: Jan Holesovsky 

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index f5af9895..21f6965f 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -103,14 +103,13 @@ Poco::URI DocumentBroker::sanitizeURI(const std::string& 
uri)
 std::string DocumentBroker::getDocKey(const Poco::URI& uri)
 {
 // If multiple host-names are used to access us, then
-// they must be aliases. Permission to access aliased hosts
-// is checked at the point of accepting incoming connections.
-// At this point storing the hostname artificially discriminates
-// between aliases and forces same document (when opened from
+// we force same document (when opened from
 // alias hosts) to load as separate documents and sharing doesn't
 // work. Worse, saving overwrites one another.
+// But we also do not want different WOPI hosts using the same path
+// for some file getting shared across WOPI hosts
 std::string docKey;
-Poco::URI::encode(uri.getPath(), "", docKey);
+Poco::URI::encode(uri.getHost() + ":" + std::to_string(uri.getPort()) + 
uri.getPath(), "", docKey);
 return docKey;
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-04-20 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |   10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

New commits:
commit 874b86ac89e0a6cd456d5dca6dda312ab584d322
Author: Ashod Nakashian 
Date:   Thu Apr 20 23:50:03 2017 -0400

wsd: simplify

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 9cd27989..999cab12 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -244,14 +244,10 @@ void DocumentBroker::pollThread()
 
 // First copy into local container, since removeSession
 // will erase from _sessions, but will leave the last.
-std::vector sessions;
-for (const auto& pair : _sessions)
-{
-sessions.push_back(pair.second);
-}
-
-for (const std::shared_ptr& session : sessions)
+std::map sessions = 
_sessions;
+for (const auto& pair : sessions)
 {
+std::shared_ptr session = pair.second;
 try
 {
 // Notify the client and disconnect.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-04-20 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

New commits:
commit 560406a3081cfc5b48f4d6900b1f3c702261f81f
Author: Ashod Nakashian 
Date:   Thu Apr 20 22:43:27 2017 -0400

wsd: don't remove session after saving unconditionally

We should only remove sessions that had already been
disconnected, which caused the saving.

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index a2b90d50..9cd27989 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -562,11 +562,12 @@ bool DocumentBroker::saveToStorage(const std::string& 
sessionId,
 
 const bool res = saveToStorageInternal(sessionId, success, result);
 
-// We've saved and can safely destroy this session.
-removeSessionInternal(sessionId);
+// If marked to destroy, or session is disconnected, remove.
+const auto it = _sessions.find(sessionId);
+if (_markToDestroy || (it != _sessions.end() && 
it->second->isCloseFrame()))
+removeSessionInternal(sessionId);
 
 // If marked to destroy, then this was the last session.
-// Otherwise, check that we are (which we might be by now).
 if (_markToDestroy || _sessions.empty())
 {
 // Stop so we get cleaned up and removed.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-04-18 Thread Jan Holesovsky
 wsd/DocumentBroker.cpp |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 324499b0d92d4bb99538787fe462557ea69d1888
Author: Jan Holesovsky 
Date:   Tue Apr 18 12:13:04 2017 +0200

Safer place for the tile cache cleanup.

When calling the cleanup from DocumentBroker::destroyIfLastEditor(), it 
might
be (theoretically) too early; so let's do it safer - as the last thing when
shutting down the DocumentBroker::pollThread().

Change-Id: Idc5e34b36d524c8f87a3a0fc99c87244e9784abf

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index e0c8b05b..8ad9571e 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -287,6 +287,10 @@ void DocumentBroker::pollThread()
 // Async cleanup.
 LOOLWSD::doHousekeeping();
 
+// Remove all tiles related to this document from the cache if configured 
so.
+if (_tileCache && !LOOLWSD::TileCachePersistent)
+_tileCache->completeCleanup();
+
 LOG_INF("Finished docBroker polling thread for docKey [" << _docKey << 
"].");
 }
 
@@ -1198,10 +1202,6 @@ void DocumentBroker::destroyIfLastEditor(const 
std::string& id)
 _markToDestroy = (_sessions.size() <= 1);
 LOG_DBG("startDestroy on session [" << id << "] on docKey [" << _docKey <<
 "], markToDestroy: " << _markToDestroy << ", lastEditableSession: 
" << _lastEditableSession);
-
-// Remove all tiles related to this document from the cache.
-if (_markToDestroy && !LOOLWSD::TileCachePersistent)
-_tileCache->completeCleanup();
 }
 
 void DocumentBroker::setModified(const bool value)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-04-12 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit ed51fafecef9424a71cca73edf8bb428d835f372
Author: Ashod Nakashian 
Date:   Wed Apr 12 21:19:51 2017 -0400

wsd: DocBroker is Alive if not flagged to stop

There is a race between creating and adding
a DocBroker into the DocBrokers container
and cleanupDocBrokers is invoked (on timer)
before it had a chance to start its poll
thread. This is exceedingly rare, but it
has happened.

We check that_stop==false flag when deciding
isAlive such that cleanDocBrokers will
not remove it before its thread had
a chance to run (which would happen
after adding it and creating the
ClientSession).

Also, no point in checking isAlive from
the polling thread itself (of course it is
alive).

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 3cac2e70..e0c8b05b 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -242,7 +242,7 @@ void DocumentBroker::pollThread()
 
 // If all sessions have been removed, no reason to linger.
 if ((isLoaded() || _markToDestroy) && notSaving &&
-(_sessions.empty() || !isAlive() || idle))
+(_sessions.empty() || idle))
 {
 LOG_INF("Terminating " << (idle ? "idle" : "dead") <<
 " DocumentBroker for docKey [" << getDocKey() << "].");
@@ -292,8 +292,8 @@ void DocumentBroker::pollThread()
 
 bool DocumentBroker::isAlive() const
 {
-if (_poll->isAlive())
-return true; // Polling thread still running.
+if (!_stop || _poll->isAlive())
+return true; // Polling thread not started or still running.
 
 // Shouldn't have live child process outside of the polling thread.
 return _childProcess && _childProcess->isAlive();
___
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/DocumentBroker.hpp

2017-04-11 Thread Miklos Vajna
 wsd/DocumentBroker.cpp |8 
 wsd/DocumentBroker.hpp |8 
 2 files changed, 8 insertions(+), 8 deletions(-)

New commits:
commit 8a1f321c8492d6c2824317c7e4be1a3bdfa81665
Author: Miklos Vajna 
Date:   Tue Apr 11 08:54:09 2017 +0200

DocumentBroker: avoid unnecessary copying

Change-Id: Iaa555ed8e347d0e1712c617839f007d0b4f3204b

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 33f88ef7..e041db70 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -522,7 +522,7 @@ bool DocumentBroker::load(const 
std::shared_ptr& session, const s
 return true;
 }
 
-bool DocumentBroker::saveToStorage(const std::string sessionId,
+bool DocumentBroker::saveToStorage(const std::string& sessionId,
bool success, const std::string& result)
 {
 assertCorrectThread();
@@ -823,7 +823,7 @@ size_t DocumentBroker::addSession(const 
std::shared_ptr& session)
 return count;
 }
 
-size_t DocumentBroker::removeSession(const std::string id, bool destroyIfLast)
+size_t DocumentBroker::removeSession(const std::string& id, bool destroyIfLast)
 {
 assertCorrectThread();
 
@@ -846,7 +846,7 @@ size_t DocumentBroker::removeSession(const std::string id, 
bool destroyIfLast)
 return _sessions.size();
 }
 
-size_t DocumentBroker::removeSessionInternal(const std::string id)
+size_t DocumentBroker::removeSessionInternal(const std::string& id)
 {
 assertCorrectThread();
 try
@@ -894,7 +894,7 @@ size_t DocumentBroker::removeSessionInternal(const 
std::string id)
 return _sessions.size();
 }
 
-void DocumentBroker::addCallback(SocketPoll::CallbackFn fn)
+void DocumentBroker::addCallback(const SocketPoll::CallbackFn& fn)
 {
 _poll->addCallback(fn);
 }
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 20bdc496..62cb6a95 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -233,7 +233,7 @@ public:
 void setLoaded();
 
 /// Save the document to Storage if it needs persisting.
-bool saveToStorage(const std::string sesionId, bool success, const 
std::string& result = "");
+bool saveToStorage(const std::string& sesionId, bool success, const 
std::string& result = "");
 bool isModified() const { return _isModified; }
 void setModified(const bool value);
 
@@ -265,10 +265,10 @@ public:
 size_t addSession(const std::shared_ptr& session);
 
 /// Removes a session by ID. Returns the new number of sessions.
-size_t removeSession(const std::string id, bool destroyIfLast = false);
+size_t removeSession(const std::string& id, bool destroyIfLast = false);
 
 /// Add a callback to be invoked in our polling thread.
-void addCallback(SocketPoll::CallbackFn fn);
+void addCallback(const SocketPoll::CallbackFn& fn);
 
 /// Transfer this socket into our polling thread / loop.
 void addSocketToPoll(const std::shared_ptr& socket);
@@ -342,7 +342,7 @@ private:
 bool saveToStorageInternal(const std::string& sesionId, bool success, 
const std::string& result = "");
 
 /// Removes a session by ID. Returns the new number of sessions.
-size_t removeSessionInternal(const std::string id);
+size_t removeSessionInternal(const std::string& id);
 
 /// Forward a message from child session to its respective client session.
 bool forwardToClient(const std::shared_ptr& payload);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-04-06 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |   15 +--
 1 file changed, 5 insertions(+), 10 deletions(-)

New commits:
commit 37f499a7f631d1909a71a026c8ae8853d7d65fc3
Author: Ashod Nakashian 
Date:   Thu Apr 6 23:38:54 2017 -0400

wsd: merge DocumentBroker poll exit conditions

These conditions must be checked together. Otherwise we might
set _stop prematurely.

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index eb53f195..f7bbd9f1 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -234,19 +234,14 @@ void DocumentBroker::pollThread()
 last30SecCheckTime = std::chrono::steady_clock::now();
 }
 
-// If all sessions have been removed, no reason to linger.
-if (_sessions.empty() && 
std::chrono::duration_cast
-(std::chrono::steady_clock::now() - _lastSaveRequestTime).count() 
> COMMAND_TIMEOUT_MS)
-{
-LOG_INF("No more sessions in doc [" << _docKey << "]. 
Terminating.");
-_stop = true;
-}
+const bool notSaving = 
(std::chrono::duration_cast
+(std::chrono::steady_clock::now() - 
_lastSaveRequestTime).count() > COMMAND_TIMEOUT_MS);
 
 // Remove idle documents after 1 hour.
-const bool idle = getIdleTimeSecs() >= 3600;
+const bool idle = (getIdleTimeSecs() >= 3600);
 
-// Cleanup used and dead entries.
-if ((isLoaded() || _markToDestroy) &&
+// If all sessions have been removed, no reason to linger.
+if ((isLoaded() || _markToDestroy) && notSaving &&
 (_sessions.empty() || !isAlive() || idle))
 {
 LOG_INF("Terminating " << (idle ? "idle" : "dead") <<
___
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/DocumentBroker.hpp

2017-04-06 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |   10 +++---
 wsd/DocumentBroker.hpp |6 +++---
 2 files changed, 10 insertions(+), 6 deletions(-)

New commits:
commit 1e1f23716c9ee3ce880d1d927945386cf5400293
Author: Ashod Nakashian 
Date:   Thu Apr 6 13:49:44 2017 -0400

wsd: don't take reference to session member being destroyed

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 9550dfd2..eb53f195 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -516,7 +516,7 @@ bool DocumentBroker::load(const 
std::shared_ptr& session, const s
 return true;
 }
 
-bool DocumentBroker::saveToStorage(const std::string& sessionId,
+bool DocumentBroker::saveToStorage(const std::string sessionId,
bool success, const std::string& result)
 {
 assertCorrectThread();
@@ -817,7 +817,7 @@ size_t DocumentBroker::addSession(const 
std::shared_ptr& session)
 return count;
 }
 
-size_t DocumentBroker::removeSession(const std::string& id, bool destroyIfLast)
+size_t DocumentBroker::removeSession(const std::string id, bool destroyIfLast)
 {
 assertCorrectThread();
 
@@ -840,7 +840,7 @@ size_t DocumentBroker::removeSession(const std::string& id, 
bool destroyIfLast)
 return _sessions.size();
 }
 
-size_t DocumentBroker::removeSessionInternal(const std::string& id)
+size_t DocumentBroker::removeSessionInternal(const std::string id)
 {
 assertCorrectThread();
 try
@@ -853,6 +853,10 @@ size_t DocumentBroker::removeSessionInternal(const 
std::string& id)
 LOOLWSD::dumpEndSessionTrace(getJailId(), id, _uriOrig);
 
 const auto readonly = (it->second ? it->second->isReadOnly() : 
false);
+
+//FIXME: We might be called from the session we are removing,
+//FIXME: and if this is the last/only reference, we destroy it.
+//FIXME: Should flag and remove from the poll thread.
 _sessions.erase(it);
 
 const auto count = _sessions.size();
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index c8758ba9..88fa2b6e 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -233,7 +233,7 @@ public:
 void setLoaded();
 
 /// Save the document to Storage if it needs persisting.
-bool saveToStorage(const std::string& sesionId, bool success, const 
std::string& result = "");
+bool saveToStorage(const std::string sesionId, bool success, const 
std::string& result = "");
 bool isModified() const { return _isModified; }
 void setModified(const bool value);
 
@@ -265,7 +265,7 @@ public:
 size_t addSession(const std::shared_ptr& session);
 
 /// Removes a session by ID. Returns the new number of sessions.
-size_t removeSession(const std::string& id, bool destroyIfLast = false);
+size_t removeSession(const std::string id, bool destroyIfLast = false);
 
 /// Add a callback to be invoked in our polling thread.
 void addCallback(SocketPoll::CallbackFn fn);
@@ -342,7 +342,7 @@ private:
 bool saveToStorageInternal(const std::string& sesionId, bool success, 
const std::string& result = "");
 
 /// Removes a session by ID. Returns the new number of sessions.
-size_t removeSessionInternal(const std::string& id);
+size_t removeSessionInternal(const std::string id);
 
 /// Forward a message from child session to its respective client session.
 bool forwardToClient(const std::shared_ptr& payload);
___
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/DocumentBroker.hpp

2017-04-06 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |4 ++--
 wsd/DocumentBroker.hpp |5 -
 2 files changed, 2 insertions(+), 7 deletions(-)

New commits:
commit 7da1909d3c7596f6801391f7286efeadd114c44b
Author: Ashod Nakashian 
Date:   Thu Apr 6 13:49:22 2017 -0400

wsd: kill DocumentBroker::getSessionsCount

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 0ee99738..9550dfd2 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -247,7 +247,7 @@ void DocumentBroker::pollThread()
 
 // Cleanup used and dead entries.
 if ((isLoaded() || _markToDestroy) &&
-(getSessionsCount() == 0 || !isAlive() || idle))
+(_sessions.empty() || !isAlive() || idle))
 {
 LOG_INF("Terminating " << (idle ? "idle" : "dead") <<
 " DocumentBroker for docKey [" << getDocKey() << "].");
@@ -1369,7 +1369,7 @@ void DocumentBroker::dumpState(std::ostream& os)
 os << "\n  jailed uri: " << _uriJailed.toString();
 os << "\n  doc key: " << _docKey;
 os << "\n  doc id: " << _docId;
-os << "\n  num sessions: " << getSessionsCount();
+os << "\n  num sessions: " << _sessions.size();
 os << "\n  last editable?: " << _lastEditableSession;
 std::time_t t = std::chrono::system_clock::to_time_t(
 std::chrono::system_clock::now()
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index fd8d20e8..c8758ba9 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -251,11 +251,6 @@ public:
 const std::string& getFilename() const { return _filename; };
 TileCache& tileCache() { return *_tileCache; }
 bool isAlive() const;
-size_t getSessionsCount() const
-{
-Util::assertIsLocked(_mutex);
-return _sessions.size();
-}
 
 /// Are we running in either shutdown, or the polling thread.
 /// Asserts in the debug builds, otherwise just logs.
___
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/DocumentBroker.hpp wsd/LOOLWSD.cpp

2017-04-06 Thread Michael Meeks
 wsd/DocumentBroker.cpp |   12 
 wsd/DocumentBroker.hpp |2 +-
 wsd/LOOLWSD.cpp|   32 +++-
 3 files changed, 20 insertions(+), 26 deletions(-)

New commits:
commit 90127ac0e3e7d4dd90e3143c7b310249c274c1a9
Author: Michael Meeks 
Date:   Thu Apr 6 17:58:41 2017 +0100

Let the DocBroker thread clean itself up and expire.

(cherry picked from commit 2e372b70b32d4e052458547daa229c537442774f)

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index a5a995df..0ee99738 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -241,6 +241,18 @@ void DocumentBroker::pollThread()
 LOG_INF("No more sessions in doc [" << _docKey << "]. 
Terminating.");
 _stop = true;
 }
+
+// Remove idle documents after 1 hour.
+const bool idle = getIdleTimeSecs() >= 3600;
+
+// Cleanup used and dead entries.
+if ((isLoaded() || _markToDestroy) &&
+(getSessionsCount() == 0 || !isAlive() || idle))
+{
+LOG_INF("Terminating " << (idle ? "idle" : "dead") <<
+" DocumentBroker for docKey [" << getDocKey() << "].");
+_stop = true;
+}
 }
 
 LOG_INF("Finished polling doc [" << _docKey << "]. stop: " << _stop << ", 
continuePolling: " <<
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index d05437e9..fd8d20e8 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -304,7 +304,7 @@ public:
 void handleTileCombinedResponse(const std::vector& payload);
 
 void destroyIfLastEditor(const std::string& id);
-bool isMarkedToDestroy() const { return _markToDestroy; }
+bool isMarkedToDestroy() const { return _markToDestroy || _stop; }
 
 bool handleInput(const std::vector& payload);
 
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index e5d4cb68..439ab67e 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -235,33 +235,15 @@ void cleanupDocBrokers()
 {
 auto docBroker = it->second;
 
-// If document busy at the moment, cleanup later.
-auto lock = docBroker->getDeferredLock();
-if (lock.try_lock())
+// Remove only when not alive.
+if (!docBroker->isAlive())
 {
-// Remove idle documents after 1 hour.
-const bool idle = (docBroker->getIdleTimeSecs() >= 3600);
-
-// Cleanup used and dead entries.
-if ((docBroker->isLoaded() || docBroker->isMarkedToDestroy()) &&
-(docBroker->getSessionsCount() == 0 || !docBroker->isAlive() 
|| idle))
-{
-LOG_INF("Terminating " << (idle ? "idle" : "dead") <<
-" DocumentBroker for docKey [" << it->first << "].");
-docBroker->stop();
-
-// Remove only when not alive.
-if (!docBroker->isAlive())
-{
-LOG_INF("Removing " << (idle ? "idle" : "dead") <<
-" DocumentBroker for docKey [" << it->first << 
"].");
-it = DocBrokers.erase(it);
-continue;
-}
-}
+LOG_INF("Removing DocumentBroker for docKey [" << it->first << 
"].");
+it = DocBrokers.erase(it);
+continue;
+} else {
+++it;
 }
-
-++it;
 }
 
 if (count != DocBrokers.size())
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-04-06 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |2 --
 1 file changed, 2 deletions(-)

New commits:
commit 5e4528b59353733cc95b29613ba74ce2b26af0c4
Author: Ashod Nakashian 
Date:   Thu Apr 6 01:59:20 2017 -0400

wsd: leave the poll running so DocBroker can flush the sockets

By stopping the poll we fail to notify the clients
of the shutdown. Let the DocBroker poll thread
take care of the poll stopping when it's ready.

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 3ab3d121..8dd3fa42 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1325,8 +1325,6 @@ void DocumentBroker::terminateChild(const std::string& 
closeReason, const bool r
 _childProcess->close(rude);
 }
 
-// Stop the polling thread.
-_poll->stop();
 _stop = true;
 }
 
___
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/DocumentBroker.hpp wsd/LOOLWSD.cpp

2017-04-06 Thread Michael Meeks
 wsd/DocumentBroker.cpp |8 +++-
 wsd/DocumentBroker.hpp |3 +--
 wsd/LOOLWSD.cpp|   15 ++-
 3 files changed, 14 insertions(+), 12 deletions(-)

New commits:
commit 01519eff70f1157dbbb4cb329acc7754f34a2765
Author: Michael Meeks 
Date:   Wed Apr 5 21:31:15 2017 +0100

Always cleanup DocBrokers in the PrisonerPoll thread.

This simplifies things, and keeps process management in one thread.
Also - wakeup the DocumentBroker when we want to stop it.

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 5a4de9e2..396bf52b 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -264,7 +264,7 @@ void DocumentBroker::pollThread()
 _poll->poll(std::min(flushTimeoutMs - elapsedMs, POLL_TIMEOUT_MS / 5));
 }
 
-// Cleanup.
+// Async cleanup.
 LOOLWSD::doHousekeeping();
 
 LOG_INF("Finished docBroker polling thread for docKey [" << _docKey << 
"].");
@@ -306,6 +306,12 @@ void DocumentBroker::joinThread()
 _poll->joinThread();
 }
 
+void DocumentBroker::stop()
+{
+_stop = true;
+_poll->wakeup();
+}
+
 bool DocumentBroker::load(const std::shared_ptr& session, const 
std::string& jailId)
 {
 assertCorrectThread();
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 0af441ff..d05437e9 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -222,8 +222,7 @@ public:
 void startThread();
 
 /// Flag for termination.
-//TODO: Take reason to broadcast to clients.
-void stop() { _stop = true; }
+void stop();
 
 /// Thread safe termination of this broker if it has a lingering thread
 void joinThread();
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 08a20ce7..e5d4cb68 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -226,7 +226,7 @@ void alertAllUsersInternal(const std::string& msg)
 /// Remove dead and idle DocBrokers.
 /// The client of idle document should've greyed-out long ago.
 /// Returns true if at least one is removed.
-bool cleanupDocBrokers()
+void cleanupDocBrokers()
 {
 Util::assertIsLocked(DocBrokersMutex);
 
@@ -277,11 +277,7 @@ bool cleanupDocBrokers()
 
 LOG_END(logger);
 }
-
-return true;
 }
-
-return false;
 }
 
 /// Forks as many children as requested.
@@ -582,7 +578,7 @@ class PrisonerPoll : public TerminatingPoll {
 public:
 PrisonerPoll() : TerminatingPoll("prisoner_poll") {}
 
-/// Check prisoners are still alive and balaned.
+/// Check prisoners are still alive and balanced.
 void wakeupHook() override;
 };
 
@@ -1099,12 +1095,13 @@ bool LOOLWSD::checkAndRestoreForKit()
 #endif
 }
 
-void PrisonerPoll::wakeupHook()
+void LOOLWSD::doHousekeeping()
 {
-LOOLWSD::doHousekeeping();
+PrisonerPoll.wakeup();
 }
 
-void LOOLWSD::doHousekeeping()
+/// Really do the house-keeping
+void PrisonerPoll::wakeupHook()
 {
 if (!LOOLWSD::checkAndRestoreForKit())
 {
___
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/TileCache.cpp

2017-04-04 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |8 
 wsd/TileCache.cpp  |3 ++-
 2 files changed, 10 insertions(+), 1 deletion(-)

New commits:
commit 2254b71682a7314c1113ce4aa521de786d1d69c1
Author: Ashod Nakashian 
Date:   Wed Apr 5 00:26:09 2017 -0400

wsd: some informative logging

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 97626af9..cafbd424 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -243,6 +243,10 @@ void DocumentBroker::pollThread()
 }
 }
 
+LOG_INF("Finished polling doc [" << _docKey << "]. stop: " << _stop << ", 
continuePolling: " <<
+_poll->continuePolling() << ", TerminationFlag: " << 
TerminationFlag <<
+", ShutdownRequestFlag: " << ShutdownRequestFlag << ".");
+
 // Terminate properly while we can.
 //TODO: pass some sensible reason.
 terminateChild("", false);
@@ -839,6 +843,10 @@ size_t DocumentBroker::removeSessionInternal(const 
std::string& id)
 LOG_TRC("Removed " << (readonly ? "readonly" : "non-readonly") <<
 " session [" << id << "] from docKey [" <<
 _docKey << "] to have " << count << " sessions.");
+for (const auto& pair : _sessions)
+{
+LOG_TRC("Session: " << pair.second->getName());
+}
 
 // Let the child know the client has disconnected.
 const std::string msg("child-" + id + " disconnect");
diff --git a/wsd/TileCache.cpp b/wsd/TileCache.cpp
index 4c1d7572..b744eded 100644
--- a/wsd/TileCache.cpp
+++ b/wsd/TileCache.cpp
@@ -53,7 +53,8 @@ TileCache::TileCache(const std::string& docURL,
 _cacheDir(cacheDir)
 {
 LOG_INF("TileCache ctor for uri [" << _docURL <<
-"] modifiedTime=" << (modifiedTime.raw()/100) <<
+"], cacheDir: [" << _cacheDir <<
+"], modifiedTime=" << (modifiedTime.raw()/100) <<
 " getLastModified()=" << (getLastModified().raw()/100));
 File directory(_cacheDir);
 std::string unsaved;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-04-03 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |   11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

New commits:
commit d11b3a76d9284c23b0262abd2c48a2dc89bed571
Author: Ashod Nakashian 
Date:   Tue Apr 4 00:11:06 2017 -0400

wsd: move correct-thread assertions

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 483e7c5e..97626af9 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -277,6 +277,8 @@ bool DocumentBroker::isAlive() const
 
 DocumentBroker::~DocumentBroker()
 {
+assert(isCorrectThread());
+
 Admin::instance().rmDoc(_docKey);
 
 LOG_INF("~DocumentBroker [" << _uriPublic.toString() <<
@@ -630,6 +632,8 @@ void DocumentBroker::setLoaded()
 
 bool DocumentBroker::autoSave(const bool force)
 {
+assert(isCorrectThread());
+
 if (_sessions.empty() || _storage == nullptr || !_isLoaded ||
 !_childProcess->isAlive() || (!_isModified && !force))
 {
@@ -669,6 +673,8 @@ bool DocumentBroker::autoSave(const bool force)
 
 bool DocumentBroker::sendUnoSave(const bool dontSaveIfUnmodified)
 {
+assert(isCorrectThread());
+
 LOG_INF("Autosave triggered for doc [" << _docKey << "].");
 
 std::shared_ptr savingSession;
@@ -1168,6 +1174,8 @@ void DocumentBroker::setModified(const bool value)
 
 bool DocumentBroker::forwardToChild(const std::string& viewId, const 
std::string& message)
 {
+assert(isCorrectThread());
+
 LOG_TRC("Forwarding payload to child [" << viewId << "]: " << message);
 
 std::string msg = "child-" + viewId + ' ' + message;
@@ -1242,7 +1250,7 @@ bool DocumentBroker::forwardToClient(const 
std::shared_ptr& payload)
 
 void DocumentBroker::childSocketTerminated()
 {
-std::lock_guard lock(_mutex);
+assert(isCorrectThread());
 
 if (!_childProcess->isAlive())
 {
@@ -1338,6 +1346,7 @@ void DocumentBroker::dumpState(std::ostream& os)
 os << "\n  public uri: " << _uriPublic.toString();
 os << "\n  jailed uri: " << _uriJailed.toString();
 os << "\n  doc key: " << _docKey;
+os << "\n  doc id: " << _docId;
 os << "\n  num sessions: " << getSessionsCount();
 os << "\n  last editable?: " << _lastEditableSession;
 std::time_t t = std::chrono::system_clock::to_time_t(
___
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

2017-04-02 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

New commits:
commit bd82bf4c4b7ed57d55cd1cf05ea681517b8c1bf3
Author: Ashod Nakashian 
Date:   Sun Apr 2 17:50:17 2017 -0400

wsd: set DocBroker poll thread once

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 259ca5aa..ae7f6e71 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -155,7 +155,7 @@ DocumentBroker::DocumentBroker(const std::string& uri,
 _cursorPosY(0),
 _cursorWidth(0),
 _cursorHeight(0),
-_poll(new DocumentBrokerPoll("docbrk_poll", *this)),
+_poll(new DocumentBrokerPoll("docbroker_" + _docId, *this)),
 _stop(false),
 _tileVersion(0),
 _debugRenderedTileCount(0)
@@ -180,8 +180,6 @@ bool DocumentBroker::isCorrectThread()
 // The inner heart of the DocumentBroker - our poll loop.
 void DocumentBroker::pollThread()
 {
-Util::setThreadName("docbroker_" + _docId);
-
 LOG_INF("Starting docBroker polling thread for docKey [" << _docKey << 
"].");
 
 _threadStart = std::chrono::steady_clock::now();
___
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/DocumentBroker.hpp wsd/LOOLWSD.cpp

2017-04-01 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |   28 ++--
 wsd/DocumentBroker.hpp |9 ++---
 wsd/LOOLWSD.cpp|   47 +--
 3 files changed, 33 insertions(+), 51 deletions(-)

New commits:
commit 63ab3bcfa49ec9f6efb0fa81657ea64eaf0ab007
Author: Ashod Nakashian 
Date:   Sat Apr 1 19:20:54 2017 -0400

wsd: remove queueSession and simplify session loading

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 0a6d2f01..494f21f3 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -223,22 +223,6 @@ void DocumentBroker::pollThread()
 // Main polling loop goodness.
 while (!_stop && _poll->continuePolling() && !TerminationFlag && 
!ShutdownRequestFlag)
 {
-// First, load new sessions.
-for (const auto& pair : _sessions)
-{
-try
-{
-auto& session = pair.second;
-if (!session->isAttached())
-addSession(session);
-}
-catch (const std::exception& exc)
-{
-LOG_ERR("Error while adding new session to doc [" << _docKey 
<< "]: " << exc.what());
-//TODO: Send failure to client and remove session.
-}
-}
-
 _poll->poll(SocketPoll::DefaultPollTimeoutMs);
 
 if (!std::getenv("LOOL_NO_AUTOSAVE") && !_stop &&
@@ -746,16 +730,6 @@ std::string DocumentBroker::getJailRoot() const
 return Poco::Path(_childRoot, _jailId).toString();
 }
 
-size_t DocumentBroker::queueSession(std::shared_ptr& session)
-{
-std::unique_lock lock(_mutex);
-
-_sessions.emplace(session->getId(), session);
-_poll->wakeup();
-
-return _sessions.size();
-}
-
 size_t DocumentBroker::addSession(const std::shared_ptr& 
session)
 {
 assert(isCorrectThread());
@@ -788,6 +762,8 @@ size_t DocumentBroker::addSession(const 
std::shared_ptr& session)
 _markToDestroy = false;
 _stop = false;
 
+// Add and attach the session.
+_sessions.emplace(session->getId(), session);
 session->setAttached();
 
 const auto id = session->getId();
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index a7473531..915db5a6 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -266,10 +266,8 @@ public:
 
 std::string getJailRoot() const;
 
-/// Queue a new session to be attached asynchronously.
-/// @return amount of session we have after all the queued ones will be
-/// created.
-size_t queueSession(std::shared_ptr& session);
+/// Add a new session. Returns the new number of sessions.
+size_t addSession(const std::shared_ptr& session);
 
 /// Removes a session by ID. Returns the new number of sessions.
 size_t removeSession(const std::string& id, bool destroyIfLast = false);
@@ -354,9 +352,6 @@ private:
 /// Forward a message from child session to its respective client session.
 bool forwardToClient(const std::shared_ptr& payload);
 
-/// Add a new session. Returns the new number of sessions.
-size_t addSession(const std::shared_ptr& session);
-
 /// The thread function that all of the I/O for all sessions
 /// associated with this document.
 void pollThread();
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index db5f55a2..05c6e1da 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1324,8 +1324,6 @@ static std::shared_ptr 
createNewClientSession(const WebSocketHand
 // (UserCanWrite param).
 auto session = std::make_shared(id, docBroker, 
uriPublic, isReadOnly);
 
-docBroker->queueSession(session);
-
 return session;
 }
 catch (const std::exception& exc)
@@ -1860,17 +1858,18 @@ private:
 auto clientSession = createNewClientSession(nullptr, _id, 
uriPublic, docBroker, isReadOnly);
 if (clientSession)
 {
+clientSession->setSaveAsSocket(socket);
+
 // Transfer the client socket to the DocumentBroker.
 // Move the socket into DocBroker.
 docBroker->addSocketToPoll(socket);
 socketOwnership = 
SocketHandlerInterface::SocketOwnership::MOVED;
 
-clientSession->setSaveAsSocket(socket);
-
-docBroker->startThread();
-
-docBroker->addCallback([&]()
+docBroker->addCallback([&, clientSession]()
 {
+// First add and load the session.
+docBroker->addSession(clientSession);
+
 // Load the 

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

2017-03-27 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 99844c1c924e6c2de8011c9f680151f228e74f61
Author: Ashod Nakashian 
Date:   Tue Mar 28 01:05:18 2017 -0400

wsd: protect DocBrokers session member

It is accessed from the PrisonerPoll
when cleaning up.

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 32f55aae..83e00329 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -525,6 +525,8 @@ bool DocumentBroker::saveToStorageInternal(const 
std::string& sessionId,
 return true;
 }
 
+std::unique_lock lock(_mutex);
+
 const auto it = _sessions.find(sessionId);
 if (it == _sessions.end())
 {
___
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


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

2017-03-27 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |   13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

New commits:
commit 06249045006c438e41ec7037778fcc57017735ec
Author: Ashod Nakashian 
Date:   Mon Mar 27 20:50:30 2017 -0400

wsd: flush sockets using timed loops

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 97b81fdd..384e66cf 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -248,8 +248,17 @@ void DocumentBroker::pollThread()
 }
 
 // Flush socket data.
-for (int i = 0; i < 7 && _poll->getSocketCount() > 0; ++i)
-_poll->poll(POLL_TIMEOUT_MS / 5);
+const int flushTimeoutMs = POLL_TIMEOUT_MS * 2; // ~1000ms
+const auto flushStartTime = std::chrono::steady_clock::now();
+while (_poll->getSocketCount())
+{
+const auto now = std::chrono::steady_clock::now();
+const int elapsedMs = 
std::chrono::duration_cast(now - 
flushStartTime).count();
+if (elapsedMs > flushTimeoutMs)
+break;
+
+_poll->poll(std::min(flushTimeoutMs - elapsedMs, POLL_TIMEOUT_MS / 5));
+}
 
 // Terminate properly while we can.
 auto lock = getLock();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-03-26 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit fddb86744e72ef6d2a0427126d56c154217d4df3
Author: Ashod Nakashian 
Date:   Sun Mar 26 23:09:59 2017 -0400

wsd: stop DocBroker poll thread when poll is flagged to stop

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 47e86ecb..26452a9b 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -209,7 +209,7 @@ void DocumentBroker::pollThread()
 auto last30SecCheckTime = std::chrono::steady_clock::now();
 
 // Main polling loop goodness.
-while (!_stop && !TerminationFlag && !ShutdownRequestFlag)
+while (!_stop && _poll->continuePolling() && !TerminationFlag && 
!ShutdownRequestFlag)
 {
 // First, load new sessions.
 for (const auto& pair : _sessions)
@@ -1290,6 +1290,7 @@ void 
DocumentBroker::terminateChild(std::unique_lock& lock, const st
 
 // Stop the polling thread.
 _poll->stop();
+_stop = true;
 }
 
 void DocumentBroker::closeDocument(const std::string& reason)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-03-25 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 5eed6575df0133ed38a6a47509d6b96c771e2b3c
Author: Ashod Nakashian 
Date:   Sun Mar 26 00:52:34 2017 -0400

wsd: don't pretent there was a recent save on creating DocBroker

Now the poll thread can exit immediately when loading
fails, since we don't think there is an active
saving on going.

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index fe0372e7..ba3a7595 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -143,7 +143,7 @@ DocumentBroker::DocumentBroker(const std::string& uri,
 _childRoot(childRoot),
 _cacheRoot(getCachePath(uriPublic.toString())),
 _lastSaveTime(std::chrono::steady_clock::now()),
-_lastSaveRequestTime(std::chrono::steady_clock::now()),
+_lastSaveRequestTime(std::chrono::steady_clock::now() - 
std::chrono::milliseconds(COMMAND_TIMEOUT_MS)),
 _markToDestroy(false),
 _lastEditableSession(false),
 _isLoaded(false),
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-03-25 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |   11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

New commits:
commit bd00aa405727ae193c6ae762ce0efd9b580043ae
Author: Ashod Nakashian 
Date:   Sat Mar 25 13:57:08 2017 -0400

wsd: assert isCorrectThread

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 2f7ab961..2f542b14 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -302,7 +302,7 @@ DocumentBroker::~DocumentBroker()
 
 bool DocumentBroker::load(const std::shared_ptr& session, const 
std::string& jailId)
 {
-Util::assertIsLocked(_mutex);
+assert(isCorrectThread());
 
 const std::string sessionId = session->getId();
 
@@ -519,7 +519,7 @@ bool DocumentBroker::saveToStorage(const std::string& 
sessionId,
 bool DocumentBroker::saveToStorageInternal(const std::string& sessionId,
bool success, const std::string& 
result)
 {
-assert(_poll->isCorrectThread());
+assert(isCorrectThread());
 
 // If save requested, but core didn't save because document was unmodified
 // notify the waiting thread, if any.
@@ -745,7 +745,7 @@ size_t 
DocumentBroker::queueSession(std::shared_ptr& session)
 
 size_t DocumentBroker::addSession(const std::shared_ptr& 
session)
 {
-Util::assertIsLocked(_mutex);
+assert(isCorrectThread());
 
 try
 {
@@ -948,6 +948,7 @@ void DocumentBroker::invalidateTiles(const std::string& 
tiles)
 void DocumentBroker::handleTileRequest(TileDesc& tile,
const std::shared_ptr& 
session)
 {
+assert(isCorrectThread());
 std::unique_lock lock(_mutex);
 
 tile.setVersion(++_tileVersion);
@@ -1213,6 +1214,8 @@ bool DocumentBroker::forwardToChild(const std::string& 
viewId, const std::string
 
 bool DocumentBroker::forwardToClient(const std::shared_ptr& payload)
 {
+assert(isCorrectThread());
+
 const std::string& msg = payload->abbr();
 const std::string& prefix = payload->forwardToken();
 LOG_TRC("Forwarding payload to [" << prefix << "]: " << msg);
@@ -1224,8 +1227,6 @@ bool DocumentBroker::forwardToClient(const 
std::shared_ptr& payload)
 const auto& data = payload->data().data();
 const auto& size = payload->size();
 
-// std::unique_lock lock(_mutex);
-
 if (sid == "all")
 {
 // Broadcast to all.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-03-25 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |   11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

New commits:
commit a190084b43d6e4b2bedb3ddcfa6376db1f5b161c
Author: Ashod Nakashian 
Date:   Sat Mar 25 13:57:47 2017 -0400

wsd: log document loading stats only the first time

Since these numbers are against the thread start time,
they aren't useful for loading subsequent views.

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 2f542b14..eb204b8d 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -617,10 +617,13 @@ bool DocumentBroker::saveToStorageInternal(const 
std::string& sessionId,
 
 void DocumentBroker::setLoaded()
 {
-_isLoaded = true;
-_loadDuration = std::chrono::duration_cast(
-std::chrono::steady_clock::now() - _threadStart);
-LOG_TRC("Document loaded in " << _loadDuration.count() << "ms");
+if (!_isLoaded)
+{
+_isLoaded = true;
+_loadDuration = std::chrono::duration_cast(
+std::chrono::steady_clock::now() - 
_threadStart);
+LOG_TRC("Document loaded in " << _loadDuration.count() << "ms");
+}
 }
 
 bool DocumentBroker::autoSave(const bool force)
___
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/DocumentBroker.hpp

2017-03-25 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |5 ++---
 wsd/DocumentBroker.hpp |4 ++--
 2 files changed, 4 insertions(+), 5 deletions(-)

New commits:
commit a57b9e6917c6d1a80eb4d800d63dfde7f40f79f2
Author: Ashod Nakashian 
Date:   Sat Mar 25 13:56:17 2017 -0400

wsd: const correctness

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index d3934d1b..2f7ab961 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -300,7 +300,7 @@ DocumentBroker::~DocumentBroker()
 _childProcess.reset();
 }
 
-bool DocumentBroker::load(std::shared_ptr& session, const 
std::string& jailId)
+bool DocumentBroker::load(const std::shared_ptr& session, const 
std::string& jailId)
 {
 Util::assertIsLocked(_mutex);
 
@@ -743,7 +743,7 @@ size_t 
DocumentBroker::queueSession(std::shared_ptr& session)
 return _sessions.size() + _newSessions.size();
 }
 
-size_t DocumentBroker::addSession(std::shared_ptr& session)
+size_t DocumentBroker::addSession(const std::shared_ptr& 
session)
 {
 Util::assertIsLocked(_mutex);
 
@@ -864,7 +864,6 @@ size_t DocumentBroker::removeSessionInternal(const 
std::string& id)
 return _sessions.size();
 }
 
-
 void DocumentBroker::addCallback(SocketPoll::CallbackFn fn)
 {
 _poll->addCallback(fn);
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 526f873d..13acb9bb 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -225,7 +225,7 @@ public:
 void startThread();
 
 /// Loads a document from the public URI into the jail.
-bool load(std::shared_ptr& session, const std::string& 
jailId);
+bool load(const std::shared_ptr& session, const 
std::string& jailId);
 bool isLoaded() const { return _isLoaded; }
 void setLoaded();
 
@@ -354,7 +354,7 @@ private:
 bool forwardToClient(const std::shared_ptr& payload);
 
 /// Add a new session. Returns the new number of sessions.
-size_t addSession(std::shared_ptr& session);
+size_t addSession(const std::shared_ptr& session);
 
 /// The thread function that all of the I/O for all sessions
 /// associated with this document.
___
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/Storage.cpp wsd/Storage.hpp

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

New commits:
commit 0314f8751c76482216f8f7fe842c2f615e8526d6
Author: Ashod Nakashian 
Date:   Tue Mar 21 22:56:16 2017 -0400

wsd: fix saving of modified documents

Detection of modified documents used the
directory path rather than the document
path, which obviously wasn't correct.

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 936fee9a..d3934d1b 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -473,7 +473,7 @@ bool DocumentBroker::load(std::shared_ptr& 
session, const std::st
 _filename = fileInfo._filename;
 
 // Use the local temp file's timestamp.
-_lastFileModifiedTime = 
Poco::File(_storage->getLocalRootPath()).getLastModified();
+_lastFileModifiedTime = 
Poco::File(_storage->getRootFilePath()).getLastModified();
 _tileCache.reset(new TileCache(uriPublic.toString(), 
_lastFileModifiedTime, _cacheRoot));
 }
 
@@ -497,7 +497,6 @@ bool DocumentBroker::load(std::shared_ptr& 
session, const std::st
 bool DocumentBroker::saveToStorage(const std::string& sessionId,
bool success, const std::string& result)
 {
-LOG_TRC("Saving to storage docKey [" << _docKey << "] for session [" << 
sessionId << "]: " << result);
 const bool res = saveToStorageInternal(sessionId, success, result);
 
 // If marked to destroy, then this was the last session.
@@ -524,6 +523,8 @@ bool DocumentBroker::saveToStorageInternal(const 
std::string& sessionId,
 
 // If save requested, but core didn't save because document was unmodified
 // notify the waiting thread, if any.
+LOG_TRC("Saving to storage docKey [" << _docKey << "] for session [" << 
sessionId <<
+"]. Success: " << success << ", result: " << result);
 if (!success && result == "unmodified")
 {
 LOG_DBG("Save skipped as document [" << _docKey << "] was not 
modified.");
@@ -544,7 +545,7 @@ bool DocumentBroker::saveToStorageInternal(const 
std::string& sessionId,
 
 // If we aren't destroying the last editable session just yet,
 // and the file timestamp hasn't changed, skip saving.
-const auto newFileModifiedTime = 
Poco::File(_storage->getLocalRootPath()).getLastModified();
+const auto newFileModifiedTime = 
Poco::File(_storage->getRootFilePath()).getLastModified();
 if (!_lastEditableSession && newFileModifiedTime == _lastFileModifiedTime)
 {
 // Nothing to do.
diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 9d2f9917..639d057d 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -208,11 +208,9 @@ std::unique_ptr 
LocalStorage::getLocalFileInfo(cons
 
 std::string LocalStorage::loadStorageFileToLocal()
 {
-const auto rootPath = getLocalRootPath();
-
 // /chroot/jailId/user/doc/childId/file.ext
 const auto filename = Poco::Path(_uri.getPath()).getFileName();
-_jailedFilePath = Poco::Path(rootPath, filename).toString();
+_jailedFilePath = Poco::Path(getLocalRootPath(), filename).toString();
 LOG_INF("Public URI [" << _uri.getPath() <<
 "] jailed to [" << _jailedFilePath << "].");
 
diff --git a/wsd/Storage.hpp b/wsd/Storage.hpp
index 4f642d62..7def9822 100644
--- a/wsd/Storage.hpp
+++ b/wsd/Storage.hpp
@@ -74,10 +74,9 @@ public:
 LOG_DBG("Storage ctor: " << uri.toString());
 }
 
-std::string getLocalRootPath() const;
-
 const std::string getUri() const { return _uri.toString(); }
 
+/// Returns the root path to the jailed file.
 const std::string& getRootFilePath() const { return _jailedFilePath; };
 
 bool isLoaded() const { return _isLoaded; }
@@ -101,6 +100,10 @@ public:
 static std::unique_ptr create(const Poco::URI& uri,
const std::string& jailRoot,
const std::string& jailPath);
+protected:
+
+/// Returns the root path of the jail directory of docs.
+std::string getLocalRootPath() const;
 
 protected:
 const Poco::URI _uri;
___
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

2017-03-12 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |3 ++
 wsd/LOOLWSD.cpp|   54 +
 2 files changed, 35 insertions(+), 22 deletions(-)

New commits:
commit 3d78e5f2a1a6c1369e6cdeddd39cb00a6e33d1bd
Author: Ashod Nakashian 
Date:   Sun Mar 12 22:31:50 2017 -0400

wsd: improved logging of extant DocBrokers after cleanup

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 25686bf..a53a7c1 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1274,6 +1274,9 @@ void 
DocumentBroker::terminateChild(std::unique_lock& lock, const st
 
 _childProcess->close(false);
 }
+
+// Stop the polling thread.
+_poll->stop();
 }
 
 void DocumentBroker::closeDocument(const std::string& reason)
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 310d576..97cf845 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -261,38 +261,48 @@ bool cleanupDocBrokers()
 for (auto it = DocBrokers.begin(); it != DocBrokers.end(); )
 {
 auto docBroker = it->second;
+
+// If document busy at the moment, cleanup later.
 auto lock = docBroker->getDeferredLock();
-if (!lock.try_lock())
+if (lock.try_lock())
 {
-// Document busy at the moment, cleanup later.
-++it;
-continue;
-}
+// Remove idle documents after 1 hour.
+const bool idle = (docBroker->getIdleTimeSecs() >= 3600);
 
-// Remove idle documents after 1 hour.
-const bool idle = (docBroker->getIdleTimeSecs() >= 3600);
+// Cleanup used and dead entries.
+if ((docBroker->isLoaded() || docBroker->isMarkedToDestroy()) &&
+(docBroker->getSessionsCount() == 0 || !docBroker->isAlive() 
|| idle))
+{
+LOG_INF("Terminating " << (idle ? "idle" : "dead") <<
+" DocumentBroker for docKey [" << it->first << "].");
+docBroker->terminateChild(lock, idle ? "idle" : "");
 
-// Cleanup used and dead entries.
-if (docBroker->isLoaded() &&
-(docBroker->getSessionsCount() == 0 || !docBroker->isAlive() || 
idle))
-{
-LOG_INF("Removing " << (idle ? "idle" : "dead") <<
-" DocumentBroker for docKey [" << it->first << "].");
-it = DocBrokers.erase(it);
-docBroker->terminateChild(lock, idle ? "idle" : "");
-}
-else
-{
-++it;
+// Remove only when not alive.
+if (!docBroker->isAlive())
+{
+LOG_INF("Removing " << (idle ? "idle" : "dead") <<
+" DocumentBroker for docKey [" << it->first << 
"].");
+it = DocBrokers.erase(it);
+continue;
+}
+}
 }
+
+++it;
 }
 
 if (count != DocBrokers.size())
 {
-LOG_TRC("Have " << DocBrokers.size() << " DocBrokers after cleanup.");
-for (auto& pair : DocBrokers)
+auto logger = Log::trace();
+if (logger.enabled())
 {
-LOG_TRC("DocumentBroker [" << pair.first << "].");
+logger << "Have " << DocBrokers.size() << " DocBrokers after 
cleanup.\n";
+for (auto& pair : DocBrokers)
+{
+logger << "DocumentBroker [" << pair.first << "].\n";
+}
+
+LOG_END(logger);
 }
 
 return true;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-03-12 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

New commits:
commit c939eeab6837dd4151815da597acea6e6b36dd99
Author: Ashod Nakashian 
Date:   Sun Mar 12 14:13:48 2017 -0400

wsd: remove the last session immediately if no saving needed

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index fa8ba94..aacdfae 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -601,7 +601,7 @@ bool DocumentBroker::autoSave(const bool force)
 {
 // Nothing to do.
 LOG_TRC("Nothing to autosave [" << _docKey << "].");
-return true;
+return false;
 }
 
 // Remember the last save time, since this is the predicate.
@@ -779,9 +779,7 @@ size_t DocumentBroker::removeSession(const std::string& id, 
bool destroyIfLast)
 LOG_INF("Removing session [" << id << "] on docKey [" << _docKey <<
 "]. Have " << _sessions.size() << " sessions.");
 
-if (_lastEditableSession)
-autoSave(true);
-else
+if (!_lastEditableSession || !autoSave(true))
 return removeSessionInternal(id);
 }
 catch (const std::exception& ex)
@@ -797,7 +795,8 @@ size_t DocumentBroker::removeSessionInternal(const 
std::string& id)
 try
 {
 // remove also from the _newSessions
-_newSessions.erase(std::remove_if(_newSessions.begin(), 
_newSessions.end(), [](NewSession& newSession) { return 
newSession._session->getId() == id; }),
+_newSessions.erase(std::remove_if(_newSessions.begin(), 
_newSessions.end(),
+  [](NewSession& newSession) { 
return newSession._session->getId() == id; }),
_newSessions.end());
 
 Admin::instance().rmDoc(_docKey, id);
___
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/DocumentBroker.hpp wsd/LOOLWSD.cpp

2017-03-12 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |5 -
 wsd/DocumentBroker.hpp |8 
 wsd/LOOLWSD.cpp|6 +-
 3 files changed, 5 insertions(+), 14 deletions(-)

New commits:
commit 388d7b1dbf1a5c2d155c0149247b3a319114f8b0
Author: Ashod Nakashian 
Date:   Sun Mar 12 14:12:36 2017 -0400

wsd: TerminatingPoll always starts its own thread

Since all TerminatingPoll instances need to fire
a thread, no reason to do it manually and risk
races. Now TerminatingPoll does it in the ctor.

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 1b47d68..fa8ba94 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -163,11 +163,6 @@ DocumentBroker::DocumentBroker(const std::string& uri,
 _stop = false;
 }
 
-void DocumentBroker::startThread()
-{
-_poll->startThread();
-}
-
 // The inner heart of the DocumentBroker - our poll loop.
 void DocumentBroker::pollThread()
 {
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 2d30802..2a9c152 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -44,7 +44,10 @@ class TerminatingPoll : public SocketPoll
 {
 public:
 TerminatingPoll(const std::string ) :
-SocketPoll(threadName) {}
+SocketPoll(threadName)
+{
+startThread();
+}
 
 bool continuePolling() override
 {
@@ -220,9 +223,6 @@ public:
 
 ~DocumentBroker();
 
-/// Start processing events
-void startThread();
-
 /// Loads a document from the public URI into the jail.
 bool load(std::shared_ptr& session, const std::string& 
jailId);
 bool isLoaded() const { return _isLoaded; }
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index a459bf4..98250b4 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2167,7 +2167,6 @@ private:
 
 void handleClientWsUpgrade(const Poco::Net::HTTPRequest& request, const 
std::string& url)
 {
-// requestHandler = new ClientRequestHandler();
 LOG_INF("Client WS request" << request.getURI() << ", url: " << url);
 
 // First Upgrade.
@@ -2221,9 +2220,9 @@ private:
 _clientSession->onConnect(socket);
 docBroker->addSocketToPoll(socket);
 }
-docBroker->startThread();
 }
 }
+
 if (!docBroker || !_clientSession)
 LOG_WRN("Failed to connect DocBroker and Client Session.");
 }
@@ -2349,14 +2348,11 @@ public:
 void startPrisoners(const int port)
 {
 PrisonerPoll.insertNewSocket(findPrisonerServerPort(port));
-PrisonerPoll.startThread();
 }
 
 void start(const int port)
 {
 _acceptPoll.insertNewSocket(findServerPort(port));
-_acceptPoll.startThread();
-WebServerPoll.startThread();
 }
 
 void stop()
___
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/DocumentBroker.hpp wsd/LOOLWSD.cpp

2017-03-12 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |   34 ++
 wsd/DocumentBroker.hpp |   10 +-
 wsd/LOOLWSD.cpp|4 ++--
 3 files changed, 13 insertions(+), 35 deletions(-)

New commits:
commit cbd00bf7c8600afb0f7ec09a8ad90f1b5ed2f298
Author: Ashod Nakashian 
Date:   Sun Mar 12 13:56:42 2017 -0400

wsd: simplify DocumentBroker construction

DocumentBrokerPoll is always owned by a
single DocumentBroker instance, so we
can hold a reference to it. This eliminates
the need to hold a shared_ptr to the owner
which, in turn, eliminates the need for
a create wrapper.

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index c4c3307..1b47d68 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -114,23 +114,22 @@ std::string DocumentBroker::getDocKey(const Poco::URI& 
uri)
 }
 
 /// The Document Broker Poll - one of these in a thread per document
-class DocumentBroker::DocumentBrokerPoll : public TerminatingPoll
+class DocumentBroker::DocumentBrokerPoll final : public TerminatingPoll
 {
-std::shared_ptr _docBroker;
+/// The DocumentBroker owning us.
+DocumentBroker& _docBroker;
+
 public:
-DocumentBrokerPoll(const std::string )
-: TerminatingPoll(threadName)
-{
-}
-void setDocumentBroker(const std::shared_ptr )
+DocumentBrokerPoll(const std::string , DocumentBroker& 
docBroker) :
+TerminatingPoll(threadName),
+_docBroker(docBroker)
 {
-_docBroker = docBroker;
 }
 
 virtual void pollingThread()
 {
-assert (_docBroker);
-_docBroker->pollThread();
+// Delegate to the docBroker.
+_docBroker.pollThread();
 }
 };
 
@@ -152,7 +151,7 @@ DocumentBroker::DocumentBroker(const std::string& uri,
 _cursorPosY(0),
 _cursorWidth(0),
 _cursorHeight(0),
-_poll(new DocumentBrokerPoll("docbrk_poll")),
+_poll(new DocumentBrokerPoll("docbrk_poll", *this)),
 _tileVersion(0),
 _debugRenderedTileCount(0)
 {
@@ -164,19 +163,6 @@ DocumentBroker::DocumentBroker(const std::string& uri,
 _stop = false;
 }
 
-std::shared_ptr DocumentBroker::create(
-const std::string& uri,
-const Poco::URI& uriPublic,
-const std::string& docKey,
-const std::string& childRoot)
-{
-std::shared_ptr docBroker = 
std::make_shared(uri, uriPublic, docKey, childRoot);
-
-docBroker->_poll->setDocumentBroker(docBroker);
-
-return docBroker;
-}
-
 void DocumentBroker::startThread()
 {
 _poll->startThread();
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 0ca4ab7..2d30802 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -212,19 +212,11 @@ public:
 /// Dummy document broker that is marked to destroy.
 DocumentBroker();
 
-/// Use create - not this constructor ...
-/// FIXME: friend with make_shared etc.
+/// Construct DocumentBroker with URI, docKey, and root path.
 DocumentBroker(const std::string& uri,
const Poco::URI& uriPublic,
const std::string& docKey,
const std::string& childRoot);
-public:
-static std::shared_ptr create(
-   const std::string& uri,
-   const Poco::URI& uriPublic,
-   const std::string& docKey,
-   const std::string& childRoot);
-
 
 ~DocumentBroker();
 
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index eb06f5f..a459bf4 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1296,7 +1296,7 @@ static std::shared_ptr 
createDocBroker(WebSocketHandler& ws,
 
 // Set the one we just created.
 LOG_DBG("New DocumentBroker for docKey [" << docKey << "].");
-auto docBroker = DocumentBroker::create(uri, uriPublic, docKey, 
LOOLWSD::ChildRoot);
+auto docBroker = std::make_shared(uri, uriPublic, docKey, 
LOOLWSD::ChildRoot);
 DocBrokers.emplace(docKey, docBroker);
 LOG_TRC("Have " << DocBrokers.size() << " DocBrokers after inserting [" << 
docKey << "].");
 
@@ -1958,7 +1958,7 @@ private:
 std::unique_lock 
docBrokersLock(DocBrokersMutex);
 
 LOG_DBG("New DocumentBroker for docKey [" << docKey << 
"].");
-auto docBroker = DocumentBroker::create(fromPath, 
uriPublic, docKey, LOOLWSD::ChildRoot);
+auto docBroker = 
std::make_shared(fromPath, uriPublic, docKey, 
LOOLWSD::ChildRoot);
 
 cleanupDocBrokers();
 
___
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/DocumentBroker.hpp

2017-03-11 Thread Michael Meeks
 wsd/DocumentBroker.cpp |   15 ++-
 wsd/DocumentBroker.hpp |4 +++-
 2 files changed, 17 insertions(+), 2 deletions(-)

New commits:
commit 51ae42d513842994091d10b15565ba4741092122
Author: Michael Meeks 
Date:   Sat Mar 11 22:01:27 2017 +

DocumentBroker: log load time and dump it on request.

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 6ddb463..c4c3307 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -190,6 +190,8 @@ void DocumentBroker::pollThread()
 
 LOG_INF("Starting docBroker polling thread for docKey [" << _docKey << 
"].");
 
+_threadStart = std::chrono::steady_clock::now();
+
 // Request a kit process for this doc.
 _childProcess = getNewChild_Blocks();
 if (!_childProcess)
@@ -603,6 +605,14 @@ bool DocumentBroker::saveToStorageInternal(const 
std::string& sessionId,
 return false;
 }
 
+void DocumentBroker::setLoaded()
+{
+_isLoaded = true;
+_loadDuration = std::chrono::duration_cast(
+std::chrono::steady_clock::now() - _threadStart);
+LOG_TRC("Document loaded in " << _loadDuration.count() << "ms");
+}
+
 bool DocumentBroker::autoSave(const bool force)
 {
 if (_sessions.empty() || _storage == nullptr || !_isLoaded ||
@@ -1311,7 +1321,10 @@ void DocumentBroker::dumpState()
 std::cerr << " *** Marked to destroy ***\n";
 else
 std::cerr << " has live sessions\n";
-std::cerr << "  loaded?: " << _isLoaded << "\n";
+if (_isLoaded)
+std::cerr << "  loaded in: " << _loadDuration.count() << "ms\n";
+else
+std::cerr << "  still loading...\n";
 std::cerr << "  modified?: " << _isModified << "\n";
 std::cerr << "  jail id: " << _jailId << "\n";
 std::cerr << "  public uri: " << _uriPublic.toString() << "\n";
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index b07b9b5..0ca4ab7 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -234,7 +234,7 @@ public:
 /// Loads a document from the public URI into the jail.
 bool load(std::shared_ptr& session, const std::string& 
jailId);
 bool isLoaded() const { return _isLoaded; }
-void setLoaded() { _isLoaded = true; }
+void setLoaded();
 
 /// Save the document to Storage if it needs persisting.
 bool saveToStorage(const std::string& sesionId, bool success, const 
std::string& result = "");
@@ -417,6 +417,8 @@ private:
 int _debugRenderedTileCount;
 
 std::chrono::steady_clock::time_point _lastActivityTime;
+std::chrono::steady_clock::time_point _threadStart;
+std::chrono::milliseconds _loadDuration;
 
 static constexpr auto IdleSaveDurationMs = 30 * 1000;
 static constexpr auto AutoSaveDurationMs = 300 * 1000;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-03-10 Thread Michael Meeks
 wsd/DocumentBroker.cpp |1 -
 1 file changed, 1 deletion(-)

New commits:
commit 93d46fc469c5356e4bc1651c87072fe413c6e98a
Author: Michael Meeks 
Date:   Fri Mar 10 23:52:28 2017 +

Don't treat a session as non-editable when it is not (yet) loaded.

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 2f53f7b..6ddb463 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1129,7 +1129,6 @@ void DocumentBroker::destroyIfLastEditor(const 
std::string& id)
 for (const auto& it : _sessions)
 {
 if (it.second->getId() != id &&
-it.second->isLoaded() &&
 !it.second->isReadOnly())
 {
 // Found another editable.
___
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/FileServer.cpp wsd/LOOLWSD.cpp

2017-03-10 Thread Michael Meeks
 wsd/DocumentBroker.cpp |   11 ++-
 wsd/FileServer.cpp |2 --
 wsd/LOOLWSD.cpp|2 +-
 3 files changed, 11 insertions(+), 4 deletions(-)

New commits:
commit 3b370022c02944fb26cf5f445d49f0d13a65e4e8
Author: Michael Meeks 
Date:   Fri Mar 10 15:37:09 2017 +

Improve state dumping.

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index d2b563d..de6bac6 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1305,12 +1305,21 @@ void DocumentBroker::dumpState()
 {
 std::unique_lock lock(_mutex);
 
-std::cerr << " Broker: " << _filename << "\n";
+std::cerr << " Broker: " << _filename;
+if (_markToDestroy)
+std::cerr << " *** Marked to destroy ***\n";
+else
+std::cerr << " has live sessions\n";
+std::cerr << "  loaded?: " << _isLoaded << "\n";
+std::cerr << "  modified?: " << _isModified << "\n";
 std::cerr << "  jail id: " << _jailId << "\n";
 std::cerr << "  public uri: " << _uriPublic.toString() << "\n";
 std::cerr << "  jailed uri: " << _uriJailed.toString() << "\n";
 std::cerr << "  doc key: " << _docKey << "\n";
 std::cerr << "  num sessions: " << getSessionsCount() << "\n";
+std::cerr << "  last editable?: " << _lastEditableSession << "\n";
+std::cerr << "  cursor " << _cursorPosX << ", " << _cursorPosY
+  << "( " << _cursorWidth << "," << _cursorHeight << ")\n";
 
 _poll->dumpState();
 }
diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp
index f1d35cf..65b43d4 100644
--- a/wsd/FileServer.cpp
+++ b/wsd/FileServer.cpp
@@ -34,8 +34,6 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 
 #include "Auth.hpp"
 #include "Common.hpp"
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 589d0b6..8d0a3a4e 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2259,7 +2259,7 @@ private:
 _clientSession = createNewClientSession(ws, _id, uriPublic, 
docBroker, isReadOnly);
 if (_clientSession)
 {
-// Transfer the socket to the DocumentBroker.
+// Transfer the client socket to the DocumentBroker.
 auto socket = _socket.lock();
 if (socket)
 {
___
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

2017-02-10 Thread Miklos Vajna
 wsd/DocumentBroker.cpp |1 -
 wsd/LOOLWSD.cpp|2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)

New commits:
commit f81ab32c57c71b123d137c0bd71dfc46a8f9ce48
Author: Miklos Vajna 
Date:   Fri Feb 10 09:07:30 2017 +0100

wsd: remove remaining unused using declarations

Change-Id: I7d0d453194bdd069654f29105e3f17769036cd39

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 32c4c17..0225f46 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -37,7 +37,6 @@
 using namespace LOOLProtocol;
 
 using Poco::JSON::Object;
-using Poco::StringTokenizer;
 
 void ChildProcess::socketProcessor()
 {
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 05cd665..97a6088 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -156,7 +156,9 @@ using Poco::ProcessHandle;
 using Poco::StreamCopier;
 using Poco::StringTokenizer;
 using Poco::TemporaryFile;
+#if FUZZER
 using Poco::Thread;
+#endif
 using Poco::ThreadPool;
 using Poco::URI;
 using Poco::Util::Application;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-02-09 Thread Ashod Nakashian
 wsd/DocumentBroker.cpp |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 15862a5b5f59140a572450428209c2b2ec8083fa
Author: Ashod Nakashian 
Date:   Fri Feb 10 01:09:01 2017 -0500

wsd: we need to dump NewSession event on every connection

...and not just when loading a new document.

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

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index fe3ea89..32c4c17 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -366,10 +366,10 @@ bool DocumentBroker::load(std::shared_ptr& 
session, const std::st
 // Use the local temp file's timestamp.
 _lastFileModifiedTime = 
Poco::File(_storage->getLocalRootPath()).getLastModified();
 _tileCache.reset(new TileCache(uriPublic.toString(), 
_lastFileModifiedTime, _cacheRoot));
-
-LOOLWSD::dumpNewSessionTrace(getJailId(), sessionId, _uriOrig, 
_storage->getRootFilePath());
 }
 
+LOOLWSD::dumpNewSessionTrace(getJailId(), sessionId, _uriOrig, 
_storage->getRootFilePath());
+
 // Since document has been loaded, send the stats if its WOPI
 if (wopiStorage != nullptr)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


  1   2   >