From c2f4f8031de14582fc5f4cdb044987476d3ba2d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Tue, 30 Apr 2024 12:11:18 +0100 Subject: [PATCH] disable watchdog while loading and saving MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Caolán McNamara Change-Id: Ic1757f1cafcaed7feb3ce0cbc21fe8e03c5d4bd4 --- kit/ChildSession.cpp | 26 ++++++++++++++++++++++++++ net/Socket.cpp | 14 ++++++++++++-- net/Socket.hpp | 3 +++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp index a45e440cb4..165a34c3f4 100644 --- a/kit/ChildSession.cpp +++ b/kit/ChildSession.cpp @@ -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 diff --git a/net/Socket.cpp b/net/Socket.cpp index df3e0bdda4..edefd96e32 100644 --- a/net/Socket.cpp +++ b/net/Socket.cpp @@ -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) diff --git a/net/Socket.hpp b/net/Socket.hpp index d863c8dad4..eb47426576 100644 --- a/net/Socket.hpp +++ b/net/Socket.hpp @@ -806,6 +806,9 @@ public: return false; } + void disableWatchdog(); + void enableWatchdog(); + protected: bool isStop() const {