extract some functions to extra files for in process mode
Extract some functions from ForKit.cpp and COOLWSD.cpp to new files so we can do a kit in process mode without using ifdef directives. Signed-off-by: Jaume Pujantell <jaume.pujantell@collabora.com> Change-Id: I7529f8f46a8026318244666b27d1ce72ed5ad4capull/7850/head
parent
a1e08c1aab
commit
8f178ef6cd
|
@ -100,6 +100,7 @@ loadtest
|
|||
unittest
|
||||
clientnb
|
||||
libsimd.a
|
||||
coolwsd-inproc
|
||||
|
||||
# Fuzzer
|
||||
*_fuzzer
|
||||
|
|
|
@ -147,7 +147,8 @@ coolwsd_sources = common/Crypto.cpp \
|
|||
wsd/WopiProxy.cpp
|
||||
|
||||
coolwsd_SOURCES = $(coolwsd_sources) \
|
||||
$(shared_sources)
|
||||
$(shared_sources) \
|
||||
wsd/coolwsd-fork.cpp
|
||||
|
||||
EXTRA_coolwsd_DEPENDENCIES = browser/node_modules
|
||||
|
||||
|
@ -189,7 +190,8 @@ coolforkit_sources = kit/ChildSession.cpp \
|
|||
kit/Kit.cpp
|
||||
|
||||
coolforkit_SOURCES = $(coolforkit_sources) \
|
||||
$(shared_sources)
|
||||
$(shared_sources) \
|
||||
kit/forkit-main.cpp
|
||||
|
||||
coolforkit_LDADD = libsimd.a
|
||||
|
||||
|
@ -200,6 +202,7 @@ coolforkit_SOURCES += \
|
|||
common_fuzzer_sources = \
|
||||
common/DummyTraceEventEmitter.cpp \
|
||||
$(coolwsd_sources) \
|
||||
wsd/coolwsd-inproc.cpp \
|
||||
$(coolforkit_sources) \
|
||||
$(shared_sources)
|
||||
|
||||
|
|
|
@ -28,7 +28,8 @@ add_library(androidapp SHARED
|
|||
../../../../../wsd/COOLWSD.cpp
|
||||
../../../../../wsd/RequestDetails.cpp
|
||||
../../../../../wsd/Storage.cpp
|
||||
../../../../../wsd/TileCache.cpp)
|
||||
../../../../../wsd/TileCache.cpp
|
||||
../../../../../wsd/coolwsd-fork.cpp)
|
||||
|
||||
target_compile_definitions(androidapp PRIVATE COOLWSD_CONFIGDIR="/assets/etc/coolwsd")
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ wsd_sources = ../wsd/ClientSession.cpp \
|
|||
../wsd/COOLWSD.cpp \
|
||||
../wsd/RequestDetails.cpp \
|
||||
../wsd/Storage.cpp \
|
||||
../wsd/TileCache.cpp
|
||||
../wsd/TileCache.cpp \
|
||||
../wsd/coolwsd-fork.cpp
|
||||
|
||||
mobile_SOURCES = mobile.cpp $(common_sources) $(kit_sources) $(net_sources) $(wsd_sources)
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
1FCFA28A2B2AF13F007EE2DF /* coolwsd-fork.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1FCFA2892B2AF13C007EE2DF /* coolwsd-fork.cpp */; };
|
||||
3F3B54DD2A3928D100063C01 /* HttpRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3F3B54DB2A39288500063C01 /* HttpRequest.cpp */; };
|
||||
3F3B54E02A392CCB00063C01 /* NetUtil.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3F3B54DE2A392C9C00063C01 /* NetUtil.cpp */; };
|
||||
A5C2FA5A2AC1BB3900265946 /* Simd.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5C2FA592AC1BB3800265946 /* Simd.cpp */; };
|
||||
|
@ -80,6 +81,7 @@
|
|||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
1FCFA2892B2AF13C007EE2DF /* coolwsd-fork.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "coolwsd-fork.cpp"; sourceTree = "<group>"; };
|
||||
3F3B54DB2A39288500063C01 /* HttpRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HttpRequest.cpp; sourceTree = "<group>"; };
|
||||
3F3B54DC2A39288500063C01 /* HttpRequest.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = HttpRequest.hpp; sourceTree = "<group>"; };
|
||||
3F3B54DE2A392C9C00063C01 /* NetUtil.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetUtil.cpp; sourceTree = "<group>"; };
|
||||
|
@ -2203,6 +2205,7 @@
|
|||
BE5EB5B7213FE21600E0826C /* wsd */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1FCFA2892B2AF13C007EE2DF /* coolwsd-fork.cpp */,
|
||||
BEBF3EAF246EB1C800415E87 /* RequestDetails.cpp */,
|
||||
BEBF3EAE246EB1C800415E87 /* RequestDetails.hpp */,
|
||||
BE5EB5CC213FE2D000E0826C /* ClientSession.cpp */,
|
||||
|
@ -3653,6 +3656,7 @@
|
|||
BEA28360214ACA8500848631 /* FakeSocket.cpp in Sources */,
|
||||
BE80E45821B68F5700859C97 /* TemplateCollectionViewController.mm in Sources */,
|
||||
BE8D77352136762500AC58EA /* CODocument.mm in Sources */,
|
||||
1FCFA28A2B2AF13F007EE2DF /* coolwsd-fork.cpp in Sources */,
|
||||
BE5EB5C7213FE29900E0826C /* Protocol.cpp in Sources */,
|
||||
BE8D772F2136762500AC58EA /* DocumentBrowserViewController.mm in Sources */,
|
||||
BE9ADE3F265D046600BC034A /* TraceEvent.cpp in Sources */,
|
||||
|
|
|
@ -77,11 +77,6 @@ static std::map<pid_t, std::string> childJails;
|
|||
/// The jails that need cleaning up. This should be small.
|
||||
static std::vector<std::string> cleanupJailPaths;
|
||||
|
||||
#ifndef KIT_IN_PROCESS
|
||||
int ClientPortNumber = DEFAULT_CLIENT_PORT_NUMBER;
|
||||
std::string MasterLocation;
|
||||
#endif
|
||||
|
||||
extern "C" { void dump_forkit_state(void); /* easy for gdb */ }
|
||||
|
||||
void dump_forkit_state()
|
||||
|
@ -490,7 +485,6 @@ void forkLibreOfficeKit(const std::string& childRoot,
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef KIT_IN_PROCESS
|
||||
static void printArgumentHelp()
|
||||
{
|
||||
std::cout << "Usage: coolforkit [OPTION]..." << std::endl;
|
||||
|
@ -500,7 +494,7 @@ static void printArgumentHelp()
|
|||
std::cout << "" << std::endl;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
int forkit_main(int argc, char** argv)
|
||||
{
|
||||
/*WARNING: PRIVILEGED CODE CHECKING START */
|
||||
|
||||
|
@ -808,6 +802,5 @@ int main(int argc, char** argv)
|
|||
LOG_INF("ForKit process finished.");
|
||||
Util::forcedExit(returnValue);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
|
|
@ -151,6 +151,9 @@ void forkLibreOfficeKit(const std::string& childRoot,
|
|||
const std::string& loTemplate,
|
||||
int limit = 0);
|
||||
|
||||
/// main function of the forkit process or thread
|
||||
int forkit_main(int argc, char** argv);
|
||||
|
||||
/// Anonymize the basename of filenames, preserving the path and extension.
|
||||
std::string anonymizeUrl(const std::string& url);
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright the Collabora Online contributors.
|
||||
*
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
#include "config.h"
|
||||
#include "Common.hpp"
|
||||
#include "Kit.hpp"
|
||||
|
||||
int ClientPortNumber = DEFAULT_CLIENT_PORT_NUMBER;
|
||||
std::string MasterLocation;
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
return forkit_main(argc, argv);
|
||||
}
|
|
@ -46,7 +46,8 @@ online_SOURCES = \
|
|||
../wsd/COOLWSD.cpp \
|
||||
../wsd/RequestDetails.cpp \
|
||||
../wsd/Storage.cpp \
|
||||
../wsd/TileCache.cpp
|
||||
../wsd/TileCache.cpp \
|
||||
../wsd/coolwsd-fork.cpp
|
||||
|
||||
online_DEPENDENCIES = \
|
||||
@LOBUILDDIR@/instdir/program/soffice.html.linkdeps \
|
||||
|
|
|
@ -136,7 +136,7 @@ using Poco::Net::PartHandler;
|
|||
#include <common/JsonUtil.hpp>
|
||||
#include <common/FileUtil.hpp>
|
||||
#include <common/JailUtil.hpp>
|
||||
#if defined KIT_IN_PROCESS || MOBILEAPP
|
||||
#if MOBILEAPP
|
||||
# include <Kit.hpp>
|
||||
#endif
|
||||
#include <Log.hpp>
|
||||
|
@ -398,31 +398,6 @@ void COOLWSD::writeTraceEventRecording(const std::string &recording)
|
|||
writeTraceEventRecording(recording.data(), recording.length());
|
||||
}
|
||||
|
||||
#if !LIBFUZZER
|
||||
// FIXME: Somewhat idiotically, the parameter to emitOneRecordingIfEnabled() should end with a
|
||||
// newline, while the paramter to emitOneRecording() should not.
|
||||
|
||||
void TraceEvent::emitOneRecordingIfEnabled(const std::string &recording)
|
||||
{
|
||||
if (COOLWSD::TraceEventFile == NULL)
|
||||
return;
|
||||
|
||||
COOLWSD::writeTraceEventRecording(recording);
|
||||
}
|
||||
|
||||
void TraceEvent::emitOneRecording(const std::string &recording)
|
||||
{
|
||||
if (COOLWSD::TraceEventFile == NULL)
|
||||
return;
|
||||
|
||||
if (!TraceEvent::isRecordingOn())
|
||||
return;
|
||||
|
||||
COOLWSD::writeTraceEventRecording(recording + "\n");
|
||||
}
|
||||
|
||||
#endif //!LIBFUZZER
|
||||
|
||||
void COOLWSD::checkSessionLimitsAndWarnClients()
|
||||
{
|
||||
#if !ENABLE_SUPPORT_KEY
|
||||
|
@ -3484,9 +3459,6 @@ void PrisonPoll::wakeupHook()
|
|||
|
||||
bool COOLWSD::createForKit()
|
||||
{
|
||||
#if defined KIT_IN_PROCESS
|
||||
return true;
|
||||
#else
|
||||
LOG_INF("Creating new forkit process.");
|
||||
|
||||
// Creating a new forkit is always a slow process.
|
||||
|
@ -3574,6 +3546,8 @@ bool COOLWSD::createForKit()
|
|||
// Always reap first, in case we haven't done so yet.
|
||||
if (ForKitProcId != -1)
|
||||
{
|
||||
if (Util::isKitInProcess())
|
||||
return true;
|
||||
int status;
|
||||
waitpid(ForKitProcId, &status, WUNTRACED | WNOHANG);
|
||||
ForKitProcId = -1;
|
||||
|
@ -3590,7 +3564,7 @@ bool COOLWSD::createForKit()
|
|||
LOG_INF("Launching forkit process: " << forKitPath << ' ' << args.cat(' ', 0));
|
||||
|
||||
LastForkRequestTime = std::chrono::steady_clock::now();
|
||||
int child = Util::spawnProcess(forKitPath, args);
|
||||
int child = createForkit(forKitPath, args);
|
||||
ForKitProcId = child;
|
||||
|
||||
LOG_INF("Forkit process launched: " << ForKitProcId);
|
||||
|
@ -3603,7 +3577,6 @@ bool COOLWSD::createForKit()
|
|||
rebalanceChildren(balance);
|
||||
|
||||
return ForKitProcId != -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
void COOLWSD::sendMessageToForKit(const std::string& message)
|
||||
|
|
|
@ -656,4 +656,8 @@ public:
|
|||
#endif
|
||||
};
|
||||
|
||||
#if !MOBILEAPP
|
||||
int createForkit(const std::string& forKitPath, const StringVector& args);
|
||||
#endif
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright the Collabora Online contributors.
|
||||
*
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
#include "StringVector.hpp"
|
||||
#include "Util.hpp"
|
||||
#include "TraceEvent.hpp"
|
||||
#include "COOLWSD.hpp"
|
||||
|
||||
#if !MOBILEAPP
|
||||
int createForkit(const std::string& forKitPath, const StringVector& args)
|
||||
{
|
||||
// create forkit in a process
|
||||
return Util::spawnProcess(forKitPath, args);
|
||||
};
|
||||
#endif
|
||||
|
||||
// FIXME: Somewhat idiotically, the parameter to emitOneRecordingIfEnabled() should end with a
|
||||
// newline, while the paramter to emitOneRecording() should not.
|
||||
|
||||
void TraceEvent::emitOneRecordingIfEnabled(const std::string& recording)
|
||||
{
|
||||
if (COOLWSD::TraceEventFile == NULL)
|
||||
return;
|
||||
|
||||
COOLWSD::writeTraceEventRecording(recording);
|
||||
}
|
||||
|
||||
void TraceEvent::emitOneRecording(const std::string& recording)
|
||||
{
|
||||
if (COOLWSD::TraceEventFile == NULL)
|
||||
return;
|
||||
|
||||
if (!TraceEvent::isRecordingOn())
|
||||
return;
|
||||
|
||||
COOLWSD::writeTraceEventRecording(recording + "\n");
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Copyright the Collabora Online contributors.
|
||||
*
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
#include "StringVector.hpp"
|
||||
#include "Util.hpp"
|
||||
#include "COOLWSD.hpp"
|
||||
#include "Kit.hpp"
|
||||
|
||||
int createForkit(const std::string& forKitPath, const StringVector& args)
|
||||
{
|
||||
// create forkit in a thread
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue