bgsave: rename parameter to background, and add setting.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: Ic49ec5715682b71461b49741d022fc7149aa5a13
pull/8782/head
Michael Meeks 2024-04-16 15:02:28 +01:00 committed by Caolán McNamara
parent 2d018d38a5
commit af749c2237
4 changed files with 16 additions and 9 deletions

View File

@ -64,6 +64,7 @@
<limit_convert_secs desc="Maximum number of seconds to wait for a document conversion to succeed. 0 for unlimited." type="uint" default="100">100</limit_convert_secs>
<min_time_between_saves_ms desc="Minimum number of milliseconds between saving the document on disk." type="uint" default="500">500</min_time_between_saves_ms>
<min_time_between_uploads_ms desc="Minimum number of milliseconds between uploading the document to storage." type="uint" default="5000">5000</min_time_between_uploads_ms>
<background_autosave desc="Allow auto-saves to occur in a forked background process where possible." type="bool" default="false">false</background_autosave>
<cleanup desc="Checks for resource consuming (bad) documents and kills associated kit process. A document is considered resource consuming (bad) if is in idle state for idle_time_secs period and memory usage passed limit_dirty_mem_mb or CPU usage passed limit_cpu_per" enable="true">
<cleanup_interval_ms desc="Interval between two checks" type="uint" default="10000">10000</cleanup_interval_ms>
<bad_behavior_period_secs desc="Minimum time period for a document to be in bad state before associated kit process is killed. If in this period the condition for bad document is not met once then this period is reset" type="uint" default="60">60</bad_behavior_period_secs>

View File

@ -551,15 +551,13 @@ bool ChildSession::_handleInput(const char *buffer, int length)
}
else if (tokens.equals(0, "save"))
{
static bool doBgSave = !!getenv("COOL_BGSAVE");
bool background = tokens[1] == "background=true";
SigUtil::addActivity(getId(), (background ? "bg " : "") + firstLine);
SigUtil::addActivity(getId(), (doBgSave ? "bg " : "") + firstLine);
bool autosave = tokens[1] == "autosave=true";
StringVector unoSave = StringVector::tokenize("uno .uno:Save " + tokens.cat(' ', 2));
bool saving = false;
if (doBgSave && autosave)
if (background)
saving = !saveDocumentBackground(unoSave);
if (!saving)

View File

@ -184,6 +184,7 @@ DocumentBroker::DocumentBroker(ChildType type, const std::string& uri, const Poc
, _wopiDownloadDuration(0)
, _mobileAppDocId(mobileAppDocId)
, _alwaysSaveOnExit(COOLWSD::getConfigValue<bool>("per_document.always_save_on_exit", false))
, _backgroundAutoSave(COOLWSD::getConfigValue<bool>("per_document.background_autosave", true))
#if !MOBILEAPP
, _admin(Admin::instance())
#endif
@ -2649,8 +2650,8 @@ void DocumentBroker::autoSaveAndStop(const std::string& reason)
}
bool DocumentBroker::sendUnoSave(const std::shared_ptr<ClientSession>& session,
bool dontTerminateEdit, bool dontSaveIfUnmodified, bool isAutosave,
const std::string& extendedData)
bool dontTerminateEdit, bool dontSaveIfUnmodified,
bool isAutosave, const std::string& extendedData)
{
ASSERT_CORRECT_THREAD();
@ -2689,8 +2690,12 @@ bool DocumentBroker::sendUnoSave(const std::shared_ptr<ClientSession>& session,
// If Core does report something different after saving, we'll update this flag.
_nextStorageAttrs.setUserModified(isModified() || haveModifyActivityAfterSaveRequest());
static bool forceBackgroundSave = !!getenv("COOL_FORCE_BGSAVE");
// Note: It's odd to capture these here, but this function is used from ClientSession too.
bool autosave = isAutosave || (_unitWsd && _unitWsd->isAutosave());
bool background = forceBackgroundSave || (autosave && _backgroundAutoSave);
_nextStorageAttrs.setIsAutosave(autosave);
_nextStorageAttrs.setExtendedData(extendedData);
@ -2698,7 +2703,7 @@ bool DocumentBroker::sendUnoSave(const std::shared_ptr<ClientSession>& session,
LOG_TRC("save arguments: " << saveArgs);
// re-written to .uno:Save in the Kit.
const auto command = std::string("save autosave=") + (autosave ? "true" : "")+ " " + saveArgs;
const auto command = std::string("save background=") + (background ? "true" : "")+ " " + saveArgs;
if (forwardToChild(session, command))
{
_saveManager.markLastSaveRequestTime();

View File

@ -1618,7 +1618,10 @@ private:
std::map<std::string, std::string> _embeddedMedia;
/// True iff the config per_document.always_save_on_exit is true.
const bool _alwaysSaveOnExit;
const bool _alwaysSaveOnExit : 1;
/// True iff the config per_document.background_autosave is true.
const bool _backgroundAutoSave : 1;
#if !MOBILEAPP
Admin& _admin;