BIND 10 trac2414, updated. e97b6bb7995463200de064519d705023f578da96 [2414] Remove "using namespace boost"
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Nov 8 20:32:49 UTC 2012
The branch, trac2414 has been updated
via e97b6bb7995463200de064519d705023f578da96 (commit)
via fed0360031161014bfdbc11d4e38adeaed697150 (commit)
from 89886bb661e47985e05643ced62d0da4c14fdd8d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit e97b6bb7995463200de064519d705023f578da96
Author: Stephen Morris <stephen at isc.org>
Date: Thu Nov 8 20:30:24 2012 +0000
[2414] Remove "using namespace boost"
For some reason, on Solaris this causes types "uintXX_t" to become
undefined. The "using" statement was removed and an explicit
namespace prepended to declarations of shared_ptr and dynamic_pointer_cast.
commit fed0360031161014bfdbc11d4e38adeaed697150
Author: Stephen Morris <stephen at isc.org>
Date: Thu Nov 8 20:09:10 2012 +0000
[2414] Get rid of memory leak
The allocation engine is now pointed to by a shared pointer. Previously
it was pointed toi by a raw pointer and not deleted in the destructor.
Also, use an automatic variable to hold the DHCP6 server in the
unit tests.
-----------------------------------------------------------------------
Summary of changes:
src/bin/dhcp6/dhcp6_srv.cc | 10 ++---
src/bin/dhcp6/dhcp6_srv.h | 8 ++--
src/bin/dhcp6/tests/config_parser_unittest.cc | 36 +++++++++---------
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc | 49 ++++++++++++-------------
4 files changed, 48 insertions(+), 55 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc
index a2e0404..7b1f721 100644
--- a/src/bin/dhcp6/dhcp6_srv.cc
+++ b/src/bin/dhcp6/dhcp6_srv.cc
@@ -47,12 +47,12 @@ using namespace isc::asiolink;
using namespace isc::dhcp;
using namespace isc::util;
using namespace std;
-using namespace boost;
namespace isc {
namespace dhcp {
-Dhcpv6Srv::Dhcpv6Srv(uint16_t port) {
+Dhcpv6Srv::Dhcpv6Srv(uint16_t port) : alloc_engine_(), serverid_(),
+ shutdown_(false) {
LOG_DEBUG(dhcp6_logger, DBG_DHCP6_START, DHCP6_OPEN_SOCKET).arg(port);
@@ -94,9 +94,7 @@ Dhcpv6Srv::Dhcpv6Srv(uint16_t port) {
.arg(LeaseMgr::instance().getName());
// Instantiate allocation engine
- alloc_engine_ = new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100);
-
- shutdown_ = false;
+ alloc_engine_.reset(new AllocEngine(AllocEngine::ALLOC_ITERATIVE, 100));
}
Dhcpv6Srv::~Dhcpv6Srv() {
@@ -451,7 +449,7 @@ OptionPtr Dhcpv6Srv::handleIA_NA(const Subnet6Ptr& subnet, const DuidPtr& duid,
// Check if the client sent us a hint in his IA_NA. Clients may send an
// address in their IA_NA options as a suggestion (e.g. the last address
// they used before).
- shared_ptr<Option6IAAddr> hintOpt = dynamic_pointer_cast<Option6IAAddr>
+ boost::shared_ptr<Option6IAAddr> hintOpt = boost::dynamic_pointer_cast<Option6IAAddr>
(ia->getOption(D6O_IAADDR));
IOAddress hint("::");
if (hintOpt) {
diff --git a/src/bin/dhcp6/dhcp6_srv.h b/src/bin/dhcp6/dhcp6_srv.h
index 0beccaf..c703de4 100644
--- a/src/bin/dhcp6/dhcp6_srv.h
+++ b/src/bin/dhcp6/dhcp6_srv.h
@@ -246,14 +246,14 @@ protected:
void initStdOptionDefs();
private:
- /// server DUID (to be sent in server-identifier option)
- boost::shared_ptr<isc::dhcp::Option> serverid_;
-
/// @brief Allocation Engine.
/// Pointer to the allocation engine that we are currently using
/// It must be a pointer, because we will support changing engines
/// during normal operation (e.g. to use different allocators)
- AllocEngine* alloc_engine_;
+ boost::shared_ptr<AllocEngine> alloc_engine_;
+
+ /// Server DUID (to be sent in server-identifier option)
+ boost::shared_ptr<isc::dhcp::Option> serverid_;
/// Indicates if shutdown is in progress. Setting it to true will
/// initiate server shutdown procedure.
diff --git a/src/bin/dhcp6/tests/config_parser_unittest.cc b/src/bin/dhcp6/tests/config_parser_unittest.cc
index 929a6d2..780b5db 100644
--- a/src/bin/dhcp6/tests/config_parser_unittest.cc
+++ b/src/bin/dhcp6/tests/config_parser_unittest.cc
@@ -41,12 +41,11 @@ namespace {
class Dhcp6ParserTest : public ::testing::Test {
public:
- Dhcp6ParserTest()
- :rcode_(-1) {
- // Open port 0 means to not do anything at all. We don't want to
+ Dhcp6ParserTest() :rcode_(-1), srv_(0) {
+ // srv_(0) means to not open any sockets. We don't want to
// deal with sockets here, just check if configuration handling
// is sane.
- srv_ = new Dhcpv6Srv(0);
+
// Create instances of option definitions and put them into storage.
// This is normally initialized by the server when calling run()
// run() function.
@@ -54,7 +53,6 @@ public:
}
~Dhcp6ParserTest() {
- delete srv_;
};
/// @brief Create the simple configuration with single option.
@@ -133,7 +131,7 @@ public:
ConstElementPtr x;
std::string config = createConfigWithOption(param_value, parameter);
ElementPtr json = Element::fromJSON(config);
- EXPECT_NO_THROW(x = configureDhcp6Server(*srv_, json));
+ EXPECT_NO_THROW(x = configureDhcp6Server(srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
ASSERT_EQ(1, rcode_);
@@ -179,7 +177,7 @@ public:
EXPECT_TRUE(memcmp(expected_data, data, expected_data_len));
}
- Dhcpv6Srv* srv_;
+ Dhcpv6Srv srv_;
int rcode_;
ConstElementPtr comment_;
@@ -192,7 +190,7 @@ TEST_F(Dhcp6ParserTest, version) {
ConstElementPtr x;
- EXPECT_NO_THROW(x = configureDhcp6Server(*srv_,
+ EXPECT_NO_THROW(x = configureDhcp6Server(srv_,
Element::fromJSON("{\"version\": 0}")));
// returned value must be 0 (configuration accepted)
@@ -207,7 +205,7 @@ TEST_F(Dhcp6ParserTest, bogusCommand) {
ConstElementPtr x;
- EXPECT_NO_THROW(x = configureDhcp6Server(*srv_,
+ EXPECT_NO_THROW(x = configureDhcp6Server(srv_,
Element::fromJSON("{\"bogus\": 5}")));
// returned value must be 1 (configuration parse error)
@@ -223,7 +221,7 @@ TEST_F(Dhcp6ParserTest, emptySubnet) {
ConstElementPtr status;
- EXPECT_NO_THROW(status = configureDhcp6Server(*srv_,
+ EXPECT_NO_THROW(status = configureDhcp6Server(srv_,
Element::fromJSON("{ \"interface\": [ \"all\" ],"
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
@@ -255,7 +253,7 @@ TEST_F(Dhcp6ParserTest, subnetGlobalDefaults) {
ElementPtr json = Element::fromJSON(config);
- EXPECT_NO_THROW(status = configureDhcp6Server(*srv_, json));
+ EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
// check if returned status is OK
ASSERT_TRUE(status);
@@ -294,7 +292,7 @@ TEST_F(Dhcp6ParserTest, subnetLocal) {
ElementPtr json = Element::fromJSON(config);
- EXPECT_NO_THROW(status = configureDhcp6Server(*srv_, json));
+ EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
// returned value should be 0 (configuration success)
ASSERT_TRUE(status);
@@ -327,7 +325,7 @@ TEST_F(Dhcp6ParserTest, poolOutOfSubnet) {
ElementPtr json = Element::fromJSON(config);
- EXPECT_NO_THROW(status = configureDhcp6Server(*srv_, json));
+ EXPECT_NO_THROW(status = configureDhcp6Server(srv_, json));
// returned value must be 2 (values error)
// as the pool does not belong to that subnet
@@ -355,7 +353,7 @@ TEST_F(Dhcp6ParserTest, poolPrefixLen) {
ElementPtr json = Element::fromJSON(config);
- EXPECT_NO_THROW(x = configureDhcp6Server(*srv_, json));
+ EXPECT_NO_THROW(x = configureDhcp6Server(srv_, json));
// returned value must be 1 (configuration parse error)
ASSERT_TRUE(x);
@@ -397,7 +395,7 @@ TEST_F(Dhcp6ParserTest, optionDataDefaults) {
ElementPtr json = Element::fromJSON(config);
- EXPECT_NO_THROW(x = configureDhcp6Server(*srv_, json));
+ EXPECT_NO_THROW(x = configureDhcp6Server(srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
ASSERT_EQ(0, rcode_);
@@ -472,7 +470,7 @@ TEST_F(Dhcp6ParserTest, optionDataInSingleSubnet) {
ElementPtr json = Element::fromJSON(config);
- EXPECT_NO_THROW(x = configureDhcp6Server(*srv_, json));
+ EXPECT_NO_THROW(x = configureDhcp6Server(srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
ASSERT_EQ(0, rcode_);
@@ -538,7 +536,7 @@ TEST_F(Dhcp6ParserTest, optionDataInMultipleSubnets) {
ElementPtr json = Element::fromJSON(config);
- EXPECT_NO_THROW(x = configureDhcp6Server(*srv_, json));
+ EXPECT_NO_THROW(x = configureDhcp6Server(srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
ASSERT_EQ(0, rcode_);
@@ -656,7 +654,7 @@ TEST_F(Dhcp6ParserTest, optionDataLowerCase) {
std::string config = createConfigWithOption("0a0b0C0D", "data");
ElementPtr json = Element::fromJSON(config);
- EXPECT_NO_THROW(x = configureDhcp6Server(*srv_, json));
+ EXPECT_NO_THROW(x = configureDhcp6Server(srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
ASSERT_EQ(0, rcode_);
@@ -697,7 +695,7 @@ TEST_F(Dhcp6ParserTest, stdOptionData) {
std::string config = createConfigWithOption(params);
ElementPtr json = Element::fromJSON(config);
- EXPECT_NO_THROW(x = configureDhcp6Server(*srv_, json));
+ EXPECT_NO_THROW(x = configureDhcp6Server(srv_, json));
ASSERT_TRUE(x);
comment_ = parseAnswer(rcode_, x);
ASSERT_EQ(0, rcode_);
diff --git a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
index 7f7072b..ea8dbf3 100644
--- a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
+++ b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
@@ -34,14 +34,11 @@
#include <dhcp/option6_int_array.h>
#include <dhcp6/config_parser.h>
#include <dhcp6/dhcp6_srv.h>
-#include <dhcp6/dhcp6_srv.h>
#include <util/buffer.h>
#include <util/range_utilities.h>
-using namespace boost;
using namespace isc;
using namespace isc::asiolink;
-using namespace isc::asiolink;
using namespace isc::config;
using namespace isc::data;
using namespace isc::dhcp;
@@ -76,9 +73,9 @@ public:
}
// Generate IA_NA option with specified parameters
- shared_ptr<Option6IA> generateIA(uint32_t iaid, uint32_t t1, uint32_t t2) {
- shared_ptr<Option6IA> ia =
- shared_ptr<Option6IA>(new Option6IA(D6O_IA_NA, iaid));
+ boost::shared_ptr<Option6IA> generateIA(uint32_t iaid, uint32_t t1, uint32_t t2) {
+ boost::shared_ptr<Option6IA> ia =
+ boost::shared_ptr<Option6IA>(new Option6IA(D6O_IA_NA, iaid));
ia->setT1(t1);
ia->setT2(t2);
return (ia);
@@ -122,27 +119,27 @@ public:
// Checks that server response (ADVERTISE or REPLY) contains proper IA_NA option
// It returns IAADDR option for each chaining with checkIAAddr method.
- shared_ptr<Option6IAAddr> checkIA_NA(const Pkt6Ptr& rsp, uint32_t expected_iaid,
+ boost::shared_ptr<Option6IAAddr> checkIA_NA(const Pkt6Ptr& rsp, uint32_t expected_iaid,
uint32_t expected_t1, uint32_t expected_t2) {
OptionPtr tmp = rsp->getOption(D6O_IA_NA);
// Can't use ASSERT_TRUE() in method that returns something
if (!tmp) {
ADD_FAILURE() << "IA_NA option not present in response";
- return (shared_ptr<Option6IAAddr>());
+ return (boost::shared_ptr<Option6IAAddr>());
}
- shared_ptr<Option6IA> ia = dynamic_pointer_cast<Option6IA>(tmp);
+ boost::shared_ptr<Option6IA> ia = boost::dynamic_pointer_cast<Option6IA>(tmp);
EXPECT_EQ(expected_iaid, ia->getIAID() );
EXPECT_EQ(expected_t1, ia->getT1());
EXPECT_EQ(expected_t2, ia->getT2());
tmp = ia->getOption(D6O_IAADDR);
- shared_ptr<Option6IAAddr> addr = dynamic_pointer_cast<Option6IAAddr>(tmp);
+ boost::shared_ptr<Option6IAAddr> addr = boost::dynamic_pointer_cast<Option6IAAddr>(tmp);
return (addr);
}
// Check that generated IAADDR option contains expected address.
- void checkIAAddr(shared_ptr<Option6IAAddr> addr, const IOAddress& expected_addr,
+ void checkIAAddr(boost::shared_ptr<Option6IAAddr> addr, const IOAddress& expected_addr,
uint32_t expected_preferred, uint32_t expected_valid) {
// Check that the assigned address is indeed from the configured pool
EXPECT_TRUE(subnet_->inPool(addr->getAddress()));
@@ -161,8 +158,8 @@ public:
// Checks if the lease sent to client is present in the database
Lease6Ptr checkLease(const DuidPtr& duid, const OptionPtr& ia_na,
- shared_ptr<Option6IAAddr> addr) {
- shared_ptr<Option6IA> ia = dynamic_pointer_cast<Option6IA>(ia_na);
+ boost::shared_ptr<Option6IAAddr> addr) {
+ boost::shared_ptr<Option6IA> ia = boost::dynamic_pointer_cast<Option6IA>(ia_na);
Lease6Ptr lease = LeaseMgr::instance().getLease6(addr->getAddress());
if (!lease) {
@@ -427,7 +424,7 @@ TEST_F(Dhcpv6SrvTest, SolicitBasic) {
checkResponse(reply, DHCPV6_ADVERTISE, 1234);
// check that IA_NA was returned and that there's an address included
- shared_ptr<Option6IAAddr> addr = checkIA_NA(reply, 234, subnet_->getT1(),
+ boost::shared_ptr<Option6IAAddr> addr = checkIA_NA(reply, 234, subnet_->getT1(),
subnet_->getT2());
// Check that the assigned address is indeed from the configured pool
@@ -460,7 +457,7 @@ TEST_F(Dhcpv6SrvTest, SolicitHint) {
// Let's create a SOLICIT
Pkt6Ptr sol = Pkt6Ptr(new Pkt6(DHCPV6_SOLICIT, 1234));
sol->setRemoteAddr(IOAddress("fe80::abcd"));
- shared_ptr<Option6IA> ia = generateIA(234, 1500, 3000);
+ boost::shared_ptr<Option6IA> ia = generateIA(234, 1500, 3000);
// with a valid hint
IOAddress hint("2001:db8:1:1::dead:beef");
@@ -481,7 +478,7 @@ TEST_F(Dhcpv6SrvTest, SolicitHint) {
ASSERT_TRUE(tmp);
// check that IA_NA was returned and that there's an address included
- shared_ptr<Option6IAAddr> addr = checkIA_NA(reply, 234, subnet_->getT1(),
+ boost::shared_ptr<Option6IAAddr> addr = checkIA_NA(reply, 234, subnet_->getT1(),
subnet_->getT2());
// check that we've got the address we requested
@@ -514,7 +511,7 @@ TEST_F(Dhcpv6SrvTest, SolicitInvalidHint) {
// Let's create a SOLICIT
Pkt6Ptr sol = Pkt6Ptr(new Pkt6(DHCPV6_SOLICIT, 1234));
sol->setRemoteAddr(IOAddress("fe80::abcd"));
- shared_ptr<Option6IA> ia = generateIA(234, 1500, 3000);
+ boost::shared_ptr<Option6IA> ia = generateIA(234, 1500, 3000);
IOAddress hint("2001:db8:1::cafe:babe");
ASSERT_FALSE(subnet_->inPool(hint));
OptionPtr hint_opt(new Option6IAAddr(D6O_IAADDR, hint, 300, 500));
@@ -530,7 +527,7 @@ TEST_F(Dhcpv6SrvTest, SolicitInvalidHint) {
checkResponse(reply, DHCPV6_ADVERTISE, 1234);
// check that IA_NA was returned and that there's an address included
- shared_ptr<Option6IAAddr> addr = checkIA_NA(reply, 234, subnet_->getT1(),
+ boost::shared_ptr<Option6IAAddr> addr = checkIA_NA(reply, 234, subnet_->getT1(),
subnet_->getT2());
// Check that the assigned address is indeed from the configured pool
@@ -585,11 +582,11 @@ TEST_F(Dhcpv6SrvTest, ManySolicits) {
checkResponse(reply3, DHCPV6_ADVERTISE, 3456);
// check that IA_NA was returned and that there's an address included
- shared_ptr<Option6IAAddr> addr1 = checkIA_NA(reply1, 1, subnet_->getT1(),
+ boost::shared_ptr<Option6IAAddr> addr1 = checkIA_NA(reply1, 1, subnet_->getT1(),
subnet_->getT2());
- shared_ptr<Option6IAAddr> addr2 = checkIA_NA(reply2, 2, subnet_->getT1(),
+ boost::shared_ptr<Option6IAAddr> addr2 = checkIA_NA(reply2, 2, subnet_->getT1(),
subnet_->getT2());
- shared_ptr<Option6IAAddr> addr3 = checkIA_NA(reply3, 3, subnet_->getT1(),
+ boost::shared_ptr<Option6IAAddr> addr3 = checkIA_NA(reply3, 3, subnet_->getT1(),
subnet_->getT2());
// Check that the assigned address is indeed from the configured pool
@@ -637,7 +634,7 @@ TEST_F(Dhcpv6SrvTest, RequestBasic) {
// Let's create a REQUEST
Pkt6Ptr req = Pkt6Ptr(new Pkt6(DHCPV6_REQUEST, 1234));
req->setRemoteAddr(IOAddress("fe80::abcd"));
- shared_ptr<Option6IA> ia = generateIA(234, 1500, 3000);
+ boost::shared_ptr<Option6IA> ia = generateIA(234, 1500, 3000);
// with a valid hint
IOAddress hint("2001:db8:1:1::dead:beef");
@@ -658,7 +655,7 @@ TEST_F(Dhcpv6SrvTest, RequestBasic) {
ASSERT_TRUE(tmp);
// check that IA_NA was returned and that there's an address included
- shared_ptr<Option6IAAddr> addr = checkIA_NA(reply, 234, subnet_->getT1(),
+ boost::shared_ptr<Option6IAAddr> addr = checkIA_NA(reply, 234, subnet_->getT1(),
subnet_->getT2());
// check that we've got the address we requested
@@ -717,11 +714,11 @@ TEST_F(Dhcpv6SrvTest, ManyRequests) {
checkResponse(reply3, DHCPV6_REPLY, 3456);
// check that IA_NA was returned and that there's an address included
- shared_ptr<Option6IAAddr> addr1 = checkIA_NA(reply1, 1, subnet_->getT1(),
+ boost::shared_ptr<Option6IAAddr> addr1 = checkIA_NA(reply1, 1, subnet_->getT1(),
subnet_->getT2());
- shared_ptr<Option6IAAddr> addr2 = checkIA_NA(reply2, 2, subnet_->getT1(),
+ boost::shared_ptr<Option6IAAddr> addr2 = checkIA_NA(reply2, 2, subnet_->getT1(),
subnet_->getT2());
- shared_ptr<Option6IAAddr> addr3 = checkIA_NA(reply3, 3, subnet_->getT1(),
+ boost::shared_ptr<Option6IAAddr> addr3 = checkIA_NA(reply3, 3, subnet_->getT1(),
subnet_->getT2());
// Check that the assigned address is indeed from the configured pool
More information about the bind10-changes
mailing list