[svn] commit: r3494 - in /branches/trac327: ./ src/bin/auth/main.cc src/bin/recurse/main.cc src/lib/asiolink/internal/coroutine.h src/lib/asiolink/internal/tcpdns.h src/lib/asiolink/internal/udpdns.h src/lib/asiolink/tcpdns.cc src/lib/asiolink/udpdns.cc
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Nov 9 08:53:52 UTC 2010
Author: vorner
Date: Tue Nov 9 08:53:48 2010
New Revision: 3494
Log:
Merge 394 into 327
Modified:
branches/trac327/ (props changed)
branches/trac327/src/bin/auth/main.cc
branches/trac327/src/bin/recurse/main.cc
branches/trac327/src/lib/asiolink/internal/coroutine.h
branches/trac327/src/lib/asiolink/internal/tcpdns.h
branches/trac327/src/lib/asiolink/internal/udpdns.h
branches/trac327/src/lib/asiolink/tcpdns.cc
branches/trac327/src/lib/asiolink/udpdns.cc
Modified: branches/trac327/src/bin/auth/main.cc
==============================================================================
--- branches/trac327/src/bin/auth/main.cc (original)
+++ branches/trac327/src/bin/auth/main.cc Tue Nov 9 08:53:48 2010
@@ -240,6 +240,8 @@
cout << "[b10-auth] Server started." << endl;
io_service.run();
+
+ delete dns_service;
} catch (const std::exception& ex) {
cerr << "[b10-auth] Server failed: " << ex.what() << endl;
ret = 1;
Modified: branches/trac327/src/bin/recurse/main.cc
==============================================================================
--- branches/trac327/src/bin/recurse/main.cc (original)
+++ branches/trac327/src/bin/recurse/main.cc Tue Nov 9 08:53:48 2010
@@ -119,7 +119,6 @@
int ret = 0;
- // XXX: we should eventually pass io_service here.
Session* cc_session = NULL;
ModuleCCSession* config_session = NULL;
try {
Modified: branches/trac327/src/lib/asiolink/internal/coroutine.h
==============================================================================
--- branches/trac327/src/lib/asiolink/internal/coroutine.h (original)
+++ branches/trac327/src/lib/asiolink/internal/coroutine.h Tue Nov 9 08:53:48 2010
@@ -67,6 +67,7 @@
{
public:
coroutine() : value_(0) {}
+ virtual ~coroutine() {}
bool is_child() const { return value_ < 0; }
bool is_parent() const { return !is_child(); }
bool is_complete() const { return value_ == -1; }
Modified: branches/trac327/src/lib/asiolink/internal/tcpdns.h
==============================================================================
--- branches/trac327/src/lib/asiolink/internal/tcpdns.h (original)
+++ branches/trac327/src/lib/asiolink/internal/tcpdns.h Tue Nov 9 08:53:48 2010
@@ -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 @@
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 @@
const SimpleCallback* checkin_callback_;
const DNSLookup* lookup_callback_;
const DNSAnswer* answer_callback_;
+
+ boost::shared_ptr<IOEndpoint> peer_;
+ boost::shared_ptr<IOSocket> iosock_;
};
}
Modified: branches/trac327/src/lib/asiolink/internal/udpdns.h
==============================================================================
--- branches/trac327/src/lib/asiolink/internal/udpdns.h (original)
+++ branches/trac327/src/lib/asiolink/internal/udpdns.h Tue Nov 9 08:53:48 2010
@@ -162,7 +162,7 @@
isc::dns::OutputBufferPtr respbuf_;
// 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.
@@ -173,6 +173,9 @@
const SimpleCallback* checkin_callback_;
const DNSLookup* lookup_callback_;
const DNSAnswer* answer_callback_;
+
+ boost::shared_ptr<IOEndpoint> peer_;
+ boost::shared_ptr<IOSocket> iosock_;
};
//
@@ -219,12 +222,7 @@
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_;
};
}
Modified: branches/trac327/src/lib/asiolink/tcpdns.cc
==============================================================================
--- branches/trac327/src/lib/asiolink/tcpdns.cc (original)
+++ branches/trac327/src/lib/asiolink/tcpdns.cc Tue Nov 9 08:53:48 2010
@@ -72,9 +72,7 @@
/// 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;
- IOEndpoint* peer;
- IOSocket* iosock;
+ OutputBuffer lenbuf(TCP_MESSAGE_LENGTHSIZE);
CORO_REENTER (this) {
do {
@@ -96,7 +94,7 @@
/// 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 @@
// (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
@@ -164,9 +162,8 @@
(*answer_callback_)(*io_message_, message_, respbuf_);
// Set up the response, beginning with two length bytes.
- lenbuf = new OutputBuffer(TCP_MESSAGE_LENGTHSIZE);
- lenbuf->writeUint16(respbuf_->getLength());
- bufs[0] = buffer(lenbuf->getData(), lenbuf->getLength());
+ lenbuf.writeUint16(respbuf_->getLength());
+ bufs[0] = buffer(lenbuf.getData(), lenbuf.getLength());
bufs[1] = buffer(respbuf_->getData(), respbuf_->getLength());
// Begin an asynchronous send, and then yield. When the
Modified: branches/trac327/src/lib/asiolink/udpdns.cc
==============================================================================
--- branches/trac327/src/lib/asiolink/udpdns.cc (original)
+++ branches/trac327/src/lib/asiolink/udpdns.cc Tue Nov 9 08:53:48 2010
@@ -73,8 +73,6 @@
/// 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 @@
// (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).
More information about the bind10-changes
mailing list