[Libreoffice-commits] online.git: kit/Kit.cpp net/Socket.hpp net/WebSocketHandler.hpp

2020-09-15 Thread Miklos Vajna (via logerrit)
 kit/Kit.cpp  |2 +-
 net/Socket.hpp   |4 ++--
 net/WebSocketHandler.hpp |2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 3d082ad4513421e31f126f35889cde2b5663d8bc
Author: Miklos Vajna 
AuthorDate: Tue Sep 15 09:08:21 2020 +0200
Commit: Miklos Vajna 
CommitDate: Tue Sep 15 09:34:18 2020 +0200

Mark processInputEnabled() as const

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 87335ecaa..c955a3339 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1391,7 +1391,7 @@ private:
 
 public:
 void enableProcessInput(bool enable = true){ _inputProcessingEnabled = 
enable; }
-bool processInputEnabled() { return _inputProcessingEnabled; }
+bool processInputEnabled() const { return _inputProcessingEnabled; }
 
 bool hasQueueItems() const
 {
diff --git a/net/Socket.hpp b/net/Socket.hpp
index 7ec78f00a..4c2ba13eb 100644
--- a/net/Socket.hpp
+++ b/net/Socket.hpp
@@ -371,7 +371,7 @@ public:
 
 /// Enable/disable processing of incoming data at socket level.
 virtual void enableProcessInput(bool /*enable*/){};
-virtual bool processInputEnabled(){ return true; };
+virtual bool processInputEnabled() const { return true; };
 
 /// Called after successful socket reads.
 virtual void handleIncomingMessage(SocketDisposition ) = 0;
@@ -1063,7 +1063,7 @@ public:
 return _incomingFD;
 }
 
-bool processInputEnabled(){ return _inputProcessingEnabled; }
+bool processInputEnabled() const { return _inputProcessingEnabled; }
 void enableProcessInput(bool enable = true){ _inputProcessingEnabled = 
enable; }
 
 protected:
diff --git a/net/WebSocketHandler.hpp b/net/WebSocketHandler.hpp
index 9cab57118..7fb38c86d 100644
--- a/net/WebSocketHandler.hpp
+++ b/net/WebSocketHandler.hpp
@@ -826,7 +826,7 @@ protected:
 socket->enableProcessInput(enable);
 }
 
-virtual bool processInputEnabled() override
+virtual bool processInputEnabled() const override
 {
 std::shared_ptr 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: kit/Kit.cpp

2020-08-13 Thread Tor Lillqvist (via logerrit)
 kit/Kit.cpp |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 5df5329f837f242b9c9d4e2bede24931061325b4
Author: Tor Lillqvist 
AuthorDate: Thu Aug 13 18:14:06 2020 +0300
Commit: Tor Lillqvist 
CommitDate: Thu Aug 13 22:07:28 2020 +0200

Guard against view count being zero

Happened for me once in the iOS app, not sure if it was just a random
fluke while debugging, or whether it can happen in normal use. Anyway,
take it into consideration.

If the view count is zero, don't overwrite the '['.

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 42af4b531..8819947fd 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1033,7 +1033,8 @@ private:
 oss << "\"color\":" << color << "},";
 }
 
-oss.seekp(-1, std::ios_base::cur); // Remove last comma.
+if (viewCount > 0)
+oss.seekp(-1, std::ios_base::cur); // Remove last comma.
 oss << ']';
 
 // Broadcast updated viewinfo to all clients.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp loolwsd.xml.in wsd/LOOLWSD.cpp wsd/Storage.cpp wsd/Storage.hpp

2020-08-11 Thread Ashod Nakashian (via logerrit)
 kit/Kit.cpp |1 -
 loolwsd.xml.in  |1 +
 wsd/LOOLWSD.cpp |1 +
 wsd/Storage.cpp |8 +++-
 wsd/Storage.hpp |   10 +-
 5 files changed, 18 insertions(+), 3 deletions(-)

New commits:
commit c5f9d605e433701680a533fa20a3390f1e7ff5eb
Author: Ashod Nakashian 
AuthorDate: Thu Jul 16 10:44:41 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Tue Aug 11 20:11:14 2020 +0200

wsd: make outgoing connection timeout configurable

The default Poco connection timeout is 60 seconds,
which is probably excessive. The current configurable
default is a more reasonable 30 seconds.

Currently we set this timeout on Storage connections
going out (i.e. WOPI connections).

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 2ad1c545a..42af4b531 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -43,7 +43,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/loolwsd.xml.in b/loolwsd.xml.in
index ceb78992e..f1235d618 100644
--- a/loolwsd.xml.in
+++ b/loolwsd.xml.in
@@ -99,6 +99,7 @@
 :::172\.17\.[0-9]{1,3}\.[0-9]{1,3}
   
   
+  
 
 
 
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 3756db0fb..806c22a0d 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -928,6 +928,7 @@ void LOOLWSD::initialize(Application& self)
 { "loleaflet_html", "loleaflet.html" },
 { "loleaflet_logging", "false" },
 { "mount_jail_tree", "true" },
+{ "net.connection_timeout_secs", "30" },
 { "net.listen", "any" },
 { "net.proto", "all" },
 { "net.service_root", "" },
diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 08a974d0d..9e3854d99 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -422,10 +422,16 @@ Poco::Net::HTTPClientSession* 
StorageBase::getHTTPClientSession(const Poco::URI&
 // We decoupled the Wopi communication from client communication because
 // the Wopi communication must have an independent policy.
 // So, we will use here only Storage settings.
-return useSSL
+Poco::Net::HTTPClientSession* session = useSSL
 ? new Poco::Net::HTTPSClientSession(uri.getHost(), uri.getPort(),
 
Poco::Net::SSLManager::instance().defaultClientContext())
 : new Poco::Net::HTTPClientSession(uri.getHost(), uri.getPort());
+
+// Set the timeout to the configured value.
+static int timeoutSec = 
LOOLWSD::getConfigValue("net.connection_timeout_secs", 30);
+session->setTimeout(Poco::Timespan(timeoutSec, 0));
+
+return session;
 }
 
 namespace
diff --git a/wsd/Storage.hpp b/wsd/Storage.hpp
index df1b59e5e..652b9bb17 100644
--- a/wsd/Storage.hpp
+++ b/wsd/Storage.hpp
@@ -17,7 +17,6 @@
 
 #include 
 #include 
-#include 
 #include 
 
 #include "Auth.hpp"
@@ -26,6 +25,15 @@
 #include "Util.hpp"
 #include 
 
+namespace Poco
+{
+namespace Net
+{
+class HTTPClientSession;
+}
+
+} // namespace Poco
+
 /// Represents whether the underlying file is locked
 /// and with what token.
 struct LockContext
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp net/WebSocketHandler.hpp

2020-07-25 Thread Gabriel Masei (via logerrit)
 kit/Kit.cpp  |   12 ++--
 net/WebSocketHandler.hpp |2 +-
 2 files changed, 11 insertions(+), 3 deletions(-)

New commits:
commit d458f35c1f17f74dfa17558b74b74ab5d9c3edeb
Author: Gabriel Masei 
AuthorDate: Fri Jul 24 19:50:43 2020 +0300
Commit: Gabriel Masei 
CommitDate: Sat Jul 25 21:22:50 2020 +0200

kit: disable parallel processing at higher levels

Sometimes multiple messages are processed in a single iteration
at socket level. This happens in WebSocketHandler and when draining
Document queue.Just covered these cases.

Change-Id: Ifa46f5d484b67015cca64008b2c89426cc839e64
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/99387
Tested-by: Jenkins
Tested-by: Gabriel Masei 
Reviewed-by: Michael Meeks 
Reviewed-by: Gabriel Masei 

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 3ca92b01b..2ad1c545a 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -455,7 +455,8 @@ public:
 _isLoading(0),
 _editorId(-1),
 _editorChangeWarning(false),
-_mobileAppDocId(mobileAppDocId)
+_mobileAppDocId(mobileAppDocId),
+_inputProcessingEnabled(true)
 {
 LOG_INF("Document ctor for [" << _docKey <<
 "] url [" << anonymizeUrl(_url) << "] on child [" << _jailId <<
@@ -1388,6 +1389,9 @@ private:
 }
 
 public:
+void enableProcessInput(bool enable = true){ _inputProcessingEnabled = 
enable; }
+bool processInputEnabled() { return _inputProcessingEnabled; }
+
 bool hasQueueItems() const
 {
 return _tileQueue && !_tileQueue->isEmpty();
@@ -1397,7 +1401,7 @@ public:
 {
 try
 {
-while (hasQueueItems())
+while (processInputEnabled() && hasQueueItems())
 {
 if (_stop || SigUtil::getTerminationFlag())
 {
@@ -1640,6 +1644,7 @@ private:
 #endif
 
 const unsigned _mobileAppDocId;
+bool _inputProcessingEnabled;
 };
 
 #ifdef __ANDROID__
@@ -1942,6 +1947,9 @@ protected:
 virtual void enableProcessInput(bool enable = true) override
 {
 WebSocketHandler::enableProcessInput(enable);
+if (_document)
+_document->enableProcessInput(enable);
+
 // Wake up poll to process data from socket input buffer
 if (enable && _ksPoll)
 {
diff --git a/net/WebSocketHandler.hpp b/net/WebSocketHandler.hpp
index 615400798..9cab57118 100644
--- a/net/WebSocketHandler.hpp
+++ b/net/WebSocketHandler.hpp
@@ -422,7 +422,7 @@ public:
 #endif
 else
 {
-while (handleTCPStream(socket))
+while (socket->processInputEnabled() && handleTCPStream(socket))
 ; // might have multiple messages in the accumulated buffer.
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2020-07-21 Thread Miklos Vajna (via logerrit)
 kit/Kit.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 57959d6e865ccbe09fead3d96da866df52b3220e
Author: Miklos Vajna 
AuthorDate: Tue Jul 21 08:56:18 2020 +0200
Commit: Miklos Vajna 
CommitDate: Tue Jul 21 09:17:24 2020 +0200

Document::dumpState: fix isLoading typo

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 7c8f426d0..1853bed45 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1556,7 +1556,7 @@ public:
 {
 oss << "Kit Document:\n"
 << "\n\tstop: " << _stop
-<< "\n\tisLoading: " << _stop
+<< "\n\tisLoading: " << _isLoading
 << "\n\tjailId: " << _jailId
 << "\n\tdocKey: " << _docKey
 << "\n\tdocId: " << _docId
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2020-07-17 Thread Michael Meeks (via logerrit)
 kit/Kit.cpp |   12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

New commits:
commit 0084c3b275bbbad7f3ee2d36f86afc10fbc5400c
Author: Michael Meeks 
AuthorDate: Thu Jul 16 19:10:05 2020 +0100
Commit: Michael Meeks 
CommitDate: Fri Jul 17 12:29:54 2020 +0200

Process any pending tileQueue items first.

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 123a87e66..37016d420 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1386,11 +1386,16 @@ private:
 }
 
 public:
+bool hasQueueItems() const
+{
+return _tileQueue && !_tileQueue->isEmpty();
+}
+
 void drainQueue(const std::chrono::steady_clock::time_point &/*now*/)
 {
 try
 {
-while (!_tileQueue->isEmpty())
+while (hasQueueItems())
 {
 if (_stop || SigUtil::getTerminationFlag())
 {
@@ -1679,7 +1684,10 @@ public:
 _pollEnd = std::chrono::steady_clock::now() + 
std::chrono::microseconds(timeoutMicroS);
 do
 {
-if (poll(timeoutMicroS) <= 0)
+int realTimeout = timeoutMicroS;
+if (_document && _document->hasQueueItems())
+realTimeout = 0;
+if (poll(realTimeout) <= 0)
 break;
 
 const auto now = 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: kit/Kit.cpp net/Socket.hpp

2020-07-14 Thread Tor Lillqvist (via logerrit)
 kit/Kit.cpp|   49 +
 net/Socket.hpp |1 +
 2 files changed, 22 insertions(+), 28 deletions(-)

New commits:
commit 07bf5984305955725c1cfe0d5cada0b46d42dbc6
Author: Tor Lillqvist 
AuthorDate: Tue Jul 14 17:06:11 2020 +0300
Commit: Tor Lillqvist 
CommitDate: Tue Jul 14 16:56:20 2020 +0200

Make objects and threads go away more reliably in the iOS app

We probably used to have circular references that made KitSocketPoll
and KitWebSocketHandler objects hang around forever, or something.
(Not a problem in web-based Online where kit processes have a
restricted lifetime.)

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index f10493e50..284e552f3 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1623,19 +1623,7 @@ class KitSocketPoll final : public SocketPoll
 public:
 ~KitSocketPoll()
 {
-#ifdef IOS
-std::unique_lock lock(KSPollsMutex);
-std::shared_ptr p;
-auto i = KSPolls.begin();
-for (; i != KSPolls.end(); ++i)
-{
-p = i->lock();
-if (p && p.get() == this)
-break;
-}
-assert(i != KSPolls.end());
-KSPolls.erase(i);
-#endif
+// Just to make it easier to set a breakpoint
 }
 
 static std::shared_ptr create()
@@ -1645,7 +1633,6 @@ public:
 #ifdef IOS
 std::unique_lock lock(KSPollsMutex);
 KSPolls.push_back(result);
-// KSPollsCV.notify_one();
 #endif
 return result;
 }
@@ -1762,6 +1749,11 @@ public:
 {
 }
 
+~KitWebSocketHandler()
+{
+// Just to make it easier to set a breakpoint
+}
+
 protected:
 void handleMessage(const std::vector& data) override
 {
@@ -1881,10 +1873,13 @@ protected:
 SigUtil::setTerminationFlag();
 #endif
 #ifdef IOS
-std::unique_lock lock(_ksPoll->terminationMutex);
-_ksPoll->terminationFlag = true;
-_ksPoll->terminationCV.notify_all();
+{
+std::unique_lock lock(_ksPoll->terminationMutex);
+_ksPoll->terminationFlag = true;
+_ksPoll->terminationCV.notify_all();
+}
 #endif
+_ksPoll.reset();
 }
 };
 
@@ -1903,22 +1898,20 @@ int pollCallback(void* pData, int timeoutUs)
 return reinterpret_cast(pData)->kitPoll(timeoutUs);
 #else
 std::unique_lock lock(KitSocketPoll::KSPollsMutex);
-if (KitSocketPoll::KSPolls.size() == 0)
+std::vector> v;
+for (const auto  : KitSocketPoll::KSPolls)
+{
+auto p = i.lock();
+if (p)
+v.push_back(p);
+}
+lock.unlock();
+if (v.size() == 0)
 {
-// KitSocketPoll::KSPollsCV.wait(lock);
-lock.unlock();
 std::this_thread::sleep_for(std::chrono::microseconds(timeoutUs));
 }
 else
 {
-std::vector> v;
-for (const auto  : KitSocketPoll::KSPolls)
-{
-auto p = i.lock();
-if (p)
-v.push_back(p);
-}
-lock.unlock();
 for (const auto  : v)
 p->kitPoll(timeoutUs);
 }
diff --git a/net/Socket.hpp b/net/Socket.hpp
index 9ee336950..84b4bfafd 100644
--- a/net/Socket.hpp
+++ b/net/Socket.hpp
@@ -799,6 +799,7 @@ public:
 {
 assertCorrectThread();
 _socketHandler->onDisconnect();
+_socketHandler.reset();
 }
 
 if (!_shutdownSignalled)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2020-07-03 Thread Tor Lillqvist (via logerrit)
 kit/Kit.cpp |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 4ac9bd5c1b6b9485ae471c1ecf099628011352c8
Author: Tor Lillqvist 
AuthorDate: Fri Jul 3 16:27:53 2020 +0300
Commit: Tor Lillqvist 
CommitDate: Fri Jul 3 16:02:42 2020 +0200

Fix a couple uses of misleading function names in logging

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 16b2febb6..5eefa30f9 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1032,7 +1032,7 @@ public:
 auto duration = std::chrono::system_clock::now() - start;
 auto elapsed = 
std::chrono::duration_cast(duration).count();
 double totalTime = elapsed/1000.;
-LOG_DBG("paintTile (combined) at (" << renderArea.getLeft() << ", " << 
renderArea.getTop() << "), (" <<
+LOG_DBG("paintPartTile at (" << renderArea.getLeft() << ", " << 
renderArea.getTop() << "), (" <<
 renderArea.getWidth() << ", " << renderArea.getHeight() << ") 
" <<
 " rendered in " << totalTime << " ms (" << area / elapsed << " 
MP/s).");
 const auto mode = 
static_cast(_loKitDocument->getTileMode());
@@ -1175,9 +1175,9 @@ public:
 duration = std::chrono::system_clock::now() - start;
 elapsed = 
std::chrono::duration_cast(duration).count();
 totalTime = elapsed/1000.;
-LOG_DBG("renderCombinedTiles at (" << renderArea.getLeft() << ", " << 
renderArea.getTop() << "), (" <<
+LOG_DBG("renderTiles at (" << renderArea.getLeft() << ", " << 
renderArea.getTop() << "), (" <<
 renderArea.getWidth() << ", " << renderArea.getHeight() << ") 
" <<
-" took " << totalTime << " ms (including the paintTile).");
+" took " << totalTime << " ms (including the paintPartTile).");
 
 if (tileIndex == 0)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2020-06-29 Thread Miklos Vajna (via logerrit)
 kit/Kit.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 2604913fb64caad2721027fe08dd6bf3012f780f
Author: Miklos Vajna 
AuthorDate: Mon Jun 29 09:03:22 2020 +0200
Commit: Miklos Vajna 
CommitDate: Mon Jun 29 09:18:16 2020 +0200

kit: mark KitSocketPoll as final

KitSocketPoll has virtual functions, but a non-virtual destructor. Mark
it as final to make it clear that it's safe to call delete on it.

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 269120e60..7a5fc1f7a 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -2158,7 +2158,7 @@ std::shared_ptr 
getLOKDocumentForAndroidOnly()
 
 #endif
 
-class KitSocketPoll : public SocketPoll
+class KitSocketPoll final : public SocketPoll
 {
 std::chrono::steady_clock::time_point _pollEnd;
 std::shared_ptr _document;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp Makefile.am wsd/QueueHandler.hpp

2020-06-02 Thread Ashod Nakashian (via logerrit)
 Makefile.am  |1 
 kit/Kit.cpp  |5 +--
 wsd/QueueHandler.hpp |   70 ---
 3 files changed, 2 insertions(+), 74 deletions(-)

New commits:
commit 68bdbcf79858f762b4a56f74d45a6455dfcaa0db
Author: Ashod Nakashian 
AuthorDate: Tue Jun 2 00:36:32 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Tue Jun 2 17:26:08 2020 +0200

wsd: remove unused QueueHandler

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

diff --git a/Makefile.am b/Makefile.am
index d3c79a36b..ca868c8e7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -224,7 +224,6 @@ wsd_headers = wsd/Admin.hpp \
   wsd/FileServer.hpp \
   wsd/LOOLWSD.hpp \
   wsd/ProofKey.hpp \
-  wsd/QueueHandler.hpp \
   wsd/RequestDetails.hpp \
   wsd/SenderQueue.hpp \
   wsd/ServerURL.hpp \
diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index da722b369..367ca60c0 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -48,7 +48,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include "ChildSession.hpp"
@@ -2039,7 +2038,7 @@ public:
 }
 catch (const std::exception& exc)
 {
-LOG_FTL("QueueHandler::run: Exception: " << exc.what());
+LOG_FTL("drainQueue: Exception: " << exc.what());
 #if !MOBILEAPP
 Log::shutdown();
 std::_Exit(EX_SOFTWARE);
@@ -2047,7 +2046,7 @@ public:
 }
 catch (...)
 {
-LOG_FTL("QueueHandler::run: Unknown exception");
+LOG_FTL("drainQueue: Unknown exception");
 #if !MOBILEAPP
 Log::shutdown();
 std::_Exit(EX_SOFTWARE);
diff --git a/wsd/QueueHandler.hpp b/wsd/QueueHandler.hpp
deleted file mode 100644
index 434742ea8..0
--- a/wsd/QueueHandler.hpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; 
fill-column: 100 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#pragma once
-
-#include 
-
-#include "Protocol.hpp"
-#include "Session.hpp"
-#include "MessageQueue.hpp"
-#include "Util.hpp"
-
-/// This thread handles incoming messages on a given kit instance.
-class QueueHandler : public Poco::Runnable
-{
-public:
-QueueHandler(std::shared_ptr queue,
- const std::shared_ptr& session,
- const std::string& name):
-_queue(std::move(queue)),
-_session(session),
-_name(name)
-{
-}
-
-void run() override
-{
-Util::setThreadName(_name);
-
-LOG_DBG("Thread started.");
-
-try
-{
-while (true)
-{
-const auto input = _queue->get();
-if (LOOLProtocol::getFirstToken(input) == "eof")
-{
-LOG_INF("Received EOF. Finishing.");
-break;
-}
-
-if (!_session->handleInput(input.data(), input.size()))
-{
-LOG_INF("Socket handler flagged for finishing.");
-break;
-}
-}
-}
-catch (const std::exception& exc)
-{
-LOG_ERR("QueueHandler::run: Exception: " << exc.what());
-}
-
-LOG_DBG("Thread finished.");
-}
-
-private:
-std::shared_ptr _queue;
-std::shared_ptr _session;
-const std::string _name;
-};
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp net/Socket.cpp net/Socket.hpp wsd/Admin.cpp wsd/Admin.hpp wsd/AdminModel.cpp wsd/AdminModel.hpp wsd/DocumentBroker.cpp wsd/LOOLWSD.cpp

2020-04-28 Thread Gabriel Masei (via logerrit)
 kit/Kit.cpp|   22 ++
 net/Socket.cpp |   15 +++
 net/Socket.hpp |6 --
 wsd/Admin.cpp  |   10 +++---
 wsd/Admin.hpp  |5 +++--
 wsd/AdminModel.cpp |   11 +++
 wsd/AdminModel.hpp |5 +++--
 wsd/DocumentBroker.cpp |   15 ++-
 wsd/LOOLWSD.cpp|3 ++-
 9 files changed, 33 insertions(+), 59 deletions(-)

New commits:
commit d006204478cb4a10e35574f4c12a37318f7b39eb
Author: Gabriel Masei 
AuthorDate: Tue Apr 28 16:55:47 2020 +0300
Commit: Michael Meeks 
CommitDate: Tue Apr 28 17:20:07 2020 +0200

wsd: admin: send smaps fd along websocket upgrade request

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index ae775fee3..b5409ca68 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -649,9 +649,6 @@ public:
 }
 };
 
-#if !MOBILEAPP
-static int ProcSMapsFile = -1;
-#endif
 
 class ThreadPool {
 std::mutex _mutex;
@@ -795,22 +792,6 @@ public:
 "] and id [" << _docId << "].");
 assert(_loKit);
 
-#if !MOBILEAPP
-if (ProcSMapsFile >= 0)
-{
-static const std::string str = "smapsfd:";
-if (websocketHandler->sendTextMessageWithFD(str.c_str(), 
str.size(), ProcSMapsFile) > 0)
-{
-LOG_DBG("Successfully sent smaps fd to wsd");
-close(ProcSMapsFile);
-ProcSMapsFile = -1;
-}
-else
-{
-LOG_ERR("Failed to send smaps fd to wsd");
-}
-}
-#endif
 }
 
 virtual ~Document()
@@ -2505,6 +2486,7 @@ void lokit_main(
 
 std::string userdir_url;
 std::string instdir_path;
+int ProcSMapsFile = -1;
 
 // lokit's destroy typically throws from
 // framework/source/services/modulemanager.cxx:198
@@ -2749,7 +2731,7 @@ void lokit_main(
 std::make_shared("child_ws", loKit, jailId, 
mainKit);
 
 #if !MOBILEAPP
-mainKit.insertNewUnixSocket(MasterLocation, pathAndQuery, 
websocketHandler);
+mainKit.insertNewUnixSocket(MasterLocation, pathAndQuery, 
websocketHandler, ProcSMapsFile);
 #else
 mainKit.insertNewFakeSocket(docBrokerSocket, websocketHandler);
 #endif
diff --git a/net/Socket.cpp b/net/Socket.cpp
index 0b7a2f2ff..5e96ab2ac 100644
--- a/net/Socket.cpp
+++ b/net/Socket.cpp
@@ -407,7 +407,7 @@ void SocketPoll::insertNewWebSocketSync(
 // should this be a static method in the WebsocketHandler(?)
 void SocketPoll::clientRequestWebsocketUpgrade(const 
std::shared_ptr& socket,
const 
std::shared_ptr& websocketHandler,
-   const std::string )
+   const std::string 
, const int shareFD)
 {
 // cf. WebSocketHandler::upgradeToWebSocket (?)
 // send Sec-WebSocket-Key:  ... Sec-WebSocket-Protocol: chat, 
Sec-WebSocket-Version: 13
@@ -426,14 +426,21 @@ void SocketPoll::clientRequestWebsocketUpgrade(const 
std::shared_ptrsend(oss.str());
+if (shareFD == -1)
+socket->send(oss.str());
+else
+{
+std::string request = oss.str();
+socket->sendFD(request.c_str(), request.size(), shareFD);
+}
 websocketHandler->onConnect(socket);
 }
 
 void SocketPoll::insertNewUnixSocket(
 const std::string ,
 const std::string ,
-const std::shared_ptr& websocketHandler)
+const std::shared_ptr& websocketHandler,
+const int shareFD)
 {
 int fd = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0);
 
@@ -456,7 +463,7 @@ void SocketPoll::insertNewUnixSocket(
 if (socket)
 {
 LOG_DBG("Connected to local UDS " << location << " #" << 
socket->getFD());
-clientRequestWebsocketUpgrade(socket, websocketHandler, 
pathAndQuery);
+clientRequestWebsocketUpgrade(socket, websocketHandler, 
pathAndQuery, shareFD);
 insertNewSocket(socket);
 }
 }
diff --git a/net/Socket.hpp b/net/Socket.hpp
index ed59edb23..34da98aab 100644
--- a/net/Socket.hpp
+++ b/net/Socket.hpp
@@ -640,7 +640,8 @@ public:
 void insertNewUnixSocket(
 const std::string ,
 const std::string ,
-const std::shared_ptr& websocketHandler);
+const std::shared_ptr& websocketHandler,
+const int shareFD = -1);
 #else
 void insertNewFakeSocket(
 int peerSocket,
@@ -698,9 +699,10 @@ protected:
 
 private:
 /// Generate the request to connect & upgrade this socket to a given path
+/// and sends a file descriptor along request if is != -1.
 void clientRequestWebsocketUpgrade(const std::shared_ptr& 
socket,
const 
std::shared_ptr& websocketHandler,
-   

[Libreoffice-commits] online.git: kit/Kit.cpp

2020-04-28 Thread Dennis Francis (via logerrit)
 kit/Kit.cpp |5 -
 1 file changed, 5 deletions(-)

New commits:
commit 986bcce1c961df09169ff87dd22c1f84e4be036c
Author: Dennis Francis 
AuthorDate: Sun Apr 26 08:08:58 2020 +0530
Commit: Dennis Francis 
CommitDate: Tue Apr 28 13:30:22 2020 +0200

kit: Do not broadcast cell-cursor invalidation messages

is a follow up of 217dd2de5458cb91c6b9dffeb7db84e9cde88c0c
"Do not broadcast view-cursor invalidation messages"

But this change is implicitly Calc specific because
LOK_CALLBACK_CELL_VIEW_CURSOR is used only in Calc.

This patch fixes the following bug:

Suppose there are at least three clients each with a different zoom and the
all client's cursors are placed in same tab-view and away from A1. Now
it can be seen at once that the cursors of other clients in each client
are rendered incorrectly.

The commit c6b18508aec0e609b4c3c000faf89c21e93620bd in core.git
"lok: send other views our cursor position in their view co-ordinates"
does the right thing by sending view specific cell-cursor positions.
But the broadcast of these messages in Kit.cpp means every client will
get the messages intended for others and possibly end up using the
wrong messages to draw the cell-cursors.

Change-Id: I6e9534c2e562f34b5c1fe37242b36e076b9319c8
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92916
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Dennis Francis 

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 46eaf55c9..ae775fee3 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1388,11 +1388,6 @@ public:
 // all views have to be in sync
 tileQueue->put("callback all " + std::to_string(type) + ' ' + 
payload);
 }
-else if (type == LOK_CALLBACK_CELL_VIEW_CURSOR)
-{
-// these should go to all views but the one that that triggered it
-tileQueue->put("callback except-" + targetViewId + ' ' + 
std::to_string(type) + ' ' + payload);
-}
 else
 tileQueue->put("callback " + 
std::to_string(descriptor->getViewId()) + ' ' + std::to_string(type) + ' ' + 
payload);
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2020-04-25 Thread Michael Meeks (via logerrit)
 kit/Kit.cpp |   18 --
 1 file changed, 8 insertions(+), 10 deletions(-)

New commits:
commit 3bbbc4f2af97554df91377ac696a9a9224166c16
Author: Michael Meeks 
AuthorDate: Sat Apr 25 10:06:03 2020 +0100
Commit: Michael Meeks 
CommitDate: Sat Apr 25 14:58:18 2020 +0200

Kit: remove redundant FILE wrapper around the fd.

Change-Id: I76f00a6855c486c18fb18fbcefe93ba0072a6eea
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92890
Reviewed-by: Gabriel Masei 
Tested-by: Jenkins CollaboraOffice 

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 8cd62f43b..46eaf55c9 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -650,7 +650,7 @@ public:
 };
 
 #if !MOBILEAPP
-static FILE* ProcSMapsFile = nullptr;
+static int ProcSMapsFile = -1;
 #endif
 
 class ThreadPool {
@@ -796,14 +796,14 @@ public:
 assert(_loKit);
 
 #if !MOBILEAPP
-if (ProcSMapsFile)
+if (ProcSMapsFile >= 0)
 {
 static const std::string str = "smapsfd:";
-if (websocketHandler->sendTextMessageWithFD(str.c_str(), 
str.size(), ProcSMapsFile->_fileno) > 0)
+if (websocketHandler->sendTextMessageWithFD(str.c_str(), 
str.size(), ProcSMapsFile) > 0)
 {
 LOG_DBG("Successfully sent smaps fd to wsd");
-fclose(ProcSMapsFile);
-ProcSMapsFile = nullptr;
+close(ProcSMapsFile);
+ProcSMapsFile = -1;
 }
 else
 {
@@ -2601,11 +2601,9 @@ void lokit_main(
 LOG_SYS("mknod(" << jailPath.toString() << "/dev/random) 
failed. Mount must not use nodev flag.");
 }
 
-ProcSMapsFile = fopen("/proc/self/smaps", "r");
-if (ProcSMapsFile == nullptr)
-{
-LOG_SYS("Failed to symlink /proc/self/smaps. Memory stats will 
be missing.");
-}
+ProcSMapsFile = open("/proc/self/smaps", O_RDONLY);
+if (ProcSMapsFile < 0)
+LOG_SYS("Failed to open /proc/self/smaps. Memory stats will be 
missing.");
 
 LOG_INF("chroot(\"" << jailPath.toString() << "\")");
 if (chroot(jailPath.toString().c_str()) == -1)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2020-04-24 Thread Ashod Nakashian (via logerrit)
 kit/Kit.cpp |  105 +---
 1 file changed, 73 insertions(+), 32 deletions(-)

New commits:
commit 7ea8d62cf6ce0a5cef65222beca8b89aed9f97b9
Author: Ashod Nakashian 
AuthorDate: Sat Apr 11 14:56:08 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Fri Apr 24 16:39:46 2020 +0200

wsd: improved logging of jail setup

And some formatting, but no functional changes.

Reduced the maximum time before logging all
link/copy activity of jail files, which typically
takes < 200ms.

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index eefffb98b..ff4663d44 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -129,7 +129,25 @@ namespace
 Path destinationForLinkOrCopy;
 std::chrono::time_point linkOrCopyStartTime;
 bool linkOrCopyVerboseLogging = false;
-unsigned slowLinkOrCopyLimitInSecs = 10; // after this much seconds, start 
spamming the logs
+unsigned linkOrCopyFileCount = 0; // Track to help quantify the 
link-or-copy performance.
+constexpr unsigned SlowLinkOrCopyLimitInSecs = 2; // After this many 
seconds, start spamming the logs.
+
+/// Returns the LinkOrCopyType as a human-readable string (for logging).
+std::string linkOrCopyTypeString(LinkOrCopyType type)
+{
+switch (type)
+{
+case LinkOrCopyType::NoUsr:
+return "non-user";
+case LinkOrCopyType::LO:
+return "LibreOffice";
+case LinkOrCopyType::All:
+return "all";
+default:
+assert(!"Unknown LinkOrCopyType.");
+return "unknown";
+}
+}
 
 bool shouldCopyDir(const char *path)
 {
@@ -205,8 +223,10 @@ namespace
 
 void linkOrCopyFile(const char *fpath, const Path& newPath)
 {
+++linkOrCopyFileCount;
 if (linkOrCopyVerboseLogging)
 LOG_INF("Linking file \"" << fpath << "\" to \"" << 
newPath.toString() << "\"");
+
 if (link(fpath, newPath.toString().c_str()) == -1)
 {
 LOG_INF("link(\"" << fpath << "\", \"" <<
@@ -231,16 +251,20 @@ namespace
struct FTW* /*ftwbuf*/)
 {
 if (strcmp(fpath, sourceForLinkOrCopy.c_str()) == 0)
-return 0;
+{
+LOG_TRC("nftw: Skipping redundant path: " << fpath);
+return FTW_CONTINUE;
+}
 
 if (!linkOrCopyVerboseLogging)
 {
 const auto durationInSecs = 
std::chrono::duration_cast(
 std::chrono::steady_clock::now() - linkOrCopyStartTime);
-if (durationInSecs.count() > slowLinkOrCopyLimitInSecs)
+if (durationInSecs.count() > SlowLinkOrCopyLimitInSecs)
 {
-LOG_WRN("Linking/copying files from " << sourceForLinkOrCopy 
<< " to " << destinationForLinkOrCopy.toString() <<
-" is taking too much time. Enabling verbose link/copy 
logging at information level.");
+LOG_WRN("Linking/copying files from "
+<< sourceForLinkOrCopy << " to " << 
destinationForLinkOrCopy.toString()
+<< " is taking too much time. Enabling verbose 
link/copy logging.");
 linkOrCopyVerboseLogging = true;
 }
 }
@@ -263,12 +287,12 @@ namespace
 struct stat st;
 if (stat(fpath, ) == -1)
 {
-LOG_SYS("stat(\"" << std::string(fpath) << "\") failed.");
-return 1;
+LOG_SYS("nftw: stat(\"" << fpath << "\") failed");
+return FTW_STOP;
 }
 if (!shouldCopyDir(relativeOldPath))
 {
-LOG_TRC("skip redundant paths " << relativeOldPath);
+LOG_TRC("nftw: Skipping redundant path: " << 
relativeOldPath);
 return FTW_SKIP_SUBTREE;
 }
 File(newPath).createDirectories();
@@ -277,18 +301,19 @@ namespace
 ut.modtime = st.st_mtime;
 if (utime(newPath.toString().c_str(), ) == -1)
 {
-LOG_SYS("utime(\"" << newPath.toString() << "\") failed.");
-return 1;
+LOG_SYS("nftw: utime(\"" << newPath.toString() << "\") 
failed");
+return FTW_STOP;
 }
 }
 break;
 case FTW_SL:
 {
-size_t size = sb->st_size;
+const size_t size = sb->st_size;
 char target[size + 1];
-ssize_t written = readlink(fpath, target, size);
-if (written <= 0 || static_cast(written) > size) {
-

[Libreoffice-commits] online.git: kit/Kit.cpp

2020-04-24 Thread Ashod Nakashian (via logerrit)
 kit/Kit.cpp |   11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

New commits:
commit ce03253e52f779ab409eb658bd5cd12a7dccec85
Author: Ashod Nakashian 
AuthorDate: Sat Apr 11 14:45:03 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Fri Apr 24 16:40:14 2020 +0200

wsd: linkOrCopy now uses realpath to avoid links

This is needed in case the original template
directory itself is linked, which after setting
the FTW_PHYS flag to nftw skips them.

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index ff4663d44..ad37d3a2e 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -343,10 +343,19 @@ namespace
 return FTW_CONTINUE;
 }
 
-void linkOrCopy(const std::string& source,
+void linkOrCopy(std::string source,
 const Path& destination,
 LinkOrCopyType type)
 {
+char* resolved = realpath(source.c_str(), nullptr);
+if (resolved && resolved != source)
+{
+LOG_DBG("linkOrCopy: Using real path [" << resolved << "] instead 
of original link ["
+<< source << "].");
+source = resolved;
+free(resolved);
+}
+
 LOG_INF("linkOrCopy " << linkOrCopyTypeString(type) << " from [" << 
source << "] to ["
   << destination.toString() << "].");
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2020-04-24 Thread Ashod Nakashian (via logerrit)
 kit/Kit.cpp |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

New commits:
commit 5471e967b914693ea8dc24b74a6989793ea65083
Author: Ashod Nakashian 
AuthorDate: Fri Apr 10 11:02:02 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Fri Apr 24 15:40:30 2020 +0200

wsd: killpoco - reduce Poco usage where unnecessary

Poco's File::linkTo was added in version 1.8.1 and
we still support older versions. Also, symlink(2) is
far more transparent and simpler here.

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index acb8d6eec..eefffb98b 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -295,7 +295,12 @@ namespace
 target[written] = '\0';
 
 File(newPath.parent()).createDirectories();
-File(target).linkTo(newPath.toString(), 
Poco::File::LinkType::LINK_SYMBOLIC);
+if (symlink(target, newPath.toString().c_str()) == -1)
+{
+LOG_SYS("symlink(\"" << target << "\", \"" << 
newPath.toString()
+ << "\") failed");
+return 1;
+}
 }
 break;
 case FTW_DNR:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2020-04-22 Thread Miklos Vajna (via logerrit)
 kit/Kit.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 49fa1aa1c0b79e78512218b687f1f15b08ff87fb
Author: Miklos Vajna 
AuthorDate: Wed Apr 22 09:11:26 2020 +0200
Commit: Miklos Vajna 
CommitDate: Wed Apr 22 09:58:26 2020 +0200

Fix -Werror,-Winconsistent-missing-override

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 3801af4bd..acb8d6eec 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1196,7 +1196,7 @@ public:
 return false;
 }
 
-void alertAllUsers(const std::string& cmd, const std::string& kind)
+void alertAllUsers(const std::string& cmd, const std::string& kind) 
override
 {
 alertAllUsers("errortoall: cmd=" + cmd + " kind=" + kind);
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2020-04-22 Thread Dennis Francis (via logerrit)
 kit/Kit.cpp |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

New commits:
commit 217dd2de5458cb91c6b9dffeb7db84e9cde88c0c
Author: Dennis Francis 
AuthorDate: Tue Apr 21 14:40:30 2020 +0530
Commit: Michael Meeks 
CommitDate: Wed Apr 22 09:48:55 2020 +0200

Do not broadcast view-cursor invalidation messages

in kit as these are sent by core to specific view(s) by ultimately calling 
either
(as seen from the usages of LOK_CALLBACK_INVALIDATE_VIEW_CURSOR in core)

1. SfxLokHelper::notifyOtherView() where it sends to particular view.

or

2. SfxLokHelper::notifyOtherViews() where it sends to all views except
the current view.

The core makes the decision to broadcast or not, and if it does, then
the kit's broadcast of broadcasted messages can only cause a blowup of 
messaging
complexiity w.r.t number of views. It also does not make sense to send
view-cursor messages meant for a view to be sent to others in Calc
with clients of hetrogeneous zooms.

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index a34b91334..3801af4bd 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1322,8 +1322,7 @@ public:
 // all views have to be in sync
 tileQueue->put("callback all " + std::to_string(type) + ' ' + 
payload);
 }
-else if (type == LOK_CALLBACK_INVALIDATE_VIEW_CURSOR ||
- type == LOK_CALLBACK_CELL_VIEW_CURSOR)
+else if (type == LOK_CALLBACK_CELL_VIEW_CURSOR)
 {
 // these should go to all views but the one that that triggered it
 tileQueue->put("callback except-" + targetViewId + ' ' + 
std::to_string(type) + ' ' + payload);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2020-04-19 Thread Tor Lillqvist (via logerrit)
 kit/Kit.cpp |1 -
 1 file changed, 1 deletion(-)

New commits:
commit 927f77354c625854531593ccafabecab5b2d08e9
Author: Tor Lillqvist 
AuthorDate: Mon Apr 20 00:06:50 2020 +0300
Commit: Tor Lillqvist 
CommitDate: Sun Apr 19 23:28:53 2020 +0200

Bin unused variable

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 539615da5..dff8f08d3 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -109,7 +109,6 @@ static std::shared_ptr document;
 #ifndef BUILDING_TESTS
 static bool AnonymizeUserData = false;
 static uint64_t AnonymizationSalt = 82589933;
-static std::string ObfuscatedFileId;
 #endif
 
 #if ENABLE_DEBUG
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2020-04-18 Thread Tor Lillqvist (via logerrit)
 kit/Kit.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 2a16f34812cf69bbe0f21b7e7d048fdb3271fa9d
Author: Tor Lillqvist 
AuthorDate: Sat Apr 18 16:20:17 2020 +0300
Commit: Tor Lillqvist 
CommitDate: Sat Apr 18 16:33:56 2020 +0200

Don't use "kitbroker" as part of the thread name in a 'kit' process

It just causes confusion with the name "DocumentBroker".
DocumentBroker objects exist only in the WSD process. Instead just use
"kit".

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 5e28c0ca0..539615da5 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -2154,7 +2154,7 @@ protected:
 std::string url;
 URI::decode(docKey, url);
 LOG_INF("New session [" << sessionId << "] request on url [" << 
url << "].");
-Util::setThreadName("kitbroker_" + docId);
+Util::setThreadName("kit_" + docId);
 
 if (!document)
 document = std::make_shared(
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2020-04-14 Thread Michael Meeks (via logerrit)
 kit/Kit.cpp |7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

New commits:
commit eab1832b06f5da6533ba5ddd1eff714245729a25
Author: Michael Meeks 
AuthorDate: Tue Apr 14 17:04:09 2020 +0100
Commit: Michael Meeks 
CommitDate: Tue Apr 14 18:57:38 2020 +0200

tdf#132100 - don't copy debugsource into jails.

gdb will take it from the system anyway, so it's just amazingly
excessive weight wrapped in a performance problem.

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 77c3d9e2b..5e28c0ca0 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -144,6 +144,7 @@ namespace
 return
 strcmp(path, "program/wizards") != 0 &&
 strcmp(path, "sdk") != 0 &&
+strcmp(path, "debugsource") != 0 &&
 strcmp(path, "share/basic") != 0 &&
 strcmp(path, "share/Scripts/java") != 0 &&
 strcmp(path, "share/Scripts/javascript") != 0 &&
@@ -163,8 +164,10 @@ namespace
 if (!dot)
 return true;
 
-if (!strcmp(dot, ".dbg") ||
-!strcmp(dot, ".so"))
+if (!strcmp(dot, ".dbg"))
+return false;
+
+if (!strcmp(dot, ".so"))
 {
 // NSS is problematic ...
 if (strstr(path, "libnspr4") ||
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2020-04-07 Thread Martin Milata (via logerrit)
 kit/Kit.cpp |   22 +++---
 1 file changed, 19 insertions(+), 3 deletions(-)

New commits:
commit c571d9286df907f05838e6f1fca3139aae62cbc5
Author: Martin Milata 
AuthorDate: Thu Jan 30 17:44:31 2020 +0100
Commit: Michael Meeks 
CommitDate: Tue Apr 7 13:22:42 2020 +0200

tdf#129895: handle symlinks when populating chroot

In linkOrCopy, the nftw() function is used without the FTW_PHYS flag to
populate child roots from systemplate. From man nftw:

  FTW_PHYS
If set, do not follow symbolic links.  (This is what you want.)
If not set, symbolic links are followed, but no file is reported twice.

Because the order in which directory entries are visited is not defined,
having multiple symlinks to a file results in only one of the paths
being created in the chroot.

This is not really a problem because loolwsd-systemplate-setup creates
systemplate without symlinks. Fixing it might prevent unpleasant
surprises in the future though, and might possibly allow to make
systemplate and chroots smaller (also the manpage says that you want
it:)).

The commit adds FTW_PHYS flag to the call as well as symlink handling.

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index f647f1e8f..e99ec8e61 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -210,7 +210,7 @@ namespace
 if (link(fpath, newPath.toString().c_str()) == -1)
 {
 LOG_INF("link(\"" << fpath << "\", \"" <<
-newPath.toString() << "\") failed. Will copy.");
+newPath.toString() << "\") failed: " << strerror(errno) << 
". Will copy.");
 try
 {
 File(fpath).copyTo(newPath.toString());
@@ -226,7 +226,7 @@ namespace
 }
 
 int linkOrCopyFunction(const char *fpath,
-   const struct stat* /*sb*/,
+   const struct stat* sb,
int typeflag,
struct FTW* /*ftwbuf*/)
 {
@@ -282,6 +282,22 @@ namespace
 }
 }
 break;
+case FTW_SL:
+{
+size_t size = sb->st_size;
+char target[size + 1];
+ssize_t written = readlink(fpath, target, size);
+if (written <= 0 || static_cast(written) > size) {
+LOG_FTL("readlink(\"" << std::string(fpath) << "\") 
failed: " << strerror(errno));
+Log::shutdown();
+std::_Exit(EX_SOFTWARE);
+}
+target[written] = '\0';
+
+File(newPath.parent()).createDirectories();
+File(target).linkTo(newPath.toString(), 
Poco::File::LinkType::LINK_SYMBOLIC);
+}
+break;
 case FTW_DNR:
 LOG_ERR("Cannot read directory '" << fpath << "'");
 return 1;
@@ -306,7 +322,7 @@ namespace
 sourceForLinkOrCopy.pop_back();
 destinationForLinkOrCopy = destination;
 linkOrCopyStartTime = std::chrono::steady_clock::now();
-if (nftw(source.c_str(), linkOrCopyFunction, 10, FTW_ACTIONRETVAL) == 
-1)
+if (nftw(source.c_str(), linkOrCopyFunction, 10, 
FTW_ACTIONRETVAL|FTW_PHYS) == -1)
 {
 LOG_ERR("linkOrCopy: nftw() failed for '" << source << "'");
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2020-03-13 Thread Tor Lillqvist (via logerrit)
 kit/Kit.cpp |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

New commits:
commit 2154306e57d66a4a962f6beb1e917ff7079852c8
Author: Tor Lillqvist 
AuthorDate: Fri Mar 13 11:05:23 2020 +0200
Commit: Tor Lillqvist 
CommitDate: Fri Mar 13 10:50:36 2020 +0100

Make the iOS (and Android?) app work again

Now one can open another document after closing the first one. Turns
out that throwing an exception to return through the call stack to
SocketPoll::poll() is not necessary after all. But doing
document.reset() as before a86508d815013c40e3ae8c494b883e112a7195f2 is
essential.

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 8e2b2ddc5..3a3121b43 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -2159,9 +2159,7 @@ protected:
 #else
 LOG_INF("Setting TerminationFlag due to 'exit' command.");
 SigUtil::setTerminationFlag();
-
-// Not really a logic error, but hey. This is expected to be 
caught in SocketPoll::poll().
-throw std::logic_error("exit");
+document.reset();
 #endif
 }
 else if (tokens.equals(0, "tile") || tokens.equals(0, "tilecombine") 
|| tokens.equals(0, "canceltiles") ||
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp net/Socket.hpp wsd/DocumentBroker.hpp

2020-03-12 Thread Tor Lillqvist (via logerrit)
 kit/Kit.cpp|   11 +--
 net/Socket.hpp |1 +
 wsd/DocumentBroker.hpp |3 +--
 3 files changed, 11 insertions(+), 4 deletions(-)

New commits:
commit d4e08350431a7662eef22a21b5b0fede226ae0e6
Author: Tor Lillqvist 
AuthorDate: Thu Mar 12 22:17:05 2020 +0200
Commit: Tor Lillqvist 
CommitDate: Fri Mar 13 00:28:19 2020 +0100

Make closing the document work again in the iOS (and Android?) app

But opening a second document now hangs.

Sigh, the plumbing in the mobile apps is so extremely fragile. But
that is to be expected when turning a multi-process structure (where
one class of processes exit as soon as they have done their job) into
a single process running forever.

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index f8c76a06a..8e2b2ddc5 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -2149,14 +2149,21 @@ protected:
 LOG_DBG("CreateSession failed.");
 }
 }
-#if !MOBILEAPP
+
 else if (tokens.equals(0, "exit"))
 {
+#if !MOBILEAPP
 LOG_INF("Terminating immediately due to parent 'exit' command.");
 Log::shutdown();
 std::_Exit(EX_SOFTWARE);
-}
+#else
+LOG_INF("Setting TerminationFlag due to 'exit' command.");
+SigUtil::setTerminationFlag();
+
+// Not really a logic error, but hey. This is expected to be 
caught in SocketPoll::poll().
+throw std::logic_error("exit");
 #endif
+}
 else if (tokens.equals(0, "tile") || tokens.equals(0, "tilecombine") 
|| tokens.equals(0, "canceltiles") ||
 tokens.equals(0, "paintwindow") || tokens.equals(0, 
"resizewindow") ||
 LOOLProtocol::getFirstToken(tokens[0], '-') == "child")
diff --git a/net/Socket.hpp b/net/Socket.hpp
index 5427b99fa..1e632516e 100644
--- a/net/Socket.hpp
+++ b/net/Socket.hpp
@@ -673,6 +673,7 @@ public:
 LOG_ERR("Error while handling poll for socket #" <<
 _pollFds[i].fd << " in " << _name << ": " << 
exc.what());
 disposition.setClosed();
+rc = -1;
 }
 
 if (disposition.isMove() || disposition.isClosed())
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 7096afd4c..68369d274 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -108,7 +108,6 @@ public:
 
 try
 {
-#if !MOBILEAPP // There is no "child process" in a mobile app
 LOG_DBG("Closing ChildProcess [" << _pid << "].");
 
 // Request the child to exit
@@ -117,7 +116,7 @@ public:
 LOG_DBG("Stopping ChildProcess [" << _pid << "] by sending 
'exit' command.");
 sendTextFrame("exit");
 }
-#endif
+
 // Shutdown the socket.
 if (_ws)
 _ws->shutdown();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2020-03-12 Thread Tor Lillqvist (via logerrit)
 kit/Kit.cpp|2 ++
 wsd/DocumentBroker.hpp |3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 47d22d538ac5c09df6aa098922f8750cb939102b
Author: Tor Lillqvist 
AuthorDate: Thu Mar 12 15:13:28 2020 +0200
Commit: Tor Lillqvist 
CommitDate: Thu Mar 12 17:08:19 2020 +0100

Fix build for MOBILEAPP

Change-Id: I0903f13438493d167c263020d923536b4de71e5d
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90385
Tested-by: Tor Lillqvist 
Reviewed-by: Tor Lillqvist 

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index f14362c35..f8c76a06a 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -2149,12 +2149,14 @@ protected:
 LOG_DBG("CreateSession failed.");
 }
 }
+#if !MOBILEAPP
 else if (tokens.equals(0, "exit"))
 {
 LOG_INF("Terminating immediately due to parent 'exit' command.");
 Log::shutdown();
 std::_Exit(EX_SOFTWARE);
 }
+#endif
 else if (tokens.equals(0, "tile") || tokens.equals(0, "tilecombine") 
|| tokens.equals(0, "canceltiles") ||
 tokens.equals(0, "paintwindow") || tokens.equals(0, 
"resizewindow") ||
 LOOLProtocol::getFirstToken(tokens[0], '-') == "child")
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 68369d274..7096afd4c 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -108,6 +108,7 @@ public:
 
 try
 {
+#if !MOBILEAPP // There is no "child process" in a mobile app
 LOG_DBG("Closing ChildProcess [" << _pid << "].");
 
 // Request the child to exit
@@ -116,7 +117,7 @@ public:
 LOG_DBG("Stopping ChildProcess [" << _pid << "] by sending 
'exit' command.");
 sendTextFrame("exit");
 }
-
+#endif
 // Shutdown the socket.
 if (_ws)
 _ws->shutdown();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp net/Socket.hpp wsd/LOOLWSD.cpp

2020-03-12 Thread Ashod Nakashian (via logerrit)
 kit/Kit.cpp |2 +-
 net/Socket.hpp  |   26 +++---
 wsd/LOOLWSD.cpp |3 +--
 3 files changed, 17 insertions(+), 14 deletions(-)

New commits:
commit a0cdafca41f41638214fc0f59006bd7f1e4e67f5
Author: Ashod Nakashian 
AuthorDate: Sun Mar 8 14:33:47 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Thu Mar 12 13:23:57 2020 +0100

wsd: some logging improvements

Change-Id: Icf4c4845e10f44fe1518e58ea598c2d1053b40c1
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90357
Tested-by: Ashod Nakashian 
Reviewed-by: Ashod Nakashian 

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 496514e46..8b8e6514d 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1869,7 +1869,7 @@ public:
 
 const TileQueue::Payload input = _tileQueue->pop();
 
-LOG_TRC("Kit Recv " << 
LOOLProtocol::getAbbreviatedMessage(input));
+LOG_TRC("Kit handling queue message: " << 
LOOLProtocol::getAbbreviatedMessage(input));
 
 const StringVector tokens = 
LOOLProtocol::tokenize(input.data(), input.size());
 
diff --git a/net/Socket.hpp b/net/Socket.hpp
index 99fdf259a..b15aeb21b 100644
--- a/net/Socket.hpp
+++ b/net/Socket.hpp
@@ -588,8 +588,8 @@ public:
 int rc;
 do
 {
-LOG_TRC("Poll start");
 #if !MOBILEAPP
+LOG_TRC("Poll start, timeoutMs: " << timeoutMaxMs);
 rc = ::poll(&_pollFds[0], size + 1, std::max(timeoutMaxMs,0));
 #else
 LOG_TRC("SocketPoll Poll");
@@ -1106,12 +1106,14 @@ protected:
 // Always try to read.
 closed = !readIncomingData() || closed;
 
+LOG_TRC("#" << getFD() << ": Incoming data buffer " << 
_inBuffer.size() <<
+" bytes, closeSocket? " << closed);
+
+#ifdef LOG_SOCKET_DATA
 auto& log = Log::logger();
-if (log.trace()) {
-LOG_TRC("#" << getFD() << ": Incoming data buffer " << 
_inBuffer.size() <<
-" bytes, closeSocket? " << closed);
-// log.dump("", &_inBuffer[0], _inBuffer.size());
-}
+if (log.trace() && _inBuffer.size() > 0)
+log.dump("", &_inBuffer[0], _inBuffer.size());
+#endif
 
 // If we have data, allow the app to consume.
 size_t oldSize = 0;
@@ -1174,12 +1176,14 @@ public:
 len = writeData(&_outBuffer[0], 
std::min((int)_outBuffer.size(),
  getSendBufferSize()));
 
+LOG_TRC("#" << getFD() << ": Wrote outgoing data " << len << " 
bytes of "
+<< _outBuffer.size() << " bytes buffered.");
+
+#ifdef LOG_SOCKET_DATA
 auto& log = Log::logger();
-if (log.trace() && len > 0) {
-LOG_TRC("#" << getFD() << ": Wrote outgoing data " << len 
<<
-" bytes of " << _outBuffer.size() << " bytes 
buffered.");
-// log.dump("", &_outBuffer[0], len);
-}
+if (log.trace() && len > 0)
+log.dump("", &_outBuffer[0], len);
+#endif
 
 if (len <= 0 && errno != EAGAIN && errno != EWOULDBLOCK)
 LOG_SYS("#" << getFD() << ": Socket write returned " << 
len);
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 2a59b961c..a06687788 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3654,12 +3654,11 @@ int LOOLWSD::main(const std::vector& 
/*args*/)
 
 UnitWSD::get().returnValue(returnValue);
 
-LOG_INF("Process [loolwsd] finished.");
-
 #if MOBILEAPP
 fakeSocketDumpState();
 #endif
 
+LOG_INF("Process [loolwsd] finished.");
 return returnValue;
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2020-03-12 Thread Ashod Nakashian (via logerrit)
 kit/Kit.cpp |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit a86508d815013c40e3ae8c494b883e112a7195f2
Author: Ashod Nakashian 
AuthorDate: Sun Mar 8 14:27:02 2020 -0400
Commit: Ashod Nakashian 
CommitDate: Thu Mar 12 13:20:47 2020 +0100

wsd: kit now exits immediately when wsd send exit

The 'exit' command from DocBroker to Kit is processed
immediately. It set the termination flag and destroyed
the Document instance in Kit. Unfortunately, this is
highly problematic. There are a number of races here.

Normal disconnection procedure from DocBroker is to
first send 'disconnect'. This tells Kit to unload
and close the view in question, and when 0 views
are left, it simply exits the process.

However, since 'disconnect' is processed in the
message queue, the 'exit' (and indeed the socket
disconnection that follows 'exit') may be handled
before the message queue is drained, and so the
'disconnect' wouldn't have been processed yet.
The end result of these two races is that Kit
tries to exit the Core main loop, which fails
a number of assertion (f.e. that no LOK Windows
remain, which is presumably a leak check, which
we care not about as we don't attempt to cleanup
the sidebar).

The fix here is to process 'exit' immediately,
because DocBroker is gone, there is absolutely
nothing for Kit to do anymore.

Change-Id: I5c09fcfdb1713f4e0b56b717c747d919d0c6728f
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90356
Reviewed-by: Michael Meeks 
Tested-by: Ashod Nakashian 

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 54ad81647..496514e46 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -2151,9 +2151,9 @@ protected:
 }
 else if (tokens.equals(0, "exit"))
 {
-LOG_INF("Setting TerminationFlag due to 'exit' command from 
parent.");
-SigUtil::setTerminationFlag();
-document.reset();
+LOG_INF("Terminating immediately due to parent 'exit' command.");
+Log::shutdown();
+std::_Exit(EX_SOFTWARE);
 }
 else if (tokens.equals(0, "tile") || tokens.equals(0, "tilecombine") 
|| tokens.equals(0, "canceltiles") ||
 tokens.equals(0, "paintwindow") || tokens.equals(0, 
"resizewindow") ||
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2020-03-11 Thread Miklos Vajna (via logerrit)
 kit/Kit.cpp |   23 ++-
 1 file changed, 10 insertions(+), 13 deletions(-)

New commits:
commit 7ecae1b66de938a3186f05698e3c5aac3bc03eab
Author: Miklos Vajna 
AuthorDate: Tue Mar 10 17:21:04 2020 +0100
Commit: Miklos Vajna 
CommitDate: Wed Mar 11 09:08:25 2020 +0100

Document::sendFrame: vector -> unique_ptr

Open Writer, insert a multi-MP JPEG, select it.

Before:

ChildSession::renderShapeSelection: finished in 74.67 ms

After:

ChildSession::renderShapeSelection: finished in 67.33 ms (90.17% of 
baseline)

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 0b417f5e4..a302f6e35 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -752,16 +752,16 @@ public:
 const std::string& getUrl() const { return _url; }
 
 /// Post the message - in the unipoll world we're in the right thread 
anyway
-bool postMessage(const std::shared_ptr>& message, const 
WSOpCode code) const
+bool postMessage(const char* data, int size, const WSOpCode code) const
 {
-LOG_TRC("postMessage called with: " << 
getAbbreviatedMessage(message->data(), message->size()));
+LOG_TRC("postMessage called with: " << getAbbreviatedMessage(data, 
size));
 if (!_websocketHandler)
 {
-LOG_ERR("Child Doc: Bad socket while sending [" << 
getAbbreviatedMessage(message->data(), message->size()) << "].");
+LOG_ERR("Child Doc: Bad socket while sending [" << 
getAbbreviatedMessage(data, size) << "].");
 return false;
 }
 
-_websocketHandler->sendMessage(message->data(), message->size(), code);
+_websocketHandler->sendMessage(data, size, code);
 return true;
 }
 
@@ -1150,11 +1150,12 @@ public:
 
 LOG_TRC("Sending back painted tiles for " << tileMsg << " of size " << 
output.size() << " bytes) for: " << tileMsg);
 
-std::shared_ptr> response = 
std::make_shared>(tileMsg.size() + output.size());
-std::copy(tileMsg.begin(), tileMsg.end(), response->begin());
-std::copy(output.begin(), output.end(), response->begin() + 
tileMsg.size());
+size_t responseSize = tileMsg.size() + output.size();
+std::unique_ptr response(new char[responseSize]);
+std::copy(tileMsg.begin(), tileMsg.end(), response.get());
+std::copy(output.begin(), output.end(), response.get() + 
tileMsg.size());
 
-postMessage(response, WSOpCode::Binary);
+postMessage(response.get(), responseSize, WSOpCode::Binary);
 }
 
 bool sendTextFrame(const std::string& message)
@@ -1166,11 +1167,7 @@ public:
 {
 try
 {
-std::shared_ptr> message = 
std::make_shared>();
-message->resize(length);
-std::memcpy(message->data(), buffer, length);
-
-return postMessage(message, opCode);
+return postMessage(buffer, length, opCode);
 }
 catch (const Exception& exc)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2020-02-21 Thread Jan Holesovsky (via logerrit)
 kit/Kit.cpp |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

New commits:
commit fd3e6fb722dfb1d5da724cff1767bd7dd6ec91ea
Author: Jan Holesovsky 
AuthorDate: Fri Feb 21 15:32:21 2020 +0100
Commit: Jan Holesovsky 
CommitDate: Fri Feb 21 16:46:01 2020 +0100

android: Even with debug, the loolkitconfig.xcu path is the same.

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 60865cbbc..134abf2d6 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -2303,12 +2303,10 @@ void setupKitEnvironment()
 
"userext:${${BRAND_BASE_DIR}/program/lounorc:UNO_USER_PACKAGES_CACHE}/registry/com.sun.star.comp.deployment.configuration.PackageRegistryBackend/configmgr.ini
 "
 #ifdef IOS
 "user:*${BRAND_BASE_DIR}/loolkitconfig.xcu "
-#else
-#if ENABLE_DEBUG // '*' denotes non-writable.
+#elif ENABLE_DEBUG && !defined(ANDROID) // '*' denotes non-writable.
 "user:*file://" DEBUG_ABSSRCDIR "/loolkitconfig.xcu "
 #else
 "user:*file://" LOOLWSD_CONFIGDIR "/loolkitconfig.xcu "
-#endif
 #endif
 );
 ::setenv("CONFIGURATION_LAYERS", layers.c_str(),
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2020-01-21 Thread Michael Meeks (via logerrit)
 kit/Kit.cpp |8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

New commits:
commit c187f414c5bf76bbd6bf511ce8a62263e86abc46
Author: Michael Meeks 
AuthorDate: Tue Jan 21 13:36:14 2020 +
Commit: Michael Meeks 
CommitDate: Tue Jan 21 16:07:31 2020 +0100

kit: show the correct documentLoad URL when a template is used.

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 78eea14eb..34d5b86a5 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -54,6 +54,7 @@
 
 #include "ChildSession.hpp"
 #include 
+#include 
 #include 
 #include "KitHelper.hpp"
 #include "Kit.hpp"
@@ -1636,13 +1637,14 @@ private:
 _jailedUrl = uri;
 _isDocPasswordProtected = false;
 
-LOG_DBG("Calling lokit::documentLoad(" << uriAnonym << ", \"" << 
options << "\").");
+const char *pURL = docTemplate.empty() ? uri.c_str() : 
docTemplate.c_str();
+LOG_DBG("Calling lokit::documentLoad(" << 
FileUtil::anonymizeUrl(pURL) << ", \"" << options << "\").");
 const auto start = std::chrono::system_clock::now();
-_loKitDocument.reset(_loKit->documentLoad(docTemplate.empty() ? 
uri.c_str() : docTemplate.c_str(), options.c_str()));
+_loKitDocument.reset(_loKit->documentLoad(pURL, options.c_str()));
 const auto duration = std::chrono::system_clock::now() - start;
 const auto elapsed = 
std::chrono::duration_cast(duration).count();
 const double totalTime = elapsed/1000.;
-LOG_DBG("Returned lokit::documentLoad(" << uriAnonym << ") in " << 
totalTime << "ms.");
+LOG_DBG("Returned lokit::documentLoad(" << 
FileUtil::anonymizeUrl(pURL) << ") in " << totalTime << "ms.");
 #ifdef IOS
 // The iOS app (and the Android one) has max one document open at 
a time, so we can keep
 // a pointer to it in a global.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2020-01-14 Thread Ashod Nakashian (via logerrit)
 kit/Kit.cpp |   17 ++---
 1 file changed, 6 insertions(+), 11 deletions(-)

New commits:
commit 4619ac73ffb31ce7f3bb30accb5a5be116529bff
Author: Ashod Nakashian 
AuthorDate: Wed Jan 8 03:37:47 2020 -0500
Commit: Michael Meeks 
CommitDate: Tue Jan 14 13:01:05 2020 +0100

wsd: minor cleanup

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index a8855f1c3..78eea14eb 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1854,27 +1854,22 @@ private:
 }
 
 public:
-bool hasQueued()
-{
-return !_tileQueue->isEmpty();
-}
-
 void drainQueue(const std::chrono::steady_clock::time_point )
 {
 try
 {
-while (hasQueued())
+while (!_tileQueue->isEmpty())
 {
-const TileQueue::Payload input = _tileQueue->pop();
-
-LOG_TRC("Kit Recv " << 
LOOLProtocol::getAbbreviatedMessage(input));
-
 if (_stop || SigUtil::getTerminationFlag())
 {
-LOG_INF("_stop or TerminationFlag is set, breaking out of 
loop");
+LOG_INF("_stop or TerminationFlag is set, breaking 
Document::drainQueue of loop");
 break;
 }
 
+const TileQueue::Payload input = _tileQueue->pop();
+
+LOG_TRC("Kit Recv " << 
LOOLProtocol::getAbbreviatedMessage(input));
+
 const std::vector tokens = 
LOOLProtocol::tokenize(input.data(), input.size());
 
 if (tokens[0] == "eof")
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2020-01-07 Thread Michael Meeks (via logerrit)
 kit/Kit.cpp |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 28acde16e6271cc3712b7785a20722c1a11dde50
Author: Michael Meeks 
AuthorDate: Tue Jan 7 18:05:53 2020 +
Commit: Michael Meeks 
CommitDate: Tue Jan 7 21:25:56 2020 +0100

Mention the nodev mount flag on failed mknod.

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index b6446887b..a8855f1c3 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -2443,14 +2443,14 @@ void lokit_main(
   S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | 
S_IROTH | S_IWOTH,
   makedev(1, 8)) != 0)
 {
-LOG_SYS("mknod(" << jailPath.toString() << "/dev/random) 
failed.");
+LOG_SYS("mknod(" << jailPath.toString() << "/dev/random) 
failed. Mount must not use nodev flag.");
 }
 
 if (mknod((jailPath.toString() + "/dev/urandom").c_str(),
   S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | 
S_IROTH | S_IWOTH,
   makedev(1, 9)) != 0)
 {
-LOG_SYS("mknod(" << jailPath.toString() << "/dev/urandom) 
failed.");
+LOG_SYS("mknod(" << jailPath.toString() << "/dev/random) 
failed. Mount must not use nodev flag.");
 }
 
 ProcSMapsFile = fopen("/proc/self/smaps", "r");
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2020-01-07 Thread Michael Meeks (via logerrit)
 kit/Kit.cpp |   16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

New commits:
commit 873110de88cd57955893e2e7779673cd51ee0daf
Author: Michael Meeks 
AuthorDate: Tue Jan 7 10:51:21 2020 +
Commit: Michael Meeks 
CommitDate: Tue Jan 7 19:22:01 2020 +0100

android: don't use std::vector allocation for large pixel buffers.

Amazingly more time was spent allocating, wiping and freeing these
vectors on Android than the actual rendering of pixels in a profile.

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index fd5ebc9ba..b6446887b 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -899,6 +899,20 @@ public:
 renderedTiles.back().setImgSize(imgSize);
 }
 
+struct RenderBuffer {
+unsigned char *_data;
+RenderBuffer(size_t x, size_t y)
+{
+_data = static_cast(calloc(x * y, 4));
+}
+~RenderBuffer()
+{
+if (_data)
+free (_data);
+}
+unsigned char *data() { return _data; }
+};
+
 void renderTiles(TileCombined , bool combined)
 {
 auto& tiles = tileCombined.getTiles();
@@ -934,7 +948,7 @@ public:
 LOG_WRN("Unusual extremely large tile combine of size " << 
pixmapWidth << "x" << pixmapHeight);
 
 const size_t pixmapSize = 4 * pixmapWidth * pixmapHeight;
-std::vector pixmap(pixmapSize, 0);
+RenderBuffer pixmap(pixmapWidth, pixmapHeight);
 
 if (!_loKitDocument)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2020-01-07 Thread Michael Meeks (via logerrit)
 kit/Kit.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 8522cbdb9fc067e1666fd2fdb739ec120e2752d7
Author: Michael Meeks 
AuthorDate: Tue Jan 7 10:45:34 2020 +
Commit: Michael Meeks 
CommitDate: Tue Jan 7 12:43:47 2020 +0100

android: pick a good value for threads.

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index f2930d923..fd5ebc9ba 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -598,7 +598,7 @@ public:
 {
 int maxConcurrency = 2;
 #if MOBILEAPP && !defined(GTKAPP)
-#  warning "Good defaults ? - 2 for iOS, 4 for Android ?"
+maxConcurrency = std::max(std::thread::hardware_concurrency(), 2);
 #else
 const char *max = getenv("MAX_CONCURRENCY");
 if (max)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2019-11-30 Thread Michael Meeks (via logerrit)
 kit/Kit.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 1c1989ad778b7429d6324af9af4d83fd16fa078c
Author: Michael Meeks 
AuthorDate: Sat Nov 30 22:46:31 2019 +
Commit: Michael Meeks 
CommitDate: Sat Nov 30 22:47:01 2019 +

insert image needs fps_office component these days.

Change-Id: I29a5d5a5c9c180f7cab3b008874f9f2a7ea323f0

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 101a40445..b46a0785b 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -2724,7 +2724,7 @@ bool globalPreinit(const std::string )
  "abp avmediagst avmediavlc cmdmail losessioninstall OGLTrans 
PresenterScreen "
  "syssh ucpftp1 ucpgio1 ucphier1 ucpimage updatecheckui updatefeed 
updchk"
  // Database
- "dbaxml dbmm dbp dbu deployment firebird_sdbc fps_office mork "
+ "dbaxml dbmm dbp dbu deployment firebird_sdbc mork "
  "mysql mysqlc odbc postgresql-sdbc postgresql-sdbc-impl sdbc2 
sdbt"
  // Java
  "javaloader javavm jdbc rpt rptui rptxml ",
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] online.git: kit/Kit.cpp

2019-10-08 Thread Tor Lillqvist (via logerrit)
 kit/Kit.cpp |4 
 1 file changed, 4 insertions(+)

New commits:
commit e51d0a642d34e00e1167ca1a8c94395beead46ef
Author: Tor Lillqvist 
AuthorDate: Tue Oct 8 14:49:35 2019 +0300
Commit: Michael Meeks 
CommitDate: Tue Oct 8 14:08:23 2019 +0200

Fix build for MOBILEAPP where we don't have Log::shutdown()

(Because a mobile app is not supposed to ever exit voluntarily and
cleanly anyway.)

Perhaps we should call abort() in thse cases, though, and not just
continue as if nothing is wrong?

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index fbe42a7f1..b40577878 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -2115,14 +2115,18 @@ public:
 catch (const std::exception& exc)
 {
 LOG_FTL("QueueHandler::run: Exception: " << exc.what());
+#if !MOBILEAPP
 Log::shutdown();
 std::_Exit(Application::EXIT_SOFTWARE);
+#endif
 }
 catch (...)
 {
 LOG_FTL("QueueHandler::run: Unknown exception");
+#if !MOBILEAPP
 Log::shutdown();
 std::_Exit(Application::EXIT_SOFTWARE);
+#endif
 }
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] online.git: kit/Kit.cpp

2019-09-29 Thread Tor Lillqvist (via logerrit)
 kit/Kit.cpp |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 908240741daba5e8b9991bc0979a506b62bf1c72
Author: Tor Lillqvist 
AuthorDate: Thu Sep 26 17:39:41 2019 +0300
Commit: Andras Timar 
CommitDate: Sun Sep 29 13:23:25 2019 +0200

tdf#125575: Must reset the "kit" callback to null when closing document

As we register the global "kit" callback with the Document object
pointer as callback data, we must unregister it when the document is
being "unloaded" and the Document object will destruct shortly.
Otherwise the callback might be called for the next document with a
stale pointer.

Relevant only for the iOS app, and presumably the Android one. In
web-based Online, the kit process will exit anyway after the document
is closed. But in an app there is just one process that keeps running
for a long time handling all documents that are edited.

For some reason the crash only showed up when a document was created
from a template, closed, and another document was created from a
template.

Change-Id: Ieb47838a597c5bcab89c1a33d9bc2f2adb57b3b3
Reviewed-on: https://gerrit.libreoffice.org/79633
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Tor Lillqvist 
Tested-by: Tor Lillqvist 
(cherry picked from commit ee497b873eadfa3ab4ba77793748e83ff649dacf)
Reviewed-on: https://gerrit.libreoffice.org/79650
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 0dd75ff7b..2a26b7118 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1524,6 +1524,7 @@ private:
 
 _loKitDocument->setView(viewId);
 _loKitDocument->registerCallback(nullptr, nullptr);
+_loKit->registerCallback(nullptr, nullptr);
 
 int viewCount = _loKitDocument->getViewsCount();
 if (viewCount == 1)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] online.git: kit/Kit.cpp

2019-06-04 Thread Miklos Vajna (via logerrit)
 kit/Kit.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 54e5a1000be777dbb9732b0f9c921983b6cc119c
Author: Miklos Vajna 
AuthorDate: Tue Jun 4 09:14:26 2019 +0200
Commit: Miklos Vajna 
CommitDate: Tue Jun 4 09:15:38 2019 +0200

kit: mark Document as final

Document has to be final: its constructor calls sendTextFrame(), which
calls the virtual sendFrame(). So the only situation where this code
works correctly is when Document is never subclassed.

Change-Id: I7c13abdae57d9e1ba3416ec1963b58bce0d42e6f

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 99d34bf73..b18e62c74 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -855,7 +855,7 @@ public:
 /// per process. But for security reasons don't.
 /// However, we could have a loolkit instance
 /// per user or group of users (a trusted circle).
-class Document : public DocumentManagerInterface
+class Document final : public DocumentManagerInterface
 {
 public:
 /// We have two types of password protected documents
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

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

2019-06-03 Thread Libreoffice Gerrit user
 kit/Kit.cpp |2 --
 wsd/LOOLWSD.cpp |2 --
 2 files changed, 4 deletions(-)

New commits:
commit a4fd83794e8fcfda46dbb1d033088ebcaeecf4cd
Author: Miklos Vajna 
AuthorDate: Mon Jun 3 09:05:58 2019 +0200
Commit: Miklos Vajna 
CommitDate: Mon Jun 3 09:06:11 2019 +0200

Remove unused using declarations

Change-Id: I0d4336fc8f85a18b2c41de233166e725166385f6

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 892289f23..99d34bf73 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -95,7 +95,6 @@ using Poco::File;
 using Poco::JSON::Array;
 using Poco::JSON::Object;
 using Poco::JSON::Parser;
-using Poco::Runnable;
 using Poco::StringTokenizer;
 using Poco::Thread;
 using Poco::Timestamp;
@@ -104,7 +103,6 @@ using Poco::Util::Application;
 
 #ifndef BUILDING_TESTS
 using Poco::Path;
-using Poco::Process;
 #endif
 
 using namespace LOOLProtocol;
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 28c91dbdf..80f657b22 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -155,7 +155,6 @@ using Poco::Net::HTTPResponse;
 using Poco::Net::MessageHeader;
 using Poco::Net::NameValueCollection;
 using Poco::Path;
-using Poco::Process;
 using Poco::StreamCopier;
 using Poco::StringTokenizer;
 using Poco::TemporaryFile;
@@ -165,7 +164,6 @@ using Poco::Thread;
 using Poco::URI;
 using Poco::Util::Application;
 using Poco::Util::HelpFormatter;
-using Poco::Util::IncompatibleOptionsException;
 using Poco::Util::MissingOptionException;
 using Poco::Util::Option;
 using Poco::Util::OptionSet;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] online.git: kit/Kit.cpp

2019-05-10 Thread Libreoffice Gerrit user
 kit/Kit.cpp |   13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

New commits:
commit 70eb802184b93560c100808fd154f25829c46d8f
Author: Michael Meeks 
AuthorDate: Fri May 10 18:03:11 2019 +0100
Commit: Michael Meeks 
CommitDate: Fri May 10 18:03:11 2019 +0100

unipoll: remove now redundant SocketPoll parameters.

Change-Id: I8308a0b503db34ac43658a5461005a32132d392f

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 5152a80fd..89a259e39 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -873,7 +873,6 @@ public:
  const std::string& docId,
  const std::string& url,
  std::shared_ptr tileQueue,
- SocketPoll& /*socketPoll*/,
  const std::shared_ptr& websocketHandler)
   : _loKit(loKit),
 _jailId(jailId),
@@ -2209,16 +2208,14 @@ class KitWebSocketHandler final : public 
WebSocketHandler, public std::enable_sh
 std::string _socketName;
 std::shared_ptr _loKit;
 std::string _jailId;
-SocketPoll& _socketPoll;
 
 public:
-KitWebSocketHandler(const std::string& socketName, const 
std::shared_ptr& loKit, const std::string& jailId, SocketPoll& 
socketPoll) :
+KitWebSocketHandler(const std::string& socketName, const 
std::shared_ptr& loKit, const std::string& jailId) :
 WebSocketHandler(/* isClient = */ true, /* isMasking */ false),
 _queue(std::make_shared()),
 _socketName(socketName),
 _loKit(loKit),
-_jailId(jailId),
-_socketPoll(socketPoll)
+_jailId(jailId)
 {
 }
 
@@ -2269,9 +2266,7 @@ protected:
 LOG_INF("New session [" << sessionId << "] request on url [" << 
url << "].");
 
 if (!document)
-{
-document = std::make_shared(_loKit, _jailId, docKey, 
docId, url, _queue, _socketPoll, shared_from_this());
-}
+document = std::make_shared(_loKit, _jailId, docKey, 
docId, url, _queue, shared_from_this());
 
 // Validate and create session.
 if (!(url == document->getUrl() && 
document->createSession(sessionId)))
@@ -2720,7 +2715,7 @@ void lokit_main(
 mainKit.runOnClientThread(); // We will do the polling on this thread.
 
 std::shared_ptr websocketHandler =
-std::make_shared("child_ws", loKit, jailId, 
mainKit);
+std::make_shared("child_ws", loKit, jailId);
 #if !MOBILEAPP
 mainKit.insertNewUnixSocket(MasterLocation, pathAndQuery, 
websocketHandler);
 #else
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] online.git: kit/Kit.cpp

2019-05-10 Thread Libreoffice Gerrit user
 kit/Kit.cpp |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

New commits:
commit eb376d122f318ba02780b25a03bfd861281ed848
Author: Miklos Vajna 
AuthorDate: Fri May 10 16:39:10 2019 +0200
Commit: Miklos Vajna 
CommitDate: Fri May 10 16:39:10 2019 +0200

Fix recently introduced clang warnings

kit/Kit.cpp:2166:17: error: private field '_socketPoll' is not used 
[-Werror,-Wunused-private-field]


/usr/lib64/gcc/x86_64-suse-linux/7/../../../../include/c++/7/ext/new_allocator.h:140:22:
 error: destructor called on non-final 'Document' that has virtual functions 
but non-virtual destructor [-Werror,-Wdelete-non-abstract-non-virtual-dtor]

Change-Id: I47849db2b0bc64e811577e3a8cede0e2d2c0e2e6

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 216c8d757..5152a80fd 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -873,7 +873,7 @@ public:
  const std::string& docId,
  const std::string& url,
  std::shared_ptr tileQueue,
- SocketPoll& socketPoll,
+ SocketPoll& /*socketPoll*/,
  const std::shared_ptr& websocketHandler)
   : _loKit(loKit),
 _jailId(jailId),
@@ -882,7 +882,6 @@ public:
 _url(url),
 _obfuscatedFileId(Util::getFilenameFromURL(docKey)),
 _tileQueue(std::move(tileQueue)),
-_socketPoll(socketPoll),
 _websocketHandler(websocketHandler),
 _docPassword(""),
 _haveDocPassword(false),
@@ -904,7 +903,7 @@ public:
 #endif
 }
 
-~Document()
+virtual ~Document()
 {
 LOG_INF("~Document dtor for [" << _docKey <<
 "] url [" << anonymizeUrl(_url) << "] on child [" << _jailId <<
@@ -2163,7 +2162,6 @@ private:
 
 std::shared_ptr _loKitDocument;
 std::shared_ptr _tileQueue;
-SocketPoll& _socketPoll;
 std::shared_ptr _websocketHandler;
 
 std::mutex _pngMutex;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] online.git: kit/Kit.cpp wsd/LOOLWSD.cpp wsd/TileDesc.hpp

2019-05-02 Thread Libreoffice Gerrit user
 kit/Kit.cpp  |  275 +--
 wsd/LOOLWSD.cpp  |1 
 wsd/TileDesc.hpp |   18 ++-
 3 files changed, 239 insertions(+), 55 deletions(-)

New commits:
commit 8172885f74bef3e4d90e41a54a596add5b292b6a
Author: Michael Meeks 
AuthorDate: Sat Apr 20 01:53:12 2019 +0100
Commit: Michael Meeks 
CommitDate: Thu May 2 22:36:52 2019 +0100

PNG compression a bottleneck: thread it to accelerate things.

Also have a separate hash <-> wid cache to avoid re-rendering
older tiles as/when we see them.

Change-Id: I238fe6701a1d1cb486473c67faba8c56e9c98dcb

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 25050e04b..c6ab8fd4a 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -435,13 +435,15 @@ private:
 size_t _cacheSize;
 static const size_t CacheSizeSoftLimit = (1024 * 4 * 32); // 128k of cache
 static const size_t CacheSizeHardLimit = CacheSizeSoftLimit * 2;
+static const size_t CacheWidHardLimit = 4096;
 size_t _cacheHits;
 size_t _cacheTests;
 TileWireId _nextId;
 DeltaGenerator _deltaGen;
 
-std::map< TileBinaryHash, CacheEntry > _cache;
-std::map< TileWireId, TileBinaryHash > _wireToHash;
+std::unordered_map< TileBinaryHash, CacheEntry > _cache;
+// This uses little storage so can be much larger
+std::unordered_map< TileBinaryHash, TileWireId > _hashToWireId;
 
 void clearCache(bool logStats = false)
 {
@@ -449,6 +451,7 @@ private:
 LOG_DBG("cache clear " << _cache.size() << " items total size " <<
 _cacheSize << " current hits " << _cacheHits);
 _cache.clear();
+_hashToWireId.clear();
 _cacheSize = 0;
 _cacheHits = 0;
 _cacheTests = 0;
@@ -465,6 +468,8 @@ private:
 return id;
 }
 
+public:
+// Performed only after a complete combinetiles
 void balanceCache()
 {
 // A normalish PNG image size for text in a writer document is
@@ -489,10 +494,6 @@ private:
 // the chance of hitting these entries in the future.
 _cacheSize -= it->second.getData()->size();
 
-auto wIt = _wireToHash.find(it->second.getWireId());
-assert(wIt != _wireToHash.end());
-_wireToHash.erase(wIt);
-
 it = _cache.erase(it);
 }
 else
@@ -506,9 +507,22 @@ private:
 LOG_DBG("PNG cache has " << _cache.size() << " items, total size " 
<<
 _cacheSize << " after balance.");
 }
+
+if (_hashToWireId.size() > CacheWidHardLimit)
+{
+LOG_DBG("Clear half of wid cache of size " << 
_hashToWireId.size());
+TileWireId max = _nextId - CacheWidHardLimit/2;
+for (auto it = _hashToWireId.begin(); it != _hashToWireId.end();)
+{
+if (it->second < max)
+it = _hashToWireId.erase(it);
+else
+++it;
+}
+LOG_DBG("Wid cache is now size " << _hashToWireId.size());
+}
 }
 
-public:
 /// Lookup an entry in the cache and store the data in output.
 /// Returns true on success, otherwise false.
 bool copyFromCache(const TileBinaryHash hash, std::vector& output, 
size_t )
@@ -540,10 +554,13 @@ public:
 
 if (hash)
 {
+// Adding duplicates causes grim wid mixups
+assert(hashToWireId(hash) == wid);
+assert(_cache.find(hash) == _cache.end());
+
 data->shrink_to_fit();
 _cache.emplace(hash, newEntry);
 _cacheSize += data->size();
-balanceCache();
 }
 }
 
@@ -552,18 +569,18 @@ public:
 clearCache();
 }
 
-TileWireId hashToWireId(TileBinaryHash id)
+TileWireId hashToWireId(TileBinaryHash hash)
 {
 TileWireId wid;
-if (id == 0)
+if (hash == 0)
 return 0;
-auto it = _cache.find(id);
-if (it != _cache.end())
-wid = it->second.getWireId();
+auto it = _hashToWireId.find(hash);
+if (it != _hashToWireId.end())
+wid = it->second;
 else
 {
 wid = createNewWireId();
-_wireToHash.emplace(wid, id);
+_hashToWireId.emplace(hash, wid);
 }
 return wid;
 }
@@ -737,6 +754,103 @@ private:
 static FILE* ProcSMapsFile = nullptr;
 #endif
 
+class ThreadPool {
+std::mutex _mutex;
+std::condition_variable _cond;
+std::condition_variable _complete;
+typedef std::function ThreadFn;
+std::queue _work;
+std::vector _threads;
+size_t _working;
+bool   _shutdown;
+public:
+ThreadPool()
+: _working(0),
+  _shutdown(false)
+{
+int maxConcurrency = 2;
+#if MOBILEAPP
+#  warning "Good defaults ? - 2 for iOS, 4 for Android ?"
+#else
+const char *max = 

[Libreoffice-commits] online.git: kit/Kit.cpp

2019-04-22 Thread Libreoffice Gerrit user
 kit/Kit.cpp |5 +
 1 file changed, 5 insertions(+)

New commits:
commit 2ec5023dbf4e8fd8d59a82f9040ad88933a10aa2
Author: Ashod Nakashian 
AuthorDate: Mon Apr 22 12:02:58 2019 -0400
Commit: Ashod Nakashian 
CommitDate: Tue Apr 23 03:02:09 2019 +0200

wsd: assert on 0-sized tiles

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index d098cd773..759e78e24 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1080,6 +1080,11 @@ public:
 
 LOG_TRC("Encoded tile #" << tileIndex << " at (" << positionX << 
"," << positionY << ") with oldWireId=" <<
 tiles[tileIndex].getOldWireId() << ", hash=" << hash << " 
wireId: " << wireId << " in " << imgSize << " bytes.");
+if (imgSize == 0)
+{
+LOG_ERR("Encoded 0-sized tile!");
+assert(!"0-sized tile enocded!");
+}
 tiles[tileIndex].setWireId(wireId);
 tiles[tileIndex].setImgSize(imgSize);
 tileIndex++;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] online.git: kit/Kit.cpp

2019-04-19 Thread Libreoffice Gerrit user
 kit/Kit.cpp |   88 +++-
 1 file changed, 41 insertions(+), 47 deletions(-)

New commits:
commit a088e09193663cad03915ba9f6cad269de0b60ba
Author: Michael Meeks 
AuthorDate: Sat Apr 20 00:49:13 2019 +0100
Commit: Michael Meeks 
CommitDate: Sat Apr 20 01:26:50 2019 +0100

re-factor PNG compression to share and protect TileDesc updates.

Change-Id: I3cbda6ecd78c7be8ca7fc767d9a5a288a020df7b

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 73e4ed3f0..991ac51c8 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -389,20 +389,20 @@ namespace
 /// wherever possible.
 class PngCache
 {
+public:
 typedef std::shared_ptr< std::vector< char > > CacheData;
-
+private:
 struct CacheEntry {
 private:
 size_t_hitCount;
 TileWireId _wireId;
 CacheData _data;
 public:
-CacheEntry(size_t defaultSize, TileWireId id) :
+CacheEntry(const CacheData , TileWireId id) :
 _hitCount(1),   // Every entry is used at least once; prevent 
removal at birth.
 _wireId(id),
-_data( new std::vector< char >() )
+_data(data)
 {
-_data->reserve( defaultSize );
 }
 
 size_t getHitCount() const
@@ -430,6 +430,7 @@ class PngCache
 return _wireId;
 }
 } ;
+
 size_t _cacheSize;
 static const size_t CacheSizeSoftLimit = (1024 * 4 * 32); // 128k of cache
 static const size_t CacheSizeHardLimit = CacheSizeSoftLimit * 2;
@@ -509,7 +510,7 @@ class PngCache
 public:
 /// Lookup an entry in the cache and store the data in output.
 /// Returns true on success, otherwise false.
-bool copyFromCache(const uint64_t hash, std::vector& output)
+bool copyFromCache(const TileBinaryHash hash, std::vector& output, 
size_t )
 {
 if (hash)
 {
@@ -523,6 +524,8 @@ public:
   it->second.getData()->begin(),
   it->second.getData()->end());
 it->second.incrementHitCount();
+imgSize = it->second.getData()->size();
+
 return true;
 }
 }
@@ -530,43 +533,17 @@ public:
 return false;
 }
 
-bool encodeSubBufferToPNG(unsigned char* pixmap, size_t startX, size_t 
startY,
-  int width, int height,
-  int bufferWidth, int bufferHeight,
-  std::vector& output, 
LibreOfficeKitTileMode mode,
-  TileBinaryHash hash, TileWireId wid, TileWireId 
/*oldWid*/)
+void addToCache(const CacheData , TileWireId wid, const 
TileBinaryHash hash)
 {
-LOG_DBG("PNG cache with hash " << hash << " missed.");
-/*
- *Disable for now - pushed in error.
- *
-if (_deltaGen.createDelta(pixmap, startX, startY, width, height,
-  bufferWidth, bufferHeight,
-  output, wid, oldWid))
-return true;
-*/
+CacheEntry newEntry(data, wid);
 
-LOG_DBG("Encode a new png for this tile.");
-CacheEntry newEntry(bufferWidth * bufferHeight * 1, wid);
-if (Png::encodeSubBufferToPNG(pixmap, startX, startY, width, height,
-  bufferWidth, bufferHeight,
-  *newEntry.getData(), mode))
+if (hash)
 {
-if (hash)
-{
-newEntry.getData()->shrink_to_fit();
-_cache.emplace(hash, newEntry);
-_cacheSize += newEntry.getData()->size();
-}
-
-output.insert(output.end(),
-  newEntry.getData()->begin(),
-  newEntry.getData()->end());
+data->shrink_to_fit();
+_cache.emplace(hash, newEntry);
+_cacheSize += data->size();
 balanceCache();
-return true;
 }
-else
-return false;
 }
 
 PngCache()
@@ -1035,16 +1012,15 @@ public:
 output.reserve(pixmapSize);
 
 // Compress the area as tiles
+const int pixelWidth = tileCombined.getWidth();
+const int pixelHeight = tileCombined.getHeight();
+
 size_t tileIndex = 0;
 for (Util::Rectangle& tileRect : tileRecs)
 {
 const size_t positionX = (tileRect.getLeft() - 
renderArea.getLeft()) / tileCombined.getTileWidth();
 const size_t positionY = (tileRect.getTop() - renderArea.getTop()) 
/ tileCombined.getTileHeight();
 
-const size_t oldSize = output.size();
-const int pixelWidth = tileCombined.getWidth();
-const int pixelHeight = tileCombined.getHeight();
-
 const int offsetX = positionX * pixelWidth;
 const int offsetY = positionY * pixelHeight;
 
@@ -1062,27 +1038,45 @@ public:
 continue;

[Libreoffice-commits] online.git: kit/Kit.cpp

2019-04-19 Thread Libreoffice Gerrit user
 kit/Kit.cpp |   59 ---
 1 file changed, 24 insertions(+), 35 deletions(-)

New commits:
commit adfaa76ff6ce7381127eade7d7a56c6aa7af37c6
Author: Michael Meeks 
AuthorDate: Fri Apr 19 23:56:20 2019 +0100
Commit: Michael Meeks 
CommitDate: Fri Apr 19 23:56:20 2019 +0100

Inline PngCache lookup to avoid redundant watermark blending.

Change-Id: I6fe5cca81b9268c903e011fe0e77f478befbc836

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index a9e59aac4..73e4ed3f0 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -506,9 +506,10 @@ class PngCache
 }
 }
 
+public:
 /// Lookup an entry in the cache and store the data in output.
 /// Returns true on success, otherwise false.
-bool cacheTest(const uint64_t hash, std::vector& output)
+bool copyFromCache(const uint64_t hash, std::vector& output)
 {
 if (hash)
 {
@@ -529,11 +530,11 @@ class PngCache
 return false;
 }
 
-bool cacheEncodeSubBufferToPNG(unsigned char* pixmap, size_t startX, 
size_t startY,
-   int width, int height,
-   int bufferWidth, int bufferHeight,
-   std::vector& output, 
LibreOfficeKitTileMode mode,
-   TileBinaryHash hash, TileWireId wid, 
TileWireId /*oldWid*/)
+bool encodeSubBufferToPNG(unsigned char* pixmap, size_t startX, size_t 
startY,
+  int width, int height,
+  int bufferWidth, int bufferHeight,
+  std::vector& output, 
LibreOfficeKitTileMode mode,
+  TileBinaryHash hash, TileWireId wid, TileWireId 
/*oldWid*/)
 {
 LOG_DBG("PNG cache with hash " << hash << " missed.");
 /*
@@ -568,7 +569,6 @@ class PngCache
 return false;
 }
 
-public:
 PngCache()
 {
 clearCache();
@@ -589,20 +589,6 @@ public:
 }
 return wid;
 }
-
-bool encodeSubBufferToPNG(unsigned char* pixmap, size_t startX, size_t 
startY,
-  int width, int height,
-  int bufferWidth, int bufferHeight,
-  std::vector& output, 
LibreOfficeKitTileMode mode,
-  TileBinaryHash hash, TileWireId wid, TileWireId 
oldWid)
-{
-if (cacheTest(hash, output))
-return true;
-
-return cacheEncodeSubBufferToPNG(pixmap, startX, startY, width, height,
- bufferWidth, bufferHeight, output, 
mode,
- hash, wid, oldWid);
-}
 };
 
 class Watermark
@@ -1076,21 +1062,24 @@ public:
 continue;
 }
 
-if (_docWatermark)
-_docWatermark->blending(pixmap.data(), offsetX, offsetY,
-pixmapWidth, pixmapHeight,
-pixelWidth, pixelHeight,
-mode);
-
-if (!_pngCache.encodeSubBufferToPNG(pixmap.data(), offsetX, 
offsetY,
-pixelWidth, pixelHeight,
-pixmapWidth, pixmapHeight, 
output, mode,
-hash, wireId, oldWireId))
+if (!_pngCache.copyFromCache(hash, output))
 {
-//FIXME: Return error.
-//sendTextFrame("error: cmd=tile kind=failure");
-LOG_ERR("Failed to encode tile into PNG.");
-return;
+if (_docWatermark)
+_docWatermark->blending(pixmap.data(), offsetX, offsetY,
+pixmapWidth, pixmapHeight,
+pixelWidth, pixelHeight,
+mode);
+
+if (!_pngCache.encodeSubBufferToPNG(pixmap.data(), offsetX, 
offsetY,
+pixelWidth, pixelHeight,
+pixmapWidth, pixmapHeight, 
output, mode,
+hash, wireId, oldWireId))
+{
+// FIXME: Return error.
+// sendTextFrame("error: cmd=tile kind=failure");
+LOG_ERR("Failed to encode tile into PNG.");
+return;
+}
 }
 
 const size_t imgSize = output.size() - oldSize;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] online.git: kit/Kit.cpp scripts/perftrace.pl

2019-04-04 Thread Libreoffice Gerrit user
 kit/Kit.cpp  |2 ++
 scripts/perftrace.pl |   40 +++-
 2 files changed, 29 insertions(+), 13 deletions(-)

New commits:
commit ca619e6fd7add691b1e44c0b19a46b7cf9e0da8f
Author: Michael Meeks 
AuthorDate: Thu Apr 4 20:01:19 2019 +0100
Commit: Michael Meeks 
CommitDate: Thu Apr 4 20:01:19 2019 +0100

perftrace: annotate start events as idle as well.

Change-Id: Iaf603101426caca1f48ebe10918170287aee006d

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 42663d3ee..7555ae9eb 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1344,6 +1344,8 @@ public:
 }
 else
 tileQueue->put("callback " + 
std::to_string(descriptor->getViewId()) + ' ' + std::to_string(type) + ' ' + 
payload);
+
+LOG_TRC("Document::ViewCallback end.");
 }
 
 private:
diff --git a/scripts/perftrace.pl b/scripts/perftrace.pl
index a5b1a01d4..f639fb2f1 100755
--- a/scripts/perftrace.pl
+++ b/scripts/perftrace.pl
@@ -88,21 +88,33 @@ my @event_pairs = (
 );
 
 # Idle events
-my @idle_types = (
+my @idleend_types = (
 '^Poll completed'
 );
 
+my @idlestart_types = (
+'^Document::ViewCallback end\.'
+);
+
 my %pair_starts;
 my %proc_names;
 
-sub get_event_type($$$)
+sub match_list($@)
 {
-my ($type, $emitter, $message) = @_;
-foreach my $match (@idle_types) {
+my $message = shift;
+while (my $match =  shift) {
if ($message =~ m/$match/) {
-   return 'idle';
+   return 1;
}
 }
+return 0;
+}
+
+sub get_event_type($$$)
+{
+my ($type, $emitter, $message) = @_;
+return 'idle_end' if (match_list($message, @idleend_types));
+return 'idle_start' if (match_list($message, @idlestart_types));
 return '';
 }
 
@@ -110,6 +122,9 @@ sub consume()
 {
 my ($proc, $pid, $tid, $time, $emitter, $type, $message, $line) = @_;
 
+$pid = int($pid);
+$tid = int($tid);
+
 # print STDERR "$emitter, $type, $time, $message, $line\n";
 
 $time = offset_microsecs($time) if ($json); # microseconds from start
@@ -118,13 +133,13 @@ sub consume()
 if (!defined $emitters{$emitter}) {
$emitters{$emitter} = (scalar keys %emitters) + 1;
if ($json) {
-   push @events, "{\"name\": \"thread_name\", \"ph\": \"M\", \"pid\": 
$pid, \"tid\": $tid, \"args\": { \"name\" : \"$emitter\" } }";
+   push @events, "{\"name\": \"thread_name\", \"thread_sort_index\": 
-$tid, \"ph\": \"M\", \"pid\": $pid, \"tid\": $tid, \"args\": { \"name\" : 
\"$emitter\" } }";
}
 }
 if (!defined $proc_names{$pid}) {
$proc_names{$pid} = 1;
if ($json) {
-   push @events, "{\"name\": \"process_name\", \"ph\": \"M\", \"pid\": 
$pid, \"args\": { \"name\" : \"$proc\" } }";
+   push @events, "{\"name\": \"process_name\", \"process_sort_index\": 
-$pid, \"ph\": \"M\", \"pid\": $pid, \"args\": { \"name\" : \"$proc\" } }";
}
 }
 
@@ -178,17 +193,16 @@ sub consume()
$dur = $time - $last_times{$key};
my $idx = $last_event_idx{$key};
 
-   if ($event_type ne 'idle') { # onlt re-write if not idle
-   $events[$idx] =~ s/\"dur\":10/\"dur\":$dur/;
-   } else {
-   print STDERR "idle re-write to $dur\n";
-   }
+   $dur = 1 if ($event_type eq 'idle_end' && $dur > 1);
+   $events[$idx] =~ s/\"dur\":10/\"dur\":$dur/;
}
$last_times{$key} = $time;
$last_event_idx{$key} = scalar @events;
 
my $json_type = "\"ph\":\"X\", \"s\":\"p\"";
-   push @events, "{\"pid\":$pid, \"tid\":$tid, \"ts\":$time, \"dur\":10, 
$json_type, \"name\":\"$content_e\" }";
+   my $replace_dur = 10;
+   $replace_dur = 1 if ($event_type eq 'idle_start'); # miss the regexp
+   push @events, "{\"pid\":$pid, \"tid\":$tid, \"ts\":$time, 
\"dur\":$replace_dur, $json_type, \"name\":\"$content_e\" }";
 }
 else
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] online.git: kit/Kit.cpp net/ServerSocket.hpp net/Socket.cpp wsd/LOOLWSD.cpp

2019-03-31 Thread Libreoffice Gerrit user
 kit/Kit.cpp  |2 +-
 net/ServerSocket.hpp |4 
 net/Socket.cpp   |   19 ---
 wsd/LOOLWSD.cpp  |2 ++
 4 files changed, 15 insertions(+), 12 deletions(-)

New commits:
commit 9c02d82f7ccb4abb19dd40837418ac10a8da9040
Author: Tor Lillqvist 
AuthorDate: Sun Mar 31 14:34:24 2019 +0300
Commit: Tor Lillqvist 
CommitDate: Sun Mar 31 14:34:24 2019 +0300

Fix build in the MOBILEAPP case

Did not check how well it works.

Change-Id: I5ca1b349aafcfddaed517e51ca6bd25e9749779d

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index ff4a3a7ed..42663d3ee 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -2530,7 +2530,7 @@ void lokit_main(
 #if !MOBILEAPP
 mainKit.insertNewUnixSocket(MasterLocation, pathAndQuery, 
websocketHandler);
 #else
-mainKit.insertNewFakeSocketSync(docBrokerSocket, websocketHandler);
+mainKit.insertNewFakeSocket(docBrokerSocket, websocketHandler);
 #endif
 
 LOG_INF("New kit client websocket inserted.");
diff --git a/net/ServerSocket.hpp b/net/ServerSocket.hpp
index dd07af4fe..ff4d4aa26 100644
--- a/net/ServerSocket.hpp
+++ b/net/ServerSocket.hpp
@@ -96,6 +96,8 @@ protected:
 std::shared_ptr _sockFactory;
 };
 
+#if !MOBILEAPP
+
 /// A non-blocking, streaming Unix Domain Socket for local use
 class LocalServerSocket : public ServerSocket
 {
@@ -114,4 +116,6 @@ private:
 
 #endif
 
+#endif
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/net/Socket.cpp b/net/Socket.cpp
index 02fb7f972..441128f16 100644
--- a/net/Socket.cpp
+++ b/net/Socket.cpp
@@ -200,6 +200,8 @@ void SocketPoll::wakeupWorld()
 wakeup(fd);
 }
 
+#if !MOBILEAPP
+
 void SocketPoll::insertNewWebSocketSync(
 const Poco::URI ,
 const std::shared_ptr& websocketHandler)
@@ -331,7 +333,8 @@ void SocketPoll::insertNewUnixSocket(
 }
 }
 
-#if MOBILEAPP
+#else
+
 void SocketPoll::insertNewFakeSocket(
 int peerSocket,
 const std::shared_ptr& websocketHandler)
@@ -361,6 +364,7 @@ void SocketPoll::insertNewFakeSocket(
 }
 }
 }
+
 #endif
 
 void ServerSocket::dumpState(std::ostream& os)
@@ -539,6 +543,8 @@ std::shared_ptr ServerSocket::accept()
 return nullptr;
 }
 
+#if !MOBILEAPP
+
 int Socket::getPid() const
 {
 struct ucred creds;
@@ -553,11 +559,7 @@ int Socket::getPid() const
 
 std::shared_ptr LocalServerSocket::accept()
 {
-#if !MOBILEAPP
 const int rc = ::accept4(getFD(), nullptr, nullptr, SOCK_NONBLOCK);
-#else
-const int rc = fakeSocketAccept4(getFD());
-#endif
 try
 {
 LOG_DBG("Accepted prisoner socket #" << rc << ", creating socket 
object.");
@@ -565,7 +567,6 @@ std::shared_ptr LocalServerSocket::accept()
 return std::shared_ptr(nullptr);
 
 std::shared_ptr _socket = _sockFactory->create(rc);
-#if MOBILEAPP
 // Sanity check this incoming socket
 struct ucred creds;
 socklen_t credSize = sizeof(struct ucred);
@@ -592,7 +593,6 @@ std::shared_ptr LocalServerSocket::accept()
 std::shared_ptr _socket = _sockFactory->create(rc);
 LOG_DBG("Accepted socket is UDS - address " << addr <<
 " and pid/gid " << creds.pid << "/" << creds.gid);
-#endif
 return _socket;
 }
 catch (const std::exception& ex)
@@ -605,7 +605,6 @@ std::shared_ptr LocalServerSocket::accept()
 /// Returns true on success only.
 std::string LocalServerSocket::bind()
 {
-#if !MOBILEAPP
 int rc;
 struct sockaddr_un addrunix;
 do
@@ -625,12 +624,10 @@ std::string LocalServerSocket::bind()
 
 if (rc >= 0)
 return std::string(_path[1]);
-#endif
+
 return "";
 }
 
-#if !MOBILEAPP
-
 bool StreamSocket::parseHeader(const char *clientName,
Poco::MemoryInputStream ,
Poco::Net::HTTPRequest ,
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index b4060d643..e7365eef2 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2900,12 +2900,14 @@ public:
 SocketPoll::InhibitThreadChecks = true;
 
 os << "LOOLWSDServer:\n"
+#if !MOBILEAPP
<< "  Ports: server " << ClientPortNumber
<<  " prisoner " << MasterLocation << "\n"
<< "  SSL: " << (LOOLWSD::isSSLEnabled() ? "https" : "http") << "\n"
<< "  SSL-Termination: " << (LOOLWSD::isSSLTermination() ? "yes" : 
"no") << "\n"
<< "  Security " << (LOOLWSD::NoCapsForKit ? "no" : "") << " 
chroot, "
 << (LOOLWSD::NoSeccomp ? "no" : "") << " api 
lockdown\n"
+#endif
<< "  TerminationFlag: " << TerminationFlag << "\n"
<< "  isShuttingDown: " << ShutdownRequestFlag << "\n"
<< "  NewChildren: " << NewChildren.size() << "\n"
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] online.git: kit/Kit.cpp net/ServerSocket.hpp net/Socket.cpp net/Socket.hpp wsd/LOOLWSD.cpp

2019-03-30 Thread Libreoffice Gerrit user
 kit/Kit.cpp  |8 ---
 net/ServerSocket.hpp |   55 +--
 net/Socket.cpp   |  121 ++-
 net/Socket.hpp   |3 +
 wsd/LOOLWSD.cpp  |   13 +
 5 files changed, 131 insertions(+), 69 deletions(-)

New commits:
commit 201bcb0762c838e75b61f030725c9bf0ba59c1c3
Author: Michael Meeks 
AuthorDate: Sat Mar 30 21:07:58 2019 +
Commit: Michael Meeks 
CommitDate: Sat Mar 30 21:37:05 2019 +

Use peercreds to identify processes connecting rather than URL params.

Change-Id: I241e80962fb8cf2f3fff1bb4be81d9f0ee74c648

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 819fb2698..ff4a3a7ed 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -2485,11 +2485,8 @@ void lokit_main(
 
 LOG_INF("Process is ready.");
 
-static const std::string pid = std::to_string(Process::id());
 std::string pathAndQuery(NEW_CHILD_URI);
-pathAndQuery.append("?pid=");
-pathAndQuery.append(pid);
-pathAndQuery.append("=");
+pathAndQuery.append("?jailid=");
 pathAndQuery.append(jailId);
 if (queryVersion)
 {
@@ -2522,7 +2519,6 @@ void lokit_main(
 
 // Dummies
 const std::string jailId = "jailid";
-const std::string pid = "101";
 
 #endif // MOBILEAPP
 
@@ -2530,7 +2526,7 @@ void lokit_main(
 mainKit.runOnClientThread(); // We will do the polling on this thread.
 
 std::shared_ptr websocketHandler =
-std::make_shared("child_ws_" + pid, loKit, 
jailId, mainKit);
+std::make_shared("child_ws", loKit, jailId, 
mainKit);
 #if !MOBILEAPP
 mainKit.insertNewUnixSocket(MasterLocation, pathAndQuery, 
websocketHandler);
 #else
diff --git a/net/ServerSocket.hpp b/net/ServerSocket.hpp
index 79a7795bc..dd07af4fe 100644
--- a/net/ServerSocket.hpp
+++ b/net/ServerSocket.hpp
@@ -61,58 +61,7 @@ public:
 /// Accepts an incoming connection (Servers only).
 /// Does not retry on error.
 /// Returns a valid Socket shared_ptr on success only.
-std::shared_ptr accept()
-{
-// Accept a connection (if any) and set it to non-blocking.
-// There still need the client's address to filter request from 
POST(call from REST) here.
-#if !MOBILEAPP
-struct sockaddr_in6 clientInfo;
-socklen_t addrlen = sizeof(clientInfo);
-const int rc = ::accept4(getFD(), (struct sockaddr *), 
, SOCK_NONBLOCK);
-#else
-const int rc = fakeSocketAccept4(getFD());
-#endif
-LOG_DBG("Accepted socket #" << rc << ", creating socket object.");
-try
-{
-// Create a socket object using the factory.
-if (rc != -1)
-{
-#if !MOBILEAPP
-char addrstr[INET6_ADDRSTRLEN];
-
-const void *inAddr;
-if (clientInfo.sin6_family == AF_INET)
-{
-auto ipv4 = (struct sockaddr_in *)
-inAddr = &(ipv4->sin_addr);
-}
-else
-{
-auto ipv6 = (struct sockaddr_in6 *)
-inAddr = &(ipv6->sin6_addr);
-}
-
-inet_ntop(clientInfo.sin6_family, inAddr, addrstr, 
sizeof(addrstr));
-std::shared_ptr _socket = _sockFactory->create(rc);
-_socket->setClientAddress(addrstr);
-LOG_DBG("Accepted socket has family " << 
clientInfo.sin6_family <<
-" address " << _socket->clientAddress());
-#else
-std::shared_ptr _socket = _sockFactory->create(rc);
-_socket->setClientAddress("dummy");
-#endif
-return _socket;
-}
-return std::shared_ptr(nullptr);
-}
-catch (const std::exception& ex)
-{
-LOG_SYS("Failed to create client socket #" << rc << ". Error: " << 
ex.what());
-}
-
-return nullptr;
-}
+virtual std::shared_ptr accept();
 
 int getPollEvents(std::chrono::steady_clock::time_point /* now */,
   int & /* timeoutMaxMs */) override
@@ -143,6 +92,7 @@ public:
 private:
 Socket::Type _type;
 SocketPoll& _clientPoller;
+protected:
 std::shared_ptr _sockFactory;
 };
 
@@ -155,6 +105,7 @@ public:
 {
 }
 virtual bool bind(Type, int) { assert(false); return false; }
+virtual std::shared_ptr accept() override;
 std::string bind();
 
 private:
diff --git a/net/Socket.cpp b/net/Socket.cpp
index a1762352e..02fb7f972 100644
--- a/net/Socket.cpp
+++ b/net/Socket.cpp
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -398,7 +399,8 @@ void StreamSocket::dumpState(std::ostream& os)
 int events = getPollEvents(std::chrono::steady_clock::now(), timeoutMaxMs);
 os << "\t" << getFD() << "\t" << events << "\t"
<< _inBuffer.size() << "\t" << _outBuffer.size() << "\t"
- 

[Libreoffice-commits] online.git: kit/Kit.cpp

2019-01-30 Thread Libreoffice Gerrit user
 kit/Kit.cpp |1 -
 1 file changed, 1 deletion(-)

New commits:
commit 6364ed0a2f7d5b5678c9c6286edbdf87b2c4dd06
Author: Andras Timar 
AuthorDate: Wed Jan 30 11:07:13 2019 +0100
Commit: Andras Timar 
CommitDate: Wed Jan 30 11:13:47 2019 +0100

we need share/template/common/internal/idxexample.odt for Insert TOC dialog

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index f1846f9a4..a91514ed4 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -153,7 +153,6 @@ namespace
 strcmp(path, "share/basic") != 0 &&
 strcmp(path, "share/Scripts/java") != 0 &&
 strcmp(path, "share/Scripts/javascript") != 0 &&
-strcmp(path, "share/template") != 0 &&
 strcmp(path, "share/config/wizard") != 0;
 default: // LinkOrCopyType::All
 return true;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2019-01-30 Thread Libreoffice Gerrit user
 kit/Kit.cpp |1 -
 1 file changed, 1 deletion(-)

New commits:
commit 309cb0591610317dc63b204942ac54dfc470d610
Author: Andras Timar 
AuthorDate: Wed Jan 30 11:05:29 2019 +0100
Commit: Andras Timar 
CommitDate: Wed Jan 30 11:11:11 2019 +0100

remove duplicated check for 'share/config/wizard'

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 181c99d1f..f1846f9a4 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -154,7 +154,6 @@ namespace
 strcmp(path, "share/Scripts/java") != 0 &&
 strcmp(path, "share/Scripts/javascript") != 0 &&
 strcmp(path, "share/template") != 0 &&
-strcmp(path, "share/config/wizard") != 0 &&
 strcmp(path, "share/config/wizard") != 0;
 default: // LinkOrCopyType::All
 return true;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2018-12-12 Thread Libreoffice Gerrit user
 kit/Kit.cpp |1 -
 1 file changed, 1 deletion(-)

New commits:
commit 6c6eaaadf00cb7983d614a9b97b51b97a39da9fd
Author: Tamás Zolnai 
AuthorDate: Wed Dec 12 12:51:10 2018 +0100
Commit: Andras Timar 
CommitDate: Wed Dec 12 13:18:48 2018 +0100

Now we need gallery for inserting some special shapes

So copy it from the lotemplate.

Change-Id: I84d1514e5e06ec194e549b36f8db2dc6fdd04f38
(cherry picked from commit 66dcff38a7248fb7facc6d459ac872262bb1)
Reviewed-on: https://gerrit.libreoffice.org/65018
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index bc3ebeba1..72bf5a289 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -151,7 +151,6 @@ namespace
 strcmp(path, "program/wizards") != 0 &&
 strcmp(path, "sdk") != 0 &&
 strcmp(path, "share/basic") != 0 &&
-strcmp(path, "share/gallery") != 0 &&
 strcmp(path, "share/Scripts/java") != 0 &&
 strcmp(path, "share/Scripts/javascript") != 0 &&
 strcmp(path, "share/template") != 0 &&
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2018-11-08 Thread Libreoffice Gerrit user
 kit/Kit.cpp |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 1521685c81b026cccbd0c6f9f20876838f2e6d4e
Author: Tor Lillqvist 
AuthorDate: Thu Nov 8 14:59:35 2018 +0200
Commit: Tor Lillqvist 
CommitDate: Thu Nov 8 15:01:45 2018 +0200

Avoid assertion failure in the MOBILEAPP case

The dummy Unit thing is of type Wsd, not Kit, there. Just put this
into #ifndef.

Change-Id: Ic709472154fd17761a82df9814e5d3746f96f607

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 2c21155d7..bc3ebeba1 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -2109,9 +2109,10 @@ protected:
 {
 std::string message(data.data(), data.size());
 
+#ifndef MOBILEAPP
 if (UnitKit::get().filterKitMessage(this, message))
 return;
-
+#endif
 std::vector tokens = LOOLProtocol::tokenize(message);
 Log::StreamLogger logger = Log::debug();
 if (logger.enabled())
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2018-11-07 Thread Libreoffice Gerrit user
 kit/Kit.cpp |6 ++
 1 file changed, 6 insertions(+)

New commits:
commit adbcc28273da6511050ca37c3d5ee4c93ac3ba7f
Author: Tor Lillqvist 
AuthorDate: Wed Nov 7 13:21:25 2018 +0200
Commit: Tamás Zolnai 
CommitDate: Wed Nov 7 14:19:02 2018 +0100

If we skipped all tiles, don't bother sending an empty tilecombine: message

It would just be ignored later anyway, and produce the warning "WRN
Dropping empty tilecombine response".

Change-Id: I6d92367262dc306369f2ca6c2e1964b5d151acc1
Reviewed-on: https://gerrit.libreoffice.org/63013
Reviewed-by: Tamás Zolnai 
Tested-by: Tamás Zolnai 

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index c78f73c3b..8eda6ce10 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1179,6 +1179,12 @@ public:
 renderArea.getWidth() << ", " << renderArea.getHeight() << ") 
" <<
 " took " << (elapsed/1000.) << " ms (including the 
paintTile).");
 
+if (tileIndex == 0)
+{
+LOG_DBG("All tiles skipped, not producing empty tilecombine: 
message");
+return;
+}
+
 const auto tileMsg = 
ADD_DEBUG_RENDERID(tileCombined.serialize("tilecombine:")) + "\n";
 LOG_TRC("Sending back painted tiles for " << tileMsg);
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2018-11-05 Thread Libreoffice Gerrit user
 kit/Kit.cpp |   59 +++
 1 file changed, 43 insertions(+), 16 deletions(-)

New commits:
commit af22ebbbc07a445de1f086da2e566e157e25
Author: Miklos Vajna 
AuthorDate: Mon Nov 5 10:04:17 2018 +0100
Commit: Miklos Vajna 
CommitDate: Mon Nov 5 10:04:22 2018 +0100

CacheEntry: make members private

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 46cccafae..c78f73c3b 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -395,9 +395,11 @@ class PngCache
 typedef std::shared_ptr< std::vector< char > > CacheData;
 
 struct CacheEntry {
+private:
 size_t_hitCount;
 TileWireId _wireId;
 CacheData _data;
+public:
 CacheEntry(size_t defaultSize, TileWireId id) :
 _hitCount(1),   // Every entry is used at least once; prevent 
removal at birth.
 _wireId(id),
@@ -405,6 +407,31 @@ class PngCache
 {
 _data->reserve( defaultSize );
 }
+
+size_t getHitCount() const
+{
+return _hitCount;
+}
+
+void incrementHitCount()
+{
+++_hitCount;
+}
+
+void decrementHitCount()
+{
+--_hitCount;
+}
+
+const CacheData& getData() const
+{
+return _data;
+}
+
+TileWireId getWireId() const
+{
+return _wireId;
+}
 } ;
 size_t _cacheSize;
 static const size_t CacheSizeSoftLimit = (1024 * 4 * 32); // 128k of cache
@@ -447,7 +474,7 @@ class PngCache
 {
 size_t avgHits = 0;
 for (auto it = _cache.begin(); it != _cache.end(); ++it)
-avgHits += it->second._hitCount;
+avgHits += it->second.getHitCount();
 
 LOG_DBG("cache " << _cache.size() << " items total size " <<
 _cacheSize << " current hits " << avgHits << ", total hit 
rate " <<
@@ -456,14 +483,14 @@ class PngCache
 
 for (auto it = _cache.begin(); it != _cache.end();)
 {
-if ((_cacheSize > CacheSizeSoftLimit && it->second._hitCount 
== 0) ||
-(_cacheSize > CacheSizeHardLimit && it->second._hitCount > 
0 && it->second._hitCount <= avgHits))
+if ((_cacheSize > CacheSizeSoftLimit && 
it->second.getHitCount() == 0) ||
+(_cacheSize > CacheSizeHardLimit && 
it->second.getHitCount() > 0 && it->second.getHitCount() <= avgHits))
 {
 // Shrink cache when we exceed the size to maximize
 // the chance of hitting these entries in the future.
-_cacheSize -= it->second._data->size();
+_cacheSize -= it->second.getData()->size();
 
-auto wIt = _wireToHash.find(it->second._wireId);
+auto wIt = _wireToHash.find(it->second.getWireId());
 assert(wIt != _wireToHash.end());
 _wireToHash.erase(wIt);
 
@@ -471,8 +498,8 @@ class PngCache
 }
 else
 {
-if (it->second._hitCount > 0)
-it->second._hitCount--;
+if (it->second.getHitCount() > 0)
+it->second.decrementHitCount();
 ++it;
 }
 }
@@ -495,9 +522,9 @@ class PngCache
 ++_cacheHits;
 LOG_DBG("PNG cache with hash " << hash << " hit.");
 output.insert(output.end(),
-  it->second._data->begin(),
-  it->second._data->end());
-it->second._hitCount++;
+  it->second.getData()->begin(),
+  it->second.getData()->end());
+it->second.incrementHitCount();
 return true;
 }
 }
@@ -525,18 +552,18 @@ class PngCache
 CacheEntry newEntry(bufferWidth * bufferHeight * 1, wid);
 if (Png::encodeSubBufferToPNG(pixmap, startX, startY, width, height,
   bufferWidth, bufferHeight,
-  *newEntry._data, mode))
+  *newEntry.getData(), mode))
 {
 if (hash)
 {
-newEntry._data->shrink_to_fit();
+newEntry.getData()->shrink_to_fit();
 _cache.emplace(hash, newEntry);
-_cacheSize += newEntry._data->size();
+_cacheSize += newEntry.getData()->size();
 }
 
 output.insert(output.end(),
-  newEntry._data->begin(),
-  newEntry._data->end());
+  newEntry.getData()->begin(),
+  newEntry.getData()->end());
 balanceCache();
 

[Libreoffice-commits] online.git: kit/Kit.cpp kit/Kit.hpp

2018-10-31 Thread Libreoffice Gerrit user
 kit/Kit.cpp |8 
 kit/Kit.hpp |   22 --
 2 files changed, 24 insertions(+), 6 deletions(-)

New commits:
commit 4c423fad84c1ee9d4e1a3eba4a75888e8863a9bc
Author: Miklos Vajna 
AuthorDate: Wed Oct 31 09:02:08 2018 +0100
Commit: Miklos Vajna 
CommitDate: Wed Oct 31 09:02:15 2018 +0100

CallbackDescriptor: make members private

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index d063e0bb6..b731d0eb9 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1219,13 +1219,13 @@ public:
 
 CallbackDescriptor* descriptor = 
static_cast(data);
 assert(descriptor && "Null callback data.");
-assert(descriptor->Doc && "Null Document instance.");
+assert(descriptor->getDoc() && "Null Document instance.");
 
-std::shared_ptr tileQueue = descriptor->Doc->getTileQueue();
+std::shared_ptr tileQueue = 
descriptor->getDoc()->getTileQueue();
 assert(tileQueue && "Null TileQueue.");
 
 const std::string payload = p ? p : "(nil)";
-LOG_TRC("Document::ViewCallback [" << descriptor->ViewId <<
+LOG_TRC("Document::ViewCallback [" << descriptor->getViewId() <<
 "] [" << LOKitHelper::kitCallbackTypeToString(type) <<
 "] [" << payload << "].");
 
@@ -1301,7 +1301,7 @@ public:
 tileQueue->put("callback except-" + targetViewId + ' ' + 
std::to_string(type) + ' ' + payload);
 }
 else
-tileQueue->put("callback " + std::to_string(descriptor->ViewId) + 
' ' + std::to_string(type) + ' ' + payload);
+tileQueue->put("callback " + 
std::to_string(descriptor->getViewId()) + ' ' + std::to_string(type) + ' ' + 
payload);
 }
 
 private:
diff --git a/kit/Kit.hpp b/kit/Kit.hpp
index cf7d34d46..efd768f14 100644
--- a/kit/Kit.hpp
+++ b/kit/Kit.hpp
@@ -49,8 +49,26 @@ class DocumentManagerInterface;
 /// callback to a specific view.
 struct CallbackDescriptor
 {
-DocumentManagerInterface* const Doc;
-const int ViewId;
+CallbackDescriptor(DocumentManagerInterface* const doc,
+   const int viewId) :
+_doc(doc),
+_viewId(viewId)
+{
+}
+
+DocumentManagerInterface* getDoc() const
+{
+return _doc;
+}
+
+int getViewId() const
+{
+return _viewId;
+}
+
+private:
+DocumentManagerInterface* const _doc;
+const int _viewId;
 };
 
 /// User Info container used to store user information
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2018-10-30 Thread Libreoffice Gerrit user
 kit/Kit.cpp  |2 ++
 net/WebSocketHandler.hpp |3 +--
 wsd/DocumentBroker.cpp   |3 ++-
 wsd/LOOLWSD.cpp  |   21 +
 wsd/Storage.cpp  |2 +-
 5 files changed, 19 insertions(+), 12 deletions(-)

New commits:
commit ffe66b3efc1809415fb78f3525b2e9b6e1518d17
Author: Tor Lillqvist 
AuthorDate: Tue Oct 30 21:52:26 2018 +0200
Commit: Tor Lillqvist 
CommitDate: Tue Oct 30 22:03:04 2018 +0200

Avoid 'Unused variable' warnings in the MOBILEAPP casse

Change-Id: I30d631559379da4baa5a73712f002435b1a36360

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 46fb1efe4..d063e0bb6 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -757,7 +757,9 @@ private:
 std::vector _pixmap;
 };
 
+#ifndef MOBILEAPP
 static FILE* ProcSMapsFile = nullptr;
+#endif
 
 /// A document container.
 /// Owns LOKitDocument instance and connections.
diff --git a/net/WebSocketHandler.hpp b/net/WebSocketHandler.hpp
index f6457787e..a037cb6b5 100644
--- a/net/WebSocketHandler.hpp
+++ b/net/WebSocketHandler.hpp
@@ -209,7 +209,6 @@ public:
 _wsPayload.insert(_wsPayload.end(), p, p + len);
 const size_t headerLen = 0;
 const size_t payloadLen = len;
-const bool hasMask = false;
 #endif
 
 assert(_wsPayload.size() >= payloadLen);
@@ -445,9 +444,9 @@ private:
 
 socket->assertCorrectThread();
 std::vector& out = socket->getOutBuffer();
-const size_t oldSize = out.size();
 
 #ifndef MOBILEAPP
+const size_t oldSize = out.size();
 
 out.push_back(flags);
 
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 015deb26e..2aa4edda8 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -473,9 +473,10 @@ bool DocumentBroker::load(const 
std::shared_ptr& session, const s
 std::string userId, username;
 std::string userExtraInfo;
 std::string watermarkText;
-std::chrono::duration getInfoCallDuration(0);
 
 #ifndef MOBILEAPP
+std::chrono::duration getInfoCallDuration(0);
+
 WopiStorage* wopiStorage = dynamic_cast(_storage.get());
 if (wopiStorage != nullptr)
 {
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 8d281a2f5..e7e49e021 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -189,13 +189,6 @@ ServerSocket::Type ClientListenAddr = 
ServerSocket::Type::Public;
 /// Port for prisoners to connect to
 int MasterPortNumber = DEFAULT_MASTER_PORT_NUMBER;
 
-/// New LOK child processes ready to host documents.
-//TODO: Move to a more sensible namespace.
-static bool DisplayVersion = false;
-
-/// Funky latency simulation basic delay (ms)
-static int SimulatedLatencyMs = 0;
-
 // Tracks the set of prisoners / children waiting to be used.
 static std::mutex NewChildrenMutex;
 static std::condition_variable NewChildrenCV;
@@ -219,8 +212,19 @@ std::string LOOLWSD::Cache = LOOLWSD_CACHEDIR;
 std::set LOOLWSD::EditFileExtensions;
 
 #ifdef MOBILEAPP
+
 // Or can this be retreieved in some other way?
 int LOOLWSD::prisonerServerSocketFD;
+
+#else
+
+/// New LOK child processes ready to host documents.
+//TODO: Move to a more sensible namespace.
+static bool DisplayVersion = false;
+
+/// Funky latency simulation basic delay (ms)
+static int SimulatedLatencyMs = 0;
+
 #endif
 
 namespace
@@ -1789,11 +1793,12 @@ private:
 Poco::MemoryInputStream message(>getInBuffer()[0],
 socket->getInBuffer().size());;
 Poco::Net::HTTPRequest request;
-size_t requestSize = 0;
 
 try
 {
 #ifndef MOBILEAPP
+size_t requestSize = 0;
+
 if (!socket->parseHeader("Prisoner", message, request, 
))
 return;
 
diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index c589e988e..8e46dc333 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -86,8 +86,8 @@ size_t StorageBase::getFileSize(const std::string& filename)
 
 void StorageBase::initialize()
 {
-const auto& app = Poco::Util::Application::instance();
 #ifndef MOBILEAPP
+const auto& app = Poco::Util::Application::instance();
 FilesystemEnabled = app.config().getBool("storage.filesystem[@allow]", 
false);
 
 // Parse the WOPI settings.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2018-10-30 Thread Libreoffice Gerrit user
 kit/Kit.cpp |4 
 1 file changed, 4 insertions(+)

New commits:
commit 888b529ffcf9941c59d5aa66db05471a4062560f
Author: Tor Lillqvist 
AuthorDate: Tue Oct 30 21:09:43 2018 +0200
Commit: Tor Lillqvist 
CommitDate: Tue Oct 30 21:09:43 2018 +0200

For MOBILEAPP, call SocketPoll::wakeupWorld() when lokit_main() is dying

This wakes up the mainWait poll in LOOLWSD::innerMain(), causing the
process to get back to the clean idle state right away, without having
to wait for the mainWait poll to get a timeout.

Change-Id: Ifbe586d41661737be2864bedaddf9a40d23501f4

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index cbfa9f01e..46fb1efe4 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -2508,6 +2508,10 @@ void lokit_main(
 
 LOG_INF("Kit poll terminated.");
 
+#ifdef MOBILEAPP
+SocketPoll::wakeupWorld();
+#endif
+
 // Let forkit handle the jail cleanup.
 }
 catch (const Exception& exc)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2018-10-26 Thread Libreoffice Gerrit user
 kit/Kit.cpp |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit f7ebab8902609c4b19e84472c9bd986b16e755db
Author: Tor Lillqvist 
AuthorDate: Fri Oct 26 10:22:33 2018 +0300
Commit: Tor Lillqvist 
CommitDate: Fri Oct 26 10:22:33 2018 +0300

Use Poco to convert from pathname to URI

(Yesterday I talked about GLib in a commit message, I meant Poco of
course, for this source file. It's gtk/mobile.cpp that uses GTK+.)

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index e37a88e98..3654865ca 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -2454,7 +2454,8 @@ void lokit_main(
 #else // MOBILEAPP
 
 #ifdef __linux
-LibreOfficeKit *kit = lok_init_2(LO_PATH "/program", "file://" 
LO_PATH);
+Poco::URI userInstallationURI("file", LO_PATH);
+LibreOfficeKit *kit = lok_init_2(LO_PATH "/program", 
userInstallationURI.toString().c_str());
 #else
 LibreOfficeKit *kit = lok_init_2(nullptr, nullptr);
 #endif
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2018-10-15 Thread Libreoffice Gerrit user
 kit/Kit.cpp |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit ef3e09728fabcf5165c1f2afe85aa40f5709e17c
Author: Tor Lillqvist 
AuthorDate: Mon Oct 15 18:59:51 2018 +0300
Commit: Tor Lillqvist 
CommitDate: Tue Oct 16 01:03:47 2018 +0300

Revert "Drop one use of TerminationFlag"

Turns out not to be useful for the iOS app after all.

This reverts commit bff5c176937543540c521882994900339a4191e7.

Change-Id: I93367e9de1b6e66b1cbb7587259f1136564e53a4

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index c22fae469..d609fcb28 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -2433,12 +2433,12 @@ void lokit_main(
 
 if (document && document->purgeSessions() == 0)
 {
-LOG_INF("Last session discarded. Breaking out of loop");
-break;
+LOG_INF("Last session discarded. Setting TerminationFlag");
+TerminationFlag = true;
 }
 }
 
-LOG_INF("Kit poll finished.");
+LOG_INF("Kit poll terminated.");
 
 // Let forkit handle the jail cleanup.
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2018-10-15 Thread Libreoffice Gerrit user
 kit/Kit.cpp |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit c05079d6d5d6f253e9aeaf3560574f50979bc85e
Author: Tor Lillqvist 
AuthorDate: Mon Oct 15 16:41:52 2018 +0300
Commit: Tor Lillqvist 
CommitDate: Tue Oct 16 00:08:44 2018 +0300

Mention TerminationFlag in a couple more log lines

Why log something vague like "Stop flagged" when we can log what we
actually do?

Also, the log lines already include the name of the thread, so no need
to prefix with "Kit:".

Change-Id: I5a05492aa4e8a26714889cc6341a26862c80e4d0

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 2c99d962c..c22fae469 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1851,7 +1851,7 @@ private:
 
 if (_stop || TerminationFlag)
 {
-LOG_INF("Kit: Stop flagged.");
+LOG_INF("_stop or TerminationFlag is set, breaking out of 
loop");
 break;
 }
 
@@ -2066,7 +2066,7 @@ protected:
 // Note: Syntax or parsing errors here are unexpected and fatal.
 if (TerminationFlag)
 {
-LOG_DBG("Too late, we're going down");
+LOG_DBG("Too late, TerminationFlag is set, we're going down");
 }
 else if (tokens[0] == "session")
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2018-10-15 Thread Libreoffice Gerrit user
 kit/Kit.cpp |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit bff5c176937543540c521882994900339a4191e7
Author: Tor Lillqvist 
AuthorDate: Mon Oct 15 16:56:00 2018 +0300
Commit: Tor Lillqvist 
CommitDate: Mon Oct 15 17:59:40 2018 +0300

Drop one use of TerminationFlag

Doesn't help my current issue in the iOS app, but the less use of
TerminationFlag the better, I think. (Doesn't break 'make check' on
Linux.)

Change-Id: I8fef271d6e0e81dea92e0da76ecb7211239adab6

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index e726055dc..2c99d962c 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -2433,12 +2433,12 @@ void lokit_main(
 
 if (document && document->purgeSessions() == 0)
 {
-LOG_INF("Last session discarded. Setting TerminationFlag");
-TerminationFlag = true;
+LOG_INF("Last session discarded. Breaking out of loop");
+break;
 }
 }
 
-LOG_INF("Kit poll terminated.");
+LOG_INF("Kit poll finished.");
 
 // Let forkit handle the jail cleanup.
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp net/Socket.hpp

2018-09-17 Thread Libreoffice Gerrit user
 kit/Kit.cpp|6 --
 net/Socket.hpp |4 
 2 files changed, 10 deletions(-)

New commits:
commit 7fd28d5676642332d537a90de5194740cedd4cec
Author: Tor Lillqvist 
AuthorDate: Mon Sep 17 13:44:29 2018 +0300
Commit: Miklos Vajna 
CommitDate: Mon Sep 17 12:51:07 2018 +0200

Revert part of my iOS related commit, causes compilation warning with Clang

Won't actually be needed anyway, the way the code is going in my work
tree.

Change-Id: I4480ed59fe96ddcfad8483517f2a23452606f332
Reviewed-on: https://gerrit.libreoffice.org/60576
Reviewed-by: Miklos Vajna 
Tested-by: Miklos Vajna 

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index f67617a8f..1161507c2 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -2054,12 +2054,6 @@ protected:
 {
 std::string message(data.data(), data.size());
 
-handleMessage(message);
-}
-
-void handleMessage(const std::string& message) override
-{
-
 #if 0 // FIXME might be needed for unit tests #ifndef KIT_IN_PROCESS
 if (UnitKit::get().filterKitMessage(ws, message))
 {
diff --git a/net/Socket.hpp b/net/Socket.hpp
index 3e86055e0..3a081d526 100644
--- a/net/Socket.hpp
+++ b/net/Socket.hpp
@@ -340,10 +340,6 @@ public:
 
 /// Append pretty printed internal state to a line
 virtual void dumpState(std::ostream& os) { os << "\n"; }
-
-virtual void handleMessage(const std::string& /*message*/)
-{
-}
 };
 
 /// Handles non-blocking socket event polling.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2018-09-12 Thread Libreoffice Gerrit user
 kit/Kit.cpp |1 -
 1 file changed, 1 deletion(-)

New commits:
commit 290137c99b979979dec62259f1b0ca0fd0073941
Author: Tor Lillqvist 
AuthorDate: Tue Sep 11 13:11:51 2018 +0300
Commit: Tor Lillqvist 
CommitDate: Wed Sep 12 13:36:00 2018 +0300

Bin unnecessary assert(loKit)

We already explicitly check earlier, after attempting to create it,
and log a fatal error and exit on failure.

Change-Id: Ia3fde4026839a255d4d19932300e16a05f9a33d2

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 1c7ec94ff..dc792b865 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -2346,7 +2346,6 @@ void lokit_main(const std::string& childRoot,
 else
 LOG_SYS("Failed to get RLIMIT_NOFILE.");
 
-assert(loKit);
 LOG_INF("Process is ready.");
 
 static const std::string pid = std::to_string(Process::id());
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2018-09-11 Thread Libreoffice Gerrit user
 kit/Kit.cpp |1 +
 1 file changed, 1 insertion(+)

New commits:
commit d5f913486ac42a8c73942b5c07bdd459ff64e74b
Author: Tor Lillqvist 
AuthorDate: Tue Sep 11 13:01:37 2018 +0300
Commit: Tor Lillqvist 
CommitDate: Tue Sep 11 13:01:37 2018 +0300

Add a clarifying comment

Change-Id: Ia32b3ad65dd410e0f9f9d18c11be2d566ca0d6e0

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index da518d2fa..1c7ec94ff 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -2062,6 +2062,7 @@ protected:
 
 if (!document)
 {
+// Creating the Document object starts a thread running 
Document::run().
 document = std::make_shared(_loKit, _jailId, docKey, 
docId, url, _queue, _socketPoll, shared_from_this());
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2018-05-28 Thread Miklos Vajna
 kit/Kit.cpp |   18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

New commits:
commit d718b1c0545fe77b0552269057bff707f8bee347
Author: Miklos Vajna 
Date:   Mon May 28 09:11:06 2018 +0200

kit: let alphaBlend() take an std::vector instead of raw pointer

So that it's more obvious that the two for loops don't read past the end
of the vector.

Change-Id: I49752c1bc316b6d73568ab334b07727ef60bdce5

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 25b03f2af..8ef9840bd 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -600,19 +600,19 @@ public:
 offsetX += (tileWidth - maxX) / 2;
 offsetY += (tileHeight - maxY) / 2;
 
-alphaBlend(pixmap->data(), _width, _height, offsetX, offsetY, 
tilePixmap, tilesPixmapWidth, tilesPixmapHeight);
+alphaBlend(*pixmap, _width, _height, offsetX, offsetY, tilePixmap, 
tilesPixmapWidth, tilesPixmapHeight);
 }
 }
 
 private:
 /// Alpha blend pixels from 'from' over the 'to'.
-void alphaBlend(const unsigned char* from, int from_width, int 
from_height, int from_offset_x, int from_offset_y,
+void alphaBlend(const std::vector& from, int from_width, 
int from_height, int from_offset_x, int from_offset_y,
 unsigned char* to, int to_width, int to_height)
 {
 for (int to_y = from_offset_y, from_y = 0; (to_y < to_height) && 
(from_y < from_height) ; ++to_y, ++from_y)
 for (int to_x = from_offset_x, from_x = 0; (to_x < to_width) && 
(from_x < from_width); ++to_x, ++from_x)
 {
-const unsigned char* f = from + 4 * (from_y * from_width + 
from_x);
+const unsigned char* f = from.data() + 4 * (from_y * 
from_width + from_x);
 double src_r = f[0];
 double src_g = f[1];
 double src_b = f[2];
@@ -657,14 +657,19 @@ private:
 // are always set to 0 (black) and the alpha level is 0 everywhere
 // except on the text area; the alpha level take into account of
 // performing anti-aliasing over the text edges.
-unsigned char* text = _loKitDoc->renderFont(_font.c_str(), 
_text.c_str(), &_width, &_height);
+unsigned char* textPixels = _loKitDoc->renderFont(_font.c_str(), 
_text.c_str(), &_width, &_height);
 
-if (!text)
+if (!textPixels)
 {
 LOG_ERR("Watermark: rendering failed.");
 }
 
 const unsigned int pixel_count = width * height * 4;
+
+std::vector text(textPixels, textPixels + pixel_count);
+// No longer needed.
+std::free(textPixels);
+
 _pixmap.reserve(pixel_count);
 
 // Create the white blurred background
@@ -703,9 +708,6 @@ private:
 // Now copy the (black) text over the (white) blur
 alphaBlend(text, _width, _height, 0, 0, _pixmap.data(), _width, 
_height);
 
-// No longer needed.
-std::free(text);
-
 // Make the resulting pixmap semi-transparent
 for (unsigned char* p = _pixmap.data(); p < _pixmap.data() + 
pixel_count; p++)
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2018-05-25 Thread Miklos Vajna
 kit/Kit.cpp |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 8f4c348be35e63af28ea54093ba571b7ce3275b8
Author: Miklos Vajna 
Date:   Fri May 25 09:11:44 2018 +0200

kit: let getPixmap() return an std::vector instead of raw pointer

So the callers can know not only the address of the pixmap, but also the
size of it.

Change-Id: I3aecc33cb354f5878364b11398c276fcabd3103e

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 0b02d5569..25b03f2af 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -590,7 +590,7 @@ public:
 int width = tileWidth * 0.9;
 int height = tileHeight * 0.9;
 
-const unsigned char* pixmap = getPixmap(width, height);
+const std::vector* pixmap = getPixmap(width, height);
 
 if (pixmap && tilePixmap)
 {
@@ -600,7 +600,7 @@ public:
 offsetX += (tileWidth - maxX) / 2;
 offsetY += (tileHeight - maxY) / 2;
 
-alphaBlend(pixmap, _width, _height, offsetX, offsetY, tilePixmap, 
tilesPixmapWidth, tilesPixmapHeight);
+alphaBlend(pixmap->data(), _width, _height, offsetX, offsetY, 
tilePixmap, tilesPixmapWidth, tilesPixmapHeight);
 }
 }
 
@@ -637,10 +637,10 @@ private:
 }
 
 /// Create bitmap that we later use as the watermark for every tile.
-const unsigned char* getPixmap(int width, int height)
+const std::vector* getPixmap(int width, int height)
 {
 if (!_pixmap.empty() && width == _width && height == _height)
-return _pixmap.data();
+return &_pixmap;
 
 _pixmap.clear();
 
@@ -712,7 +712,7 @@ private:
 *p = static_cast(*p * _alphaLevel);
 }
 
-return _pixmap.data();
+return &_pixmap;
 }
 
 private:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2018-05-23 Thread Miklos Vajna
 kit/Kit.cpp |4 
 1 file changed, 4 deletions(-)

New commits:
commit 51631b4e2295d7e40a0a6a03771e15609d96c730
Author: Miklos Vajna 
Date:   Wed May 23 09:13:47 2018 +0200

kit: remove unused using declarations

Change-Id: Ide76d327b3b064180aa4eaa28f13827d665edaa5

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index b76dc1094..0b02d5569 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -82,7 +82,6 @@ using Poco::File;
 using Poco::JSON::Array;
 using Poco::JSON::Object;
 using Poco::JSON::Parser;
-using Poco::Net::WebSocket;
 using Poco::Runnable;
 using Poco::StringTokenizer;
 using Poco::Thread;
@@ -91,9 +90,6 @@ using Poco::URI;
 using Poco::Util::Application;
 
 #ifndef BUILDING_TESTS
-using Poco::Net::HTTPClientSession;
-using Poco::Net::HTTPRequest;
-using Poco::Net::HTTPResponse;
 using Poco::Path;
 using Poco::Process;
 #endif
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2018-05-18 Thread Michael Meeks
 kit/Kit.cpp |6 ++
 1 file changed, 6 insertions(+)

New commits:
commit c5cef26fb6dfa4153e7d7ef16eb3fd366696aebc
Author: Michael Meeks 
Date:   Fri May 18 16:05:36 2018 +0100

Shutdown kit process if connection dies.

Change-Id: I34e627a03a9859ccd3ae9f9925fe6ab080697b72

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index d7f4cc05b..b76dc1094 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -2092,6 +2092,12 @@ protected:
 LOG_ERR("Bad or unknown token [" << tokens[0] << "]");
 }
 }
+
+void onDisconnect() override
+{
+LOG_WRN("Kit connection lost without exit arriving from wsd");
+TerminationFlag = true;
+}
 };
 
 void documentViewCallback(const int type, const char* payload, void* data)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2018-03-28 Thread Tor Lillqvist
 kit/Kit.cpp |4 
 1 file changed, 4 insertions(+)

New commits:
commit e9ea5e8bc7a42abc016e55038bea55b7b594664b
Author: Tor Lillqvist 
Date:   Wed Mar 28 20:17:32 2018 +0300

Python is also a special snowflake

Change-Id: I1689f992494e1abe50c45b1ae975b76b00e1b080

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index dfc8e2950..ffed796fb 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -172,6 +172,10 @@ namespace
 strstr(path, "libfreeblpriv3"))
 return true;
 
+// As is Python ...
+if (strstr(path, "python-core"))
+return true;
+
 // otherwise drop the rest of the code.
 return false;
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2018-03-28 Thread Tor Lillqvist
 kit/Kit.cpp |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit bb4c1a7fa701f791dbcb2f0b929306c6e816034f
Author: Tor Lillqvist 
Date:   Mon Jan 15 13:45:35 2018 +0200

Don't filter out all scripts, just Java and JavaScript ones

Change-Id: I3054a3f36ae1777b162fb5a1b9a456f1bce9248b
Reviewed-on: https://gerrit.libreoffice.org/51991
Reviewed-by: Tor Lillqvist 
Tested-by: Tor Lillqvist 

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index ddd0b2c83..90e9d58df 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -136,7 +136,8 @@ namespace
 strcmp(path, "sdk") != 0 &&
 strcmp(path, "share/basic") != 0 &&
 strcmp(path, "share/gallery") != 0 &&
-strcmp(path, "share/Scripts") != 0 &&
+strcmp(path, "share/Scripts/java") != 0 &&
+strcmp(path, "share/Scripts/javascript") != 0 &&
 strcmp(path, "share/template") != 0 &&
 strcmp(path, "share/config/wizard") != 0 &&
 strcmp(path, "share/config/wizard") != 0;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2018-03-14 Thread Miklos Vajna
 kit/Kit.cpp |   21 -
 1 file changed, 8 insertions(+), 13 deletions(-)

New commits:
commit b6e1a4e281d004b4d65c024747e780cbb5d91609
Author: Miklos Vajna 
Date:   Fri Mar 9 09:14:44 2018 +0100

kit: avoid manual management for Watermark::_pixmap

A simple std::vector is enough here and results in simpler code.

Change-Id: I7e6ad268aca13c4efb445c7918a3afd14e0ed146

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index d0e068d28..9868224d1 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -15,7 +15,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -562,14 +561,11 @@ public:
 , _width(0)
 , _height(0)
 , _alphaLevel(0.2)
-, _pixmap(nullptr)
 {
 }
 
 ~Watermark()
 {
-if (_pixmap)
-std::free(_pixmap);
 }
 
 void blending(unsigned char* tilePixmap,
@@ -631,11 +627,10 @@ private:
 /// Create bitmap that we later use as the watermark for every tile.
 const unsigned char* getPixmap(int width, int height)
 {
-if (_pixmap && width == _width && height == _height)
-return _pixmap;
+if (!_pixmap.empty() && width == _width && height == _height)
+return _pixmap.data();
 
-if (_pixmap)
-std::free(_pixmap);
+_pixmap.clear();
 
 _width = width;
 _height = height;
@@ -658,7 +653,7 @@ private:
 }
 
 const unsigned int pixel_count = width * height * 4;
-_pixmap = static_cast(malloc(pixel_count));
+_pixmap.reserve(pixel_count);
 
 // Create the white blurred background
 // Use box blur, it's enough for our purposes
@@ -694,18 +689,18 @@ private:
 }
 
 // Now copy the (black) text over the (white) blur
-alphaBlend(text, _width, _height, 0, 0, _pixmap, _width, _height);
+alphaBlend(text, _width, _height, 0, 0, _pixmap.data(), _width, 
_height);
 
 // No longer needed.
 std::free(text);
 
 // Make the resulting pixmap semi-transparent
-for (unsigned char* p = _pixmap; p < _pixmap + pixel_count; p++)
+for (unsigned char* p = _pixmap.data(); p < _pixmap.data() + 
pixel_count; p++)
 {
 *p = static_cast(*p * _alphaLevel);
 }
 
-return _pixmap;
+return _pixmap.data();
 }
 
 private:
@@ -715,7 +710,7 @@ private:
 int _width;
 int _height;
 double _alphaLevel;
-unsigned char* _pixmap;
+std::vector _pixmap;
 };
 
 static FILE* ProcSMapsFile = nullptr;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2018-01-30 Thread Samuel Mehrbrodt
 kit/Kit.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit e89584f933148dae4129dfd9aa7e1621e9a61ecf
Author: Samuel Mehrbrodt 
Date:   Thu Jan 25 15:15:37 2018 +0100

Show info instead of error when linking is not possible

we still try to copy the file after this and fail if that doesn't work.

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index b644a029..7651722b 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -215,7 +215,7 @@ namespace
 LOG_INF("Linking file \"" << fpath << "\" to \"" << 
newPath.toString() << "\"");
 if (link(fpath, newPath.toString().c_str()) == -1)
 {
-LOG_SYS("link(\"" << fpath << "\", \"" <<
+LOG_INF("link(\"" << fpath << "\", \"" <<
 newPath.toString() << "\") failed. Will copy.");
 try
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2018-01-29 Thread Michael Meeks
 kit/Kit.cpp |   64 ++--
 1 file changed, 50 insertions(+), 14 deletions(-)

New commits:
commit fbc28b91b38de357b43fbf549ba2bf99832d05f2
Author: Michael Meeks 
Date:   Mon Jan 22 16:39:50 2018 +

Avoid copying code into the chroot if LINK_NO_CODE is set.

Change-Id: Ibba7dfa87c779b4d809cc2ac53d0802bba1c37ef

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index c853b3ed..b644a029 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -146,6 +146,39 @@ namespace
 }
 }
 
+bool shouldLinkFile(const char *path)
+{
+static bool avoidCode = getenv("LINK_NO_CODE");
+
+if (!avoidCode)
+return true;
+
+switch (linkOrCopyType)
+{
+case LinkOrCopyType::LO:
+{
+const char *dot = strrchr(path, '.');
+if (!dot)
+return true;
+if (!strcmp(dot, ".dbg") ||
+!strcmp(dot, ".so"))
+return false;
+const char *vers;
+if ((vers = strstr(path, ".so."))) // .so.[digit]+
+{
+for(int i = sizeof (".so."); vers[i] != '\0'; ++i)
+if (!isdigit(vers[i]) && vers[i] != '.')
+return true;
+return false;
+}
+return true;
+}
+case LinkOrCopyType::NoUsr:
+default: // LinkOrCopyType::All
+return true;
+}
+}
+
 int linkOrCopyFunction(const char *fpath,
const struct stat* /*sb*/,
int typeflag,
@@ -176,21 +209,24 @@ namespace
 case FTW_SLN:
 File(newPath.parent()).createDirectories();
 
-if (linkOrCopyVerboseLogging)
-LOG_INF("Linking file \"" << fpath << "\" to \"" << 
newPath.toString() << "\"");
-if (link(fpath, newPath.toString().c_str()) == -1)
+if (shouldLinkFile(relativeOldPath))
 {
-LOG_SYS("link(\"" << fpath << "\", \"" <<
-newPath.toString() << "\") failed. Will copy.");
-try
-{
-File(fpath).copyTo(newPath.toString());
-}
-catch (const std::exception& exc)
+if (linkOrCopyVerboseLogging)
+LOG_INF("Linking file \"" << fpath << "\" to \"" << 
newPath.toString() << "\"");
+if (link(fpath, newPath.toString().c_str()) == -1)
 {
-LOG_ERR("Copying of '" << fpath << "' to " << 
newPath.toString() <<
-" failed: " << exc.what() << ". Exiting.");
-std::_Exit(Application::EXIT_SOFTWARE);
+LOG_SYS("link(\"" << fpath << "\", \"" <<
+newPath.toString() << "\") failed. Will copy.");
+try
+{
+File(fpath).copyTo(newPath.toString());
+}
+catch (const std::exception& exc)
+{
+LOG_ERR("Copying of '" << fpath << "' to " << 
newPath.toString() <<
+" failed: " << exc.what() << ". Exiting.");
+std::_Exit(Application::EXIT_SOFTWARE);
+}
 }
 }
 break;
@@ -2039,7 +2075,7 @@ void lokit_main(const std::string& childRoot,
 const auto etcPathString = etcPath.toString();
 if (File(filename).exists() && !File(etcPathString).exists() )
 {
-linkOrCopy( filename, etcPath, LinkOrCopyType::LO );
+linkOrCopy( filename, etcPath, LinkOrCopyType::All );
 }
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2018-01-26 Thread Pranav Kant
 kit/Kit.cpp |   24 
 1 file changed, 24 insertions(+)

New commits:
commit 1d22f7bc548dc48c95390c6f23b67f1972825617
Author: Pranav Kant 
Date:   Fri Jan 26 21:04:49 2018 +0530

kit: start spamming the logs when linking/copying is slowww

This is sometimes the case in docker when the link operation 'copies up'
things from lower layers to the working docker container's layer. In
such cases, let the admin know.

Change-Id: Ib72b67304a292c3832838379cc76bcb4a7268cb3
Reviewed-on: https://gerrit.libreoffice.org/48710
Reviewed-by: pranavk 
Tested-by: pranavk 

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index f38af663..c853b3ed 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -120,6 +120,9 @@ namespace
 LinkOrCopyType linkOrCopyType;
 std::string sourceForLinkOrCopy;
 Path destinationForLinkOrCopy;
+std::chrono::time_point linkOrCopyStartTime;
+bool linkOrCopyVerboseLogging = false;
+unsigned slowLinkOrCopyLimitInSecs = 10; // after this much seconds, start 
spamming the logs
 
 bool shouldCopyDir(const char *path)
 {
@@ -151,6 +154,18 @@ namespace
 if (strcmp(fpath, sourceForLinkOrCopy.c_str()) == 0)
 return 0;
 
+if (!linkOrCopyVerboseLogging)
+{
+const auto durationInSecs = 
std::chrono::duration_cast(
+std::chrono::steady_clock::now() - linkOrCopyStartTime);
+if (durationInSecs.count() > slowLinkOrCopyLimitInSecs)
+{
+LOG_WRN("Linking/copying files from " << sourceForLinkOrCopy 
<< " to " << destinationForLinkOrCopy.toString() <<
+" is taking too much time. Enabling verbose link/copy 
logging at information level.");
+linkOrCopyVerboseLogging = true;
+}
+}
+
 assert(fpath[strlen(sourceForLinkOrCopy.c_str())] == '/');
 const char *relativeOldPath = fpath + 
strlen(sourceForLinkOrCopy.c_str()) + 1;
 Path newPath(destinationForLinkOrCopy, Path(relativeOldPath));
@@ -160,6 +175,9 @@ namespace
 case FTW_F:
 case FTW_SLN:
 File(newPath.parent()).createDirectories();
+
+if (linkOrCopyVerboseLogging)
+LOG_INF("Linking file \"" << fpath << "\" to \"" << 
newPath.toString() << "\"");
 if (link(fpath, newPath.toString().c_str()) == -1)
 {
 LOG_SYS("link(\"" << fpath << "\", \"" <<
@@ -223,10 +241,16 @@ namespace
 if (sourceForLinkOrCopy.back() == '/')
 sourceForLinkOrCopy.pop_back();
 destinationForLinkOrCopy = destination;
+linkOrCopyStartTime = std::chrono::steady_clock::now();
 if (nftw(source.c_str(), linkOrCopyFunction, 10, FTW_ACTIONRETVAL) == 
-1)
 {
 LOG_ERR("linkOrCopy: nftw() failed for '" << source << "'");
 }
+if (linkOrCopyVerboseLogging)
+{
+LOG_INF("Linking/Copying of files to " << 
destinationForLinkOrCopy.toString() << " finished.");
+linkOrCopyVerboseLogging = false;
+}
 }
 
 void dropCapability(cap_value_t capability)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2018-01-21 Thread Henry Castro
 kit/Kit.cpp |   21 -
 1 file changed, 21 deletions(-)

New commits:
commit 90cd7791fa9088d0f7e2e09fceac13db20274e59
Author: Henry Castro 
Date:   Sat Jan 20 16:30:33 2018 -0400

kit: remove unused debug code

Change-Id: Ibd69a2b451be0a075759524acff5f0e9fc820d05

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index d3ac6bc9..4d054427 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -2246,27 +2246,6 @@ void lokit_main(const std::string& childRoot,
 return TerminationFlag.load();
 });
 
-#if 0
-std::string uri = "file://$HOME/docs/basic-presentation.pptx";
-std::shared_ptr loKitDoc;
-
-const auto flags = LOK_FEATURE_DOCUMENT_PASSWORD
-   | LOK_FEATURE_DOCUMENT_PASSWORD_TO_MODIFY
-   | LOK_FEATURE_PART_IN_INVALIDATION_CALLBACK
-   | LOK_FEATURE_NO_TILED_ANNOTATIONS
-   | LOK_FEATURE_RANGE_HEADERS;
-loKit->setOptionalFeatures(flags);
-loKitDoc.reset(loKit->documentLoad(uri.c_str()));
-if (!loKitDoc || !loKitDoc->get())
-{
-LOG_ERR("Failed to load: " << uri << ", error: " << 
loKit->getError());
-std::_Exit(Application::EXIT_OK);
-}
-
-// specific case to debug
-// ...
-#endif
-
 // Let forkit handle the jail cleanup.
 }
 catch (const Exception& exc)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp test/UnitFuzz.cpp wsd/LOOLWSD.cpp

2018-01-10 Thread Tor Lillqvist
 kit/Kit.cpp   |2 +-
 test/UnitFuzz.cpp |7 ---
 wsd/LOOLWSD.cpp   |6 --
 3 files changed, 1 insertion(+), 14 deletions(-)

New commits:
commit 217636ed4472acac4c3dda1a52ded64981cdc6eb
Author: Tor Lillqvist 
Date:   Wed Jan 10 13:44:23 2018 +0200

Drop meaningless "loolnb" word from a comment, drop two related #if 0 blocks

"loolnb" used to mean the concept of using non-blocking sockets back
when that was experimental proof-of-concept work in progress, but that
work has been merged in long ago and there is no neeed for the term
any longer.

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 8bb4864c..d3ac6bc9 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1637,7 +1637,7 @@ private:
 std::vector vect(size);
 vect.assign(data, data + size);
 
-// TODO loolnb - this is probably wrong...
+// TODO this is probably wrong...
 session->handleMessage(/* fin = */ false, 
WSOpCode::Binary, vect);
 return true;
 }
diff --git a/test/UnitFuzz.cpp b/test/UnitFuzz.cpp
index 075fb110..7d09819f 100644
--- a/test/UnitFuzz.cpp
+++ b/test/UnitFuzz.cpp
@@ -124,13 +124,6 @@ public:
 SocketDisposition & /* disposition */,
 WebSocketHandler & /* socket */) override
 {
-#if 0 // loolnb
-if (_dist(_mt) < 10) // 1%
-{
-std::cerr << "Mangle request URI\n";
-request.setURI(corruptString(request.getURI()));
-}
-#endif
 return false;
 }
 };
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index adbe06c0..289df5aa 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2902,12 +2902,6 @@ void UnitWSD::testHandleRequest(TestRequest type, 
UnitHTTPServerRequest& /* requ
 switch (type)
 {
 case TestRequest::Client:
-#if 0 // loolnb
-ClientRequestHandler::handleClientRequest(request, response, 
LOOLWSD::GenSessionId());
-break;
-case TestRequest::Prisoner:
-PrisonerRequestHandler::handlePrisonerRequest(request, response);
-#endif
 break;
 default:
 assert(false);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2017-12-04 Thread Pranav Kant
 kit/Kit.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 155b3131fc78ca7d7807c67d6781eee884aa20fd
Author: Pranav Kant 
Date:   Tue Dec 5 09:38:04 2017 +0530

Fix build; -Wunused-var

Change-Id: Iba03c7b64188c89d668aac07365fd8c706eeefdd

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 37405142..4e83df9b 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -408,7 +408,7 @@ class PngCache
int width, int height,
int bufferWidth, int bufferHeight,
std::vector& output, 
LibreOfficeKitTileMode mode,
-   TileBinaryHash hash, TileWireId wid, 
TileWireId oldWid)
+   TileBinaryHash hash, TileWireId wid, 
TileWireId /*oldWid*/)
 {
 LOG_DBG("PNG cache with hash " << hash << " missed.");
 /*
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2017-11-27 Thread Rene Engelhard
 kit/Kit.cpp |3 ---
 1 file changed, 3 deletions(-)

New commits:
commit 385008947d2f743f98bd61cbeebbadf7aa7cec61
Author: Rene Engelhard 
Date:   Tue Nov 28 01:10:18 2017 +0100

Revert "include "

This reverts commit af7685e49907f5b520ee9288b12f82d633ce9423.

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index aae8acf6..df2d6ce5 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -17,9 +17,6 @@
 #include 
 #include 
 #include 
-#ifdef __GLIBC__
-#include 
-#endif
 #include 
 #include 
 #include 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2017-11-26 Thread Rene Engelhard
 kit/Kit.cpp |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit af7685e49907f5b520ee9288b12f82d633ce9423
Author: Rene Engelhard 
Date:   Sun Nov 26 13:14:24 2017 +

include 

kit/Kit.cpp:1688:13: warning: In the GNU C Library, "makedev" is defined
 by . For historical compatibility, it is
 currently defined by  as well, but we plan to
 remove this soon. To use "makedev", include 
 directly. If you did not intend to use a system-defined macro
 "makedev", you should undefine it after including .

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index df2d6ce5..aae8acf6 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -17,6 +17,9 @@
 #include 
 #include 
 #include 
+#ifdef __GLIBC__
+#include 
+#endif
 #include 
 #include 
 #include 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp loleaflet/src

2017-11-08 Thread Pranav Kant
 kit/Kit.cpp|   89 +
 loleaflet/src/control/Control.LokDialog.js |   30 +
 loleaflet/src/control/Toolbar.js   |3 
 loleaflet/src/core/Socket.js   |   15 +++-
 loleaflet/src/layer/tile/TileLayer.js  |5 -
 5 files changed, 99 insertions(+), 43 deletions(-)

New commits:
commit a2a72572bbc7f48b6772ea5481b004102b3f08a0
Author: Pranav Kant 
Date:   Tue Nov 7 15:30:51 2017 +0530

lokdialog: Paint only part of the dialog when specified

Change-Id: I5543c95a48fd0192e5c654598991125bcaeb62e4
Reviewed-on: https://gerrit.libreoffice.org/44519
Reviewed-by: pranavk 
Tested-by: pranavk 

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index d798ce88..1a7d87c1 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -851,10 +851,6 @@ public:
 assert(ws && "Expected a non-null websocket.");
 
 const bool child = tokens[0] == "dialogchild";
-const int nCanvasWidth = 800;
-const int nCanvasHeight = 600;
-size_t pixmapDataSize = 4 * nCanvasWidth * nCanvasHeight;
-std::vector pixmap(pixmapDataSize);
 
 std::unique_lock lock(_documentMutex);
 if (!_loKitDocument)
@@ -869,38 +865,83 @@ public:
 return;
 }
 
-int nWidth = nCanvasWidth;
-int nHeight = nCanvasHeight;
-Timestamp timestamp;
+int startX = 0, startY = 0;
+int bufferWidth = 800, bufferHeight = 600; // hopefully, this is big 
enough
+std::string paintRectangle;
+// find the rectangle to paint, if specified
+if (tokens.size() >= 3 && getTokenString(tokens[2], "rectangle", 
paintRectangle))
+{
+const std::vector rectParts = 
LOOLProtocol::tokenize(paintRectangle.c_str(), paintRectangle.length(), ',');
+startX = std::atoi(rectParts[0].c_str());
+startY = std::atoi(rectParts[1].c_str());
+bufferWidth = std::atoi(rectParts[2].c_str());
+bufferHeight = std::atoi(rectParts[3].c_str());
+}
+
+size_t pixmapDataSize = 4 * bufferWidth * bufferHeight;
+std::vector pixmap(pixmapDataSize);
+
 char* pDialogTitle = nullptr;
+int width = bufferWidth;
+int height = bufferHeight;
+std::string response;
 if (child)
-_loKitDocument->paintActiveFloatingWindow(tokens[1].c_str(), 
pixmap.data(), nWidth, nHeight);
+{
+Timestamp timestamp;
+_loKitDocument->paintActiveFloatingWindow(tokens[1].c_str(), 
pixmap.data(), width, height);
+const auto elapsed = timestamp.elapsed();
+const double area = width * height;
+LOG_TRC("paintActiveFloatingWindow for " << tokens[1] << " 
returned floating window "
+<< width << "X" << height << " "
+<< "rendered in " << (elapsed/1000.)
+<< "ms (" << area / elapsed << " MP/s).");
+
+response = "dialogchildpaint: id=" + tokens[1] + " width=" + 
std::to_string(width) + " height=" + std::to_string(height) + "\n";
+}
 else
-_loKitDocument->paintDialog(tokens[1].c_str(), pixmap.data(), 
, nWidth, nHeight);
+{
+Timestamp timestamp;
+_loKitDocument->paintDialog(tokens[1].c_str(), pixmap.data(), 
startX, startY, width, height);
+const auto elapsed = timestamp.elapsed();
 
-const double area = nWidth * nHeight;
-const auto elapsed = timestamp.elapsed();
-LOG_TRC((child ? std::string("paintActiveFloatingWindow") : 
std::string("paintDialog")) +
-" for " << tokens[1] << " returned with size" << nWidth << "X" 
<< nHeight
-<< " and rendered in " << (elapsed/1000.) <<
-" ms (" << area / elapsed << " MP/s).");
+int dialogWidth = 0;
+int dialogHeight = 0;
+_loKitDocument->getDialogInfo(tokens[1].c_str(), , 
dialogWidth, dialogHeight);
 
-std::string encodedDialogTitle;
-if (pDialogTitle)
-{
-std::string aDialogTitle(pDialogTitle);
-URI::encode(aDialogTitle, "", encodedDialogTitle);
-free(pDialogTitle);
+std::string encodedDialogTitle;
+if (pDialogTitle)
+{
+std::string aDialogTitle(pDialogTitle);
+URI::encode(aDialogTitle, "", encodedDialogTitle);
+free(pDialogTitle);
+}
+
+// rendered width, height cannot be less than the dialog width, 
height
+width = std::min(width, dialogWidth);
+height = std::min(height, dialogHeight);
+const double area = width * height;
+
+LOG_TRC("paintDialog for " << tokens[1] << " returned " << width 
<< "X" << height
+<< "@(" << startX << "," << 

[Libreoffice-commits] online.git: kit/Kit.cpp

2017-10-03 Thread Pranav Kant
 kit/Kit.cpp |4 
 1 file changed, 4 insertions(+)

New commits:
commit c52cc45f08fed8d62d77d813c040c779e96171a2
Author: Pranav Kant 
Date:   Tue Oct 3 14:16:59 2017 +0530

Catch unknown exceptions and log it

... before lokit thread magically dissappears because some function in
LO core threw an 'Exception'

Change-Id: I8357b18d95674af8ec4d2f57ad41087f7b7dfcff

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index f1b2860b..3802ff59 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1751,6 +1751,10 @@ private:
 {
 LOG_ERR("QueueHandler::run: Exception: " << exc.what());
 }
+catch (...)
+{
+LOG_FTL("QueueHandler::run: Unknown exception");
+}
 
 LOG_DBG("Thread finished.");
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2017-09-13 Thread Miklos Vajna
 kit/Kit.cpp |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

New commits:
commit 84e4ea2c3d352a9058aa43e030acf483043ecb06
Author: Miklos Vajna 
Date:   Wed Sep 13 09:13:26 2017 +0200

Kit: pass by const reference and avoid redundant initializer

Change-Id: I550334ec9392121ff9084c35b5c8c6b410917080

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 63ebdbe1..1d1e700d 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -482,7 +482,7 @@ public:
 class Watermark
 {
 public:
-Watermark(std::shared_ptr loKitDoc, std::string text)
+Watermark(const std::shared_ptr& loKitDoc, const 
std::string& text)
 : _loKitDoc(loKitDoc)
 , _text(text)
 , _font("Liberation Sans")
@@ -628,7 +628,6 @@ public:
 _haveDocPassword(false),
 _isDocPasswordProtected(false),
 _docPasswordType(PasswordType::ToView),
-_docWatermark(),
 _stop(false),
 _isLoading(0),
 _editorId(-1),
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2017-08-16 Thread Tamas Bunth
 kit/Kit.cpp |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

New commits:
commit b285c5f321ebac5496b40399aede2e6b8c6cb1af
Author: Tamas Bunth 
Date:   Wed Aug 16 16:14:59 2017 +0200

Copy file with linkOrCopy

So that it can create folder in jails when needed.

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 228b87ab..a5a2be25 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1790,11 +1790,11 @@ void lokit_main(const std::string& childRoot,
 const auto networkFiles = {"/etc/host.conf", "/etc/hosts", 
"/etc/nsswitch.conf", "/etc/resolv.conf"};
 for (const auto& filename : networkFiles)
 {
-const auto etcPath = Path(jailPath, filename).toString();
-const File networkFile(filename);
-if (networkFile.exists() && !File(etcPath).exists())
+const auto etcPath = Path(jailPath, filename);
+const auto etcPathString = etcPath.toString();
+if (File(filename).exists() && !File(etcPathString).exists() )
 {
-networkFile.copyTo(etcPath);
+linkOrCopy( filename, etcPath, LinkOrCopyType::LO );
 }
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2017-07-20 Thread Pranav Kant
 kit/Kit.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit a283942b00b1f28be6c47d8b61494f4c8c15c348
Author: Pranav Kant 
Date:   Thu Jul 20 21:08:19 2017 +0530

Fix a superfluous condition

(a != 0 || a != 1) makes no sense. Author probably meant AND, not OR.

Change-Id: If91954e9e48e5804c54380db8c99184ef0fcc1d2

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index d3d865d0..228b87ab 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1192,7 +1192,7 @@ private:
 }
 // 0 for preventing selection of the first always
 // 1 for preventing the new users from directly beoming the editors
-if (_editorId != fastestUser && (maxSpeed != 0 || maxSpeed != 1)) {
+if (_editorId != fastestUser && (maxSpeed != 0 && maxSpeed != 1)) {
 if (!_editorChangeWarning && _editorId != -1)
 {
 _editorChangeWarning = true;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2017-06-24 Thread Michael Meeks
 kit/Kit.cpp |   20 +++-
 1 file changed, 11 insertions(+), 9 deletions(-)

New commits:
commit 294ff36ed2c461d060db7b5edebd1e806d83ee71
Author: Michael Meeks 
Date:   Sat Jun 24 13:03:09 2017 +0100

Re-factor: pass oldWid into encodePNG sub buffer.

Change-Id: I37bce07d64240aba254a0c4cbcc1804f2dd98a13

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index f811be5d..64898ef8 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -405,7 +405,7 @@ class PngCache
int width, int height,
int bufferWidth, int bufferHeight,
std::vector& output, 
LibreOfficeKitTileMode mode,
-   TileBinaryHash hash, TileWireId wid)
+   TileBinaryHash hash, TileWireId wid, 
TileWireId /* oldWid */)
 {
 LOG_DBG("PNG cache with hash " << hash << " missed.");
 CacheEntry newEntry(bufferWidth * bufferHeight * 1, wid);
@@ -454,28 +454,28 @@ public:
 
 bool encodeBufferToPNG(unsigned char* pixmap, int width, int height,
std::vector& output, LibreOfficeKitTileMode 
mode,
-   TileBinaryHash hash, TileWireId wid)
+   TileBinaryHash hash, TileWireId wid, TileWireId 
oldWid)
 {
 if (cacheTest(hash, output))
 return true;
 
 return cacheEncodeSubBufferToPNG(pixmap, 0, 0, width, height,
  width, height, output, mode,
- hash, wid);
+ hash, wid, oldWid);
 }
 
 bool encodeSubBufferToPNG(unsigned char* pixmap, size_t startX, size_t 
startY,
   int width, int height,
   int bufferWidth, int bufferHeight,
   std::vector& output, 
LibreOfficeKitTileMode mode,
-  TileBinaryHash hash, TileWireId wid)
+  TileBinaryHash hash, TileWireId wid, TileWireId 
oldWid)
 {
 if (cacheTest(hash, output))
 return true;
 
 return cacheEncodeSubBufferToPNG(pixmap, startX, startY, width, height,
  bufferWidth, bufferHeight, output, 
mode,
- hash, wid);
+ hash, wid, oldWid);
 }
 };
 
@@ -688,10 +688,11 @@ public:
 
 const TileBinaryHash hash = Png::hashBuffer(pixmap.data(), 
tile.getWidth(), tile.getHeight());
 TileWireId wid = _pngCache.hashToWireId(hash);
+TileWireId oldWireId = tile.getOldWireId();
 
 tile.setWireId(wid);
 
-if (hash != 0 && tile.getOldWireId() == wid)
+if (hash != 0 && oldWireId == wid)
 {
 // The tile content is identical to what the client already has, 
so skip it
 LOG_TRC("Match oldWireId==wid (" << wid << " for hash " << hash << 
"); unchanged");
@@ -706,7 +707,7 @@ public:
 output.resize(response.size());
 std::memcpy(output.data(), response.data(), response.size());
 
-if (!_pngCache.encodeBufferToPNG(pixmap.data(), tile.getWidth(), 
tile.getHeight(), output, mode, hash, wid))
+if (!_pngCache.encodeBufferToPNG(pixmap.data(), tile.getWidth(), 
tile.getHeight(), output, mode, hash, wid, oldWireId))
 {
 //FIXME: Return error.
 //sendTextFrame("error: cmd=tile kind=failure");
@@ -795,7 +796,8 @@ public:
  pixelWidth, pixelHeight, 
pixmapWidth, pixmapHeight);
 
 TileWireId wireId = _pngCache.hashToWireId(hash);
-if (hash != 0 && tiles[tileIndex].getOldWireId() == wireId)
+TileWireId oldWireId = tiles[tileIndex].getOldWireId();
+if (hash != 0 && oldWireId == wireId)
 {
 // The tile content is identical to what the client already 
has, so skip it
 LOG_TRC("Match for tile #" << tileIndex << " at (" << 
positionX << "," <<
@@ -806,7 +808,7 @@ public:
 
 if (!_pngCache.encodeSubBufferToPNG(pixmap.data(), positionX * 
pixelWidth, positionY * pixelHeight,
 pixelWidth, pixelHeight, 
pixmapWidth, pixmapHeight, output, mode,
-hash, wireId))
+hash, wireId, oldWireId))
 {
 //FIXME: Return error.
 //sendTextFrame("error: cmd=tile kind=failure");
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp kit/Kit.hpp loleaflet/dist

2017-05-31 Thread Ashod Nakashian
 kit/Kit.cpp   |2 +-
 kit/Kit.hpp   |3 +--
 loleaflet/dist/toolbar/toolbar.js |4 ++--
 3 files changed, 4 insertions(+), 5 deletions(-)

New commits:
commit a59f78b65670cf967981938fde45737dab8f2323
Author: Ashod Nakashian 
Date:   Wed May 31 23:57:06 2017 -0400

wsd: UserExtraInfo is a map, not array

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 5415c760..0358e7f9 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1078,7 +1078,7 @@ private:
 const auto username = itView->second.Username;
 oss << "\"username\":\"" << username << "\",";
 if (!itView->second.UserExtraInfo.empty())
-oss << itView->second.UserExtraInfo << ',';
+oss << "\"userextrainfo\":" << 
itView->second.UserExtraInfo << ",";
 const auto readonly = itView->second.IsReadOnly;
 oss << "\"readonly\":\"" << readonly << "\",";
 const auto it = viewColorsMap.find(username);
diff --git a/kit/Kit.hpp b/kit/Kit.hpp
index bbaf1bba..829ab2e2 100644
--- a/kit/Kit.hpp
+++ b/kit/Kit.hpp
@@ -52,10 +52,9 @@ struct UserInfo
  const bool readonly) :
 UserId(userId),
 Username(username),
+UserExtraInfo(userExtraInfo),
 IsReadOnly(readonly)
 {
-if (!userExtraInfo.empty())
-UserExtraInfo = "\"userextrainfo\":[" + userExtraInfo + ']';
 }
 
 std::string UserId;
diff --git a/loleaflet/dist/toolbar/toolbar.js 
b/loleaflet/dist/toolbar/toolbar.js
index 90de878e..3aa8ca29 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -1568,8 +1568,8 @@ function onUseritemClicked(e) {
 function getUserItem(viewId, userName, extraInfo, color) {
var html = '' +
 ' '
+   if (extraInfo !== undefined && extraInfo.avatar !== undefined) {
+   html += 'top=0px ! important;"> '
}
else {
html += '">';
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2017-04-07 Thread Michael Meeks
 kit/Kit.cpp |1 +
 1 file changed, 1 insertion(+)

New commits:
commit 9ea75f974c1ae1ee70e51ba87443e475f7fbd319
Author: Michael Meeks 
Date:   Fri Apr 7 22:33:01 2017 +0100

Re-allocate vector storage to compressed size.

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 6717c677..121f20e8 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -373,6 +373,7 @@ class PngCache
 {
 if (hash)
 {
+newEntry._data->shrink_to_fit();
 _cache.emplace(hash, newEntry);
 _cacheSize += newEntry._data->size();
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2017-04-04 Thread Ashod Nakashian
 kit/Kit.cpp |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

New commits:
commit fa753e5e0657b230526e71477a9fcdb16f91f4a6
Author: Ashod Nakashian 
Date:   Tue Apr 4 21:30:29 2017 -0400

wsd: time lok_preinit and log when finished

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 40a9a2df..d770a9bc 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1956,13 +1956,17 @@ bool globalPreinit(const std::string )
 LOG_FTL("No libreofficekit_hook_2 symbol in " << loadedLibrary << ": " 
<< dlerror());
 }
 
-LOG_TRC("lok_preinit(" << loTemplate << "/program\", \"file:///user\")");
+LOG_TRC("Invoking lok_preinit(" << loTemplate << "/program\", 
\"file:///user\")");
+const auto start = std::chrono::steady_clock::now();
 if (preInit((loTemplate + "/program").c_str(), "file:///user") != 0)
 {
 LOG_FTL("lok_preinit() in " << loadedLibrary << " failed");
 return false;
 }
 
+LOG_TRC("Finished lok_preinit(" << loTemplate << "/program\", 
\"file:///user\") in " <<
+
std::chrono::duration_cast(std::chrono::steady_clock::now()
 - start).count() <<
+" ms.");
 return true;
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-04-02 Thread Ashod Nakashian
 kit/Kit.cpp|   20 +++-
 wsd/DocumentBroker.cpp |8 +---
 wsd/DocumentBroker.hpp |6 ++
 3 files changed, 26 insertions(+), 8 deletions(-)

New commits:
commit c9365ad67961aee7b4be0b23883c973c38c088e1
Author: Ashod Nakashian 
Date:   Sun Apr 2 15:55:56 2017 -0400

wsd: log the DocBroker ID in the Kit as well

This matches the document between WSD and kit,
making logs much easier to read.

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 6131ba40..35a48673 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -445,12 +445,14 @@ public:
 Document(const std::shared_ptr& loKit,
  const std::string& jailId,
  const std::string& docKey,
+ const std::string& docId,
  const std::string& url,
  std::shared_ptr tileQueue,
  const std::shared_ptr& ws)
   : _loKit(loKit),
 _jailId(jailId),
 _docKey(docKey),
+_docId(docId),
 _url(url),
 _tileQueue(std::move(tileQueue)),
 _ws(ws),
@@ -461,7 +463,9 @@ public:
 _stop(false),
 _isLoading(0)
 {
-LOG_INF("Document ctor for url [" << _url << "] on child [" << _jailId 
<< "].");
+LOG_INF("Document ctor for [" << _docKey <<
+"] url [" << _url << "] on child [" << _jailId <<
+"] and id [" << _docId << "].");
 assert(_loKit);
 
 _callbackThread.start(*this);
@@ -469,8 +473,10 @@ public:
 
 ~Document()
 {
-LOG_INF("~Document dtor for url [" << _url << "] on child [" << 
_jailId <<
-"]. There are " << _sessions.size() << " views.");
+LOG_INF("~Document dtor for [" << _docKey <<
+"] url [" << _url << "] on child [" << _jailId <<
+"] and id [" << _docId << "]. There are " <<
+_sessions.size() << " views.");
 
 // Wait for the callback worker to finish.
 _stop = true;
@@ -1357,7 +1363,7 @@ private:
 
 void run() override
 {
-Util::setThreadName("lok_handler");
+Util::setThreadName("lokit_" + _docId);
 
 LOG_DBG("Thread started.");
 
@@ -1515,7 +1521,10 @@ private:
 private:
 std::shared_ptr _loKit;
 const std::string _jailId;
+/// URL-based key. May be repeated during the lifetime of WSD.
 const std::string _docKey;
+/// Short numerical ID. Unique during the lifetime of WSD.
+const std::string _docId;
 const std::string _url;
 std::string _jailedUrl;
 std::string _renderOpts;
@@ -1795,6 +1804,7 @@ void lokit_main(const std::string& childRoot,
 {
 const std::string& sessionId = tokens[1];
 const std::string& docKey = tokens[2];
+const std::string& docId = tokens[3];
 
 std::string url;
 URI::decode(docKey, url);
@@ -1802,7 +1812,7 @@ void lokit_main(const std::string& childRoot,
 
 if (!document)
 {
-document = std::make_shared(loKit, 
jailId, docKey, url, queue, ws);
+document = std::make_shared(loKit, 
jailId, docKey, docId, url, queue, ws);
 }
 
 // Validate and create session.
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 494f21f3..259ca5aa 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -133,6 +133,8 @@ public:
 }
 };
 
+std::atomic DocumentBroker::DocBrokerId(1);
+
 DocumentBroker::DocumentBroker(const std::string& uri,
const Poco::URI& uriPublic,
const std::string& docKey,
@@ -140,6 +142,7 @@ DocumentBroker::DocumentBroker(const std::string& uri,
 _uriOrig(uri),
 _uriPublic(uriPublic),
 _docKey(docKey),
+_docId(Util::encodeId(DocBrokerId++, 3)),
 _childRoot(childRoot),
 _cacheRoot(getCachePath(uriPublic.toString())),
 _lastSaveTime(std::chrono::steady_clock::now()),
@@ -177,8 +180,7 @@ bool DocumentBroker::isCorrectThread()
 // The inner heart of the DocumentBroker - our poll loop.
 void DocumentBroker::pollThread()
 {
-static std::atomic DocBrokerId(1);
-Util::setThreadName("docbroker_" + Util::encodeId(DocBrokerId++, 3));
+Util::setThreadName("docbroker_" + _docId);
 
 LOG_INF("Starting docBroker polling thread for docKey [" << _docKey << 
"].");
 
@@ -770,7 +772,7 @@ size_t DocumentBroker::addSession(const 
std::shared_ptr& session)
 const auto count = _sessions.size();
 
 // Request a new session from the child kit.
-const std::string aMessage = 

[Libreoffice-commits] online.git: kit/Kit.cpp

2017-03-27 Thread Samuel Mehrbrodt
 kit/Kit.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit fd5df2f1da9b4199d729f5a1b9e7beb58ae3d7f0
Author: Samuel Mehrbrodt 
Date:   Mon Mar 27 13:02:02 2017 +

Revert "Don't try to copy the file when it already exists"

This reverts commit 0b91533abb56bd81fa63f2ad85c2bd9bbc523f2c.

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index f227af9f..58f79b28 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -149,7 +149,7 @@ namespace
 case FTW_F:
 case FTW_SLN:
 File(newPath.parent()).createDirectories();
-if (link(fpath, newPath.toString().c_str()) == -1 && errno != 
EEXIST)
+if (link(fpath, newPath.toString().c_str()) == -1)
 {
 LOG_SYS("link(\"" << fpath << "\", \"" <<
 newPath.toString() << "\") failed. Will copy.");
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2017-03-27 Thread Samuel Mehrbrodt
 kit/Kit.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 0b91533abb56bd81fa63f2ad85c2bd9bbc523f2c
Author: Samuel Mehrbrodt 
Date:   Fri Mar 24 14:18:46 2017 +0100

Don't try to copy the file when it already exists

Without this, 'make run' fails for me

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 58f79b28..f227af9f 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -149,7 +149,7 @@ namespace
 case FTW_F:
 case FTW_SLN:
 File(newPath.parent()).createDirectories();
-if (link(fpath, newPath.toString().c_str()) == -1)
+if (link(fpath, newPath.toString().c_str()) == -1 && errno != 
EEXIST)
 {
 LOG_SYS("link(\"" << fpath << "\", \"" <<
 newPath.toString() << "\") failed. Will copy.");
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp net/loolnb.cpp net/Socket.hpp wsd/LOOLWSD.cpp

2017-03-12 Thread Ashod Nakashian
 kit/Kit.cpp |1 +
 net/Socket.hpp  |4 ++--
 net/loolnb.cpp  |2 +-
 wsd/LOOLWSD.cpp |   12 ++--
 4 files changed, 10 insertions(+), 9 deletions(-)

New commits:
commit 2e2f62eddeeb92761df1e1316aaa59687e2aac69
Author: Ashod Nakashian 
Date:   Sun Mar 12 18:34:06 2017 -0400

wsd: improved logging

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index c14007a..9886a8c 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1754,6 +1754,7 @@ void lokit_main(const std::string& childRoot,
 // Open websocket connection between the child process and WSD.
 HTTPClientSession cs("127.0.0.1", MasterPortNumber);
 cs.setTimeout(Poco::Timespan(10, 0)); // 10 second
+LOG_DBG("Connecting to Master " << cs.getHost() << ':' << 
cs.getPort());
 HTTPRequest request(HTTPRequest::HTTP_GET, requestUrl);
 HTTPResponse response;
 auto ws = std::make_shared(cs, request, response);
diff --git a/net/Socket.hpp b/net/Socket.hpp
index 88ef163..7071acd 100644
--- a/net/Socket.hpp
+++ b/net/Socket.hpp
@@ -427,9 +427,9 @@ public:
 auto it = std::find(_pollSockets.begin(), _pollSockets.end(), socket);
 assert(it != _pollSockets.end());
 
-LOG_TRC("Release socket #" << socket->getFD() << " from " << _name);
-
 _pollSockets.erase(it);
+LOG_TRC("Release socket #" << socket->getFD() << " from " << _name <<
+" leaving " << _pollSockets.size());
 }
 
 const std::string& name() const { return _name; }
diff --git a/net/loolnb.cpp b/net/loolnb.cpp
index 041397a..566ab1e 100644
--- a/net/loolnb.cpp
+++ b/net/loolnb.cpp
@@ -86,7 +86,7 @@ public:
 << "Connection: Closed\r\n"
 << "\r\n"
 << numberString;
-;
+
 std::string str = oss.str();
 socket->_outBuffer.insert(socket->_outBuffer.end(), 
str.begin(), str.end());
 return;
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 98250b4..8444f07 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1466,13 +1466,13 @@ private:
 /// Keep our socket around ...
 void onConnect(const std::weak_ptr& socket) override
 {
-LOG_TRC("Prisoner - new socket\n");
+LOG_TRC("Prisoner - new socket");
 _socket = socket;
 }
 
 void onDisconnect() override
 {
-LOG_TRC("Prisoner connection disconnected\n");
+LOG_TRC("Prisoner connection disconnected");
 }
 
 /// Called after successful socket reads.
@@ -1510,7 +1510,7 @@ private:
 auto logger = Log::info();
 if (logger.enabled())
 {
-logger << "Prisoner HTTP Request: "
+logger << "Prisoner HTTP Request from #" << socket->getFD() << 
": "
<< request.getMethod() << ' '
<< request.getURI() << ' '
<< request.getVersion();
@@ -1641,8 +1641,8 @@ private:
 disposeSession();
 
 const size_t curConnections = --LOOLWSD::NumConnections;
-LOG_TRC("Disconnected connection #" << _connectionNum << " of " <<
-(curConnections + 1) << " existing as session [" << _id << 
"].");
+LOG_TRC("Disconnected connection #" << _connectionNum << " (of " <<
+(curConnections + 1) << ") as session [" << _id << "].");
 }
 
 /// Called after successful socket reads.
@@ -1683,7 +1683,7 @@ private:
 auto logger = Log::info();
 if (logger.enabled())
 {
-logger << "Client HTTP Request: "
+logger << "Client HTTP Request: #" << socket->getFD() << ": "
<< request.getMethod() << ' '
<< request.getURI() << ' '
<< request.getVersion();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp wsd/ClientSession.cpp wsd/ClientSession.hpp wsd/DocumentBroker.cpp

2017-02-08 Thread Ashod Nakashian
 kit/Kit.cpp|   15 ++-
 wsd/ClientSession.cpp  |1 -
 wsd/ClientSession.hpp  |2 +-
 wsd/DocumentBroker.cpp |   25 +
 4 files changed, 24 insertions(+), 19 deletions(-)

New commits:
commit 404111877a01bbc9f884a1db4cd582249154fe35
Author: Ashod Nakashian 
Date:   Mon Feb 6 20:10:08 2017 -0500

wsd: broadcast client messages from WSD not from the Kit

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 4ab1da3..fbbb030 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1072,19 +1072,8 @@ private:
 oss << "]";
 const auto msg = oss.str();
 
-std::unique_lock lock(_mutex);
-
-// Broadcast updated viewinfo to all _active_ connections.
-// These are internal sockets, so unless WSD is chocked,
-// no need to send on separate thread.
-for (const auto& pair : _sessions)
-{
-const auto& session = pair.second;
-if (!session->isCloseFrame() && session->isActive())
-{
-session->sendTextFrame(msg);
-}
-}
+// Broadcast updated viewinfo to all clients.
+sendTextFrame("client-all " + msg);
 }
 
 private:
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index f8079cb..deb4680 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -676,7 +676,6 @@ bool ClientSession::forwardToClient(const 
std::shared_ptr& payload)
 return true;
 }
 
-LOG_TRC(getName() << " enqueue to client: " << message);
 enqueueSendMessage(payload);
 
 return true;
diff --git a/wsd/ClientSession.hpp b/wsd/ClientSession.hpp
index 17c5c0d..a6efb50 100644
--- a/wsd/ClientSession.hpp
+++ b/wsd/ClientSession.hpp
@@ -72,7 +72,7 @@ public:
 }
 else
 {
-LOG_TRC(getName() << " enqueueing client message: " << 
data->abbr());
+LOG_TRC(getName() << " enqueueing client message " << data->id());
 _senderQueue.enqueue(data);
 }
 }
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 2cda4a0..fe3ea89 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1037,16 +1037,33 @@ bool DocumentBroker::forwardToClient(const 
std::shared_ptr& payload)
 std::string sid;
 if (LOOLProtocol::parseNameValuePair(payload->forwardToken(), name, sid, 
'-') && name == "client")
 {
+const auto& data = payload->data().data();
+const auto& size = payload->size();
+
 std::unique_lock lock(_mutex);
 
-const auto it = _sessions.find(sid);
-if (it != _sessions.end())
+if (sid == "all")
 {
-return 
it->second->handleKitToClientMessage(payload->data().data(), payload->size());
+// Broadcast to all.
+for (const auto& pair : _sessions)
+{
+if (!pair.second->isHeadless() && !pair.second->isCloseFrame())
+{
+pair.second->handleKitToClientMessage(data, size);
+}
+}
 }
 else
 {
-LOG_WRN("Client session [" << sid << "] not found to forward 
message: " << msg);
+const auto it = _sessions.find(sid);
+if (it != _sessions.end())
+{
+return it->second->handleKitToClientMessage(data, size);
+}
+else
+{
+LOG_WRN("Client session [" << sid << "] not found to forward 
message: " << msg);
+}
 }
 }
 else
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2017-02-08 Thread Jan Holesovsky
 kit/Kit.cpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 963aeb5d1fb06dd0360f73ffb3f0ea3ab19ec794
Author: Jan Holesovsky 
Date:   Thu Feb 9 00:07:43 2017 +0100

Don't leak children that did not manage to send their PID to wsd.

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index ae56b6e..4ab1da3 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1758,7 +1758,7 @@ void lokit_main(const std::string& childRoot,
 
 // Open websocket connection between the child process and WSD.
 HTTPClientSession cs("127.0.0.1", MasterPortNumber);
-cs.setTimeout(0);
+cs.setTimeout(Poco::Timespan(10, 0)); // 10 second
 HTTPRequest request(HTTPRequest::HTTP_GET, requestUrl);
 HTTPResponse response;
 auto ws = std::make_shared(cs, request, response);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


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

2017-02-08 Thread Jan Holesovsky
 kit/Kit.cpp |8 +++-
 wsd/LOOLWSD.cpp |8 +++-
 wsd/LOOLWSD.hpp |1 +
 3 files changed, 15 insertions(+), 2 deletions(-)

New commits:
commit cd90d8adfe22f7e0368a16a9da42c0826ece0a49
Author: Jan Holesovsky 
Date:   Wed Feb 8 12:34:16 2017 +0100

fuzzer: Add --dummy-lok command line option that bypases LibreOffice.

When provided, the DummyLibreOfficeKit is used instead of the real one that
calls LibreOffice.

Change-Id: Ic170d7b4adb72ba17a2b066c509c2b1e657dbccf

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 21300d9..79e6f55 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -67,6 +67,7 @@
 
 #ifdef FUZZER
 #include 
+#include 
 #endif
 
 #define LIB_SOFFICEAPP  "lib" "sofficeapp" ".so"
@@ -1721,7 +1722,8 @@ void lokit_main(const std::string& childRoot,
 #else
 LibreOfficeKit* kit = nullptr;
 #ifdef FUZZER
-kit = dummy_lok_init_2(instdir, userdir);
+if (LOOLWSD::DummyLOK)
+kit = dummy_lok_init_2(instdir, userdir);
 #endif
 #endif
 if (!kit)
@@ -1884,6 +1886,10 @@ void lokit_main(const std::string& childRoot,
 /// Initializes LibreOfficeKit for cross-fork re-use.
 bool globalPreinit(const std::string )
 {
+#ifdef FUZZER
+if (LOOLWSD::DummyLOK)
+return true;
+#endif
 const std::string libSofficeapp = loTemplate + "/program/" LIB_SOFFICEAPP;
 const std::string libMerged = loTemplate + "/program/" LIB_MERGED;
 
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 12f91c0..9411255 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1703,6 +1703,7 @@ std::atomic LOOLWSD::ForKitProcId(-1);
 bool LOOLWSD::NoCapsForKit = false;
 #endif
 #ifdef FUZZER
+bool LOOLWSD::DummyLOK = false;
 std::string LOOLWSD::FuzzFileName = "";
 #endif
 std::string LOOLWSD::Cache = LOOLWSD_CACHEDIR;
@@ -2090,6 +2091,9 @@ void LOOLWSD::defineOptions(OptionSet& optionSet)
 #endif
 
 #ifdef FUZZER
+optionSet.addOption(Option("dummy-lok", "", "Use empty (dummy) 
LibreOfficeKit implementation instead a real LibreOffice.")
+.required(false)
+.repeatable(false));
 optionSet.addOption(Option("fuzz", "", "Read input from the specified file 
for fuzzing.")
 .required(false)
 .repeatable(false)
@@ -2142,7 +2146,9 @@ void LOOLWSD::handleOption(const std::string& optionName,
 #endif
 
 #ifdef FUZZER
-if (optionName == "fuzz")
+if (optionName == "dummy-lok")
+DummyLOK = true;
+else if (optionName == "fuzz")
 FuzzFileName = value;
 #endif
 }
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index 7438c80..5126bb1 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -38,6 +38,7 @@ public:
 static bool NoCapsForKit;
 static std::atomic ForKitWritePipe;
 static std::atomic ForKitProcId;
+static bool DummyLOK;
 static std::string FuzzFileName;
 static std::string Cache;
 static std::string ConfigFile;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2017-01-30 Thread Ashod Nakashian
 kit/Kit.cpp |   22 ++
 1 file changed, 10 insertions(+), 12 deletions(-)

New commits:
commit 85195866749dcfbd533ce75bbc126844efd44aaf
Author: Ashod Nakashian 
Date:   Mon Jan 30 02:53:38 2017 -0500

wsd: manually generate the viewinfo json string

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index b18602e..2d0ebeb 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1035,24 +1035,23 @@ private:
 
 // Double check if list of viewids from core and our list matches,
 // and create an array of JSON objects containing id and username
-Array::Ptr viewInfoArray = new Array();
-int arrayIndex = 0;
+std::ostringstream oss;
+oss << "viewinfo: [";
 for (const auto& viewId : viewIds)
 {
-Object::Ptr viewInfoObj = new Object();
-viewInfoObj->set("id", viewId);
+oss << "{\"id\":" << viewId << ",";
 int color = 0;
 const auto itView = viewInfoMap.find(viewId);
 if (itView == viewInfoMap.end())
 {
 LOG_ERR("No username found for viewId [" << viewId << "].");
-viewInfoObj->set("username", "Unknown");
+oss << "\"username\":\"Unknown\",";
 }
 else
 {
-viewInfoObj->set("userid", itView->second.userid);
+oss << "\"userid\":\"" << itView->second.userid << "\",";
 const auto username = itView->second.username;
-viewInfoObj->set("username", username);
+oss << "\"username\":\"" << username << "\",";
 const auto it = viewColorsMap.find(username);
 if (it != viewColorsMap.end())
 {
@@ -1060,13 +1059,12 @@ private:
 }
 }
 
-viewInfoObj->set("color", color);
-viewInfoArray->set(arrayIndex++, viewInfoObj);
+oss << "\"color\":" << color << "},";
 }
 
-std::ostringstream ossViewInfo;
-viewInfoArray->stringify(ossViewInfo);
-const auto msg = "viewinfo: " + ossViewInfo.str();
+oss.seekp(-1, std::ios_base::cur); // Remove last comma.
+oss << "]";
+const auto msg = oss.str();
 
 std::unique_lock lock(_mutex);
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2017-01-30 Thread Ashod Nakashian
 kit/Kit.cpp |   23 +--
 1 file changed, 13 insertions(+), 10 deletions(-)

New commits:
commit 7f15ef7ba0930f90c8d5a08c4beae5584a9e0a8e
Author: Ashod Nakashian 
Date:   Mon Jan 30 02:02:55 2017 -0500

wsd: minimize locking when generating viewinfo

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index ad47009..b18602e 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1033,8 +1033,6 @@ private:
 std::map viewInfoMap = getViewInfo();
 std::map viewColorsMap = getViewColors();
 
-std::unique_lock lock(_mutex);
-
 // Double check if list of viewids from core and our list matches,
 // and create an array of JSON objects containing id and username
 Array::Ptr viewInfoArray = new Array();
@@ -1044,38 +1042,43 @@ private:
 Object::Ptr viewInfoObj = new Object();
 viewInfoObj->set("id", viewId);
 int color = 0;
-if (viewInfoMap.find(viewId) == viewInfoMap.end())
+const auto itView = viewInfoMap.find(viewId);
+if (itView == viewInfoMap.end())
 {
 LOG_ERR("No username found for viewId [" << viewId << "].");
 viewInfoObj->set("username", "Unknown");
 }
 else
 {
-viewInfoObj->set("userid", viewInfoMap[viewId].userid);
-viewInfoObj->set("username", viewInfoMap[viewId].username);
-if (viewColorsMap.find(viewInfoMap[viewId].username) != 
viewColorsMap.end())
+viewInfoObj->set("userid", itView->second.userid);
+const auto username = itView->second.username;
+viewInfoObj->set("username", username);
+const auto it = viewColorsMap.find(username);
+if (it != viewColorsMap.end())
 {
-color = viewColorsMap[viewInfoMap[viewId].username];
+color = it->second;
 }
 }
 
 viewInfoObj->set("color", color);
-
 viewInfoArray->set(arrayIndex++, viewInfoObj);
 }
 
 std::ostringstream ossViewInfo;
 viewInfoArray->stringify(ossViewInfo);
+const auto msg = "viewinfo: " + ossViewInfo.str();
+
+std::unique_lock lock(_mutex);
 
 // Broadcast updated viewinfo to all _active_ connections.
 // These are internal sockets, so unless WSD is chocked,
 // no need to send on separate thread.
 for (const auto& pair : _sessions)
 {
-const auto session = pair.second;
+const auto& session = pair.second;
 if (!session->isCloseFrame() && session->isActive())
 {
-session->sendTextFrame("viewinfo: " + ossViewInfo.str());
+session->sendTextFrame(msg);
 }
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2017-01-30 Thread Ashod Nakashian
 kit/Kit.cpp |   17 +++--
 1 file changed, 3 insertions(+), 14 deletions(-)

New commits:
commit f33f014f987b1fb210585fa1ec34f5ee467ea241
Author: Ashod Nakashian 
Date:   Mon Jan 30 01:43:06 2017 -0500

wsd: simplify tracking of user info

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index e093d0b..ad47009 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1013,18 +1013,7 @@ private:
 {
 std::unique_lock lock(_mutex);
 
-std::map viewInfo;
-for (const auto& pair : _sessions)
-{
-const auto& session = pair.second;
-const auto viewId = session->getViewId();
-viewInfo[viewId] = UserInfo({session->getViewUserId(), 
session->getViewUserName()});
-}
-
-// Copy the old sessions to provide disconnected user info.
-viewInfo.insert(_oldSessionIds.begin(), _oldSessionIds.end());
-
-return viewInfo;
+return _sessionUserInfo;
 }
 
 std::mutex& getMutex() override
@@ -1241,6 +1230,7 @@ private:
 
 const int viewId = _loKitDocument->getView();
 session->setViewId(viewId);
+_sessionUserInfo[viewId] = UserInfo({session->getViewUserId(), 
session->getViewUserName()});
 
 _viewIdToCallbackDescr.emplace(viewId,
std::unique_ptr(new 
CallbackDescriptor({ this, viewId })));
@@ -1287,7 +1277,6 @@ private:
 strncmp(data, disconnect.data(), disconnect.size()) == 0)
 {
 LOG_DBG("Removing ChildSession [" << sessionId << "].");
-_oldSessionIds[session->getViewId()] = 
UserInfo({session->getViewUserId(), session->getViewUserName()});
 _sessions.erase(it);
 const auto count = _sessions.size();
 LOG_DBG("Have " << count << " child" << (count == 1 ? "" : 
"ren") <<
@@ -1524,7 +1513,7 @@ private:
 std::map _sessions;
 
 /// For showing disconnected user info in the doc repair dialog.
-std::map _oldSessionIds;
+std::map _sessionUserInfo;
 Poco::Thread _callbackThread;
 };
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2017-01-22 Thread Ashod Nakashian
 kit/Kit.cpp |   47 ---
 1 file changed, 40 insertions(+), 7 deletions(-)

New commits:
commit 0fe580d9ab3abe198e3143d30c83f1cffb589832
Author: Ashod Nakashian 
Date:   Fri Jan 20 00:14:29 2017 -0500

wsd: cap batches by duration

Batched loKit calls are now capped by time
to limit the maximum latency.

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index dbe25a1..3f14c19 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1379,22 +1379,50 @@ private:
 
 LOG_DBG("Thread started.");
 
+static const unsigned MaxBatchDurationMs = 125;
 size_t batched = 0;
+std::chrono::steady_clock::time_point timeBeginBatch;
 try
 {
 while (!_stop && !TerminationFlag)
 {
-// End if we have no more.
+unsigned timeoutMs = 0;
 if (batched)
 {
-LOG_TRC("Ending batch of " << batched << " messages.");
-std::unique_lock lock(_documentMutex);
-batched = 0;
-getLOKitDocument()->endBatch();
+// Cap the wait so we eventually process the batch.
+const auto duration = std::chrono::steady_clock::now() - 
timeBeginBatch;
+const auto durationMs = 
std::chrono::duration_cast(duration).count();
+if (durationMs >= MaxBatchDurationMs)
+{
+LOG_TRC("Ending batch of " << batched << " messages.");
+std::unique_lock lock(_documentMutex);
+batched = 0;
+getLOKitDocument()->endBatch();
+timeoutMs = 0;
+}
+else
+{
+timeoutMs = MaxBatchDurationMs - durationMs;
+}
 }
 
-const TileQueue::Payload input = _tileQueue->get();
-LOG_TRC("Kit Recv " << 
LOOLProtocol::getAbbreviatedMessage(input));
+LOG_TRC("Kit dequeue with max timeout of " << timeoutMs << " 
ms. Batched: " << batched);
+const TileQueue::Payload input = _tileQueue->get(timeoutMs);
+LOG_TRC("Kit dequeued " << 
LOOLProtocol::getAbbreviatedMessage(input));
+if (input.empty())
+{
+// End if we have no more.
+if (batched)
+{
+LOG_TRC("Ending batch of " << batched << " messages.");
+std::unique_lock lock(_documentMutex);
+batched = 0;
+getLOKitDocument()->endBatch();
+}
+
+// Nothing to process.
+continue;
+}
 
 if (_stop || TerminationFlag)
 {
@@ -1430,6 +1458,11 @@ private:
 else if (LOOLProtocol::getFirstToken(tokens[0], '-') == 
"child")
 {
 batched = forwardToChild(tokens[0], input, batched);
+if (batched == 1)
+{
+// New batch started.
+timeBeginBatch = std::chrono::steady_clock::now();
+}
 }
 else if (tokens[0] == "callback")
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: kit/Kit.cpp

2017-01-22 Thread Ashod Nakashian
 kit/Kit.cpp |   61 +---
 1 file changed, 34 insertions(+), 27 deletions(-)

New commits:
commit 7f8ffcfab5a774d0a480b58f594bf5e9fe698e6d
Author: Ashod Nakashian 
Date:   Thu Jan 19 20:50:19 2017 -0500

wsd: check for malformed callback messages

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

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index fa04207..4d862de 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1382,42 +1382,49 @@ private:
 }
 else if (tokens[0] == "callback")
 {
-int viewId = std::stoi(tokens[1]); // -1 means broadcast
-int type = std::stoi(tokens[2]);
+if (tokens.size() >= 3)
+{
+int viewId = std::stoi(tokens[1]); // -1 means 
broadcast
+int type = std::stoi(tokens[2]);
 
-// payload is the rest of the message
-const auto offset = tokens[0].length() + 
tokens[1].length() + tokens[2].length() + 3; // + delims
-const std::string payload(input.data() + offset, 
input.size() - offset);
+// payload is the rest of the message
+const auto offset = tokens[0].length() + 
tokens[1].length() + tokens[2].length() + 3; // + delims
+const std::string payload(input.data() + offset, 
input.size() - offset);
 
-// Forward the callback to the same view, demultiplexing 
is done by the LibreOffice core.
-// TODO: replace with a map to be faster.
-bool isFound = false;
-for (auto& it : _sessions)
-{
-auto session = it.second;
-if (session && ((session->getViewId() == viewId) || 
(viewId == -1)))
+// Forward the callback to the same view, 
demultiplexing is done by the LibreOffice core.
+// TODO: replace with a map to be faster.
+bool isFound = false;
+for (auto& it : _sessions)
 {
-if (!it.second->isCloseFrame())
-{
-isFound = true;
-session->loKitCallback(type, payload);
-}
-else
+auto session = it.second;
+if (session && ((session->getViewId() == viewId) 
|| (viewId == -1)))
 {
-LOG_ERR("Session-thread of session [" << 
session->getId() << "] for view [" <<
-viewId << "] is not running. Dropping 
[" << LOKitHelper::kitCallbackTypeToString(type) <<
-"] payload [" << payload << "].");
+if (!it.second->isCloseFrame())
+{
+isFound = true;
+session->loKitCallback(type, payload);
+}
+else
+{
+LOG_ERR("Session-thread of session [" << 
session->getId() << "] for view [" <<
+viewId << "] is not running. 
Dropping [" << LOKitHelper::kitCallbackTypeToString(type) <<
+"] payload [" << payload << "].");
+}
+
+break;
 }
+}
 
-break;
+if (!isFound)
+{
+LOG_WRN("Document::ViewCallback. Session [" << 
viewId <<
+"] is no longer active to process [" << 
LOKitHelper::kitCallbackTypeToString(type) <<
+"] [" << payload << "] message to Master 
Session.");
 }
 }
-
-if (!isFound)
+else
 {
-LOG_WRN("Document::ViewCallback. Session [" << viewId 
<<
-"] is no longer active to process [" << 
LOKitHelper::kitCallbackTypeToString(type) <<
-"] [" << payload << "] message to Master 
Session.");
+LOG_ERR("Invalid callback message: [" << 
LOOLProtocol::getAbbreviatedMessage(input) << "].");
  

  1   2   >