diff options
author | Benoit Foucher <benoit@zeroc.com> | 2006-05-17 16:02:58 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2006-05-17 16:02:58 +0000 |
commit | 5606f3cb5380c03a5a264775915f44c9e26eb4c1 (patch) | |
tree | f8f53aa193944519eef892b5c2d6e681da4cc7e4 /cpp/src/IceGrid/Allocatable.cpp | |
parent | Fix (diff) | |
download | ice-5606f3cb5380c03a5a264775915f44c9e26eb4c1.tar.bz2 ice-5606f3cb5380c03a5a264775915f44c9e26eb4c1.tar.xz ice-5606f3cb5380c03a5a264775915f44c9e26eb4c1.zip |
Fix allocation bug
Diffstat (limited to 'cpp/src/IceGrid/Allocatable.cpp')
-rw-r--r-- | cpp/src/IceGrid/Allocatable.cpp | 54 |
1 files changed, 34 insertions, 20 deletions
diff --git a/cpp/src/IceGrid/Allocatable.cpp b/cpp/src/IceGrid/Allocatable.cpp index 5673ae265d2..868c2ce8de0 100644 --- a/cpp/src/IceGrid/Allocatable.cpp +++ b/cpp/src/IceGrid/Allocatable.cpp @@ -190,6 +190,10 @@ Allocatable::tryAllocate(const AllocationRequestPtr& request, bool fromRelease) return false; } + // + // NOTE: We let exceptions go through here! The caller is + // responsible for catching it. + // return allocate(request, true, fromRelease); } @@ -265,32 +269,42 @@ Allocatable::release(const SessionIPtr& session, bool fromRelease) // if(request && allocatable->allocate(request, true) || !request && allocatable->canTryAllocate()) { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_allocateMutex); - assert(_count); - - // - // Check if there's other requests from the session - // waiting to allocate this allocatable. - // - list<pair<AllocatablePtr, AllocationRequestPtr> >::iterator p = _requests.begin(); - while(p != _requests.end()) + while(true) { - if(p->second && p->second->getSession() == _session) { - if(p->second->finish(this, _session)) + IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_allocateMutex); + assert(_count); + + allocatable = 0; + request = 0; + + // + // Check if there's other requests from the session + // waiting to allocate this allocatable. + // + list<pair<AllocatablePtr, AllocationRequestPtr> >::iterator p = _requests.begin(); + while(p != _requests.end()) + { + if(p->second && p->second->getSession() == _session) + { + allocatable = p->first; + request = p->second; + _requests.erase(p); + break; + } + ++p; + } + if(!allocatable) { - ++_count; + _releasing = false; + _allocateMutex.notifyAll(); + return; // We're done, the allocatable is allocated again! } - p = _requests.erase(p); - } - else - { - ++p; } + + assert(allocatable && request); + allocatable->allocate(request, true); } - _releasing = false; - _allocateMutex.notifyAll(); - return; // We're done, the allocatable is allocated again! } } } |