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

Michael Meeks (via logerrit) logerrit at kemper.freedesktop.org
Wed Jan 22 23:39:39 UTC 2020


 wsd/LOOLWSD.cpp |   18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

New commits:
commit c9cfde6d720f8f77f2b8b45ef3a9b04f3cd84cca
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Wed Jan 22 23:24:13 2020 +0100
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Thu Jan 23 00:39:19 2020 +0100

    wsd: use port number after, rather than before allocating it.
    
    Particularly printing it on the console, and passing it to the kit.
    
    Change-Id: I158f97b7b219c44c885939d71af2e5e8283be4c2
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/87227
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 58cd41b7d..64351f94a 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -3109,6 +3109,13 @@ public:
         stop();
     }
 
+    // allocate port & hold temporarily.
+    std::shared_ptr<ServerSocket> _serverSocket;
+    void findClientPort()
+    {
+        _serverSocket = findServerPort(ClientPortNumber);
+    }
+
     void startPrisoners()
     {
         PrisonerPoll.startThread();
@@ -3120,11 +3127,11 @@ public:
         PrisonerPoll.joinThread();
     }
 
-    void start(const int port)
+    void start()
     {
         _acceptPoll.startThread();
-        std::shared_ptr<ServerSocket> serverSocket(findServerPort(port));
-        _acceptPoll.insertNewSocket(serverSocket);
+        _acceptPoll.insertNewSocket(_serverSocket);
+        _serverSocket.reset();
 
 #if MOBILEAPP
         loolwsd_server_socket_fd = serverSocket->getFD();
@@ -3396,6 +3403,9 @@ int LOOLWSD::innerMain()
 
     ClientRequestDispatcher::InitStaticFileContentCache();
 
+    // Allocate our port - passed to prisoners.
+    srv.findClientPort();
+
     // Start the internal prisoner server and spawn forkit,
     // which in turn forks first child.
     srv.startPrisoners();
@@ -3447,7 +3457,7 @@ int LOOLWSD::innerMain()
     Util::mapAnonymized("contents", "contents");
 
     // Start the server.
-    srv.start(ClientPortNumber);
+    srv.start();
 
     /// The main-poll does next to nothing:
     SocketPoll mainWait("main");


More information about the Libreoffice-commits mailing list