summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-06-08 15:23:22 +0200
committerLuboš Luňák <l.lunak@collabora.com>2022-06-17 14:27:15 +0200
commit6373b1cc38c45e2b54649738ad89438a5b5320e3 (patch)
tree8960588688a15df23c6ac33b22fb8a449bff4f0e
parent8c53583faa493abf6cd7b2e56b5df7343e922133 (diff)
use recursive mutex for LOK queue
Callbacks may be invoked while calling getLOKPayload(), which would try to lock the mutex again. I actually originally expected this possibility, as the comment and moving the data to temporaries in CallbackFlushHandler::enqueueUpdatedTypes() shows, I just didn't realize the used mutex wasn't recursive and so would deadlock. Change-Id: I2b5c4b6b4c1a3933a32ae4641830877e085f2b6c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135499 Tested-by: Jenkins Reviewed-by: Michael Meeks <michael.meeks@collabora.com> (cherry picked from commit 118bafcfd1ce4a26ec9df912197ebd466d1bd497) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135387 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r--desktop/inc/lib/init.hxx2
-rw-r--r--desktop/source/lib/init.cxx8
2 files changed, 5 insertions, 5 deletions
diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index 6132a7a302cc..b7f3722dff1c 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -220,7 +220,7 @@ namespace desktop {
LibreOfficeKitCallback m_pCallback;
void *m_pData;
int m_nDisableCallbacks;
- std::mutex m_mutex;
+ std::recursive_mutex m_mutex;
class TimeoutIdle : public Timer
{
public:
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index ac644c8b02ba..51167cf7871b 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1460,7 +1460,7 @@ void CallbackFlushHandler::libreOfficeKitViewInvalidateTilesCallback(const tools
void CallbackFlushHandler::libreOfficeKitViewUpdatedCallback(int nType)
{
assert(isUpdatedType( nType ));
- std::unique_lock<std::mutex> lock(m_mutex);
+ std::unique_lock<std::recursive_mutex> lock(m_mutex);
SAL_INFO("lok", "Updated: [" << nType << "]");
setUpdatedType(nType, true);
}
@@ -1468,7 +1468,7 @@ void CallbackFlushHandler::libreOfficeKitViewUpdatedCallback(int nType)
void CallbackFlushHandler::libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int nViewId, int nSourceViewId)
{
assert(isUpdatedTypePerViewId( nType ));
- std::unique_lock<std::mutex> lock(m_mutex);
+ std::unique_lock<std::recursive_mutex> lock(m_mutex);
SAL_INFO("lok", "Updated: [" << nType << "]");
setUpdatedTypePerViewId(nType, nViewId, nSourceViewId, true);
}
@@ -1539,7 +1539,7 @@ void CallbackFlushHandler::queue(const int type, CallbackData& aCallbackData)
return;
}
- std::unique_lock<std::mutex> lock(m_mutex);
+ std::unique_lock<std::recursive_mutex> lock(m_mutex);
// Update types should be received via the updated callbacks for performance,
// getting them as normal callbacks is technically not wrong, but probably should be avoided.
@@ -2133,7 +2133,7 @@ void CallbackFlushHandler::Invoke()
viewShell->flushPendingLOKInvalidateTiles();
}
- std::scoped_lock<std::mutex> lock(m_mutex);
+ std::unique_lock<std::recursive_mutex> lock(m_mutex);
// Append messages for updated types, fetch them only now.
enqueueUpdatedTypes();