diff options
author | Alan Conway <aconway@apache.org> | 2009-02-11 14:34:07 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2009-02-11 14:34:07 +0000 |
commit | 71db75d3111f9a6486df70256c9676513cfd0e30 (patch) | |
tree | cb57da5f58213389945df66e846df6d34ed555f2 | |
parent | 11f9d9200cc40fc259cf46367908136faa3d34b7 (diff) | |
download | qpid-python-71db75d3111f9a6486df70256c9676513cfd0e30.tar.gz |
Fix memory leak in cluster code.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@743346 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | qpid/cpp/src/qpid/cluster/Connection.cpp | 11 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/cluster/Connection.h | 2 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/cluster/Decoder.cpp | 8 |
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) { |