[Libreoffice-commits] online.git: Branch 'private/Ashod/nonblocking' - 3 commits - common/Session.cpp common/Session.hpp kit/ChildSession.cpp kit/Kit.cpp Makefile.am test/Makefile.am wsd/ClientSession.cpp wsd/ClientSession.hpp wsd/DocumentBroker.cpp wsd/LOOLWSD.cpp
Jan Holesovsky
kendy at collabora.com
Fri Feb 24 20:39:15 UTC 2017
Makefile.am | 5 -
common/Session.cpp | 89 ++++++------------------
common/Session.hpp | 18 ++--
kit/ChildSession.cpp | 2
kit/Kit.cpp | 10 +-
test/Makefile.am | 3
wsd/ClientSession.cpp | 3
wsd/ClientSession.hpp | 1
wsd/DocumentBroker.cpp | 3
wsd/LOOLWSD.cpp | 177 ++++++++++++++++++++++++++++++++++++++++++++-----
10 files changed, 210 insertions(+), 101 deletions(-)
New commits:
commit 45188ec7c565a3d40cdc30fccdb7558b99430264
Author: Jan Holesovsky <kendy at collabora.com>
Date: Fri Feb 24 20:52:36 2017 +0100
nb: Use the non-blocking socket in the loolwsd.
This so far only builds, but I did not even try to run it yet.
Change-Id: Iceacb5fc5c8994726508e8ea00bd495d758391a8
diff --git a/Makefile.am b/Makefile.am
index cc5f9f7..0a31018 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -25,7 +25,7 @@ endif
ACLOCAL_AMFLAGS = -I m4
# quick and easy for now.
-include_paths = -I${top_srcdir}/common -I${top_srcdir}/wsd -I${top_srcdir}/kit
+include_paths = -I${top_srcdir}/common -I${top_srcdir}/net -I${top_srcdir}/wsd -I${top_srcdir}/kit
AM_CPPFLAGS = -pthread -DLOOLWSD_DATADIR='"@LOOLWSD_DATADIR@"' -DLOOLWSD_CONFIGDIR='"@LOOLWSD_CONFIGDIR@"' ${include_paths}
AM_LDFLAGS = -pthread -Wl,-E
@@ -48,7 +48,8 @@ shared_sources = common/FileUtil.cpp \
common/SpookyV2.cpp \
common/Unit.cpp \
common/UnitHTTP.cpp \
- common/Util.cpp
+ common/Util.cpp \
+ net/WebSocketHandler.cpp
loolwsd_sources = wsd/Admin.cpp \
wsd/AdminModel.cpp \
diff --git a/common/Session.cpp b/common/Session.cpp
index e30dce1..3f7fcca 100644
--- a/common/Session.cpp
+++ b/common/Session.cpp
@@ -26,7 +26,6 @@
#include <set>
#include <Poco/Exception.h>
-#include <Poco/Net/Socket.h>
#include <Poco/Path.h>
#include <Poco/String.h>
#include <Poco/StringTokenizer.h>
@@ -35,7 +34,6 @@
#include "Common.hpp"
#include "IoUtil.hpp"
#include "Protocol.hpp"
-#include <LOOLWebSocket.hpp>
#include "Log.hpp"
#include "TileCache.hpp"
#include "Util.hpp"
@@ -44,13 +42,10 @@
using namespace LOOLProtocol;
using Poco::Exception;
-using Poco::Net::Socket;
-using Poco::Net::WebSocket;
-Session::Session(const std::string& name, const std::string& id, const std::shared_ptr<LOOLWebSocket>& ws) :
+Session::Session(const std::string& name, const std::string& id) :
_id(id),
_name(name),
- _ws(ws),
_disconnected(false),
_isActive(true),
_lastActivityTime(std::chrono::steady_clock::now()),
@@ -68,51 +63,19 @@ Session::~Session()
bool Session::sendTextFrame(const char* buffer, const int length)
{
LOG_TRC(getName() << ": Send: " << getAbbreviatedMessage(buffer, length));
- try
- {
- std::unique_lock<std::mutex> lock(_mutex);
-
- if (!_ws || _ws->poll(Poco::Timespan(0), Socket::SelectMode::SELECT_ERROR))
- {
- LOG_ERR(getName() << ": Bad socket while sending [" << getAbbreviatedMessage(buffer, length) << "].");
- return false;
- }
-
- _ws->sendFrame(buffer, length);
- return true;
- }
- catch (const Exception& exc)
- {
- LOG_ERR("Session::sendTextFrame: Exception: " << exc.displayText() <<
- (exc.nested() ? "( " + exc.nested()->displayText() + ")" : ""));
- }
-
- return false;
+ std::vector<char> data(length);
+ data.assign(buffer, buffer + length);
+ sendMessage(data, WSOpCode::Text);
+ return true;
}
bool Session::sendBinaryFrame(const char *buffer, int length)
{
LOG_TRC(getName() << ": Send: " << std::to_string(length) << " bytes.");
- try
- {
- std::unique_lock<std::mutex> lock(_mutex);
-
- if (!_ws || _ws->poll(Poco::Timespan(0), Socket::SelectMode::SELECT_ERROR))
- {
- LOG_ERR(getName() << ": Bad socket while sending binary frame of " << length << " bytes.");
- return false;
- }
-
- _ws->sendFrame(buffer, length, WebSocket::FRAME_BINARY);
- return true;
- }
- catch (const Exception& exc)
- {
- LOG_ERR("Session::sendBinaryFrame: Exception: " << exc.displayText() <<
- (exc.nested() ? "( " + exc.nested()->displayText() + ")" : ""));
- }
-
- return false;
+ std::vector<char> data(length);
+ data.assign(buffer, buffer + length);
+ sendMessage(data);
+ return true;
}
void Session::parseDocOptions(const std::vector<std::string>& tokens, int& part, std::string& timestamp)
@@ -190,47 +153,43 @@ bool Session::handleDisconnect()
void Session::shutdown(Poco::UInt16 statusCode, const std::string& statusMessage)
{
- if (_ws)
- {
- LOG_TRC("Shutting down WS [" << getName() << "] with statusCode [" <<
- statusCode << "] and reason [" << statusMessage << "].");
+ LOG_TRC("Shutting down WS [" << getName() << "] with statusCode [" <<
+ statusCode << "] and reason [" << statusMessage << "].");
- // See protocol.txt for this application-level close frame.
- const std::string msg = "close: " + statusMessage;
- _ws->sendFrame(msg.data(), msg.size());
- _ws->shutdown(statusCode, statusMessage);
- }
+ // See protocol.txt for this application-level close frame.
+ const std::string msg = "close: " + statusMessage;
+ sendTextFrame(msg.data(), msg.size());
+ // TODO loolnb anything needed here? _ws->shutdown(statusCode, statusMessage);
}
-bool Session::handleInput(const char *buffer, int length)
+void Session::handleMessage(bool /*fin*/, WSOpCode /*code*/, std::vector<char> &data)
{
- LOG_CHECK_RET(buffer != nullptr, false);
-
try
{
std::unique_ptr< std::vector<char> > replace;
- if (UnitBase::get().filterSessionInput(this, buffer, length, replace))
+ if (UnitBase::get().filterSessionInput(this, &data[0], data.size(), replace))
{
- buffer = replace->data();
- length = replace->size();
+ _handleInput(replace->data(), replace->size());
+ return;
}
- return _handleInput(buffer, length);
+ _handleInput(&data[0], data.size());
+ return;
}
catch (const Exception& exc)
{
LOG_ERR("Session::handleInput: Exception while handling [" <<
- getAbbreviatedMessage(buffer, length) <<
+ getAbbreviatedMessage(data) <<
"] in " << getName() << ": " << exc.displayText() <<
(exc.nested() ? " (" + exc.nested()->displayText() + ")" : ""));
}
catch (const std::exception& exc)
{
LOG_ERR("Session::handleInput: Exception while handling [" <<
- getAbbreviatedMessage(buffer, length) << "]: " << exc.what());
+ getAbbreviatedMessage(data) << "]: " << exc.what());
}
- return false;
+ return;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/common/Session.hpp b/common/Session.hpp
index 26b5626..a96dc7c 100644
--- a/common/Session.hpp
+++ b/common/Session.hpp
@@ -28,9 +28,10 @@
#include "MessageQueue.hpp"
#include "Message.hpp"
#include "TileCache.hpp"
+#include "WebSocketHandler.hpp"
/// Base class of a LOOLWebSocket session.
-class Session
+class Session : public WebSocketHandler
{
public:
const std::string& getId() const { return _id; }
@@ -44,7 +45,7 @@ public:
return sendTextFrame(text.data(), text.size());
}
- bool handleInput(const char* buffer, int length);
+ virtual void handleMessage(bool fin, WSOpCode code, std::vector<char> &data) override;
/// Invoked when we want to disconnect a session.
virtual void disconnect();
@@ -68,10 +69,15 @@ public:
void closeFrame() { _isCloseFrame = true; };
bool isCloseFrame() const { return _isCloseFrame; }
- bool isHeadless() const { return _ws == nullptr; }
+ bool isHeadless() const
+ {
+ // TODO loolnb here we should return true when the socket was not
+ // upgraded yet
+ return false;
+ }
protected:
- Session(const std::string& name, const std::string& id, const std::shared_ptr<LOOLWebSocket>& ws);
+ Session(const std::string& name, const std::string& id);
virtual ~Session();
/// Parses the options of the "load" command, shared between MasterProcessSession::loadDocument() and ChildProcessSession::loadDocument().
@@ -98,10 +104,6 @@ private:
/// A readable name that identifies our peer and ID.
const std::string _name;
- // In the master process, the websocket to the LOOL client or the jailed child process. In a
- // jailed process, the websocket to the parent.
- std::shared_ptr<LOOLWebSocket> _ws;
-
/// True if we have been disconnected.
std::atomic<bool> _disconnected;
/// True if the user is active, otherwise false (switched tabs).
diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index 8c6942e..1cb8627 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -37,7 +37,7 @@ std::recursive_mutex ChildSession::Mutex;
ChildSession::ChildSession(const std::string& id,
const std::string& jailId,
IDocumentManager& docManager) :
- Session("ToMaster-" + id, id, nullptr),
+ Session("ToMaster-" + id, id),
_jailId(jailId),
_docManager(docManager),
_viewId(-1),
diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index fbbb030..a190669 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -77,7 +77,6 @@ using Poco::File;
using Poco::JSON::Array;
using Poco::JSON::Object;
using Poco::JSON::Parser;
-using Poco::Net::Socket;
using Poco::Net::WebSocket;
using Poco::Runnable;
using Poco::StringTokenizer;
@@ -774,7 +773,7 @@ public:
{
try
{
- if (!_ws || _ws->poll(Poco::Timespan(0), Socket::SelectMode::SELECT_ERROR))
+ if (!_ws || _ws->poll(Poco::Timespan(0), Poco::Net::Socket::SelectMode::SELECT_ERROR))
{
LOG_ERR("Child Doc: Bad socket while sending [" << getAbbreviatedMessage(message) << "].");
return false;
@@ -1288,7 +1287,12 @@ private:
lock.unlock();
if (session)
{
- return session->handleInput(data, size);
+ std::vector<char> vect(size);
+ vect.assign(data, data + size);
+
+ // TODO loolnb - this is probably wrong...
+ session->handleMessage(/* fin = */ false, WebSocketHandler::WSOpCode::Binary, vect);
+ return true;
}
}
diff --git a/test/Makefile.am b/test/Makefile.am
index 7efa3f1..167c436 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -10,7 +10,7 @@ check_PROGRAMS = test
noinst_PROGRAMS = test unittest
AM_CXXFLAGS = $(CPPUNIT_CFLAGS) -DTDOC=\"$(top_srcdir)/test/data\" \
- -I${top_srcdir}/common -I${top_srcdir}/wsd -I${top_srcdir}/kit
+ -I${top_srcdir}/common -I${top_srcdir}/net -I${top_srcdir}/wsd -I${top_srcdir}/kit
noinst_LTLIBRARIES = \
unit-timeout.la unit-prefork.la \
@@ -36,6 +36,7 @@ wsd_sources = \
../common/Protocol.cpp \
../common/Session.cpp \
../common/MessageQueue.cpp \
+ ../net/WebSocketHandler.cpp \
../kit/Kit.cpp \
../wsd/TileCache.cpp \
../common/Unit.cpp \
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index deb4680..140ea77 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -28,11 +28,10 @@ using Poco::Path;
using Poco::StringTokenizer;
ClientSession::ClientSession(const std::string& id,
- const std::shared_ptr<LOOLWebSocket>& ws,
const std::shared_ptr<DocumentBroker>& docBroker,
const Poco::URI& uriPublic,
const bool readOnly) :
- Session("ToClient-" + id, id, ws),
+ Session("ToClient-" + id, id),
_docBroker(docBroker),
_uriPublic(uriPublic),
_isReadOnly(readOnly),
diff --git a/wsd/ClientSession.hpp b/wsd/ClientSession.hpp
index a6efb50..b2ecc8a 100644
--- a/wsd/ClientSession.hpp
+++ b/wsd/ClientSession.hpp
@@ -24,7 +24,6 @@ class ClientSession final : public Session, public std::enable_shared_from_this<
{
public:
ClientSession(const std::string& id,
- const std::shared_ptr<LOOLWebSocket>& ws,
const std::shared_ptr<DocumentBroker>& docBroker,
const Poco::URI& uriPublic,
const bool isReadOnly = false);
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 0225f46..0f67e81 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1046,7 +1046,10 @@ bool DocumentBroker::forwardToClient(const std::shared_ptr<Message>& payload)
// Broadcast to all.
for (const auto& pair : _sessions)
{
+#if 0 // loolnb
if (!pair.second->isHeadless() && !pair.second->isCloseFrame())
+#endif
+ if (!pair.second->isHeadless())
{
pair.second->handleKitToClientMessage(data, size);
}
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 77d6329..d376f09 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -106,7 +106,7 @@
#include "IoUtil.hpp"
#include "Log.hpp"
#include "Protocol.hpp"
-#include "QueueHandler.hpp"
+#include "ServerSocket.hpp"
#include "Session.hpp"
#include "Storage.hpp"
#include "TraceFile.hpp"
@@ -114,8 +114,8 @@
#include "UnitHTTP.hpp"
#include "UserMessages.hpp"
#include "Util.hpp"
-#include "common/FileUtil.hpp"
-#include <LOOLWebSocket.hpp>
+#include "FileUtil.hpp"
+#include "LOOLWebSocket.hpp"
#ifdef KIT_IN_PROCESS
#include <Kit.hpp>
@@ -145,9 +145,7 @@ using Poco::Net::MessageHeader;
using Poco::Net::NameValueCollection;
using Poco::Net::PartHandler;
using Poco::Net::SecureServerSocket;
-using Poco::Net::ServerSocket;
using Poco::Net::SocketAddress;
-using Poco::Net::StreamSocket;
using Poco::Net::WebSocket;
using Poco::Path;
using Poco::Pipe;
@@ -1592,7 +1590,7 @@ public:
namespace
{
-inline ServerSocket* getServerSocket(int portNumber, bool reuseDetails)
+inline Poco::Net::ServerSocket* getServerSocket(int portNumber, bool reuseDetails)
{
try
{
@@ -1629,7 +1627,7 @@ inline ServerSocket* getServerSocket(int portNumber, bool reuseDetails)
try
{
LOG_INF("Trying first to connect to an existing loolwsd at the same port " << portNumber);
- StreamSocket s(SocketAddress("127.0.0.1:" + std::to_string(portNumber)));
+ Poco::Net::StreamSocket s(SocketAddress("127.0.0.1:" + std::to_string(portNumber)));
LOG_FTL("Connection succeeded, so we can't continue");
return nullptr;
}
@@ -1639,12 +1637,12 @@ inline ServerSocket* getServerSocket(int portNumber, bool reuseDetails)
}
}
- ServerSocket* socket = LOOLWSD::isSSLEnabled() ? new SecureServerSocket() : new ServerSocket();
+ Poco::Net::ServerSocket* socket = LOOLWSD::isSSLEnabled() ? new SecureServerSocket() : new Poco::Net::ServerSocket();
Poco::Net::IPAddress wildcardAddr;
SocketAddress address(wildcardAddr, portNumber);
socket->bind(address, reuseDetails);
// 64 is the default value for the backlog parameter in Poco
- // when creating a ServerSocket, so use it here, too.
+ // when creating a Poco::Net::ServerSocket, so use it here, too.
socket->listen(64);
return socket;
}
@@ -1655,9 +1653,9 @@ inline ServerSocket* getServerSocket(int portNumber, bool reuseDetails)
}
}
-inline ServerSocket* findFreeServerPort(int& portNumber)
+inline Poco::Net::ServerSocket* findFreeServerPort(int& portNumber)
{
- ServerSocket* socket = nullptr;
+ Poco::Net::ServerSocket* socket = nullptr;
while (!socket)
{
socket = getServerSocket(portNumber, false);
@@ -1670,12 +1668,12 @@ inline ServerSocket* findFreeServerPort(int& portNumber)
return socket;
}
-inline ServerSocket* getMasterSocket(int portNumber)
+inline Poco::Net::ServerSocket* getMasterSocket(int portNumber)
{
try
{
SocketAddress addr2("127.0.0.1", portNumber);
- return new ServerSocket(addr2);
+ return new Poco::Net::ServerSocket(addr2);
}
catch (const Exception& exc)
{
@@ -1684,9 +1682,9 @@ inline ServerSocket* getMasterSocket(int portNumber)
}
}
-inline ServerSocket* findFreeMasterPort(int &portNumber)
+inline Poco::Net::ServerSocket* findFreeMasterPort(int &portNumber)
{
- ServerSocket* socket = nullptr;
+ Poco::Net::ServerSocket* socket = nullptr;
while (!socket)
{
socket = getServerSocket(portNumber, false);
@@ -2364,6 +2362,129 @@ bool LOOLWSD::createForKit()
std::mutex Connection::Mutex;
#endif
+// TODO loolnb FIXME
+static const std::string HARDCODED_PATH("file:///local/libreoffice/online/test/data/hello-world.odt");
+
+class PlainSocketFactory : public SocketFactory
+{
+ std::shared_ptr<Socket> create(const int fd) override
+ {
+ // TODO FIXME loolnb - avoid the copy/paste between PlainSocketFactory
+ // and SslSocketFactory
+ // Request a kit process for this doc.
+ auto child = getNewChild();
+ if (!child)
+ {
+ // Let the client know we can't serve now.
+ throw std::runtime_error("Failed to spawn lokit child.");
+ }
+
+ Poco::URI uri(HARDCODED_PATH);
+ std::shared_ptr<DocumentBroker> docBroker = std::make_shared<DocumentBroker>(HARDCODED_PATH, uri, HARDCODED_PATH, LOOLWSD::ChildRoot, child);
+ return std::make_shared<StreamSocket>(fd, new ClientSession("hardcoded", docBroker, uri));
+ }
+};
+
+class SslSocketFactory : public SocketFactory
+{
+ std::shared_ptr<Socket> create(const int fd) override
+ {
+ // TODO FIXME loolnb - avoid the copy/paste between PlainSocketFactory
+ // and SslSocketFactory
+ // Request a kit process for this doc.
+ auto child = getNewChild();
+ if (!child)
+ {
+ // Let the client know we can't serve now.
+ throw std::runtime_error("Failed to spawn lokit child.");
+ }
+
+ Poco::URI uri(HARDCODED_PATH);
+ std::shared_ptr<DocumentBroker> docBroker = std::make_shared<DocumentBroker>(HARDCODED_PATH, uri, HARDCODED_PATH, LOOLWSD::ChildRoot, child);
+ return std::make_shared<StreamSocket>(fd, new ClientSession("hardcoded", docBroker, uri));
+ }
+};
+
+/// The main server thread.
+///
+/// Waits for the connections from the loleaflets, and creates the
+/// websockethandlers accordingly.
+class LOOLWSDServer
+{
+ LOOLWSDServer(LOOLWSDServer&& other) = delete;
+ const LOOLWSDServer& operator=(LOOLWSDServer&& other) = delete;
+
+public:
+ LOOLWSDServer()
+ : _stop(false)
+ {
+ }
+
+ ~LOOLWSDServer()
+ {
+ stop();
+ if (_serverThread.joinable())
+ _serverThread.join();
+ }
+
+ void start(const Poco::Net::SocketAddress& addr)
+ {
+ std::shared_ptr<ServerSocket> serverSocket = std::make_shared<ServerSocket>(_documentPoll,
+ LOOLWSD::isSSLEnabled()? std::unique_ptr<SocketFactory>{new SslSocketFactory()}:
+ std::unique_ptr<SocketFactory>{new PlainSocketFactory()});
+
+ if (!serverSocket->bind(addr))
+ {
+ const std::string msg = "Failed to bind. (errno: ";
+ throw std::runtime_error(msg + std::strerror(errno) + ")");
+ }
+
+ if (!serverSocket->listen())
+ {
+ const std::string msg = "Failed to listen. (errno: ";
+ throw std::runtime_error(msg + std::strerror(errno) + ")");
+ }
+
+ _serverPoll.insertNewSocket(serverSocket);
+
+ _serverThread = std::thread(runServer, std::ref(_stop), std::ref(_serverPoll));
+
+ // TODO loolnb - we need a documentThread per document
+ _documentThread = std::thread(runDocument, std::ref(_stop), std::ref(_documentPoll));
+ }
+
+ void stop()
+ {
+ _stop = true;
+ }
+
+private:
+ std::atomic<bool> _stop;
+
+ SocketPoll _serverPoll;
+ std::thread _serverThread;
+
+ // TODO loolnb - we need a documentThread per document
+ SocketPoll _documentPoll;
+ std::thread _documentThread;
+
+ static void runServer(std::atomic<bool>& stop, SocketPoll& serverPoll) {
+ LOG_INF("Starting master server thread.");
+ while (!stop)
+ {
+ serverPoll.poll(30000);
+ }
+ }
+
+ static void runDocument(std::atomic<bool>& stop, SocketPoll& documentPoll) {
+ LOG_INF("Starting document thread.");
+ while (!stop)
+ {
+ documentPoll.poll(5000);
+ }
+ }
+};
+
int LOOLWSD::main(const std::vector<std::string>& /*args*/)
{
#ifndef FUZZER
@@ -2461,7 +2582,7 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
// Start internal server for child processes.
SocketAddress addr2("127.0.0.1", MasterPortNumber);
- std::unique_ptr<ServerSocket> psvs2(
+ std::unique_ptr<Poco::Net::ServerSocket> psvs2(
UnitWSD::isUnitTesting() ?
findFreeMasterPort(MasterPortNumber) :
getMasterSocket(MasterPortNumber));
@@ -2485,7 +2606,7 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
#if 0 // loolnb
// Now we can serve clients; Start listening on the public port.
- std::unique_ptr<ServerSocket> psvs(
+ std::unique_ptr<Poco::Net::ServerSocket> psvs(
UnitWSD::isUnitTesting() ?
findFreeServerPort(ClientPortNumber) :
getServerSocket(ClientPortNumber, true));
@@ -2501,6 +2622,11 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
srv.start();
#endif
+ LOOLWSDServer srv;
+ // TODO loolnb
+ SocketAddress addr("127.0.0.1", ClientPortNumber);
+ srv.start(addr);
+
#if ENABLE_DEBUG
time_t startTimeSpan = time(nullptr);
#endif
@@ -2588,9 +2714,7 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
SigUtil::isShuttingDown() << ", TerminationFlag: " << TerminationFlag);
// Wait until documents are saved and sessions closed.
-#if 0 // loolnb
srv.stop();
-#endif
srv2.stop();
threadPool.joinAll();
commit f2025558a296323bf91f37294d73a94427982574
Author: Jan Holesovsky <kendy at collabora.com>
Date: Fri Feb 24 14:19:21 2017 +0100
nb: Comment out the POCO server in loolwsd.
Change-Id: Ie4f276a6f1c8f3d132b23bb2111466b38f4fb581
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index e572cbf..77d6329 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -590,6 +590,7 @@ public:
}
};
+#if 0 // loolnb
/// Handle a public connection from a client.
class ClientRequestHandler : public HTTPRequestHandler
{
@@ -1450,6 +1451,7 @@ public:
LOG_DBG("Thread finished.");
}
};
+#endif
/// Handler of announcements that a new loolkit process was created.
///
@@ -1510,6 +1512,7 @@ public:
}
};
+#if 0 // loolnb
/// External (client) connection handler factory.
/// Creates handler objects.
class ClientRequestHandlerFactory : public HTTPRequestHandlerFactory
@@ -1560,6 +1563,7 @@ public:
return requestHandler;
}
};
+#endif
/// Internal (prisoner) connection handler factory.
/// Creates handler objects.
@@ -2438,8 +2442,10 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
static_assert(MAX_CONNECTIONS >= 3, "MAX_CONNECTIONS must be at least 3");
const auto maxThreadCount = MAX_CONNECTIONS * 5;
+#if 0 // loolnb
auto params1 = new HTTPServerParams();
params1->setMaxThreads(maxThreadCount);
+#endif
auto params2 = new HTTPServerParams();
params2->setMaxThreads(maxThreadCount);
@@ -2477,6 +2483,7 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
return Application::EXIT_SOFTWARE;
}
+#if 0 // loolnb
// Now we can serve clients; Start listening on the public port.
std::unique_ptr<ServerSocket> psvs(
UnitWSD::isUnitTesting() ?
@@ -2492,6 +2499,7 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
HTTPServer srv(new ClientRequestHandlerFactory(), threadPool, *psvs, params1);
LOG_INF("Starting master server listening on " << ClientPortNumber);
srv.start();
+#endif
#if ENABLE_DEBUG
time_t startTimeSpan = time(nullptr);
@@ -2580,7 +2588,9 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
SigUtil::isShuttingDown() << ", TerminationFlag: " << TerminationFlag);
// Wait until documents are saved and sessions closed.
+#if 0 // loolnb
srv.stop();
+#endif
srv2.stop();
threadPool.joinAll();
@@ -2659,7 +2669,9 @@ void UnitWSD::testHandleRequest(TestRequest type, UnitHTTPServerRequest& request
switch (type)
{
case TestRequest::Client:
+#if 0 // loolnb
ClientRequestHandler::handleClientRequest(request, response, LOOLWSD::GenSessionId());
+#endif
break;
case TestRequest::Prisoner:
PrisonerRequestHandler::handlePrisonerRequest(request, response);
commit 16ffd218d5b525b931dddd74d979adbe5ecf16f7
Author: Jan Holesovsky <kendy at collabora.com>
Date: Fri Feb 24 13:00:04 2017 +0100
Clarify the PrisonerRequestHandler documentation.
Change-Id: Ie3750b17ce4f2d99b80f39f3c0e1374f3e9c1a5a
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 9b475e6..e572cbf 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1451,7 +1451,12 @@ public:
}
};
-/// Handle requests from prisoners (internal).
+/// Handler of announcements that a new loolkit process was created.
+///
+/// loolforkit is creating the loolkit processes. That happens
+/// completely assynchronously, and from the different process (loolforkit),
+/// so this handler is listening for annoucements that a new loolkit process
+/// has been created.
class PrisonerRequestHandler : public HTTPRequestHandler
{
public:
More information about the Libreoffice-commits
mailing list