[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - wsd/LOOLWSD.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Thu Apr 6 01:22:13 UTC 2017
wsd/LOOLWSD.cpp | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
New commits:
commit d167d2b06af62303a97bf503201d4874010121ac
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Wed Apr 5 00:21:49 2017 -0400
wsd: correctly search for available prisoner port
Search for the next 100 ports for a usable one
and pass the one found to forkit so it connects
on that one instead of the default.
Change-Id: I26697dd8b5a35992f9e000a35ad5b44c3a3699dd
Reviewed-on: https://gerrit.libreoffice.org/36114
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
(cherry picked from commit 2576f9c4e9dc8a4e7eb084b4bc74055f0c92e850)
Reviewed-on: https://gerrit.libreoffice.org/36123
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index afa59707..a1d7ec61 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2163,7 +2163,7 @@ public:
stop();
}
- void startPrisoners(const int port)
+ void startPrisoners(int& port)
{
PrisonerPoll.insertNewSocket(findPrisonerServerPort(port));
PrisonerPoll.startThread();
@@ -2245,31 +2245,27 @@ private:
if (!serverSocket->bind(addr))
{
- LOG_ERR("Failed to bind to: " << addr.toString());
+ LOG_SYS("Failed to bind to: " << addr.toString());
return nullptr;
}
if (serverSocket->listen())
return serverSocket;
- LOG_ERR("Failed to listen on: " << addr.toString());
+ LOG_SYS("Failed to listen on: " << addr.toString());
return nullptr;
}
- std::shared_ptr<ServerSocket> findPrisonerServerPort(int port)
+ std::shared_ptr<ServerSocket> findPrisonerServerPort(int& port)
{
std::shared_ptr<SocketFactory> factory = std::make_shared<PrisonerSocketFactory>();
+
+ LOG_INF("Trying to listen on prisoner port " << port << ".");
std::shared_ptr<ServerSocket> socket = getServerSocket(SocketAddress("127.0.0.1", port),
PrisonerPoll, factory);
- if (!UnitWSD::isUnitTesting() && !socket)
- {
- LOG_FTL("Failed to listen on Prisoner master port (" <<
- MasterPortNumber << "). Exiting.");
- _exit(Application::EXIT_SOFTWARE);
- }
-
- while (!socket)
+ // If we fail, try the next 100 ports.
+ for (int i = 0; i < 100 && !socket; ++i)
{
++port;
LOG_INF("Prisoner port " << (port - 1) << " is busy, trying " << port << ".");
@@ -2277,6 +2273,14 @@ private:
PrisonerPoll, factory);
}
+ if (!UnitWSD::isUnitTesting() && !socket)
+ {
+ LOG_FTL("Failed to listen on Prisoner port (" <<
+ MasterPortNumber << '-' << port << "). Exiting.");
+ _exit(Application::EXIT_SOFTWARE);
+ }
+
+ LOG_INF("Listening to prisoner connections on port " << port);
return socket;
}
More information about the Libreoffice-commits
mailing list