summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2006-11-29 14:40:22 +0000
committerBenoit Foucher <benoit@zeroc.com>2006-11-29 14:40:22 +0000
commit8fdb96f93af7f6ac27ecb50ea4a5f22856b8546c (patch)
tree463ee5268393e18f55fdf9da9946e2960ca7899c /cpp/src
parentFixes (diff)
downloadice-8fdb96f93af7f6ac27ecb50ea4a5f22856b8546c.tar.bz2
ice-8fdb96f93af7f6ac27ecb50ea4a5f22856b8546c.tar.xz
ice-8fdb96f93af7f6ac27ecb50ea4a5f22856b8546c.zip
More bug fixes
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/IceGrid/Allocatable.cpp2
-rw-r--r--cpp/src/IceGrid/Allocatable.h2
-rw-r--r--cpp/src/IceGrid/AllocatableObjectCache.cpp54
-rw-r--r--cpp/src/IceGrid/AllocatableObjectCache.h2
-rw-r--r--cpp/src/IceGrid/Parser.cpp2
-rw-r--r--cpp/src/IceGrid/ServerCache.cpp38
-rw-r--r--cpp/src/IceGrid/ServerI.cpp14
7 files changed, 67 insertions, 47 deletions
diff --git a/cpp/src/IceGrid/Allocatable.cpp b/cpp/src/IceGrid/Allocatable.cpp
index 9efa9d47c07..de543f0efb1 100644
--- a/cpp/src/IceGrid/Allocatable.cpp
+++ b/cpp/src/IceGrid/Allocatable.cpp
@@ -482,8 +482,6 @@ Allocatable::allocateFromChild(const AllocationRequestPtr& request,
bool tryAllocate,
bool fromRelease)
{
- assert(_allocatable);
-
if(_parent && !_parent->allocateFromChild(request, child, tryAllocate, fromRelease))
{
return false;
diff --git a/cpp/src/IceGrid/Allocatable.h b/cpp/src/IceGrid/Allocatable.h
index cbf6f2922e8..941dddc7574 100644
--- a/cpp/src/IceGrid/Allocatable.h
+++ b/cpp/src/IceGrid/Allocatable.h
@@ -103,7 +103,7 @@ protected:
void queueAllocationAttempt(const AllocatablePtr&, const AllocationRequestPtr&, bool);
AllocatablePtr dequeueAllocationAttempt(AllocationRequestPtr&);
- const bool _allocatable;
+ bool _allocatable;
const AllocatablePtr _parent;
std::list<std::pair<AllocatablePtr, AllocationRequestPtr> > _requests;
diff --git a/cpp/src/IceGrid/AllocatableObjectCache.cpp b/cpp/src/IceGrid/AllocatableObjectCache.cpp
index 8be86c60f7e..7f57e3a4f2d 100644
--- a/cpp/src/IceGrid/AllocatableObjectCache.cpp
+++ b/cpp/src/IceGrid/AllocatableObjectCache.cpp
@@ -162,28 +162,37 @@ AllocatableObjectCache::get(const Ice::Identity& id) const
return entry;
}
-AllocatableObjectEntryPtr
+void
AllocatableObjectCache::remove(const Ice::Identity& id)
{
- Lock sync(*this);
- AllocatableObjectEntryPtr entry = getImpl(id);
- assert(entry);
- removeImpl(id);
+ AllocatableObjectEntryPtr entry;
+ {
+ Lock sync(*this);
+ entry = getImpl(id);
+ assert(entry);
+ removeImpl(id);
+
+ map<string, TypeEntry>::iterator p = _types.find(entry->getType());
+ assert(p != _types.end());
+ if(p->second.remove(entry))
+ {
+ _types.erase(p);
+ }
- map<string, TypeEntry>::iterator p = _types.find(entry->getType());
- assert(p != _types.end());
- if(p->second.remove(entry))
- {
- _types.erase(p);
+ if(_traceLevels && _traceLevels->object > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
+ out << "removed allocatable object `" << _communicator->identityToString(id) << "'";
+ }
}
- if(_traceLevels && _traceLevels->object > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
- out << "removed allocatable object `" << _communicator->identityToString(id) << "'";
- }
-
- return entry;
+ //
+ // This must be done outside the synchronization because destroy
+ // might release the object and release might try to callback on
+ // the cache.
+ //
+ assert(entry);
+ entry->destroy();
}
void
@@ -345,7 +354,16 @@ AllocatableObjectEntry::destroy()
_destroyed = true;
session = _session;
}
- release(session);
+ if(session)
+ {
+ try
+ {
+ release(session);
+ }
+ catch(const AllocationException&)
+ {
+ }
+ }
}
void
diff --git a/cpp/src/IceGrid/AllocatableObjectCache.h b/cpp/src/IceGrid/AllocatableObjectCache.h
index db5805836df..258608a3e55 100644
--- a/cpp/src/IceGrid/AllocatableObjectCache.h
+++ b/cpp/src/IceGrid/AllocatableObjectCache.h
@@ -79,7 +79,7 @@ public:
void add(const ObjectInfo&, const AllocatablePtr&);
AllocatableObjectEntryPtr get(const Ice::Identity&) const;
- AllocatableObjectEntryPtr remove(const Ice::Identity&);
+ void remove(const Ice::Identity&);
void allocateByType(const std::string&, const ObjectAllocationRequestPtr&);
bool canTryAllocate(const AllocatableObjectEntryPtr&);
diff --git a/cpp/src/IceGrid/Parser.cpp b/cpp/src/IceGrid/Parser.cpp
index 09e585227a7..ff7fbfa1e91 100644
--- a/cpp/src/IceGrid/Parser.cpp
+++ b/cpp/src/IceGrid/Parser.cpp
@@ -1359,7 +1359,7 @@ Parser::dumpFile(const string& reader, const string& filename, const list<string
}
}
- cout << reader << " `" << id << "' " << filename << ":" << flush;
+ cout << reader << " `" << id << "' " << filename << ": " << flush;
Ice::StringSeq lines;
bool head = opts.isSet("head");
diff --git a/cpp/src/IceGrid/ServerCache.cpp b/cpp/src/IceGrid/ServerCache.cpp
index 8acb32f19da..8da34d4ffca 100644
--- a/cpp/src/IceGrid/ServerCache.cpp
+++ b/cpp/src/IceGrid/ServerCache.cpp
@@ -128,14 +128,15 @@ ServerCache::remove(const string& id, bool destroy)
ServerEntryPtr entry = getImpl(id);
ServerInfo info = entry->getInfo();
- if(destroy)
- {
- entry->destroy();
- }
+ forEachCommunicator(RemoveCommunicator(*this, entry))(info.descriptor);
_nodeCache.get(info.node)->removeServer(entry);
- forEachCommunicator(RemoveCommunicator(*this, entry))(info.descriptor);
+ if(destroy)
+ {
+ entry->destroy(); // This must be done after otherwise some allocatable objects
+ // might allocate a destroyed server.
+ }
if(_traceLevels && _traceLevels->server > 0)
{
@@ -258,11 +259,7 @@ ServerEntry::update(const ServerInfo& info)
_load = descriptor;
_loaded.reset(0);
-
- //
- // Update the allocatable flag.
- //
- const_cast<bool&>(_allocatable) = info.descriptor->allocatable || info.descriptor->activation == "session";
+ _allocatable = info.descriptor->allocatable || info.descriptor->activation == "session";
}
void
@@ -289,6 +286,7 @@ ServerEntry::destroy()
_load.reset(0);
_loaded.reset(0);
+ _allocatable = false;
}
ServerInfo
@@ -346,10 +344,10 @@ ServerEntry::getProxy(int& activationTimeout, int& deactivationTimeout, string&
Lock sync(*this);
if(_loaded.get() || _proxy && _synchronizing && !upToDate) // Synced or if not up to date is fine
{
- assert(_loaded.get() || _load.get());
+ assert(_loaded.get() || _load.get() || _destroy.get());
activationTimeout = _activationTimeout;
deactivationTimeout = _deactivationTimeout;
- node = _loaded.get() ? _loaded->node : _load->node;
+ node = _loaded.get() ? _loaded->node : (_load.get() ? _load->node : _destroy->node);
return _proxy;
}
}
@@ -362,10 +360,10 @@ ServerEntry::getProxy(int& activationTimeout, int& deactivationTimeout, string&
Lock sync(*this);
if(_loaded.get() || _proxy && _synchronizing && !upToDate) // Synced or if not up to date is fine
{
- assert(_loaded.get() || _load.get());
+ assert(_loaded.get() || _load.get() || _destroy.get());
activationTimeout = _activationTimeout;
deactivationTimeout = _deactivationTimeout;
- node = _loaded.get() ? _loaded->node : _load->node;
+ node = _loaded.get() ? _loaded->node : (_load.get() ? _load->node : _destroy->node);
return _proxy;
}
else if(_load.get())
@@ -748,6 +746,11 @@ ServerEntry::canRemove()
void
ServerEntry::allocated(const SessionIPtr& session)
{
+ if(!_loaded.get() && !_load.get())
+ {
+ return;
+ }
+
TraceLevelsPtr traceLevels = _cache.getTraceLevels();
if(traceLevels && traceLevels->server > 1)
{
@@ -755,7 +758,6 @@ ServerEntry::allocated(const SessionIPtr& session)
out << "server `" << _id << "' allocated by `" << session->getId() << "' (" << _count << ")";
}
- assert(_loaded.get() || _load.get());
ServerDescriptorPtr desc = _loaded.get() ? _loaded->descriptor : _load->descriptor;
//
@@ -834,7 +836,11 @@ ServerEntry::allocatedNoSync(const SessionIPtr& session)
void
ServerEntry::released(const SessionIPtr& session)
{
- assert(_loaded.get() || _load.get());
+ if(!_loaded.get() && !_load.get())
+ {
+ return;
+ }
+
ServerDescriptorPtr desc = _loaded.get() ? _loaded->descriptor : _load->descriptor;
//
diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp
index c47f91bf792..6243aab1e36 100644
--- a/cpp/src/IceGrid/ServerI.cpp
+++ b/cpp/src/IceGrid/ServerI.cpp
@@ -1378,14 +1378,12 @@ ServerI::activate()
ServerCommandPtr command;
{
Lock sync(*this);
- if(_state != Activating)
- {
- return;
- }
+ assert(_state == Activating);
_pid = pid;
setStateNoSync(ServerI::WaitForActivation);
checkActivation();
command = nextCommand();
+ notifyAll(); // Terminated might be waiting for the state change.
}
if(command)
{
@@ -1553,10 +1551,10 @@ ServerI::terminated(const string& msg, int status)
ServerAdapterDict adpts;
{
Lock sync(*this);
-// while(_state == ServerI::Activating)
-// {
-// wait(); // Wait for activate() to set the state to WaitForActivation
-// }
+ while(_state == ServerI::Activating)
+ {
+ wait(); // Wait for activate() to set the state to WaitForActivation
+ }
adpts = _adapters;
_activatedAdapters.clear();