diff options
author | Benoit Foucher <benoit@zeroc.com> | 2006-02-02 14:29:19 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2006-02-02 14:29:19 +0000 |
commit | adb58f8cd390e43e0821f16f0b502a2956731305 (patch) | |
tree | fee88ba8ef120a74df0823130f195f8bb3e54b50 /cpp/src/IceGrid/NodeCache.cpp | |
parent | Added missing dependencies to PingObject.ice custom build step. (diff) | |
download | ice-adb58f8cd390e43e0821f16f0b502a2956731305.tar.bz2 ice-adb58f8cd390e43e0821f16f0b502a2956731305.tar.xz ice-adb58f8cd390e43e0821f16f0b502a2956731305.zip |
Fixed memory corruption problem
Diffstat (limited to 'cpp/src/IceGrid/NodeCache.cpp')
-rw-r--r-- | cpp/src/IceGrid/NodeCache.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/cpp/src/IceGrid/NodeCache.cpp b/cpp/src/IceGrid/NodeCache.cpp index c3022bf0c9a..d5c034cfb8e 100644 --- a/cpp/src/IceGrid/NodeCache.cpp +++ b/cpp/src/IceGrid/NodeCache.cpp @@ -162,7 +162,8 @@ NodeCache::NodeCache(int sessionTimeout) : _sessionTimeout(sessionTimeout) void NodeCache::destroy() { - for(map<string, NodeEntryPtr>::const_iterator p = _entries.begin(); p != _entries.end(); ++p) + map<string, NodeEntryPtr> entries = _entries; // Copying the map is necessary as setSession might remove the entry. + for(map<string, NodeEntryPtr>::const_iterator p = entries.begin(); p != entries.end(); ++p) { p->second->setSession(0); // Break cyclic reference count. } @@ -246,10 +247,6 @@ NodeEntry::setSession(const NodeSessionIPtr& session) _session = session; remove = _servers.empty() && !_session && _descriptors.empty(); } - if(remove) - { - _cache.remove(_name); - } if(session) { @@ -277,6 +274,15 @@ NodeEntry::setSession(const NodeSessionIPtr& session) out << "node `" << _name << "' down"; } } + + // + // NOTE: this needs to be the last thing to do as this will + // destroy this entry. + // + if(remove) + { + _cache.remove(_name); + } } NodePrx |