summaryrefslogtreecommitdiff
path: root/cpp/src/Freeze/ConnectionI.cpp
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2007-09-12 15:47:00 +1000
committerMichi Henning <michi@zeroc.com>2007-09-12 15:47:00 +1000
commitbd5a0a349aa417b4d44dc89f2febbf05df916952 (patch)
treec569cb9f554d0149edac00e8aee85a26d652c049 /cpp/src/Freeze/ConnectionI.cpp
parentMore changes to DictionaryBase and CollectionBase. (diff)
parentFix to previous fix. (diff)
downloadice-bd5a0a349aa417b4d44dc89f2febbf05df916952.tar.bz2
ice-bd5a0a349aa417b4d44dc89f2febbf05df916952.tar.xz
ice-bd5a0a349aa417b4d44dc89f2febbf05df916952.zip
Merge branch 'master' of ssh://cvs.zeroc.com/home/git/ice
Diffstat (limited to 'cpp/src/Freeze/ConnectionI.cpp')
-rw-r--r--cpp/src/Freeze/ConnectionI.cpp44
1 files changed, 42 insertions, 2 deletions
diff --git a/cpp/src/Freeze/ConnectionI.cpp b/cpp/src/Freeze/ConnectionI.cpp
index 66a1e8ba0f7..258060f9f5c 100644
--- a/cpp/src/Freeze/ConnectionI.cpp
+++ b/cpp/src/Freeze/ConnectionI.cpp
@@ -46,7 +46,7 @@ Freeze::ConnectionI::close()
{
try
{
- _transaction->rollback();
+ _transaction->rollbackInternal(true);
}
catch(const DatabaseException&)
{
@@ -77,6 +77,44 @@ Freeze::ConnectionI::getName() const
return _envName;
}
+void
+Freeze::ConnectionI::__incRef()
+{
+ IceUtil::Mutex::Lock sync(_refCountMutex->mutex);
+ _refCount++;
+}
+
+
+void
+Freeze::ConnectionI::__decRef()
+{
+ IceUtil::Mutex::Lock sync(_refCountMutex->mutex);
+ if(--_refCount == 0)
+ {
+ sync.release();
+ delete this;
+ }
+ else if(_refCount == 1 && _transaction != 0 && _transaction->dbTxn() != 0 && _transaction->__getRefNoSync() == 1)
+ {
+ sync.release();
+ close();
+ }
+}
+
+int
+Freeze::ConnectionI::__getRef() const
+{
+ IceUtil::Mutex::Lock sync(_refCountMutex->mutex);
+ return _refCount;
+}
+
+int
+Freeze::ConnectionI::__getRefNoSync() const
+{
+ return _refCount;
+}
+
+
Freeze::ConnectionI::~ConnectionI()
{
close();
@@ -88,7 +126,9 @@ Freeze::ConnectionI::ConnectionI(const SharedDbEnvPtr& dbEnv) :
_envName(dbEnv->getEnvName()),
_trace(_communicator->getProperties()->getPropertyAsInt("Freeze.Trace.Map")),
_txTrace(_communicator->getProperties()->getPropertyAsInt("Freeze.Trace.Transaction")),
- _deadlockWarning(_communicator->getProperties()->getPropertyAsInt("Freeze.Warn.Deadlocks") != 0)
+ _deadlockWarning(_communicator->getProperties()->getPropertyAsInt("Freeze.Warn.Deadlocks") != 0),
+ _refCountMutex(new SharedMutex),
+ _refCount(0)
{
}