[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 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 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 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 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