You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2011/10/19 23:27:23 UTC
svn commit: r1186499 - in
/qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp:
EventHandler.cpp LockedMap.h QueueContext.cpp QueueContext.h QueueHandler.h
Author: aconway
Date: Wed Oct 19 21:27:23 2011
New Revision: 1186499
URL: http://svn.apache.org/viewvc?rev=1186499&view=rev
Log:
QPID-2920: Replace RwLock with Mutex in cluster::LockedMap.
Modified:
qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/EventHandler.cpp
qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/LockedMap.h
qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueContext.cpp
qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueContext.h
qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueHandler.h
Modified: qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/EventHandler.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/EventHandler.cpp?rev=1186499&r1=1186498&r2=1186499&view=diff
==============================================================================
--- qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/EventHandler.cpp (original)
+++ qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/EventHandler.cpp Wed Oct 19 21:27:23 2011
@@ -64,15 +64,18 @@ void EventHandler::deliver(
framing::AMQFrame frame;
// FIXME aconway 2011-09-29: don't decode own frame bodies. Ignore based on channel.
while (buf.available()) {
+ // FIXME aconway 2011-10-19: multi-version, skip unrecognized frames.
frame.decode(buf);
QPID_LOG(trace, "cluster: deliver on " << cpg.getName()
<< " from "<< PrettyId(sender, self) << ": " << frame);
try {
handle(frame);
} catch (const std::exception& e) {
- // Non-fatal error. Our state isn't compromized by receiving bad frames.
- QPID_LOG(error, "cluster: error in deliver on " << cpg.getName()
- << " from " << PrettyId(sender, self) << ": " << frame);
+ // FIXME aconway 2011-10-19: error handling.
+ QPID_LOG(error, "cluster: error in deliver on " << cpg.getName()
+ << " from " << PrettyId(sender, self)
+ << ": " << frame
+ << ": " << e.what());
}
}
}
Modified: qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/LockedMap.h
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/LockedMap.h?rev=1186499&r1=1186498&r2=1186499&view=diff
==============================================================================
--- qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/LockedMap.h (original)
+++ qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/LockedMap.h Wed Oct 19 21:27:23 2011
@@ -37,27 +37,14 @@ class LockedMap
public:
/** Get value associated with key, returns Value() if none. */
Value get(const Key& key) const {
- sys::RWlock::ScopedRlock r(lock);
+ sys::Mutex::ScopedLock r(lock);
typename Map::const_iterator i = map.find(key);
return (i == map.end()) ? Value() : i->second;
}
- /** Update value with the value for key.
- *@return true if key was found.
- */
- bool get(const Key& key, Value& value) const {
- sys::RWlock::ScopedRlock r(lock);
- typename Map::const_iterator i = map.find(key);
- if (i != map.end()) {
- value = i->second;
- return true;
- }
- return false;
- }
-
/** Associate value with key, overwriting any previous value for key. */
void put(const Key& key, const Value& value) {
- sys::RWlock::ScopedWlock w(lock);
+ sys::Mutex::ScopedLock w(lock);
map[key] = value;
}
@@ -65,19 +52,19 @@ class LockedMap
* Returns true if the value was added.
*/
bool add(const Key& key, const Value& value) {
- sys::RWlock::ScopedWlock w(lock);
+ sys::Mutex::ScopedLock w(lock);
return map.insert(std::make_pair(key, value)).second;
}
/** Erase the value associated with key if any. Return true if a value was erased. */
bool erase(const Key& key) {
- sys::RWlock::ScopedWlock w(lock);
+ sys::Mutex::ScopedLock w(lock);
return map.erase(key);
}
/** Remove and return value associated with key, returns Value() if none. */
Value pop(const Key& key) {
- sys::RWlock::ScopedWlock w(lock);
+ sys::Mutex::ScopedLock w(lock);
Value value;
typename Map::iterator i = map.find(key);
if (i != map.end()) {
@@ -90,7 +77,7 @@ class LockedMap
private:
typedef std::map<Key, Value> Map;
Map map;
- mutable sys::RWlock lock;
+ mutable sys::Mutex lock;
};
}} // namespace qpid::cluster
Modified: qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueContext.cpp
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueContext.cpp?rev=1186499&r1=1186498&r2=1186499&view=diff
==============================================================================
--- qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueContext.cpp (original)
+++ qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueContext.cpp Wed Oct 19 21:27:23 2011
@@ -124,9 +124,8 @@ void QueueContext::stopped() {
void QueueContext::requeue(uint32_t position, bool redelivered) {
// No lock, unacked has its own lock.
- broker::QueuedMessage qm;
- if (unacked.get(position, qm)) {
- unacked.erase(position);
+ broker::QueuedMessage qm = unacked.pop(position);
+ if (qm.queue) {
if (redelivered) qm.payload->redeliver();
BrokerContext::ScopedSuppressReplication ssr;
queue.requeue(qm);
Modified: qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueContext.h
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueContext.h?rev=1186499&r1=1186498&r2=1186499&view=diff
==============================================================================
--- qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueContext.h (original)
+++ qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueContext.h Wed Oct 19 21:27:23 2011
@@ -99,7 +99,7 @@ private:
size_t consumers;
size_t hash;
- typedef LockedMap<uint32_t, broker::QueuedMessage> UnackedMap; // FIXME aconway 2011-09-15: don't need read/write map? Rename
+ typedef LockedMap<uint32_t, broker::QueuedMessage> UnackedMap;
UnackedMap unacked;
};
Modified: qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueHandler.h
URL: http://svn.apache.org/viewvc/qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueHandler.h?rev=1186499&r1=1186498&r2=1186499&view=diff
==============================================================================
--- qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueHandler.h (original)
+++ qpid/branches/qpid-2920-active/qpid/cpp/src/qpid/cluster/exp/QueueHandler.h Wed Oct 19 21:27:23 2011
@@ -23,7 +23,6 @@
*/
#include "HandlerBase.h"
-#include "LockedMap.h"
#include "Settings.h"
#include "qpid/framing/AMQP_AllOperations.h"
#include "boost/shared_ptr.hpp"
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org