diff options
| author | Carl C. Trieloff <cctrieloff@apache.org> | 2011-03-14 16:30:12 +0000 |
|---|---|---|
| committer | Carl C. Trieloff <cctrieloff@apache.org> | 2011-03-14 16:30:12 +0000 |
| commit | 6a6c2889b7851ff13b27f46630616eacda3f9d36 (patch) | |
| tree | f57d6deb09c3af011d9c1ee61284eeaa8ba7c12b /cpp/src/qpid/broker/TopicExchange.cpp | |
| parent | 720ba1ca71cfe1b97ceba1cb4fd991fae31bbe27 (diff) | |
| download | qpid-python-6a6c2889b7851ff13b27f46630616eacda3f9d36.tar.gz | |
QPID-3138 some cosmetic cleanup & correction for IVE
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1081450 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/broker/TopicExchange.cpp')
| -rw-r--r-- | cpp/src/qpid/broker/TopicExchange.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/cpp/src/qpid/broker/TopicExchange.cpp b/cpp/src/qpid/broker/TopicExchange.cpp index f3baf00d1f..4447790766 100644 --- a/cpp/src/qpid/broker/TopicExchange.cpp +++ b/cpp/src/qpid/broker/TopicExchange.cpp @@ -221,7 +221,7 @@ TopicExchange::TopicExchange(const std::string& _name, bool _durable, bool TopicExchange::bind(Queue::shared_ptr queue, const string& routingKey, const FieldTable* args) { - ClearCache cc(&cacheLock,&bindingCache); // clear the cache on function exit. + ClearCache cc(&cacheLock,&bindingCache); // clear the cache on function exit. string fedOp(args ? args->getAsString(qpidFedOp) : fedOpBind); string fedTags(args ? args->getAsString(qpidFedTags) : ""); string fedOrigin(args ? args->getAsString(qpidFedOrigin) : ""); @@ -282,6 +282,7 @@ bool TopicExchange::bind(Queue::shared_ptr queue, const string& routingKey, cons } } + cc.clearCache(); // clear the cache before we IVE route. routeIVE(); if (propagate) propagateFedOp(routingKey, fedTags, fedOp, fedOrigin); @@ -289,7 +290,7 @@ bool TopicExchange::bind(Queue::shared_ptr queue, const string& routingKey, cons } bool TopicExchange::unbind(Queue::shared_ptr queue, const string& constRoutingKey, const FieldTable* /*args*/){ - ClearCache cc(&cacheLock,&bindingCache); // clear the cache on function exit. + ClearCache cc(&cacheLock,&bindingCache); // clear the cache on function exit. RWlock::ScopedWlock l(lock); string routingKey = normalize(constRoutingKey); BindingKey* bk = bindingTree.getBindingKey(routingKey); @@ -336,23 +337,24 @@ void TopicExchange::route(Deliverable& msg, const string& routingKey, const Fiel { // Note: PERFORMANCE CRITICAL!!! BindingList b; - std::map<std::string, BindingList>::iterator it; - { // only lock the cache for read + std::map<std::string, BindingList>::iterator it; + { // only lock the cache for read RWlock::ScopedRlock cl(cacheLock); - it = bindingCache.find(routingKey); - } + it = bindingCache.find(routingKey); + if (it != bindingCache.end()) { + b = it->second; + } + } PreRoute pr(msg, this); - if (it == bindingCache.end()) // no cache hit + if (!b.get()) // no cache hit { RWlock::ScopedRlock l(lock); b = BindingList(new std::vector<boost::shared_ptr<qpid::broker::Exchange::Binding> >); BindingsFinderIter bindingsFinder(b); bindingTree.iterateMatch(routingKey, bindingsFinder); - RWlock::ScopedWlock cwl(cacheLock); - bindingCache[routingKey] = b; // update cache - }else { - b = it->second; - } + RWlock::ScopedWlock cwl(cacheLock); + bindingCache[routingKey] = b; // update cache + } doRoute(msg, b); } |
