From ade48e0859d2d96fb90ad62ca4c584907f772201 Mon Sep 17 00:00:00 2001 From: Benoit Foucher Date: Mon, 12 Jun 2006 14:18:02 +0000 Subject: Fixed bug where allocation could return before the Glacier2 filters were added --- cpp/src/IceGrid/Allocatable.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'cpp/src/IceGrid/Allocatable.cpp') 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 } } -- cgit v1.2.3