[Libreoffice-commits] online.git: 10 commits - common/Util.cpp Mobile/Mobile net/FakeSocket.cpp net/Socket.cpp net/Socket.hpp wsd/LOOLWSD.cpp

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Oct 16 20:18:00 UTC 2018


 Mobile/Mobile/AppDelegate.mm            |    3 ++-
 Mobile/Mobile/DocumentViewController.mm |    2 ++
 common/Util.cpp                         |    3 +--
 net/FakeSocket.cpp                      |    8 ++++----
 net/Socket.cpp                          |    7 ++++++-
 net/Socket.hpp                          |    2 +-
 wsd/LOOLWSD.cpp                         |   21 +++++++++++++++++----
 7 files changed, 33 insertions(+), 13 deletions(-)

New commits:
commit 3feae5ccda42a04c2bf8bb3d9bef505f00695423
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue Oct 16 23:00:14 2018 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Tue Oct 16 23:11:45 2018 +0300

    Don't talk about any 'ports' in the logging in the mobile app

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index f5839e202..e65fbd282 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2780,7 +2780,9 @@ private:
     {
         std::shared_ptr<SocketFactory> factory = std::make_shared<PrisonerSocketFactory>();
 
+#ifndef MOBILEAPP
         LOG_INF("Trying to listen on prisoner port " << port << ".");
+#endif
         std::shared_ptr<ServerSocket> socket = getServerSocket(
             ServerSocket::Type::Local, port, PrisonerPoll, factory);
 
@@ -2803,9 +2805,11 @@ private:
         }
 
         MasterPortNumber = port;
+#ifndef MOBILEAPP
         LOG_INF("Listening to prisoner connections on port " << port);
-#ifdef MOBILEAPP
+#else
         LOOLWSD::prisonerServerSocketFD = socket->getFD();
+        LOG_INF("Listening to prisoner connections on #" << LOOLWSD::prisonerServerSocketFD);
 #endif
         return socket;
     }
@@ -2813,8 +2817,12 @@ private:
     /// Create the externally listening public socket
     std::shared_ptr<ServerSocket> findServerPort(int port)
     {
+#ifndef MOBILEAPP
         LOG_INF("Trying to listen on client port " << port << ".");
+#endif
+
         std::shared_ptr<SocketFactory> factory;
+
 #if ENABLE_SSL
         if (LOOLWSD::isSSLEnabled())
             factory = std::make_shared<SslSocketFactory>();
@@ -2841,7 +2849,12 @@ private:
         }
 
         ClientPortNumber = port;
+
+#ifndef MOBILEAPP
         LOG_INF("Listening to client connections on port " << port);
+#else
+        LOG_INF("Listening to client connections on #" << socket->getFD());
+#endif
         return socket;
     }
 };
commit 6316aaf0f51b3e62adb9bc4225675151c24905a9
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue Oct 16 22:24:19 2018 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Tue Oct 16 23:06:05 2018 +0300

    Initialise also _threadFinished and _stop in SocketPoll::startThread()
    
    I am trying to get a SocketPoll object to be "restartable".
    
    Also make the lambda expression in joinThread multiple lines, so that
    one can set a breakpoint in it.

diff --git a/net/Socket.cpp b/net/Socket.cpp
index 56c356221..4e87fe05a 100644
--- a/net/Socket.cpp
+++ b/net/Socket.cpp
@@ -111,6 +111,8 @@ void SocketPoll::startThread()
     if (!_threadStarted)
     {
         _threadStarted = true;
+        _threadFinished = false;
+        _stop = false;
         try
         {
             _thread = std::thread(&SocketPoll::pollingThreadEntry, this);
@@ -125,7 +127,10 @@ void SocketPoll::startThread()
 
 void SocketPoll::joinThread()
 {
-    addCallback([this](){ removeSockets(); });
+    addCallback([this]()
+                {
+                    removeSockets();
+                });
     stop();
     if (_threadStarted && _thread.joinable())
     {
commit c617a8c73fc11d2f2ae3b4023d5a24cea5fbcc6f
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue Oct 16 22:24:01 2018 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Tue Oct 16 23:05:59 2018 +0300

    Improve a comment

diff --git a/net/Socket.hpp b/net/Socket.hpp
index 55f041415..72985aa35 100644
--- a/net/Socket.hpp
+++ b/net/Socket.hpp
@@ -715,7 +715,7 @@ private:
     int _wakeup[2];
     /// The sockets we're controlling
     std::vector<std::shared_ptr<Socket>> _pollSockets;
-    /// Protects _newSockets
+    /// Protects _newSockets and _newCallbacks
     std::mutex _mutex;
     std::vector<std::shared_ptr<Socket>> _newSockets;
     std::vector<CallbackFn> _newCallbacks;
commit 64c06b1f888145bfa0e96cc67e12d64a1f7e29cf
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue Oct 16 17:21:19 2018 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Tue Oct 16 23:05:50 2018 +0300

    Give a name also to the main thread

diff --git a/Mobile/Mobile/AppDelegate.mm b/Mobile/Mobile/AppDelegate.mm
index eab0054f6..aef56be1e 100644
--- a/Mobile/Mobile/AppDelegate.mm
+++ b/Mobile/Mobile/AppDelegate.mm
@@ -32,7 +32,8 @@ static LOOLWSD *loolwsd = nullptr;
 }
 
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
-    Log::initialize("app", "trace", false, false, {});
+    Log::initialize("Mobile", "trace", false, false, {});
+    Util::setThreadName("main");
     fakeSocketSetLoggingCallback([](const std::string& line)
                                  {
                                      LOG_TRC_NOFILE(line);
commit 434a62335bb84d3001dc66992395d3b99122685f
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue Oct 16 17:20:55 2018 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Tue Oct 16 23:05:39 2018 +0300

    Give a name to the thread that forwards (fake) WebSocket messages to the JavaScript

diff --git a/Mobile/Mobile/DocumentViewController.mm b/Mobile/Mobile/DocumentViewController.mm
index 3d5e92c99..3a6660dc0 100644
--- a/Mobile/Mobile/DocumentViewController.mm
+++ b/Mobile/Mobile/DocumentViewController.mm
@@ -15,6 +15,7 @@
 
 #import "ios.h"
 #import "FakeSocket.hpp"
+#import "Util.hpp"
 
 #import "DocumentViewController.h"
 
@@ -163,6 +164,7 @@
             // Start another thread to read responses and forward them to the JavaScript
             dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
                            ^{
+                               Util::setThreadName("app2js");
                                while (true) {
                                    struct pollfd p[2];
                                    p[0].fd = self.document->fakeClientFd;
commit b6f931db5132edcc06e1294fc552337eb1fb06ac
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue Oct 16 16:54:02 2018 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Tue Oct 16 23:05:33 2018 +0300

    Maybe I now have some idea what I am doing

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 17bc8a6f9..f5839e202 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -501,7 +501,7 @@ std::shared_ptr<ChildProcess> getNewChild_Blocks(
                     Util::setThreadName("lokit_main");
 
                     // Ugly to have that static global, otoh we know there is just one LOOLWSD
-                    // object. (Even in real Online.) I have no idea what I am doing here.
+                    // object. (Even in real Online.)
                     lokit_main(uri, LOOLWSD::prisonerServerSocketFD);
                 }).detach();
 #endif
commit 157273dc5b9b3c2426626f00af7ef5e253d1e4bc
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue Oct 16 16:53:19 2018 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Tue Oct 16 23:05:05 2018 +0300

    Give also the thread running lokit_main() (in the mobile app) a name

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index f56c13226..17bc8a6f9 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -498,6 +498,8 @@ std::shared_ptr<ChildProcess> getNewChild_Blocks(
 
     std::thread([&]
                 {
+                    Util::setThreadName("lokit_main");
+
                     // Ugly to have that static global, otoh we know there is just one LOOLWSD
                     // object. (Even in real Online.) I have no idea what I am doing here.
                     lokit_main(uri, LOOLWSD::prisonerServerSocketFD);
commit 42948f6d7581620eae56c332896dfd279f127ed0
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue Oct 16 16:51:05 2018 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Tue Oct 16 23:04:33 2018 +0300

    On iOS, Util::getThreadId() just wraps std::this_thread::get_id()

diff --git a/common/Util.cpp b/common/Util.cpp
index 25a7be80b..e6a9aefec 100644
--- a/common/Util.cpp
+++ b/common/Util.cpp
@@ -510,8 +510,7 @@ namespace Util
                     ") is now called [" << s << "].");
 #elif defined IOS
         [[NSThread currentThread] setName:[NSString stringWithUTF8String:ThreadName]];
-        LOG_INF("Thread " << getThreadId() << " (" <<
-                std::this_thread::get_id() <<
+        LOG_INF("Thread " << getThreadId() <<
                 ") is now called [" << s << "].");
 #endif
     }
commit 223cc971752d95a0d08c0cd4b7cecb70b0831e1c
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue Oct 16 12:44:56 2018 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Tue Oct 16 23:04:24 2018 +0300

    Log each line separately in fakeSocketDumpState() instead of with embedded newlines

diff --git a/net/FakeSocket.cpp b/net/FakeSocket.cpp
index 580fd2af3..82d221cf4 100644
--- a/net/FakeSocket.cpp
+++ b/net/FakeSocket.cpp
@@ -658,13 +658,13 @@ void fakeSocketDumpState()
     std::vector<FakeSocketPair>& fds = getFds();
     std::unique_lock<std::mutex> lock(theMutex);
 
-    loggingBuffer << "FakeSocket open sockets:";
+    loggingBuffer << "FakeSocket open sockets:" << flush();
     for (int i = 0; i < fds.size(); i++)
     {
         if (fds[i].fd[0] != -1)
         {
             assert(fds[i].fd[0] == i*2);
-            loggingBuffer << "\n  #" << fds[i].fd[0];
+            loggingBuffer << "  #" << fds[i].fd[0];
             if (fds[i].fd[1] != -1)
             {
                 assert(fds[i].fd[1] == i*2+1);
@@ -675,15 +675,15 @@ void fakeSocketDumpState()
             {
                 loggingBuffer << " listening";
             }
+            loggingBuffer << flush();
         }
         else if (fds[i].fd[1] != -1)
         {
             assert(fds[i].fd[1] == i*2+1);
             assert(!fds[i].listening);
-            loggingBuffer << "\n  #" << fds[i].fd[1];
+            loggingBuffer << "  #" << fds[i].fd[1] << flush();
         }
     }
-    loggingBuffer << flush();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit e3d0d601f39e371628384294d7cd7595144244a1
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue Oct 16 11:51:22 2018 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Tue Oct 16 23:03:31 2018 +0300

    Bin superfluous LOG_TRC()
    
    We log the same information (and one more thing) immediately below.

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 6a559f025..f56c13226 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3008,8 +3008,6 @@ int LOOLWSD::innerMain()
 #endif
 #endif
     }
-    LOG_TRC("Loop finished. TerminationFlag=" << TerminationFlag);
-
     // Stop the listening to new connections
     // and wait until sockets close.
     LOG_INF("Stopping server socket listening. ShutdownRequestFlag: " <<


More information about the Libreoffice-commits mailing list