[Libreoffice-commits] online.git: android/lib ios/ios.h ios/ios.mm ios/Mobile wsd/LOOLWSD.cpp wsd/LOOLWSD.hpp
Jan Holesovsky (via logerrit)
logerrit at kemper.freedesktop.org
Thu Feb 6 08:44:46 UTC 2020
android/lib/src/main/cpp/androidapp.cpp | 13 +++++--------
ios/Mobile/DocumentViewController.mm | 3 ++-
ios/ios.h | 2 --
ios/ios.mm | 1 -
wsd/LOOLWSD.cpp | 8 +++++---
wsd/LOOLWSD.hpp | 4 ++++
6 files changed, 16 insertions(+), 15 deletions(-)
New commits:
commit ad32888d7c2ec960255d826c245f7df2e93c3f1b
Author: Jan Holesovsky <kendy at collabora.com>
AuthorDate: Thu Dec 5 22:27:16 2019 +0100
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Thu Feb 6 09:44:26 2020 +0100
mobile: Unify the mutex usage that protects the main lokit thread.
Effectively both approaches were doing the same thing, let's unify to
the iOS way to minimize the platform-specific code.
Change-Id: I11290410a536c26db054ffcb87e3b64cc2a11c07
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/84589
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/android/lib/src/main/cpp/androidapp.cpp b/android/lib/src/main/cpp/androidapp.cpp
index 59079d935..10f4876ad 100644
--- a/android/lib/src/main/cpp/androidapp.cpp
+++ b/android/lib/src/main/cpp/androidapp.cpp
@@ -34,7 +34,6 @@ static int fakeClientFd;
static int closeNotificationPipeForForwardingThread[2] = {-1, -1};
static JavaVM* javaVM = nullptr;
static bool lokInitialized = false;
-static std::mutex loolwsdRunningMutex;
extern "C" JNIEXPORT jint JNICALL
JNI_OnLoad(JavaVM* vm, void*) {
@@ -161,12 +160,11 @@ static void send2JS(const JNIThreadContext &jctx, jclass loActivityClz, jobject
void closeDocument()
{
// Close one end of the socket pair, that will wake up the forwarding thread that was constructed in HULLO
- if (fakeSocketClose(closeNotificationPipeForForwardingThread[0]) == 0)
- {
- LOG_DBG("Waiting for LOOLWSD to finish...");
- std::unique_lock<std::mutex> lock(loolwsdRunningMutex);
- LOG_DBG("LOOLWSD has finished.");
- }
+ fakeSocketClose(closeNotificationPipeForForwardingThread[0]);
+
+ LOG_DBG("Waiting for LOOLWSD to finish...");
+ std::unique_lock<std::mutex> lock(LOOLWSD::lokit_main_mutex);
+ LOG_DBG("LOOLWSD has finished.");
}
/// Handle a message from JavaScript.
@@ -323,7 +321,6 @@ Java_org_libreoffice_androidlib_LOActivity_createLOOLWSD(JNIEnv *env, jobject, j
{
LOG_DBG("Creating LOOLWSD");
{
- std::unique_lock<std::mutex> lock(loolwsdRunningMutex);
fakeClientFd = fakeSocketSocket();
LOG_DBG("createLOOLWSD created fakeClientFd: " << fakeClientFd);
std::unique_ptr<LOOLWSD> loolwsd(new LOOLWSD());
diff --git a/ios/Mobile/DocumentViewController.mm b/ios/Mobile/DocumentViewController.mm
index a7731ced8..8c97826e9 100644
--- a/ios/Mobile/DocumentViewController.mm
+++ b/ios/Mobile/DocumentViewController.mm
@@ -19,6 +19,7 @@
#import "ios.h"
#import "FakeSocket.hpp"
+#import "LOOLWSD.hpp"
#import "Log.hpp"
#import "SigUtil.hpp"
#import "Util.hpp"
@@ -434,7 +435,7 @@ static IMP standardImpOfInputAccessoryView = nil;
}];
// Wait for lokit_main thread to exit
- std::lock_guard<std::mutex> lock(lokit_main_mutex);
+ std::lock_guard<std::mutex> lock(LOOLWSD::lokit_main_mutex);
theSingleton = nil;
diff --git a/ios/ios.h b/ios/ios.h
index 7eb1e8357..a4283cefb 100644
--- a/ios/ios.h
+++ b/ios/ios.h
@@ -16,6 +16,4 @@ extern lok::Document *lok_document;
extern LibreOfficeKit *lo_kit;
-extern std::mutex lokit_main_mutex;
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/ios/ios.mm b/ios/ios.mm
index 8f3ccc3ca..97c49c3e9 100644
--- a/ios/ios.mm
+++ b/ios/ios.mm
@@ -20,6 +20,5 @@ extern "C" {
int loolwsd_server_socket_fd = -1;
lok::Document *lok_document = nullptr;
LibreOfficeKit *lo_kit;
-std::mutex lokit_main_mutex;
// vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index c8f4d0053..7fa1898ec 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -486,6 +486,10 @@ static size_t addNewChild(const std::shared_ptr<ChildProcess>& child)
return count;
}
+#if MOBILEAPP
+std::mutex LOOLWSD::lokit_main_mutex;
+#endif
+
std::shared_ptr<ChildProcess> getNewChild_Blocks(
#if MOBILEAPP
const std::string& uri
@@ -519,9 +523,7 @@ std::shared_ptr<ChildProcess> getNewChild_Blocks(
std::thread([&]
{
-#ifdef IOS
- std::lock_guard<std::mutex> lokit_main_lock(lokit_main_mutex);
-#endif
+ std::lock_guard<std::mutex> lokit_main_lock(LOOLWSD::lokit_main_mutex);
Util::setThreadName("lokit_main");
// Ugly to have that static global, otoh we know there is just one LOOLWSD
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index 35c283288..288ed6bb9 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -79,6 +79,10 @@ public:
static std::string OverrideWatermark;
static std::set<const Poco::Util::AbstractConfiguration*> PluginConfigurations;
static std::chrono::time_point<std::chrono::system_clock> StartTime;
+#if MOBILEAPP
+ /// This is used to be able to wait until the lokit main thread has finished (and it is safe to load a new document).
+ static std::mutex lokit_main_mutex;
+#endif
/// For testing only [!]
static int getClientPortNumber();
More information about the Libreoffice-commits
mailing list