[Libreoffice-commits] .: 2 commits - bridges/source stoc/source
Caolán McNamara
caolan at kemper.freedesktop.org
Tue Oct 12 07:37:13 PDT 2010
bridges/source/remote/context/context.cxx | 41 +++++++----------------------
stoc/source/security/access_controller.cxx | 22 ++++++++-------
stoc/source/security/file_policy.cxx | 26 ++++++++----------
3 files changed, 35 insertions(+), 54 deletions(-)
New commits:
commit fefa4fae4fb423a069c11c7c039c6f5a482ea964
Author: Caolán McNamara <caolanm at redhat.com>
Date: Tue Oct 12 13:56:53 2010 +0100
move some uno::Sequences to ensure a safer deterministic shutdown order
diff --git a/stoc/source/security/access_controller.cxx b/stoc/source/security/access_controller.cxx
index c3a4d88..d259232 100644
--- a/stoc/source/security/access_controller.cxx
+++ b/stoc/source/security/access_controller.cxx
@@ -57,6 +57,8 @@
#include "lru_cache.h"
#include "permissions.h"
+#include "bootstrapservices.hxx"
+
#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
#define SERVICE_NAME "com.sun.star.security.AccessController"
@@ -79,12 +81,8 @@ namespace stoc_sec
{
// static stuff initialized when loading lib
static OUString s_envType = OUSTR(CPPU_CURRENT_LANGUAGE_BINDING_NAME);
-static OUString s_implName = OUSTR(IMPL_NAME);
-static OUString s_serviceName = OUSTR(SERVICE_NAME);
static OUString s_acRestriction = OUSTR("access-control.restriction");
-static Sequence< OUString > s_serviceNames = Sequence< OUString >( &s_serviceName, 1 );
-
//##################################################################################################
/** ac context intersects permissions of two ac contexts
@@ -1008,14 +1006,15 @@ Reference< security::XAccessControlContext > AccessController::getContext()
OUString AccessController::getImplementationName()
throw (RuntimeException)
{
- return s_implName;
+ return stoc_bootstrap::ac_getImplementationName();
}
//__________________________________________________________________________________________________
sal_Bool AccessController::supportsService( OUString const & serviceName )
throw (RuntimeException)
{
- OUString const * pNames = s_serviceNames.getConstArray();
- for ( sal_Int32 nPos = s_serviceNames.getLength(); nPos--; )
+ Sequence< OUString > aSNL = getSupportedServiceNames();
+ const OUString * pNames = aSNL.getConstArray();
+ for ( sal_Int32 nPos = aSNL.getLength(); --nPos; )
{
if (serviceName.equals( pNames[ nPos ] ))
{
@@ -1028,7 +1027,7 @@ sal_Bool AccessController::supportsService( OUString const & serviceName )
Sequence< OUString > AccessController::getSupportedServiceNames()
throw (RuntimeException)
{
- return s_serviceNames;
+ return stoc_bootstrap::ac_getSupportedServiceNames();
}
}
//##################################################################################################
@@ -1043,12 +1042,15 @@ Reference< XInterface > SAL_CALL ac_create(
//--------------------------------------------------------------------------------------------------
Sequence< OUString > ac_getSupportedServiceNames() SAL_THROW( () )
{
- return stoc_sec::s_serviceNames;
+ static OUString s_serviceName = OUSTR(SERVICE_NAME);
+ static Sequence< OUString > s_serviceNames = Sequence< OUString >( &s_serviceName, 1 );
+ return s_serviceNames;
}
//--------------------------------------------------------------------------------------------------
OUString ac_getImplementationName() SAL_THROW( () )
{
- return stoc_sec::s_implName;
+ static OUString s_implName = OUSTR(IMPL_NAME);
+ return s_implName;
}
//--------------------------------------------------------------------------------------------------
Reference< XInterface > SAL_CALL filepolicy_create(
diff --git a/stoc/source/security/file_policy.cxx b/stoc/source/security/file_policy.cxx
index 747d9dc..975ff66 100644
--- a/stoc/source/security/file_policy.cxx
+++ b/stoc/source/security/file_policy.cxx
@@ -48,11 +48,12 @@
#include <com/sun/star/io/FilePermission.hpp>
#include <com/sun/star/connection/SocketPermission.hpp>
+#include "bootstrapservices.hxx"
+
#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
#define SERVICE_NAME "com.sun.star.security.Policy"
#define IMPL_NAME "com.sun.star.security.comp.stoc.FilePolicy"
-
using namespace ::osl;
using namespace ::rtl;
using namespace ::cppu;
@@ -63,13 +64,6 @@ extern ::rtl_StandardModuleCount g_moduleCount;
namespace stoc_sec
{
-// static stuff initialized when loading lib
-static OUString s_implName = OUSTR(IMPL_NAME);
-static OUString s_serviceName = OUSTR(SERVICE_NAME);
-
-static Sequence< OUString > s_serviceNames = Sequence< OUString >( &s_serviceName, 1 );
-//##################################################################################################
-
//--------------------------------------------------------------------------------------------------
static inline void dispose( Reference< XInterface > const & x )
SAL_THROW( (RuntimeException) )
@@ -558,14 +552,15 @@ void FilePolicy::refresh()
OUString FilePolicy::getImplementationName()
throw (RuntimeException)
{
- return s_implName;
+ return stoc_bootstrap::filepolicy_getImplementationName();
}
//__________________________________________________________________________________________________
sal_Bool FilePolicy::supportsService( OUString const & serviceName )
throw (RuntimeException)
{
- OUString const * pNames = s_serviceNames.getConstArray();
- for ( sal_Int32 nPos = s_serviceNames.getLength(); nPos--; )
+ Sequence< OUString > aSNL = getSupportedServiceNames();
+ const OUString * pNames = aSNL.getConstArray();
+ for ( sal_Int32 nPos = aSNL.getLength(); --nPos; )
{
if (serviceName.equals( pNames[ nPos ] ))
{
@@ -578,7 +573,7 @@ sal_Bool FilePolicy::supportsService( OUString const & serviceName )
Sequence< OUString > FilePolicy::getSupportedServiceNames()
throw (RuntimeException)
{
- return s_serviceNames;
+ return stoc_bootstrap::filepolicy_getSupportedServiceNames();
}
}
//##################################################################################################
@@ -594,11 +589,14 @@ Reference< XInterface > SAL_CALL filepolicy_create(
//--------------------------------------------------------------------------------------------------
Sequence< OUString > filepolicy_getSupportedServiceNames() SAL_THROW( () )
{
- return stoc_sec::s_serviceNames;
+ static OUString s_serviceName = OUSTR(SERVICE_NAME);
+ static Sequence< OUString > s_serviceNames = Sequence< OUString >( &s_serviceName, 1 );
+ return s_serviceNames;
}
//--------------------------------------------------------------------------------------------------
OUString filepolicy_getImplementationName() SAL_THROW( () )
{
- return stoc_sec::s_implName;
+ static OUString s_implName = OUSTR(IMPL_NAME);
+ return s_implName;
}
}
commit 394c48219a9126748352d11cc545325d0c28603a
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon Oct 11 14:57:45 2010 +0100
#i112784# do not leak ContextAdmin
diff --git a/bridges/source/remote/context/context.cxx b/bridges/source/remote/context/context.cxx
index 532e7f0..cf77522 100644
--- a/bridges/source/remote/context/context.cxx
+++ b/bridges/source/remote/context/context.cxx
@@ -38,6 +38,7 @@
#include <osl/mutex.hxx>
#include "rtl/ustring.hxx"
+#include "rtl/instance.hxx"
#include <bridges/remote/context.h>
#include <bridges/remote/remote.h>
@@ -109,17 +110,9 @@ ContextMap;
static MyCounter thisCounter( "DEBUG : Context" );
#endif
-class ContextAdmin;
-
-ContextAdmin *g_pTheContext = 0;
-
-
-
class ContextAdmin
{
public:
- static ContextAdmin *getInstance();
-
// listener administration
void addContextListener( remote_contextListenerFunc listener , void *pObject );
void removeContextListener( remote_contextListenerFunc listener , void *pObject );
@@ -138,7 +131,7 @@ public:
void revokeContext( uno_Context *pRemoteContext );
- uno_Context *get( rtl_uString *pHost );
+ uno_Context *getContext( rtl_uString *pHost );
rtl_uString ** getConnectionList(
sal_Int32 *pnStringCount, MemAlloc memAlloc );
@@ -152,19 +145,6 @@ private:
List m_lstListener;
};
-ContextAdmin *ContextAdmin::getInstance()
-{
- if( ! g_pTheContext ) {
- ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
- if( ! g_pTheContext ) {
- //TODO This memory is leaked; see #i63473# for when this should be
- // changed again:
- g_pTheContext = new ContextAdmin;
- }
- }
- return g_pTheContext;
-}
-
void ContextAdmin::addContextListener( remote_contextListenerFunc listener , void *pObject )
{
::osl::MutexGuard guard( m_mutex );
@@ -209,7 +189,7 @@ uno_Context *ContextAdmin::createAndRegisterContext( remote_Connection *pConnect
{
::osl::MutexGuard guard( m_mutex );
- uno_Context *pContext = get( pIdStr );
+ uno_Context *pContext = getContext( pIdStr );
if( pContext )
{
pContext->release( pContext );
@@ -245,7 +225,7 @@ void ContextAdmin::revokeContext( uno_Context *pRemoteContext )
}
-uno_Context *ContextAdmin::get( rtl_uString *pHost )
+uno_Context *ContextAdmin::getContext( rtl_uString *pHost )
{
::osl::MutexGuard guard( m_mutex );
@@ -287,6 +267,7 @@ rtl_uString ** ContextAdmin::getConnectionList(
}
+struct theContextAdmin : public rtl::Static<ContextAdmin, theContextAdmin> {};
/*****************************
* remote_ContextImpl implementation
@@ -383,7 +364,7 @@ void remote_ContextImpl::thisDispose( remote_Context *pRemoteC )
if( ! pImpl->m_bDisposed )
{
pImpl->m_bDisposed = sal_True;
- ContextAdmin::getInstance()->revokeContext( (uno_Context * ) pRemoteC );
+ theContextAdmin::get().revokeContext( (uno_Context * ) pRemoteC );
if( pImpl->m_pInstanceProvider )
{
@@ -460,7 +441,7 @@ using namespace remote_context;
extern "C" remote_Context * SAL_CALL
remote_getContext( rtl_uString *pIdString )
{
- return (remote_Context *) ContextAdmin::getInstance()->get( pIdString );
+ return (remote_Context *) theContextAdmin::get().getContext(pIdString);
}
@@ -473,7 +454,7 @@ remote_createContext( remote_Connection *pConnection,
remote_InstanceProvider *pProvider )
{
remote_ContextImpl *p = (remote_ContextImpl * )
- ContextAdmin::getInstance()->createAndRegisterContext(
+ theContextAdmin::get().createAndRegisterContext(
pConnection ,
pIdStr ,
pDescription,
@@ -487,17 +468,17 @@ remote_createContext( remote_Connection *pConnection,
extern "C" void SAL_CALL
remote_addContextListener( remote_contextListenerFunc listener, void *pObject )
{
- ContextAdmin::getInstance()->addContextListener( listener , pObject );
+ theContextAdmin::get().addContextListener( listener , pObject );
}
extern "C" void SAL_CALL
remote_removeContextListener( remote_contextListenerFunc listener , void *pObject )
{
- ContextAdmin::getInstance()->removeContextListener( listener , pObject );
+ theContextAdmin::get().removeContextListener( listener , pObject );
}
extern "C" rtl_uString ** SAL_CALL
remote_getContextList( sal_Int32 *pnStringCount, MemAlloc memAlloc )
{
- return ContextAdmin::getInstance()->getConnectionList( pnStringCount , memAlloc );
+ return theContextAdmin::get().getConnectionList( pnStringCount , memAlloc );
}
More information about the Libreoffice-commits
mailing list