qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject svn commit: r743346 - in /qpid/trunk/qpid/cpp/src/qpid/cluster: Connection.cpp Connection.h Decoder.cpp
Date Wed, 11 Feb 2009 14:34:07 GMT
Author: aconway
Date: Wed Feb 11 14:34:07 2009
New Revision: 743346

URL: http://svn.apache.org/viewvc?rev=743346&view=rev
Log:
Fix memory leak in cluster code.

Modified:
    qpid/trunk/qpid/cpp/src/qpid/cluster/Connection.cpp
    qpid/trunk/qpid/cpp/src/qpid/cluster/Connection.h
    qpid/trunk/qpid/cpp/src/qpid/cluster/Decoder.cpp

Modified: qpid/trunk/qpid/cpp/src/qpid/cluster/Connection.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/cluster/Connection.cpp?rev=743346&r1=743345&r2=743346&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/cluster/Connection.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/cluster/Connection.cpp Wed Feb 11 14:34:07 2009
@@ -77,11 +77,15 @@
     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 @@
     {
         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.

Modified: qpid/trunk/qpid/cpp/src/qpid/cluster/Connection.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/cluster/Connection.h?rev=743346&r1=743345&r2=743346&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/cluster/Connection.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/cluster/Connection.h Wed Feb 11 14:34:07 2009
@@ -147,7 +147,7 @@
     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();

Modified: qpid/trunk/qpid/cpp/src/qpid/cluster/Decoder.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/cluster/Decoder.cpp?rev=743346&r1=743345&r2=743346&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/cluster/Decoder.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/cluster/Decoder.cpp Wed Feb 11 14:34:07 2009
@@ -33,8 +33,12 @@
 
 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) {



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message