diff options
author | Matthew Newhook <matthew@zeroc.com> | 2006-11-20 10:06:45 +0000 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2006-11-20 10:06:45 +0000 |
commit | a26313a5096ca3b106b0bb681742c85d8569345c (patch) | |
tree | c6ef863af1cec0f25aae2be3863831fce0271173 | |
parent | removed comment. (diff) | |
download | ice-a26313a5096ca3b106b0bb681742c85d8569345c.tar.bz2 ice-a26313a5096ca3b106b0bb681742c85d8569345c.tar.xz ice-a26313a5096ca3b106b0bb681742c85d8569345c.zip |
break cycle on shutdown from the subscriber pool.
-rw-r--r-- | cpp/src/IceStorm/SubscriberPool.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/cpp/src/IceStorm/SubscriberPool.cpp b/cpp/src/IceStorm/SubscriberPool.cpp index 126a5b7fdd6..252e75745ee 100644 --- a/cpp/src/IceStorm/SubscriberPool.cpp +++ b/cpp/src/IceStorm/SubscriberPool.cpp @@ -201,6 +201,10 @@ void SubscriberPool::flush(list<SubscriberPtr>& subscribers) { Lock sync(*this); + if(_destroyed) + { + return; + } // // Splice on the new set of subscribers to SubscriberPool. // @@ -213,6 +217,10 @@ void SubscriberPool::flush(const SubscriberPtr& subscriber) { Lock sync(*this); + if(_destroyed) + { + return; + } _pending.push_back(subscriber); assert(invariants()); notify(); @@ -222,6 +230,10 @@ void SubscriberPool::add(const SubscriberPtr& subscriber) { Lock sync(*this); + if(_destroyed) + { + return; + } _subscribers.push_back(subscriber); assert(invariants()); } @@ -230,6 +242,10 @@ void SubscriberPool::remove(const SubscriberPtr& subscriber) { Lock sync(*this); + if(_destroyed) + { + return; + } // // Note that this cannot remove based on the subscriber id because // the pool is TopicManager scoped and not topic scoped therefore @@ -401,8 +417,10 @@ SubscriberPool::destroy() { // // First mark the pool as destroyed. This causes all of the worker - // threads to unblock and terminate. We also copy the list of subscribers - // for shutdown. No new subscribers can be added once _destroyed is set. + // threads to unblock and terminate. We also clear the set of + // subscribers here since there is a cycle (instance -> pool -> + // subscribers -> instance). No new subscribers can be added once + // _destroyed is set. // { Lock sync(*this); @@ -412,6 +430,7 @@ SubscriberPool::destroy() { _subscriberPoolMonitor->destroy(); } + _subscribers.clear(); } // // Next join with each worker. |