summaryrefslogtreecommitdiff
path: root/cpp/src/IceGrid/Allocatable.cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2006-06-02 16:11:51 +0000
committerBenoit Foucher <benoit@zeroc.com>2006-06-02 16:11:51 +0000
commit8d90c43bd49c728f3c553a4e4d2ad7d25367a872 (patch)
tree078cd0193fcdfa12936eae5a6372ae750ecb79f7 /cpp/src/IceGrid/Allocatable.cpp
parentwarm up JIT compiler before measuring latency (diff)
downloadice-8d90c43bd49c728f3c553a4e4d2ad7d25367a872.tar.bz2
ice-8d90c43bd49c728f3c553a4e4d2ad7d25367a872.tar.xz
ice-8d90c43bd49c728f3c553a4e4d2ad7d25367a872.zip
Bug fixes
Diffstat (limited to 'cpp/src/IceGrid/Allocatable.cpp')
-rw-r--r--cpp/src/IceGrid/Allocatable.cpp46
1 files changed, 27 insertions, 19 deletions
diff --git a/cpp/src/IceGrid/Allocatable.cpp b/cpp/src/IceGrid/Allocatable.cpp
index 02026f014bc..536ec5f7aa5 100644
--- a/cpp/src/IceGrid/Allocatable.cpp
+++ b/cpp/src/IceGrid/Allocatable.cpp
@@ -164,19 +164,23 @@ Allocatable::~Allocatable()
{
}
-bool
-Allocatable::allocate(const AllocationRequestPtr& request, bool fromRelease)
+void
+Allocatable::checkAllocatable()
{
- if(!_allocatable)
+ if(!isAllocatable())
{
throw AllocationException("not allocatable");
}
+}
+bool
+Allocatable::allocate(const AllocationRequestPtr& request, bool fromRelease)
+{
try
{
return allocate(request, false, fromRelease);
}
- catch(const AllocationException&)
+ catch(const SessionDestroyedException&)
{
return false; // The session was destroyed
}
@@ -185,26 +189,19 @@ Allocatable::allocate(const AllocationRequestPtr& request, bool fromRelease)
bool
Allocatable::tryAllocate(const AllocationRequestPtr& request, bool fromRelease)
{
- if(!_allocatable)
+ try
{
- return false;
+ return allocate(request, true, fromRelease);
+ }
+ catch(const AllocationException& ex)
+ {
+ return false; // Not allocatable
}
-
- //
- // NOTE: We let exceptions go through here! The caller is
- // responsible for catching it.
- //
- return allocate(request, true, fromRelease);
}
bool
Allocatable::release(const SessionIPtr& session, bool fromRelease)
{
- if(!_allocatable)
- {
- throw AllocationException("not allocatable");
- }
-
bool isReleased = false;
bool hasRequests = false;
{
@@ -384,11 +381,13 @@ Allocatable::allocate(const AllocationRequestPtr& request, bool tryAllocate, boo
try
{
Lock sync(*this);
+ checkAllocatable();
+
if(!_session && (fromRelease || !_releasing))
{
if(request->finish(this, _session))
{
- allocated(request->getSession()); // This might throw.
+ allocated(request->getSession()); // This might throw SessionDestroyedException
assert(_count == 0);
_session = request->getSession();
++_count;
@@ -409,6 +408,14 @@ Allocatable::allocate(const AllocationRequestPtr& request, bool tryAllocate, boo
queueAllocationAttempt(this, request, tryAllocate);
}
}
+ catch(const SessionDestroyedException& ex)
+ {
+ if(_parent)
+ {
+ _parent->release(request->getSession(), fromRelease);
+ }
+ throw ex;
+ }
catch(const AllocationException& ex)
{
if(_parent)
@@ -417,6 +424,7 @@ Allocatable::allocate(const AllocationRequestPtr& request, bool tryAllocate, boo
}
throw ex;
}
+
if(_parent)
{
_parent->release(request->getSession(), fromRelease);
@@ -446,7 +454,7 @@ Allocatable::allocateFromChild(const AllocationRequestPtr& request,
{
allocated(request->getSession());
}
- catch(const AllocationException&)
+ catch(const SessionDestroyedException&)
{
// Ignore
}