summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <stephan.bergmann@allotropia.de>2024-01-26 13:45:01 +0100
committerStephan Bergmann <stephan.bergmann@allotropia.de>2024-01-26 13:52:33 +0100
commitfe459b9595c851d00a861d595c8dd50b35c90be3 (patch)
treef324c79d15cfc2ea4db1778394e02cf592ecd714
parent6d553405101090ef7a7ff5270e5ef32aa41bd9b3 (diff)
Fall back to old bootstrap.ini [Win32] section, for backwards compatibility
Change-Id: I629b2a16bc889f16595cd1718d2ee4535f31aed7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162602 Tested-by: Stephan Bergmann <stephan.bergmann@allotropia.de> Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
-rw-r--r--desktop/win32/source/loader.cxx33
-rw-r--r--vcl/win/window/salframe.cxx39
2 files changed, 71 insertions, 1 deletions
diff --git a/desktop/win32/source/loader.cxx b/desktop/win32/source/loader.cxx
index 98efde9ec823..e42420391b4b 100644
--- a/desktop/win32/source/loader.cxx
+++ b/desktop/win32/source/loader.cxx
@@ -167,6 +167,8 @@ int officeloader_impl(bool bAllowConsole)
// read limit values from fundamental.override.ini
unsigned int nMaxMemoryInMB = 0;
bool bExcludeChildProcesses = true;
+ bool fallbackForMaxMemoryInMB = true;
+ bool fallbackForExcludeChildProcesses = true;
const WCHAR* szIniFile = L"\\fundamental.override.ini";
const size_t nDirLen = wcslen(szIniDirectory);
@@ -182,13 +184,44 @@ int officeloader_impl(bool bAllowConsole)
std::ifstream aFile(szBootstrapIni);
boost::property_tree::ini_parser::read_ini(aFile, pt);
nMaxMemoryInMB = pt.get("Bootstrap.LimitMaximumMemoryInMB", nMaxMemoryInMB);
+ fallbackForMaxMemoryInMB = !pt.get_child_optional("Bootstrap.LimitMaximumMemoryInMB");
bExcludeChildProcesses = pt.get("Bootstrap.ExcludeChildProcessesFromLimit", bExcludeChildProcesses);
+ fallbackForExcludeChildProcesses
+ = !pt.get_child_optional("Bootstrap.ExcludeChildProcessesFromLimit");
}
catch (...)
{
nMaxMemoryInMB = 0;
}
}
+ // For backwards compatibility, for now also try to read the values from bootstrap.ini if
+ // fundamental.override.ini does not provide them:
+ if (fallbackForMaxMemoryInMB || fallbackForExcludeChildProcesses) {
+ const WCHAR* szFallbackIniFile = L"\\bootstrap.ini";
+ const size_t nFallbackDirLen = wcslen(szIniDirectory);
+ if (wcslen(szFallbackIniFile) + nFallbackDirLen < MAX_PATH)
+ {
+ WCHAR szBootstrapIni[MAX_PATH];
+ wcscpy(szBootstrapIni, szIniDirectory);
+ wcscpy(&szBootstrapIni[nFallbackDirLen], szFallbackIniFile);
+
+ try
+ {
+ boost::property_tree::ptree pt;
+ std::ifstream aFile(szBootstrapIni);
+ boost::property_tree::ini_parser::read_ini(aFile, pt);
+ if (fallbackForMaxMemoryInMB) {
+ nMaxMemoryInMB = pt.get("Win32.LimitMaximumMemoryInMB", nMaxMemoryInMB);
+ }
+ if (fallbackForExcludeChildProcesses) {
+ bExcludeChildProcesses = pt.get("Win32.ExcludeChildProcessesFromLimit", bExcludeChildProcesses);
+ }
+ }
+ catch (...)
+ {
+ }
+ }
+ }
// create a Windows JobObject with a memory limit
HANDLE hJobObject = nullptr;
diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx
index ccc4ed70df75..ea55cae92a89 100644
--- a/vcl/win/window/salframe.cxx
+++ b/vcl/win/window/salframe.cxx
@@ -33,6 +33,12 @@
#include <comphelper/windowserrorstring.hxx>
+#include <fstream>
+#include <boost/property_tree/ptree.hpp>
+#include <boost/property_tree/ini_parser.hpp>
+#include <osl/file.hxx>
+#include <osl/process.h>
+
#include <rtl/bootstrap.hxx>
#include <rtl/string.h>
#include <rtl/ustring.h>
@@ -1940,7 +1946,38 @@ static bool EnableAttachThreadInputHack()
{
OUString s("$EnableAttachThreadInputHack");
rtl::Bootstrap::expandMacros(s);
- const bool bEnabled = s == "true";
+ bool bEnabled;
+ if (!s.isEmpty()) {
+ bEnabled = s == "true";
+ } else {
+ // For backwards compatibility, for now also try to read the value from a [Win32] section of
+ // bootstrap.ini if it is not set as a boostrap variable:
+ bEnabled = false;
+ OUString aBootstrapUri;
+ if (osl_getProcessWorkingDir(&aBootstrapUri.pData) == osl_Process_E_None) {
+ aBootstrapUri += "/bootstrap.ini";
+
+ OUString aSystemFileName;
+ if (osl::FileBase::getSystemPathFromFileURL(aBootstrapUri, aSystemFileName)
+ == osl::FileBase::E_None
+ && aSystemFileName.getLength() <= MAX_PATH)
+ {
+ // this uses the Boost ini parser, instead of tools::Config, as we already use it to
+ // read other values from bootstrap.ini in desktop/win32/source/loader.cxx, because
+ // that watchdog process can't access LO libs. This way the handling is consistent.
+ try
+ {
+ boost::property_tree::ptree pt;
+ std::ifstream aFile(o3tl::toW(aSystemFileName.getStr()));
+ boost::property_tree::ini_parser::read_ini(aFile, pt);
+ bEnabled = pt.get("Win32.EnableAttachThreadInputHack", false);
+ }
+ catch (...)
+ {
+ }
+ }
+ }
+ }
SAL_WARN_IF(bEnabled, "vcl", "AttachThreadInput hack is enabled. Watch out for deadlocks!");
return bEnabled;
}