From 4fa7e53eaeb43233ac039525b58eb8c588968019 Mon Sep 17 00:00:00 2001 From: Ashod Nakashian Date: Sun, 9 Oct 2016 16:37:13 -0400 Subject: [PATCH] loolwsd: unload child view when client disconnects Using a new internal command, when a client disconnects an internal 'disconnect' message is dispatched so the child process cleans up the ChildSession in question. Change-Id: I34166ad59e84ae389a3913bd2430fe537225bb4b Reviewed-on: https://gerrit.libreoffice.org/29650 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian --- loolwsd/DocumentBroker.cpp | 4 ++++ loolwsd/LOOLKit.cpp | 7 +++++++ loolwsd/protocol.txt | 18 ++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp index 02686fad5..4e7e618e2 100644 --- a/loolwsd/DocumentBroker.cpp +++ b/loolwsd/DocumentBroker.cpp @@ -441,6 +441,10 @@ size_t DocumentBroker::removeSession(const std::string& id) if (it != _sessions.end()) { _sessions.erase(it); + + // Let the child know the client has disconnected. + const std::string msg("child-" + id + " disconnect"); + _childProcess->getWebSocket()->sendFrame(msg.data(), msg.size()); } return _sessions.size(); diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp index 3bb689d06..17f7f3fbe 100644 --- a/loolwsd/LOOLKit.cpp +++ b/loolwsd/LOOLKit.cpp @@ -1264,6 +1264,13 @@ private: const auto it = _connections.find(viewId); if (it != _connections.end()) { + if (message == "disconnect") + { + Log::debug("Removing ChildSession " + value); + _connections.erase(it); + return true; + } + auto session = it->second->getSession(); if (session) { diff --git a/loolwsd/protocol.txt b/loolwsd/protocol.txt index 418986d17..d61735426 100644 --- a/loolwsd/protocol.txt +++ b/loolwsd/protocol.txt @@ -373,6 +373,24 @@ saveas: url= is a URL of the destination, encoded. Sent from the child to the parent after a saveAs() completed. +client- + + Forwarding message between a child and its parent session. + The payload message is forwarded to the ClientSession. + +parent -> child +=============== + +child- + + Forwarding message between a parent and its child session. + The payload message is forwarded to the ChildSession. + +disconnect + + Signals to the child that the client for the respective connection + has disconnected. + Admin console ===============