summaryrefslogtreecommitdiff
path: root/connectivity/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-09-25 14:00:30 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-09-25 17:19:38 +0100
commitbaede5e8758c406d8361b18967a5852df2cfa5d0 (patch)
tree56f82912a8e2372d6758d0996d71418bf1fa5674 /connectivity/source
parente01a142c5d1400ac489c2ac0c5bf7779e308434f (diff)
ensure that osl_atomic_decrement gets called after osl_atomic_increment
Change-Id: If110d27950a4efd1a96dc5f2702f4dfbfe58bcbe
Diffstat (limited to 'connectivity/source')
-rw-r--r--connectivity/source/drivers/firebird/Connection.cxx18
1 files changed, 15 insertions, 3 deletions
diff --git a/connectivity/source/drivers/firebird/Connection.cxx b/connectivity/source/drivers/firebird/Connection.cxx
index fd4b43f158fe..802b611fd3c5 100644
--- a/connectivity/source/drivers/firebird/Connection.cxx
+++ b/connectivity/source/drivers/firebird/Connection.cxx
@@ -106,10 +106,24 @@ void SAL_CALL Connection::release() throw()
relase_ChildImpl();
}
+struct ConnectionGuard
+{
+ oslInterlockedCount& m_refCount;
+ ConnectionGuard(oslInterlockedCount& refCount)
+ : m_refCount(refCount)
+ {
+ osl_atomic_increment(&m_refCount);
+ }
+ ~ConnectionGuard()
+ {
+ osl_atomic_decrement(&m_refCount);
+ }
+};
+
void Connection::construct(const ::rtl::OUString& url, const Sequence< PropertyValue >& info)
throw (SQLException, RuntimeException, std::exception)
{
- osl_atomic_increment( &m_refCount );
+ ConnectionGuard aGuard(m_refCount);
try
{
@@ -308,8 +322,6 @@ void Connection::construct(const ::rtl::OUString& url, const Sequence< PropertyV
{
throw std::runtime_error("Generic Firebird::Exception");
}
-
- osl_atomic_decrement( &m_refCount );
}
void Connection::notifyDatabaseModified()