Parcourir la source

another shared_ptr vs shared_array i missed in the previous commit
also reverted the peer/iosocket code as explained in http://bind10.isc.org/ticket/394?replyto=3#comment:3


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

Jelte Jansen il y a 14 ans
Parent
commit
3d9176ffae

+ 5 - 1
src/lib/asiolink/internal/tcpdns.h

@@ -21,6 +21,7 @@
 
 
 #include <asio.hpp>
+#include <boost/shared_array.hpp>
 #include <boost/shared_ptr.hpp>
 
 #include <dns/buffer.h>
@@ -167,7 +168,7 @@ private:
     isc::dns::MessagePtr message_;
 
     // The buffer into which the query packet is written
-    boost::shared_ptr<char> data_;
+    boost::shared_array<char>data_;
 
     // State information that is entirely internal to a given instance
     // of the coroutine can be declared here.
@@ -178,6 +179,9 @@ private:
     const SimpleCallback* checkin_callback_;
     const DNSLookup* lookup_callback_;
     const DNSAnswer* answer_callback_;
+
+    boost::shared_ptr<IOEndpoint> peer_;
+    boost::shared_ptr<IOSocket> iosock_;
 };
 
 }

+ 3 - 0
src/lib/asiolink/internal/udpdns.h

@@ -173,6 +173,9 @@ private:
     const SimpleCallback* checkin_callback_;
     const DNSLookup* lookup_callback_;
     const DNSAnswer* answer_callback_;
+
+    boost::shared_ptr<IOEndpoint> peer_;
+    boost::shared_ptr<IOSocket> iosock_;
 };
 
 //

+ 4 - 6
src/lib/asiolink/tcpdns.cc

@@ -73,8 +73,6 @@ TCPServer::operator()(error_code ec, size_t length) {
     /// permitted.  Certain variables used below can be declared here.
     boost::array<const_buffer,2> bufs;
     OutputBuffer* lenbuf;
-    IOEndpoint* peer;
-    IOSocket* iosock;
 
     CORO_REENTER (this) {
         do {
@@ -96,7 +94,7 @@ TCPServer::operator()(error_code ec, size_t length) {
 
         /// Instantiate the data buffer that will be used by the
         /// asynchronous read call.
-        data_ = boost::shared_ptr<char>(new char[MAX_LENGTH]);
+        data_.reset(new char[MAX_LENGTH]);
 
         /// Read the message, in two parts.  First, the message length:
         CORO_YIELD async_read(*socket_, asio::buffer(data_.get(),
@@ -122,9 +120,9 @@ TCPServer::operator()(error_code ec, size_t length) {
         // (XXX: It would be good to write a factory function
         // that would quickly generate an IOMessage object without
         // all these calls to "new".)
-        peer = new TCPEndpoint(socket_->remote_endpoint());
-        iosock = new TCPSocket(*socket_);
-        io_message_.reset(new IOMessage(data_.get(), length, *iosock, *peer));
+        peer_.reset(new TCPEndpoint(socket_->remote_endpoint()));
+        iosock_.reset(new TCPSocket(*socket_));
+        io_message_.reset(new IOMessage(data_.get(), length, *iosock_, *peer_));
         bytes_ = length;
 
         // Perform any necessary operations prior to processing the incoming

+ 3 - 5
src/lib/asiolink/udpdns.cc

@@ -73,8 +73,6 @@ UDPServer::operator()(error_code ec, size_t length) {
     /// Because the coroutine reeentry block is implemented as
     /// a switch statement, inline variable declarations are not
     /// permitted.  Certain variables used below can be declared here.
-    IOEndpoint* peer;
-    IOSocket* iosock;
 
     CORO_REENTER (this) {
         do {
@@ -106,9 +104,9 @@ UDPServer::operator()(error_code ec, size_t length) {
         // (XXX: It would be good to write a factory function
         // that would quickly generate an IOMessage object without
         // all these calls to "new".)
-        peer = new UDPEndpoint(*sender_);
-        iosock = new UDPSocket(*socket_);
-        io_message_.reset(new IOMessage(data_.get(), bytes_, *iosock, *peer));
+        peer_.reset(new UDPEndpoint(*sender_));
+        iosock_.reset(new UDPSocket(*socket_));
+        io_message_.reset(new IOMessage(data_.get(), bytes_, *iosock_, *peer_));
 
         // Perform any necessary operations prior to processing an incoming
         // query (e.g., checking for queued configuration messages).