diff options
author | Benoit Foucher <benoit@zeroc.com> | 2006-06-12 14:18:02 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2006-06-12 14:18:02 +0000 |
commit | ade48e0859d2d96fb90ad62ca4c584907f772201 (patch) | |
tree | 3b61fab3163acccf456fe16f6e7667963ab0e7ea /cpp/src | |
parent | Fixed IceGrid python scripts (diff) | |
download | ice-ade48e0859d2d96fb90ad62ca4c584907f772201.tar.bz2 ice-ade48e0859d2d96fb90ad62ca4c584907f772201.tar.xz ice-ade48e0859d2d96fb90ad62ca4c584907f772201.zip |
Fixed bug where allocation could return before the Glacier2 filters were
added
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/IceGrid/Allocatable.cpp | 25 | ||||
-rw-r--r-- | cpp/src/IceGrid/Allocatable.h | 4 | ||||
-rw-r--r-- | cpp/src/IceGrid/AllocatableObjectCache.h | 3 |
3 files changed, 18 insertions, 14 deletions
diff --git a/cpp/src/IceGrid/Allocatable.cpp b/cpp/src/IceGrid/Allocatable.cpp index e6b0e4a420a..d5135c86134 100644 --- a/cpp/src/IceGrid/Allocatable.cpp +++ b/cpp/src/IceGrid/Allocatable.cpp @@ -45,7 +45,7 @@ AllocationRequest::pending() } bool -AllocationRequest::finish(const AllocatablePtr& allocatable, const SessionIPtr& session) +AllocationRequest::allocate(const AllocatablePtr& allocatable, const SessionIPtr& session) { Lock sync(*this); switch(_state) @@ -75,16 +75,11 @@ AllocationRequest::finish(const AllocatablePtr& allocatable, const SessionIPtr& canceled(AllocationException("already allocated by the session")); return false; } - else if(allocated(allocatable, _session)) + else { _state = Allocated; return true; } - else - { - _state = Canceled; - return false; - } } void @@ -385,9 +380,18 @@ Allocatable::allocate(const AllocationRequestPtr& request, bool tryAllocate, boo if(!_session && (fromRelease || !_releasing)) { - if(request->finish(this, _session)) + if(request->allocate(this, _session)) { - allocated(request->getSession()); // This might throw SessionDestroyedException + try + { + allocated(request->getSession()); // This might throw SessionDestroyedException + request->allocated(this, request->getSession()); + } + catch(const SessionDestroyedException&) + { + request->canceled(AllocationException("session destroyed")); + throw; + } assert(_count == 0); _session = request->getSession(); ++_count; @@ -396,10 +400,11 @@ Allocatable::allocate(const AllocationRequestPtr& request, bool tryAllocate, boo } else if(_session == request->getSession()) { - if(!tryAllocate && request->finish(this, _session)) + if(!tryAllocate && request->allocate(this, _session)) { assert(_count > 0); ++_count; + request->allocated(this, _session); return true; // Allocated } } diff --git a/cpp/src/IceGrid/Allocatable.h b/cpp/src/IceGrid/Allocatable.h index 0a06134f5c3..13898863319 100644 --- a/cpp/src/IceGrid/Allocatable.h +++ b/cpp/src/IceGrid/Allocatable.h @@ -36,11 +36,11 @@ public: virtual ~AllocationRequest(); - virtual bool allocated(const AllocatablePtr&, const SessionIPtr&) = 0; + virtual void allocated(const AllocatablePtr&, const SessionIPtr&) = 0; virtual void canceled(const AllocationException&) = 0; bool pending(); - bool finish(const AllocatablePtr&, const SessionIPtr&); + bool allocate(const AllocatablePtr&, const SessionIPtr&); void cancel(const AllocationException&); void expired(bool); diff --git a/cpp/src/IceGrid/AllocatableObjectCache.h b/cpp/src/IceGrid/AllocatableObjectCache.h index 3c906fc77c7..9779314dd54 100644 --- a/cpp/src/IceGrid/AllocatableObjectCache.h +++ b/cpp/src/IceGrid/AllocatableObjectCache.h @@ -57,10 +57,9 @@ public: private: - virtual bool allocated(const AllocatablePtr& allocatable, const SessionIPtr& session) + virtual void allocated(const AllocatablePtr& allocatable, const SessionIPtr& session) { response(AllocatableObjectEntryPtr::dynamicCast(allocatable)->getProxy()); - return true; } virtual void canceled(const AllocationException& ex) |