summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorMichael Stahl <Michael.Stahl@cib.de>2019-01-28 17:56:39 +0100
committerMichael Stahl <Michael.Stahl@cib.de>2019-01-29 12:19:57 +0100
commit48c6f4e0885976f9d8ccbffc5088f37bb5f1b9f0 (patch)
tree3e0a357510cea14faa91c67eba5c326f4a81cb8a /framework
parent577a9708ea9594d60b66c1c71d24175c66d24096 (diff)
framework: avoid crashing in ~HandlerCFGAccess() in atexit()
Commit d587931fba77246db3a2ccc6ab61ca77446d23f4 changed HandlerCache::s_pConfig to a unique_ptr, which may now crash on shutdown because it's a utl::ConfigItem and by atexit() time the configmgr is long gone. Due to the HandlerCache::m_nRefCount, the crash probably only happens in case of an unclean shutdown, but we don't know whether this can happen in practice or not, so just avoid crashing on shutdown. Change-Id: Ifd2b782aa5592c344d1bc85acaa434c3f2a69b60 Reviewed-on: https://gerrit.libreoffice.org/67029 Tested-by: Jenkins Reviewed-by: Michael Stahl <Michael.Stahl@cib.de>
Diffstat (limited to 'framework')
-rw-r--r--framework/inc/classes/protocolhandlercache.hxx6
-rw-r--r--framework/source/fwi/classes/protocolhandlercache.cxx35
2 files changed, 21 insertions, 20 deletions
diff --git a/framework/inc/classes/protocolhandlercache.hxx b/framework/inc/classes/protocolhandlercache.hxx
index 7f5af88f342e..a23acb57bc39 100644
--- a/framework/inc/classes/protocolhandlercache.hxx
+++ b/framework/inc/classes/protocolhandlercache.hxx
@@ -93,11 +93,11 @@ class FWI_DLLPUBLIC HandlerCache final
private:
/// list of all registered handler registered by her uno implementation names
- static std::unique_ptr<HandlerHash> m_pHandler;
+ static std::unique_ptr<HandlerHash> s_pHandler;
/// maps URL pattern to handler names
- static std::unique_ptr<PatternHash> m_pPattern;
+ static std::unique_ptr<PatternHash> s_pPattern;
/// informs about config updates
- static std::unique_ptr<HandlerCFGAccess> m_pConfig;
+ static HandlerCFGAccess* s_pConfig;
/// ref count to construct/destruct internal member lists on demand by using singleton mechanism
static sal_Int32 m_nRefCount;
diff --git a/framework/source/fwi/classes/protocolhandlercache.cxx b/framework/source/fwi/classes/protocolhandlercache.cxx
index 41a8d5005602..0c23aaa80f37 100644
--- a/framework/source/fwi/classes/protocolhandlercache.cxx
+++ b/framework/source/fwi/classes/protocolhandlercache.cxx
@@ -73,10 +73,10 @@ PatternHash::const_iterator findPatternKey(PatternHash const * hash, const OUStr
That means it use two static member list to hold all necessary information
and a ref count mechanism to create/destroy it on demand.
*/
-std::unique_ptr<HandlerHash> HandlerCache::m_pHandler;
-std::unique_ptr<PatternHash> HandlerCache::m_pPattern;
+std::unique_ptr<HandlerHash> HandlerCache::s_pHandler;
+std::unique_ptr<PatternHash> HandlerCache::s_pPattern;
sal_Int32 HandlerCache::m_nRefCount = 0;
-std::unique_ptr<HandlerCFGAccess> HandlerCache::m_pConfig;
+HandlerCFGAccess* HandlerCache::s_pConfig = nullptr;
/**
@short ctor of the cache of all registered protocol handler
@@ -91,11 +91,11 @@ HandlerCache::HandlerCache()
if (m_nRefCount==0)
{
- m_pHandler.reset(new HandlerHash);
- m_pPattern.reset(new PatternHash);
- m_pConfig.reset(new HandlerCFGAccess(PACKAGENAME_PROTOCOLHANDLER));
- m_pConfig->read(*m_pHandler, *m_pPattern);
- m_pConfig->setCache(this);
+ s_pHandler.reset(new HandlerHash);
+ s_pPattern.reset(new PatternHash);
+ s_pConfig = new HandlerCFGAccess(PACKAGENAME_PROTOCOLHANDLER);
+ s_pConfig->read(*s_pHandler, *s_pPattern);
+ s_pConfig->setCache(this);
}
++m_nRefCount;
@@ -112,11 +112,12 @@ HandlerCache::~HandlerCache()
if( m_nRefCount==1)
{
- m_pConfig->setCache(nullptr);
+ s_pConfig->setCache(nullptr);
- m_pConfig.reset();
- m_pHandler.reset();
- m_pPattern.reset();
+ delete s_pConfig;
+ s_pConfig = nullptr;
+ s_pHandler.reset();
+ s_pPattern.reset();
}
--m_nRefCount;
@@ -133,10 +134,10 @@ bool HandlerCache::search( const OUString& sURL, ProtocolHandler* pReturn ) cons
SolarMutexGuard aGuard;
- PatternHash::const_iterator pItem = findPatternKey(m_pPattern.get(), sURL);
- if (pItem!=m_pPattern->end())
+ PatternHash::const_iterator pItem = findPatternKey(s_pPattern.get(), sURL);
+ if (pItem != s_pPattern->end())
{
- *pReturn = (*m_pHandler)[pItem->second];
+ *pReturn = (*s_pHandler)[pItem->second];
bFound = true;
}
@@ -158,8 +159,8 @@ void HandlerCache::takeOver(std::unique_ptr<HandlerHash> pHandler, std::unique_p
{
SolarMutexGuard aGuard;
- m_pHandler = std::move(pHandler);
- m_pPattern = std::move(pPattern);
+ s_pHandler = std::move(pHandler);
+ s_pPattern = std::move(pPattern);
}
/**