summaryrefslogtreecommitdiff
path: root/connectivity/source/cpool
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2016-06-08 11:29:19 +0200
committerNoel Grandin <noelgrandin@gmail.com>2016-06-09 09:45:50 +0000
commitaaebe3c45d3ceac7aba19ad8fd5b1cb621e337b3 (patch)
tree132aaabeefe2f47ab38d7296dede066fdce03e6c /connectivity/source/cpool
parenta7415828b86a02216ffed44a4fa5b785f17d657c (diff)
remove some manual ref-counting in connectivity
Change-Id: I0d00b4566c13817b296f237e993f4ce63ef0c664 Reviewed-on: https://gerrit.libreoffice.org/26053 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'connectivity/source/cpool')
-rw-r--r--connectivity/source/cpool/ZDriverWrapper.cxx11
-rw-r--r--connectivity/source/cpool/ZDriverWrapper.hxx4
-rw-r--r--connectivity/source/cpool/ZPoolCollection.cxx14
-rw-r--r--connectivity/source/cpool/ZPoolCollection.hxx3
4 files changed, 11 insertions, 21 deletions
diff --git a/connectivity/source/cpool/ZDriverWrapper.cxx b/connectivity/source/cpool/ZDriverWrapper.cxx
index eaf2762a7190..d9df6fcb3a9d 100644
--- a/connectivity/source/cpool/ZDriverWrapper.cxx
+++ b/connectivity/source/cpool/ZDriverWrapper.cxx
@@ -34,10 +34,7 @@ namespace connectivity
:m_pConnectionPool(_pPool)
{
OSL_ENSURE(_rxAggregateDriver.is(), "ODriverWrapper::ODriverWrapper: invalid aggregate!");
- OSL_ENSURE(m_pConnectionPool, "ODriverWrapper::ODriverWrapper: invalid connection pool!");
-
- if (m_pConnectionPool)
- m_pConnectionPool->acquire();
+ OSL_ENSURE(m_pConnectionPool.is(), "ODriverWrapper::ODriverWrapper: invalid connection pool!");
osl_atomic_increment( &m_refCount );
if (_rxAggregateDriver.is())
@@ -61,10 +58,6 @@ namespace connectivity
{
if (m_xDriverAggregate.is())
m_xDriverAggregate->setDelegator(nullptr);
-
- if (m_pConnectionPool)
- m_pConnectionPool->release();
- m_pConnectionPool = nullptr;
}
@@ -78,7 +71,7 @@ namespace connectivity
Reference< XConnection > SAL_CALL ODriverWrapper::connect( const OUString& url, const Sequence< PropertyValue >& info ) throw (SQLException, RuntimeException, std::exception)
{
Reference< XConnection > xConnection;
- if (m_pConnectionPool)
+ if (m_pConnectionPool.is())
// route this through the pool
xConnection = m_pConnectionPool->getConnectionWithInfo( url, info );
else if (m_xDriver.is())
diff --git a/connectivity/source/cpool/ZDriverWrapper.hxx b/connectivity/source/cpool/ZDriverWrapper.hxx
index baac4ceac590..da0d39e212d5 100644
--- a/connectivity/source/cpool/ZDriverWrapper.hxx
+++ b/connectivity/source/cpool/ZDriverWrapper.hxx
@@ -23,6 +23,7 @@
#include <com/sun/star/sdbc/XDriver.hpp>
#include <cppuhelper/implbase.hxx>
#include <osl/mutex.hxx>
+#include <rtl/ref.hxx>
#include <com/sun/star/uno/XAggregation.hpp>
@@ -41,7 +42,8 @@ namespace connectivity
m_xDriverAggregate;
css::uno::Reference< css::sdbc::XDriver >
m_xDriver;
- OConnectionPool* m_pConnectionPool;
+ rtl::Reference<OConnectionPool>
+ m_pConnectionPool;
public:
/** creates a new wrapper for a driver
diff --git a/connectivity/source/cpool/ZPoolCollection.cxx b/connectivity/source/cpool/ZPoolCollection.cxx
index f14575703e9c..4e4c1e306b40 100644
--- a/connectivity/source/cpool/ZPoolCollection.cxx
+++ b/connectivity/source/cpool/ZPoolCollection.cxx
@@ -284,11 +284,9 @@ void OPoolCollection::clearConnectionPools(bool _bDispose)
while(aIter != m_aPools.end())
{
aIter->second->clear(_bDispose);
- aIter->second->release();
- OUString sKeyValue = aIter->first;
++aIter;
- m_aPools.erase(sKeyValue);
}
+ m_aPools.clear();
}
OConnectionPool* OPoolCollection::getConnectionPool(const OUString& _sImplName,
@@ -298,16 +296,15 @@ OConnectionPool* OPoolCollection::getConnectionPool(const OUString& _sImplName,
OConnectionPool *pRet = nullptr;
OConnectionPools::const_iterator aFind = m_aPools.find(_sImplName);
if (aFind != m_aPools.end())
- pRet = aFind->second;
+ pRet = aFind->second.get();
else if (_xDriver.is() && _xDriverNode.is())
{
Reference<XPropertySet> xProp(_xDriverNode,UNO_QUERY);
if(xProp.is())
xProp->addPropertyChangeListener(getEnableNodeName(),this);
OConnectionPool* pConnectionPool = new OConnectionPool(_xDriver,_xDriverNode,m_xProxyFactory);
- pConnectionPool->acquire();
aFind = m_aPools.insert(OConnectionPools::value_type(_sImplName,pConnectionPool)).first;
- pRet = aFind->second;
+ pRet = aFind->second.get();
}
OSL_ENSURE(pRet, "Could not query DriverManager from ConnectionPool!");
@@ -456,10 +453,8 @@ void SAL_CALL OPoolCollection::propertyChange( const css::beans::PropertyChangeE
for(;aIter != m_aPools.end();++aIter)
{
aIter->second->clear(false);
- aIter->second->release();
}
m_aPools.clear();
- m_aPools = OConnectionPools();
}
}
else if(evt.Source.is())
@@ -484,10 +479,9 @@ void SAL_CALL OPoolCollection::propertyChange( const css::beans::PropertyChangeE
// 2nd clear the connectionpool
OConnectionPools::iterator aFind = m_aPools.find(sThisDriverName);
- if(aFind != m_aPools.end() && aFind->second)
+ if(aFind != m_aPools.end())
{
aFind->second->clear(false);
- aFind->second->release();
m_aPools.erase(aFind);
}
}
diff --git a/connectivity/source/cpool/ZPoolCollection.hxx b/connectivity/source/cpool/ZPoolCollection.hxx
index 865e6b037b4e..ff31c6c38435 100644
--- a/connectivity/source/cpool/ZPoolCollection.hxx
+++ b/connectivity/source/cpool/ZPoolCollection.hxx
@@ -39,6 +39,7 @@
#include <com/sun/star/reflection/XProxyFactory.hpp>
#include <comphelper/stl_types.hxx>
#include <osl/mutex.hxx>
+#include <rtl/ref.hxx>
namespace connectivity
{
@@ -59,7 +60,7 @@ namespace connectivity
typedef ::comphelper::OInterfaceCompare< css::sdbc::XDriver > ODriverCompare;
- typedef std::map<OUString, OConnectionPool*> OConnectionPools;
+ typedef std::map<OUString, rtl::Reference<OConnectionPool>> OConnectionPools;
typedef std::map<
css::uno::Reference< css::sdbc::XDriver >,