Browse Source

fixed two more memleaks;
I think the comment was wrong for the server_ member of UDPQuery, and we can use a shared_ptr here, as long as we clone() the DNSServer into said shared_ptr.
Other fix is deletion of the lenbuf buffer in the tcp handler


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac394@3419 e5f2f494-b856-4b98-b285-d166d9295462

Jelte Jansen 14 years ago
parent
commit
915d4cb622
2 changed files with 3 additions and 7 deletions
  1. 1 6
      src/lib/asiolink/internal/udpdns.h
  2. 2 1
      src/lib/asiolink/tcpdns.cc

+ 1 - 6
src/lib/asiolink/internal/udpdns.h

@@ -222,12 +222,7 @@ private:
     boost::shared_array<char> data_;
 
     // The UDP or TCP Server object from which the query originated.
-    // Note: Using a shared_ptr for this can cause problems when
-    // control is being transferred from this coroutine to the server;
-    // the reference count can drop to zero and cause the server to be
-    // destroyed before it executes.  Consequently in this case it's
-    // safer to use a raw pointer.
-    DNSServer* server_;
+    boost::shared_ptr<DNSServer> server_;
 };
 }
 

+ 2 - 1
src/lib/asiolink/tcpdns.cc

@@ -72,7 +72,7 @@ TCPServer::operator()(error_code ec, size_t length) {
     /// a switch statement, inline variable declarations are not
     /// permitted.  Certain variables used below can be declared here.
     boost::array<const_buffer,2> bufs;
-    OutputBuffer* lenbuf;
+    OutputBuffer* lenbuf = NULL;
 
     CORO_REENTER (this) {
         do {
@@ -173,6 +173,7 @@ TCPServer::operator()(error_code ec, size_t length) {
         // will simply exit at that time).
         CORO_YIELD async_write(*socket_, bufs, *this);
     }
+    delete lenbuf;
 }
 
 /// Call the DNS lookup provider.  (Expected to be called by the