bgsave: add unit testing hooks for after bgsave fork & pre exit.

Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Change-Id: I35a2ec185762138dc85db39df3e7644c60acfddc
pull/8782/head
Michael Meeks 2024-04-15 16:58:45 +01:00 committed by Caolán McNamara
parent 5dbe4fe02f
commit 2d018d38a5
3 changed files with 7 additions and 0 deletions

View File

@ -524,6 +524,10 @@ public:
/// Post fork hook - just before we init the child kit
virtual void postFork();
/// Called just after and before bg save process events
virtual void postBackgroundSaveFork() {}
virtual void preBackgroundSaveExit() {}
/// Kit got a message
virtual bool filterKitMessage(WebSocketHandler *, std::string &/* message */ )
{

View File

@ -1425,6 +1425,8 @@ bool Document::forkToSave(const std::function<void()> &childSave, int viewId)
childSocket.reset();
// now we just have a single socket to our parent
UnitKit::get().postBackgroundSaveFork();
// Hard drop our previous connections to coolwsd and shared wakeups.x
KitSocketPoll::cleanupChildProcess();

View File

@ -209,6 +209,7 @@ void BgSaveChildWebSocketHandler::handleMessage(const std::vector<char>& data)
void BgSaveChildWebSocketHandler::onDisconnect()
{
LOG_TRC("Disconnected background web socket to parent kit");
UnitKit::get().preBackgroundSaveExit();
Util::forcedExit(EX_OK);
}