2015-12-27 16:23:43 -06:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
|
|
|
/*
|
|
|
|
* 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/.
|
|
|
|
*/
|
|
|
|
|
2020-04-18 03:39:50 -05:00
|
|
|
#pragma once
|
|
|
|
|
2019-03-30 09:06:16 -05:00
|
|
|
#include <string>
|
2022-03-25 13:32:01 -05:00
|
|
|
#include <vector>
|
|
|
|
#include <memory>
|
2019-03-30 09:06:16 -05:00
|
|
|
|
2015-12-27 16:23:43 -06:00
|
|
|
// Default values and other shared data between processes.
|
|
|
|
|
2015-12-28 15:34:21 -06:00
|
|
|
constexpr int DEFAULT_CLIENT_PORT_NUMBER = 9980;
|
2016-10-14 22:00:33 -05:00
|
|
|
|
2021-08-21 09:46:27 -05:00
|
|
|
// define to wrap strace around the forkit
|
2021-11-16 03:59:05 -06:00
|
|
|
#define STRACE_COOLFORKIT 0
|
2021-08-21 09:46:27 -05:00
|
|
|
// define to wrap valgrind around the forkit
|
2021-11-16 03:59:05 -06:00
|
|
|
#define VALGRIND_COOLFORKIT 0
|
2021-08-21 09:46:27 -05:00
|
|
|
|
2021-11-16 03:59:05 -06:00
|
|
|
#if VALGRIND_COOLFORKIT
|
2021-08-21 09:46:27 -05:00
|
|
|
constexpr int TRACE_MULTIPLIER = 20;
|
2022-03-13 17:28:31 -05:00
|
|
|
#elif CODE_COVERAGE
|
|
|
|
constexpr int TRACE_MULTIPLIER = 5;
|
2021-08-21 09:46:27 -05:00
|
|
|
#else
|
|
|
|
constexpr int TRACE_MULTIPLIER = 1;
|
|
|
|
#endif
|
|
|
|
|
2022-07-17 11:03:53 -05:00
|
|
|
constexpr int COMMAND_TIMEOUT_SECS = 5 * TRACE_MULTIPLIER;
|
|
|
|
constexpr int COMMAND_TIMEOUT_MS = COMMAND_TIMEOUT_SECS * 1000;
|
2019-10-18 07:10:12 -05:00
|
|
|
constexpr int CHILD_TIMEOUT_MS = COMMAND_TIMEOUT_MS;
|
2016-10-14 22:00:33 -05:00
|
|
|
constexpr int CHILD_REBALANCE_INTERVAL_MS = CHILD_TIMEOUT_MS / 10;
|
2020-04-09 08:43:51 -05:00
|
|
|
constexpr int POLL_TIMEOUT_MICRO_S = (COMMAND_TIMEOUT_MS / 5) * 1000;
|
2021-08-21 09:46:27 -05:00
|
|
|
constexpr int WS_SEND_TIMEOUT_MS = 1000 * TRACE_MULTIPLIER;
|
2016-01-21 07:49:43 -06:00
|
|
|
|
2022-07-17 11:03:53 -05:00
|
|
|
constexpr int TILE_ROUNDTRIP_TIMEOUT_MS = COMMAND_TIMEOUT_MS;
|
2018-09-28 12:30:57 -05:00
|
|
|
|
2016-01-21 07:49:43 -06:00
|
|
|
/// Pipe and Socket read buffer size.
|
|
|
|
/// Should be large enough for ethernet packets
|
|
|
|
/// which can be 1500 bytes long.
|
2016-12-01 11:15:46 -06:00
|
|
|
constexpr long READ_BUFFER_SIZE = 64 * 1024;
|
2016-11-26 21:28:48 -06:00
|
|
|
|
2016-11-13 20:52:02 -06:00
|
|
|
/// Message larger than this will be dropped as invalid
|
|
|
|
/// or as intentionally flooding the server.
|
2016-11-26 21:28:48 -06:00
|
|
|
constexpr int MAX_MESSAGE_SIZE = 2 * 1024 * READ_BUFFER_SIZE;
|
2016-11-13 20:52:02 -06:00
|
|
|
|
wsd: faster jail setup via bind-mount
loolmount now works and supports mounting and
unmounting, plus numerous improvements,
refactoring, logging, etc.. When enabled,
binding improves the jail setup time by anywhere
from 2x to orders of magnitude (in docker, f.e.).
A new config entry mount_jail_tree controls
whether mounting is used or the old method of
linking/copying of jail contents. It is set to
true by default and falls back to linking/copying.
A test mount is done when the setting is enabled,
and if mounting fails, it's disabled to avoid noise.
Temporarily disabled for unit-tests until we can
cleanup lingering mounts after Jenkins aborts our
build job. In a future patch we will have mount/jail
cleanup as part of make.
The network/system files in /etc that need frequent
refreshing are now updated in systemplate to make
their most recent version available in the jails.
These files can change during the course of loolwsd
lifetime, and are unlikely to be updated in
systemplate after installation at all. We link to
them in the systemplate/etc directory, and if that
fails, we copy them before forking each kit
instance to have the latest.
This reworks the approach used to bind-mount the
jails and the templates such that the total is
now down to only three mounts: systemplate, lo, tmp.
As now systemplate and lotemplate are shared, they
must be mounted as readonly, this means that user/
must now be moved into tmp/user/ which is writable.
The mount-points must be recursive, because we mount
lo/ within the mount-point of systemplate (which is
the root of the jail). But because we (re)bind
recursively, and because both systemplate and
lotemplate are mounted for each jails, we need to
make them unbindable, so they wouldn't multiply the
mount-points for each jails (an explosive growth!)
Contrarywise, we don't want the mount-points to
be shared, because we don't expect to add/remove
mounts after a jail is created.
The random temp directory is now created and set
correctly, plus many logging and other improvements.
Change-Id: Iae3fda5e876cf47d2cae6669a87b5b826a8748df
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92829
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
2020-04-09 08:02:58 -05:00
|
|
|
constexpr const char JAILED_DOCUMENT_ROOT[] = "/tmp/user/docs/";
|
2021-11-18 06:08:14 -06:00
|
|
|
constexpr const char CHILD_URI[] = "/coolws/child?";
|
|
|
|
constexpr const char NEW_CHILD_URI[] = "/coolws/newchild";
|
|
|
|
constexpr const char FORKIT_URI[] = "/coolws/forkit";
|
2016-01-06 12:49:10 -06:00
|
|
|
|
2018-10-19 11:14:48 -05:00
|
|
|
constexpr const char CAPABILITIES_END_POINT[] = "/hosting/capabilities";
|
|
|
|
|
2021-05-24 13:11:40 -05:00
|
|
|
/// The file suffix used to mark the file slated for uploading.
|
|
|
|
constexpr const char TO_UPLOAD_SUFFIX[] = ".upload";
|
|
|
|
/// The file suffix used to mark the file being uploaded.
|
|
|
|
constexpr const char UPLOADING_SUFFIX[] = "ing";
|
|
|
|
|
wsd: use a shared threadname suffix for each document
The use of a common threadname suffix in the WSD and Kit
processes is intentional. It is designed to help filter
for a single document's logs across both processes.
The thread name has nothing to do with the classes in
the code, nor is it intended to imply any relationship
except with the process and the document in question.
As the comment in this patch explains, the choice of
the suffix is arbitrary and while it may be changed,
it has to be sensible and common between the two threads
to allow for easy grepping.
Historically, there were in fact dedicated threads
within the respective "broker" classes, but this
fact should be safely ignored, since at the log level
we care less about which part of the code generates a
log entry (that info, if needed, is at the end of each
log entry, in the form of filename and line number),
rather we care more about which document it relates to,
which is crucial in investigating production issues.
Logs and code structure are only incidentally related.
Logs are (or at least should be) designed around
the execution structure, not code architecture.
(This reverts 2a16f34812cf69bbe0f21b7e7d048fdb3271fa9d)
Change-Id: Ic6fe2f9425998824774d2644fe4362e75dea6b88
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/101261
Tested-by: Jenkins
Tested-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
2020-08-23 23:17:49 -05:00
|
|
|
/// A shared threadname suffix in both the WSD and Kit processes
|
|
|
|
/// is highly helpful for filtering the logs for the same document
|
2021-11-18 06:08:14 -06:00
|
|
|
/// by simply grepping for this shared suffix+ID. e.g. 'grep "broker_123" coolwsd.log'
|
wsd: use a shared threadname suffix for each document
The use of a common threadname suffix in the WSD and Kit
processes is intentional. It is designed to help filter
for a single document's logs across both processes.
The thread name has nothing to do with the classes in
the code, nor is it intended to imply any relationship
except with the process and the document in question.
As the comment in this patch explains, the choice of
the suffix is arbitrary and while it may be changed,
it has to be sensible and common between the two threads
to allow for easy grepping.
Historically, there were in fact dedicated threads
within the respective "broker" classes, but this
fact should be safely ignored, since at the log level
we care less about which part of the code generates a
log entry (that info, if needed, is at the end of each
log entry, in the form of filename and line number),
rather we care more about which document it relates to,
which is crucial in investigating production issues.
Logs and code structure are only incidentally related.
Logs are (or at least should be) designed around
the execution structure, not code architecture.
(This reverts 2a16f34812cf69bbe0f21b7e7d048fdb3271fa9d)
Change-Id: Ic6fe2f9425998824774d2644fe4362e75dea6b88
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/101261
Tested-by: Jenkins
Tested-by: Tor Lillqvist <tml@collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
2020-08-23 23:17:49 -05:00
|
|
|
/// Unfortunately grepping for only "_123" would include more noise than desirable.
|
|
|
|
/// This also makes the threadname symmetric and the entries aligned.
|
|
|
|
/// The choice of "broker" as the suffix is historic: it implies the controller
|
|
|
|
/// of which there are two: one in WSD called DocumentBroker and one in Kit
|
|
|
|
/// called Document, which wasn't called DocumentBroker to avoid confusing it
|
|
|
|
/// with the one in WSD. No such confusion should be expected in the logs, since
|
|
|
|
/// the prefix is "doc" and "kit" respectively, and each log entry has the process
|
|
|
|
/// name prefixed. And of course these threads are unrelated to the classes in
|
|
|
|
/// the code: they are logical execution unit names.
|
|
|
|
#define SHARED_DOC_THREADNAME_SUFFIX "broker_"
|
|
|
|
|
2021-03-20 16:24:13 -05:00
|
|
|
/// The HTTP request User-Agent. Used only in Requests.
|
2021-11-18 06:08:14 -06:00
|
|
|
#define HTTP_AGENT_STRING "COOLWSD HTTP Agent " COOLWSD_VERSION
|
2017-05-14 14:17:19 -05:00
|
|
|
|
2021-03-20 16:24:13 -05:00
|
|
|
/// The WOPI User-Agent. Depricated: use HTTP_AGENT_STRING.
|
|
|
|
#define WOPI_AGENT_STRING HTTP_AGENT_STRING
|
|
|
|
|
|
|
|
/// The HTTP response Server. Used only in Responses.
|
2021-11-18 06:08:14 -06:00
|
|
|
#define HTTP_SERVER_STRING "COOLWSD HTTP Server " COOLWSD_VERSION
|
2017-02-28 18:34:21 -06:00
|
|
|
|
2022-03-17 07:25:43 -05:00
|
|
|
/// The client port number, both coolwsd and the kits have this.
|
2016-04-14 12:04:19 -05:00
|
|
|
extern int ClientPortNumber;
|
2019-03-30 09:06:16 -05:00
|
|
|
extern std::string MasterLocation;
|
2016-04-14 12:04:19 -05:00
|
|
|
|
2022-03-17 07:25:43 -05:00
|
|
|
/// Controls whether experimental features/behavior is enabled or not.
|
|
|
|
extern bool EnableExperimental;
|
|
|
|
|
2022-03-25 13:32:01 -05:00
|
|
|
/// More efficient use of vectors
|
|
|
|
using BlobData = std::vector<char>;
|
|
|
|
using Blob = std::shared_ptr<BlobData>;
|
|
|
|
|
2015-12-27 16:23:43 -06:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|