stoc/source/inspect/introspection.cxx | 46 +++++++++++----------------------- 1 file changed, 16 insertions(+), 30 deletions(-)
New commits: commit 05e2d360e55d3fc1d9843a08b42f3a64ccb19733 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Tue Sep 24 21:18:20 2024 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Sep 27 11:23:03 2024 +0200 cid#1606918 Data race condition and cid#1606991 Data race condition cid#1607010 Data race condition cid#1607323 Data race condition cid#1607335 Data race condition cid#1607635 Data race condition cid#1608162 Data race condition Change-Id: I65edcf08f92fb564d56d0e8954212533c1cbec91 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173895 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> (cherry picked from commit 695a46783e7dfd7cee0e083d9a8c2864dd7ac884) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173915 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/stoc/source/inspect/introspection.cxx b/stoc/source/inspect/introspection.cxx index 5491001a070a..2594021dbaa6 100644 --- a/stoc/source/inspect/introspection.cxx +++ b/stoc/source/inspect/introspection.cxx @@ -684,8 +684,8 @@ class ImplIntrospectionAccess : public IntrospectionAccessHelper Reference<XEnumerationAccess> getXEnumerationAccess(); Reference<XIdlArray> getXIdlArray(); - void cacheXNameContainer(); - void cacheXIndexContainer(); + void cacheXNameContainer(const std::unique_lock<std::mutex>& rGuard); + void cacheXIndexContainer(const std::unique_lock<std::mutex>& rGuard); public: ImplIntrospectionAccess( Any obj, rtl::Reference< IntrospectionAccessStatic_Impl > pStaticImpl_ ); @@ -796,7 +796,7 @@ Reference<XElementAccess> ImplIntrospectionAccess::getXElementAccess() return mxObjElementAccess; } -void ImplIntrospectionAccess::cacheXNameContainer() +void ImplIntrospectionAccess::cacheXNameContainer(const std::unique_lock<std::mutex>& /*rGuard*/) { Reference<XNameContainer> xNameContainer; Reference<XNameReplace> xNameReplace; @@ -818,7 +818,6 @@ void ImplIntrospectionAccess::cacheXNameContainer() } { - std::unique_lock aGuard( m_aMutex ); if( !mxObjNameContainer.is() ) mxObjNameContainer = xNameContainer; if( !mxObjNameReplace.is() ) @@ -833,10 +832,8 @@ Reference<XNameContainer> ImplIntrospectionAccess::getXNameContainer() std::unique_lock aGuard( m_aMutex ); if( !mxObjNameContainer.is() ) - { - aGuard.unlock(); - cacheXNameContainer(); - } + cacheXNameContainer(aGuard); + return mxObjNameContainer; } @@ -845,10 +842,8 @@ Reference<XNameReplace> ImplIntrospectionAccess::getXNameReplace() std::unique_lock aGuard( m_aMutex ); if( !mxObjNameReplace.is() ) - { - aGuard.unlock(); - cacheXNameContainer(); - } + cacheXNameContainer(aGuard); + return mxObjNameReplace; } @@ -857,14 +852,12 @@ Reference<XNameAccess> ImplIntrospectionAccess::getXNameAccess() std::unique_lock aGuard( m_aMutex ); if( !mxObjNameAccess.is() ) - { - aGuard.unlock(); - cacheXNameContainer(); - } + cacheXNameContainer(aGuard); + return mxObjNameAccess; } -void ImplIntrospectionAccess::cacheXIndexContainer() +void ImplIntrospectionAccess::cacheXIndexContainer(const std::unique_lock<std::mutex>& /*rGuard*/) { Reference<XIndexContainer> xIndexContainer; Reference<XIndexReplace> xIndexReplace; @@ -886,7 +879,6 @@ void ImplIntrospectionAccess::cacheXIndexContainer() } { - std::unique_lock aGuard( m_aMutex ); if( !mxObjIndexContainer.is() ) mxObjIndexContainer = xIndexContainer; if( !mxObjIndexReplace.is() ) @@ -901,10 +893,8 @@ Reference<XIndexContainer> ImplIntrospectionAccess::getXIndexContainer() std::unique_lock aGuard( m_aMutex ); if( !mxObjIndexContainer.is() ) - { - aGuard.unlock(); - cacheXIndexContainer(); - } + cacheXIndexContainer(aGuard); + return mxObjIndexContainer; } @@ -913,10 +903,8 @@ Reference<XIndexReplace> ImplIntrospectionAccess::getXIndexReplace() std::unique_lock aGuard( m_aMutex ); if( !mxObjIndexReplace.is() ) - { - aGuard.unlock(); - cacheXIndexContainer(); - } + cacheXIndexContainer(aGuard); + return mxObjIndexReplace; } @@ -925,10 +913,8 @@ Reference<XIndexAccess> ImplIntrospectionAccess::getXIndexAccess() std::unique_lock aGuard( m_aMutex ); if( !mxObjIndexAccess.is() ) - { - aGuard.unlock(); - cacheXIndexContainer(); - } + cacheXIndexContainer(aGuard); + return mxObjIndexAccess; }