disable watchdog while loading and saving

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Ic1757f1cafcaed7feb3ce0cbc21fe8e03c5d4bd4
pull/8941/head
Caolán McNamara 2024-04-30 12:11:18 +01:00 committed by Michael Meeks
parent 038e278b03
commit c2f4f8031d
3 changed files with 41 additions and 2 deletions

View File

@ -165,6 +165,28 @@ void ChildSession::disconnect()
}
}
namespace
{
// disable Watchdog for scope
class WatchdogGuard
{
public:
WatchdogGuard()
{
// disable watchdog - we want to just watch interactive responsiveness
if (KitSocketPoll* kitPoll = KitSocketPoll::getMainPoll())
kitPoll->disableWatchdog();
}
~WatchdogGuard()
{
// reenable watchdog
if (KitSocketPoll* kitPoll = KitSocketPoll::getMainPoll())
kitPoll->enableWatchdog();
}
};
}
bool ChildSession::_handleInput(const char *buffer, int length)
{
LOG_TRC("handling [" << getAbbreviatedMessage(buffer, length) << ']');
@ -269,6 +291,8 @@ bool ChildSession::_handleInput(const char *buffer, int length)
// Disable processing of other messages while loading document
InputProcessingManager processInput(getProtocol(), false);
// disable watchdog while loading
WatchdogGuard watchdogGuard;
_isDocLoaded = loadDocument(tokens);
LOG_TRC("isDocLoaded state after loadDocument: " << _isDocLoaded);
@ -577,6 +601,8 @@ bool ChildSession::_handleInput(const char *buffer, int length)
{ // fallback to foreground save
// Disable processing of other messages while saving document
InputProcessingManager processInput(getProtocol(), false);
// disable watchdog while saving
WatchdogGuard watchdogGuard;
return unoCommand(unoSave);
}
else

View File

@ -374,6 +374,16 @@ void SocketPoll::pollingThreadEntry()
LOG_INF("Finished polling thread [" << _name << "].");
}
void SocketPoll::disableWatchdog()
{
_watchdogTime = Watchdog::getDisableStamp();
}
void SocketPoll::enableWatchdog()
{
_watchdogTime = Watchdog::getTimestamp();
}
int SocketPoll::poll(int64_t timeoutMaxMicroS)
{
if (_runOnClientThread)
@ -394,7 +404,7 @@ int SocketPoll::poll(int64_t timeoutMaxMicroS)
const size_t size = _pollSockets.size();
// disable watchdog - it's good to sleep
_watchdogTime = Watchdog::getDisableStamp();
disableWatchdog();
int rc;
do
@ -423,7 +433,7 @@ int SocketPoll::poll(int64_t timeoutMaxMicroS)
timeoutMaxMicroS << "us)" << ((rc==0) ? "(timedout)" : ""));
// from now we want to race back to sleep.
_watchdogTime = Watchdog::getTimestamp();
enableWatchdog();
// First process the wakeup pipe (always the last entry).
if (_pollFds[size].revents)

View File

@ -806,6 +806,9 @@ public:
return false;
}
void disableWatchdog();
void enableWatchdog();
protected:
bool isStop() const
{