diff options
author | Stephan Bergmann <stephan.bergmann@allotropia.de> | 2024-01-26 13:45:01 +0100 |
---|---|---|
committer | Stephan Bergmann <stephan.bergmann@allotropia.de> | 2024-02-13 08:11:57 +0100 |
commit | ebd3f0971b843527ed493a35b2303c8c15b94109 (patch) | |
tree | c52ee7c05565158c28510b1639b6b9290d144155 /desktop | |
parent | 95dace2eb1ae7ce2fc000cc67e134b7bfadf2c35 (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>
(cherry picked from commit fe459b9595c851d00a861d595c8dd50b35c90be3)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163255
Tested-by: Jenkins
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/win32/source/loader.cxx | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/desktop/win32/source/loader.cxx b/desktop/win32/source/loader.cxx index 998eb189effc..bbc97a462724 100644 --- a/desktop/win32/source/loader.cxx +++ b/desktop/win32/source/loader.cxx @@ -218,6 +218,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); @@ -233,13 +235,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; |