summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qpid/cpp/src/qpid/cluster/Connection.cpp11
-rw-r--r--qpid/cpp/src/qpid/cluster/Connection.h2
-rw-r--r--qpid/cpp/src/qpid/cluster/Decoder.cpp8
3 files changed, 14 insertions, 7 deletions
diff --git a/qpid/cpp/src/qpid/cluster/Connection.cpp b/qpid/cpp/src/qpid/cluster/Connection.cpp
index 3f331978ca..d97a1b6c68 100644
--- a/qpid/cpp/src/qpid/cluster/Connection.cpp
+++ b/qpid/cpp/src/qpid/cluster/Connection.cpp
@@ -77,11 +77,15 @@ void Connection::init() {
QPID_LOG(debug, cluster << " new connection: " << *this);
if (isLocalClient()) {
cluster.addLocalConnection(this);
- if (cluster.getReadMax())
- output.giveReadCredit(cluster.getReadMax());
+ giveReadCredit(cluster.getReadMax());
}
}
+void Connection::giveReadCredit(int credit) {
+ if (cluster.getReadMax() && credit)
+ output.giveReadCredit(credit);
+}
+
Connection::~Connection() {
QPID_LOG(debug, cluster << " deleted connection: " << *this);
}
@@ -141,8 +145,7 @@ void Connection::deliveredFrame(const EventFrame& f) {
{
connection.received(const_cast<AMQFrame&>(f.frame)); // Pass to broker connection.
}
- if (cluster.getReadMax() && f.readCredit)
- output.giveReadCredit(f.readCredit);
+ giveReadCredit(f.readCredit);
}
// A local connection is closed by the network layer.
diff --git a/qpid/cpp/src/qpid/cluster/Connection.h b/qpid/cpp/src/qpid/cluster/Connection.h
index 4923ef2920..1637b8609c 100644
--- a/qpid/cpp/src/qpid/cluster/Connection.h
+++ b/qpid/cpp/src/qpid/cluster/Connection.h
@@ -147,7 +147,7 @@ class Connection :
void queue(const std::string& encoded);
void exchange(const std::string& encoded);
- void giveReadCredit(int credit) { output.giveReadCredit(credit); }
+ void giveReadCredit(int credit);
private:
void init();
diff --git a/qpid/cpp/src/qpid/cluster/Decoder.cpp b/qpid/cpp/src/qpid/cluster/Decoder.cpp
index 4645a489c8..1ba36bb521 100644
--- a/qpid/cpp/src/qpid/cluster/Decoder.cpp
+++ b/qpid/cpp/src/qpid/cluster/Decoder.cpp
@@ -33,8 +33,12 @@ Decoder::Decoder(const Handler& h, ConnectionMap& cm) : handler(h), connections(
void Decoder::decode(const EventHeader& eh, const void* data) {
ConnectionId id = eh.getConnectionId();
- std::pair<Map::iterator, bool> ib = map.insert(id, new ConnectionDecoder(handler));
- ptr_map_ptr(ib.first)->decode(eh, data, connections);
+ Map::iterator i = map.find(id);
+ if (i == map.end()) {
+ std::pair<Map::iterator, bool> ib = map.insert(id, new ConnectionDecoder(handler));
+ i = ib.first;
+ }
+ ptr_map_ptr(i)->decode(eh, data, connections);
}
void Decoder::erase(const ConnectionId& c) {