Skip to content

Commit

Permalink
wsd: support experimental features
Browse files Browse the repository at this point in the history
This adds a new config option to enable/disable
experimental features and behavior. The default
value can be controlled at build time by
--enable-experimental.

Change-Id: Iffcb4c71d9e0933a646251b63033b6dadcd3b809
Signed-off-by: Ashod Nakashian <[email protected]>
  • Loading branch information
Ashod committed Mar 17, 2022
1 parent 3418f51 commit 97a6d1c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 1 deletion.
5 changes: 4 additions & 1 deletion common/Common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ constexpr const char UPLOADING_SUFFIX[] = "ing";
/// The HTTP response Server. Used only in Responses.
#define HTTP_SERVER_STRING "COOLWSD HTTP Server " COOLWSD_VERSION

// The client port number, both coolwsd and the kits have this.
/// The client port number, both coolwsd and the kits have this.
extern int ClientPortNumber;
extern std::string MasterLocation;

/// Controls whether experimental features/behavior is enabled or not.
extern bool EnableExperimental;

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
3 changes: 3 additions & 0 deletions common/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ static std::thread TimeoutThread;
static std::atomic<bool> TimeoutThreadRunning(false);
std::timed_mutex TimeoutThreadMutex;

/// Controls whether experimental features/behavior is enabled or not.
bool EnableExperimental = false;

UnitBase *UnitBase::linkAndCreateUnit(UnitType type, const std::string &unitLibPath)
{
#if !MOBILEAPP
Expand Down
13 changes: 13 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,10 @@ AC_ARG_ENABLE([feature-restriction],
AS_HELP_STRING([--enable-feature-restriction],
[Enable control over which uno-commands/feature to disable completely.]))

AC_ARG_ENABLE([experimental],
AS_HELP_STRING([--enable-experimental],
[Enable experimental features and behavior]))


# Handle options
AS_IF([test "$enable_debug" = yes -a -n "$with_poco_libs"],
Expand All @@ -369,6 +373,8 @@ COOLWSD_ANONYMIZE_USER_DATA=false
BROWSER_LOGGING="false"
debug_msg="secure mode: product build"
anonym_msg=""
ENABLE_EXPERIMENTAL=false
experimental_msg="disabled by default"
bundle_msg="using uglified bundled JS and CSS"
LOK_LOG_ASSERTIONS=0
log_asserts_msg="disabled"
Expand Down Expand Up @@ -443,6 +449,12 @@ if test -z "$anonym_msg"; then
anonym_msg="anonymization of user-data is disabled"
fi

if test "$enable_experimental" = "yes" ; then
ENABLE_EXPERIMENTAL=true
experimental_msg="enabled by default"
fi
AC_SUBST(ENABLE_EXPERIMENTAL)

# macOS: When configuring for building the app itself, on macOS, we need these.
# But not when just configuring for building the JS on Linux, for copying over
# to the Mac.
Expand Down Expand Up @@ -1531,6 +1543,7 @@ Configuration:
LO integration tests ${lo_msg}
SSL support $ssl_msg
Debug & low security $debug_msg
Experimental features $experimental_msg
Test assertion logging $log_asserts_msg
Uglification and bundling $bundle_msg
Anonymization $anonym_msg
Expand Down
1 change: 1 addition & 0 deletions coolwsd.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<server_name desc="External hostname:port of the server running coolwsd. If empty, it's derived from the request (please set it if this doesn't work). May be specified when behind a reverse-proxy or when the hostname is not reachable directly." type="string" default=""></server_name>
<file_server_root_path desc="Path to the directory that should be considered root for the file server. This should be the directory containing cool." type="path" relative="true" default="browser/../"></file_server_root_path>
<hexify_embedded_urls desc="Enable to protect encoded URLs from getting decoded by intermediate hops. Particularly useful on Azure deployments" type="bool" default="false"></hexify_embedded_urls>
<experimental_features desc="Enable/Disable experimental features" type="bool" default="@ENABLE_EXPERIMENTAL@">@ENABLE_EXPERIMENTAL@</experimental_features>

<memproportion desc="The maximum percentage of system memory consumed by all of the @APP_NAME@, after which we start cleaning up idle documents" type="double" default="80.0"></memproportion>
<num_prespawn_children desc="Number of child processes to keep started in advance and waiting for new clients." type="uint" default="1">1</num_prespawn_children>
Expand Down
1 change: 1 addition & 0 deletions kit/ForKit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ int main(int argc, char** argv)
// Parse the configuration.
const auto conf = std::getenv("COOL_CONFIG");
config::initialize(std::string(conf ? conf : std::string()));
EnableExperimental = config::getBool("experimental_features", false);
#endif

Util::setThreadName("forkit");
Expand Down
4 changes: 4 additions & 0 deletions wsd/COOLWSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,7 @@ void COOLWSD::innerInitialize(Application& self)
{ "child_root_path", "jails" },
{ "file_server_root_path", "browser/.." },
{ "hexify_embedded_urls", "false" },
{ "experimental_features", "false" },
{ "lo_jail_subpath", "lo" },
{ "logging.protocol", "false" },
{ "logging.anonymize.filenames", "false" }, // Deprecated.
Expand Down Expand Up @@ -1544,6 +1545,9 @@ void COOLWSD::innerInitialize(Application& self)
// Allow UT to manipulate before using configuration values.
UnitWSD::get().configure(config());

// Experimental features.
EnableExperimental = getConfigValue<bool>(conf, "experimental_features", false);

// Setup user interface mode
UserInterface = getConfigValue<std::string>(conf, "user_interface.mode", "default");

Expand Down

0 comments on commit 97a6d1c

Please sign in to comment.