summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernard Normier <bernard@zeroc.com>2007-06-11 15:50:51 -0400
committerBernard Normier <bernard@zeroc.com>2007-06-11 15:50:51 -0400
commitba3acdf41b6bd2949a6280c39771c407d117cf44 (patch)
treecb55584ebb13e5c0e898440cefb2ee986506299f
parentMore .gitignore fixes and fixed a bunch of clean rules in Makefile and Makefi... (diff)
downloadice-ba3acdf41b6bd2949a6280c39771c407d117cf44.tar.bz2
ice-ba3acdf41b6bd2949a6280c39771c407d117cf44.tar.xz
ice-ba3acdf41b6bd2949a6280c39771c407d117cf44.zip
Merge Freeze fixes from 3.2 branch
-rw-r--r--cpp/include/Freeze/Map.h6
-rw-r--r--cpp/src/Freeze/MapI.cpp48
-rw-r--r--cpp/test/Freeze/dbmap/Client.cpp17
3 files changed, 53 insertions, 18 deletions
diff --git a/cpp/include/Freeze/Map.h b/cpp/include/Freeze/Map.h
index 73206d9ec70..07459172e07 100644
--- a/cpp/include/Freeze/Map.h
+++ b/cpp/include/Freeze/Map.h
@@ -856,7 +856,7 @@ public:
// equality is not necessarily correct in the context of a
// transaction.
//
- if(count() != rhs.count())
+ if(size() != rhs.size())
{
return false;
}
@@ -1144,7 +1144,7 @@ public:
const Ice::CommunicatorPtr&
communicator() const
{
- return _communicator();
+ return _communicator;
}
protected:
@@ -1155,7 +1155,7 @@ protected:
}
std::auto_ptr<MapHelper> _helper;
- const Ice::CommunicatorPtr _communicator;
+ Ice::CommunicatorPtr _communicator;
};
diff --git a/cpp/src/Freeze/MapI.cpp b/cpp/src/Freeze/MapI.cpp
index 37c894dad0c..1011606f336 100644
--- a/cpp/src/Freeze/MapI.cpp
+++ b/cpp/src/Freeze/MapI.cpp
@@ -1491,18 +1491,20 @@ Freeze::MapIndexI::untypedCount(const Key& k, const ConnectionIPtr& connection)
int result = 0;
+ DbTxn * txn = connection->dbTxn();
+
try
{
for(;;)
{
Dbc* dbc = 0;
-
+
try
{
//
// Move to the first record
//
- _db->cursor(0, &dbc, 0);
+ _db->cursor(txn, &dbc, 0);
bool found = (dbc->get(&dbKey, &dbValue, DB_SET) == 0);
if(found)
@@ -1527,9 +1529,16 @@ Freeze::MapIndexI::untypedCount(const Key& k, const ConnectionIPtr& connection)
}
catch(const DbDeadlockException&)
{
- //
- // Ignored
- //
+ if(txn != 0)
+ {
+ throw;
+ }
+ else
+ {
+ //
+ // Ignored
+ //
+ }
}
}
@@ -1537,11 +1546,15 @@ Freeze::MapIndexI::untypedCount(const Key& k, const ConnectionIPtr& connection)
{
Warning out(connection->communicator()->getLogger());
out << "Deadlock in Freeze::MapIndexI::untypedCount while searching \""
- << _dbName << "\"; retrying ...";
+ << _dbName << "\"";
}
+ if(txn != 0)
+ {
+ throw;
+ }
//
- // Retry
+ // Otherwise retry
//
}
catch(...)
@@ -1554,20 +1567,29 @@ Freeze::MapIndexI::untypedCount(const Key& k, const ConnectionIPtr& connection)
}
catch(const DbDeadlockException&)
{
- //
- // Ignored
- //
+ if(txn != 0)
+ {
+ throw;
+ }
+ else
+ {
+ //
+ // Ignored
+ //
+ }
}
}
throw;
}
}
}
+ catch(const DbDeadlockException& dx)
+ {
+ throw DeadlockException(__FILE__, __LINE__, dx.what());
+ }
catch(const DbException& dx)
{
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
+ throw DatabaseException(__FILE__, __LINE__, dx.what());
}
return result;
diff --git a/cpp/test/Freeze/dbmap/Client.cpp b/cpp/test/Freeze/dbmap/Client.cpp
index 09ab3c7d745..d8b69750bda 100644
--- a/cpp/test/Freeze/dbmap/Client.cpp
+++ b/cpp/test/Freeze/dbmap/Client.cpp
@@ -205,12 +205,25 @@ run(const CommunicatorPtr& communicator, const string& envName)
{
const string dbName = "binary";
Freeze::ConnectionPtr connection = createConnection(communicator, envName);
- ByteIntMap m(connection, dbName);
+ ByteIntMap m1(connection, dbName);
//
// Populate the database with the alphabet
//
- populateDB(connection, m);
+ populateDB(connection, m1);
+
+ //
+ // Test ==, swap and communicator()
+ //
+ ByteIntMap m(connection, dbName + "-tmp");
+ test(!(m == m1));
+ test(m != m1);
+ m.swap(m1);
+ test(!(m == m1));
+ test(m != m1);
+ test(m1.size() == 0);
+ test(m.communicator() == m1.communicator() == communicator);
+
vector<Byte>::const_iterator j;
ByteIntMap::iterator p;