summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2002-11-23 14:37:46 +0000
committerBenoit Foucher <benoit@zeroc.com>2002-11-23 14:37:46 +0000
commit470a28fce573ec04aed074f9114295662114c870 (patch)
tree84ea896c61cd7305401890c727e00061c5c624ad /cpp/src
parent- Added DBEnvironment::openDBWithTxn (required by BerkeleyDB 4.1.2) (diff)
downloadice-470a28fce573ec04aed074f9114295662114c870.tar.bz2
ice-470a28fce573ec04aed074f9114295662114c870.tar.xz
ice-470a28fce573ec04aed074f9114295662114c870.zip
- Added DBEnvironment::openDBWithTxn (required by BerkeleyDB 4.1.2)
- Improved dispatch exception warnings. - Fix the exception test to disable dispatch warnings. - Fixed a bug in IcePack where a server adapter would wait for the server activation even though the node was being shutdown. - Fixed XML transform tests to use openDBWithTxn.
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Freeze/DBI.cpp73
-rw-r--r--cpp/src/Freeze/DBI.h6
-rw-r--r--cpp/src/Ice/Incoming.cpp49
-rw-r--r--cpp/src/IcePack/ActivatorI.cpp4
-rw-r--r--cpp/src/IcePack/ServerI.cpp2
5 files changed, 96 insertions, 38 deletions
diff --git a/cpp/src/Freeze/DBI.cpp b/cpp/src/Freeze/DBI.cpp
index 8930df70f73..a78700a8cd1 100644
--- a/cpp/src/Freeze/DBI.cpp
+++ b/cpp/src/Freeze/DBI.cpp
@@ -201,35 +201,26 @@ Freeze::DBEnvironmentI::getCommunicator()
DBPtr
Freeze::DBEnvironmentI::openDB(const string& name, bool create)
{
- IceUtil::RecMutex::Lock sync(*this);
+ return openDBImpl(0, name, create);
+}
- if(!_dbEnv)
+DBPtr
+Freeze::DBEnvironmentI::openDBWithTxn(const DBTransactionPtr& t, const string& name, bool create)
+{
+ DBTransactionPtr txn = t;
+ if(!t)
{
- ostringstream s;
- s << _errorPrefix << "\"" << _name << "\" has been closed";
- DBException ex(__FILE__, __LINE__);
- ex.message = s.str();
- throw ex;
+ txn = startTransaction();
}
- map<string, DBPtr>::iterator p = _dbMap.find(name);
- if(p != _dbMap.end())
- {
- return p->second;
- }
+ DBPtr db = openDBImpl(static_cast<const DBTransactionI*>(txn.get())->_tid, name, create);
- ::DB* db;
- checkBerkeleyDBReturn(db_create(&db, _dbEnv, 0), _errorPrefix, "db_create");
-
- try
- {
- return new DBI(_communicator, this, db, name, create);
- }
- catch(...)
+ if(!t)
{
- db->close(db, 0);
- throw;
+ txn->commit();
}
+
+ return db;
}
DBTransactionPtr
@@ -286,6 +277,40 @@ Freeze::DBEnvironmentI::sync()
}
}
+DBPtr
+Freeze::DBEnvironmentI::openDBImpl(::DB_TXN* txn, const string& name, bool create)
+{
+ IceUtil::RecMutex::Lock sync(*this);
+
+ if(!_dbEnv)
+ {
+ ostringstream s;
+ s << _errorPrefix << "\"" << _name << "\" has been closed";
+ DBException ex(__FILE__, __LINE__);
+ ex.message = s.str();
+ throw ex;
+ }
+
+ map<string, DBPtr>::iterator p = _dbMap.find(name);
+ if(p != _dbMap.end())
+ {
+ return p->second;
+ }
+
+ ::DB* db;
+ checkBerkeleyDBReturn(db_create(&db, _dbEnv, 0), _errorPrefix, "db_create");
+
+ try
+ {
+ return new DBI(_communicator, this, db, txn, name, create);
+ }
+ catch(...)
+ {
+ db->close(db, 0);
+ throw;
+ }
+}
+
void
Freeze::DBEnvironmentI::add(const string& name, const DBPtr& db)
{
@@ -656,7 +681,7 @@ DBCursorI::close()
_cursor = 0;
}
-Freeze::DBI::DBI(const CommunicatorPtr& communicator, const DBEnvironmentIPtr& dbEnvObj, ::DB* db,
+Freeze::DBI::DBI(const CommunicatorPtr& communicator, const DBEnvironmentIPtr& dbEnvObj, ::DB* db, ::DB_TXN* txn,
const string& name, bool create) :
_communicator(communicator),
_trace(0),
@@ -675,7 +700,7 @@ Freeze::DBI::DBI(const CommunicatorPtr& communicator, const DBEnvironmentIPtr& d
u_int32_t flags = (create) ? DB_CREATE : 0;
#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1)
- checkBerkeleyDBReturn(_db->open(_db, 0, _name.c_str(), 0, DB_BTREE, flags, FREEZE_DB_MODE),
+ checkBerkeleyDBReturn(_db->open(_db, txn, _name.c_str(), 0, DB_BTREE, flags, FREEZE_DB_MODE),
_errorPrefix, "DB->open");
#else
checkBerkeleyDBReturn(_db->open(_db, _name.c_str(), 0, DB_BTREE, flags, FREEZE_DB_MODE),
diff --git a/cpp/src/Freeze/DBI.h b/cpp/src/Freeze/DBI.h
index b59d89eb46b..780a6d5a4bf 100644
--- a/cpp/src/Freeze/DBI.h
+++ b/cpp/src/Freeze/DBI.h
@@ -68,6 +68,8 @@ public:
virtual DBPtr openDB(const std::string&, bool);
+ virtual DBPtr openDBWithTxn(const DBTransactionPtr&, const std::string&, bool);
+
virtual DBTransactionPtr startTransaction();
virtual void close();
@@ -78,6 +80,7 @@ private:
// DBI needs access to add, remove & eraseDB
friend class DBI;
+ DBPtr openDBImpl(::DB_TXN*, const std::string&, bool);
void add(const std::string&, const DBPtr&);
void remove(const std::string&);
void eraseDB(const std::string&);
@@ -106,6 +109,7 @@ public:
private:
+ friend class DBEnvironmentI;
friend class DBI;
::Ice::CommunicatorPtr _communicator;
@@ -122,7 +126,7 @@ class DBI : public DB, public IceUtil::Mutex
{
public:
- DBI(const ::Ice::CommunicatorPtr&, const DBEnvironmentIPtr&, ::DB*, const std::string&, bool);
+ DBI(const ::Ice::CommunicatorPtr&, const DBEnvironmentIPtr&, ::DB*, ::DB_TXN*, const std::string&, bool);
virtual ~DBI();
virtual std::string getName();
diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp
index 622878289f9..15ac2a405f8 100644
--- a/cpp/src/Ice/Incoming.cpp
+++ b/cpp/src/Ice/Incoming.cpp
@@ -19,7 +19,9 @@
#include <Ice/LocalException.h>
#include <Ice/Instance.h>
#include <Ice/Properties.h>
+#include <Ice/IdentityUtil.h>
#include <Ice/LoggerUtil.h>
+#include <Ice/StringUtil.h>
using namespace std;
using namespace Ice;
@@ -266,8 +268,9 @@ IceInternal::Incoming::invoke(bool response)
if(_os.instance()->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
{
- Warning out(_os.instance()->logger());
- out << "dispatch exception: unknown local exception:\n" << ex;
+ ostringstream str;
+ str << ex;
+ warning("dispatch exception: unknown local exception:", str.str());
}
return;
@@ -293,8 +296,9 @@ IceInternal::Incoming::invoke(bool response)
if(_os.instance()->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
{
- Warning out(_os.instance()->logger());
- out << "dispatch exception: unknown user exception:\n" << ex;
+ ostringstream str;
+ str << ex;
+ warning("dispatch exception: unknown user exception:", str.str());
}
return;
@@ -320,8 +324,9 @@ IceInternal::Incoming::invoke(bool response)
if(_os.instance()->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
{
- Warning out(_os.instance()->logger());
- out << "dispatch exception: unknown exception:\n" << ex;
+ ostringstream str;
+ str << ex;
+ warning("dispatch exception: unknown exception:", str.str());
}
return;
@@ -347,8 +352,7 @@ IceInternal::Incoming::invoke(bool response)
if(_os.instance()->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
{
- Warning out(_os.instance()->logger());
- out << "dispatch exception: unknown std::exception: " << ex.what();
+ warning("dispatch exception: unknown std::exception:", ex.what());
}
return;
@@ -373,8 +377,7 @@ IceInternal::Incoming::invoke(bool response)
if(_os.instance()->properties()->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
{
- Warning out(_os.instance()->logger());
- out << "dispatch exception: unknown c++ exception";
+ warning("dispatch exception: unknown c++ exception:", "");
}
return;
@@ -429,3 +432,29 @@ IceInternal::Incoming::os()
{
return &_os;
}
+
+void
+IceInternal::Incoming::warning(const string& msg, const string& ex)
+{
+ ostringstream str;
+ str << msg;
+ if(!ex.empty())
+ {
+ str << "\n" << ex;
+ }
+ str << "\nidentity: " << _current.id;
+ str << "\nfacet: ";
+ vector<string>::const_iterator p = _current.facet.begin();
+ while(p != _current.facet.end())
+ {
+ str << encodeString(*p++, "/");
+ if(p != _current.facet.end())
+ {
+ str << '/';
+ }
+ }
+ str << "\noperation: " << _current.operation;
+
+ Warning out(_os.instance()->logger());
+ out << str.str();
+}
diff --git a/cpp/src/IcePack/ActivatorI.cpp b/cpp/src/IcePack/ActivatorI.cpp
index b2f85b2e66b..27a2e971436 100644
--- a/cpp/src/IcePack/ActivatorI.cpp
+++ b/cpp/src/IcePack/ActivatorI.cpp
@@ -350,7 +350,7 @@ IcePack::ActivatorI::deactivate(const ServerPtr& server)
// Send a SIGTERM to the process.
//
int ret = ::kill(static_cast<pid_t>(pid), SIGTERM);
- if(ret != 0 && ret != ESRCH)
+ if(ret != 0 && getSystemErrno() != ESRCH)
{
SyscallException ex(__FILE__, __LINE__);
ex.error = getSystemErrno();
@@ -381,7 +381,7 @@ IcePack::ActivatorI::kill(const ServerPtr& server)
// Send a SIGKILL to the process.
//
int ret = ::kill(static_cast<pid_t>(pid), SIGKILL);
- if(ret != 0 && ret != ESRCH)
+ if(ret != 0 && getSystemErrno() != ESRCH)
{
SyscallException ex(__FILE__, __LINE__);
ex.error = getSystemErrno();
diff --git a/cpp/src/IcePack/ServerI.cpp b/cpp/src/IcePack/ServerI.cpp
index 16414c4c727..a7bb93fa7c4 100644
--- a/cpp/src/IcePack/ServerI.cpp
+++ b/cpp/src/IcePack/ServerI.cpp
@@ -65,12 +65,12 @@ IcePack::ServerI::start(ServerActivation act, const Ice::Current& current)
break;
}
case Activating:
+ case Deactivating:
{
wait(); // TODO: Timeout?
continue;
}
case Active:
- case Deactivating:
{
return true; // Raise an exception instead?
}