[svn] commit: r3872 - in /trunk: ./ src/lib/nsas/ src/lib/nsas/tests/
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Dec 16 13:55:56 UTC 2010
Author: jelte
Date: Thu Dec 16 13:55:56 2010
New Revision: 3872
Log:
applying two fixed for solaris; remove 'using namespace boost' where we use uint32_t, and adds jeremy's check for the multithreading flag
(also added the latter to jinmei's ac_try_link call)
should not compile yet, we are still looking for a good solution for the -Wno-missing-initializers problem
Modified:
trunk/configure.ac
trunk/src/lib/nsas/Makefile.am
trunk/src/lib/nsas/nameserver_address_store.cc
trunk/src/lib/nsas/nameserver_entry.cc
trunk/src/lib/nsas/tests/Makefile.am
trunk/src/lib/nsas/tests/nameserver_address_store_unittest.cc
trunk/src/lib/nsas/tests/nameserver_address_unittest.cc
trunk/src/lib/nsas/tests/nameserver_entry_unittest.cc
trunk/src/lib/nsas/tests/zone_entry_unittest.cc
trunk/src/lib/nsas/zone_entry.cc
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Thu Dec 16 13:55:56 2010
@@ -201,11 +201,20 @@
# (http://blogs.sun.com/sga/entry/boost_mini_howto)
if test "$SUNCXX" = "yes"; then
CXXFLAGS="$CXXFLAGS -library=stlport4 -features=tmplife -features=tmplrefstatic"
+MULTITHREADING_FLAG="-mt"
fi
# gcc specific settings:
if test "X$GXX" = "Xyes"; then
B10_CXXFLAGS="-Wall -Wextra -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare"
+case "$host" in
+*-solaris*)
+ MULTITHREADING_FLAG=-pthreads
+ ;;
+*)
+ MULTITHREADING_FLAG=-pthread
+ ;;
+esac
# Certain versions of gcc (g++) have a bug that incorrectly warns about
# the use of anonymous name spaces even if they're closed in a single
@@ -333,7 +342,7 @@
AC_MSG_CHECKING(for boost::mutex)
CPPFLAGS_SAVES="$CPPFLAGS"
LIBS_SAVES="$LIBS"
-CPPFLAGS="$BOOST_INCLUDES $CPPFLAGS"
+CPPFLAGS="$BOOST_INCLUDES $CPPFLAGS $MULTITHREADING_FLAG"
need_libboost_thread=0
AC_TRY_LINK([
#include <boost/thread.hpp>
@@ -422,6 +431,8 @@
PTHREAD_LDFLAGS=
AC_CHECK_LIB(pthread, pthread_create,[ PTHREAD_LDFLAGS=-lpthread ], [])
AC_SUBST(PTHREAD_LDFLAGS)
+
+AC_SUBST(MULTITHREADING_FLAG)
#
# ASIO: we extensively use it as the C++ event management module.
Modified: trunk/src/lib/nsas/Makefile.am
==============================================================================
--- trunk/src/lib/nsas/Makefile.am (original)
+++ trunk/src/lib/nsas/Makefile.am Thu Dec 16 13:55:56 2010
@@ -1,7 +1,7 @@
SUBDIRS = . tests
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
-AM_CPPFLAGS += $(BOOST_INCLUDES)
+AM_CPPFLAGS += $(BOOST_INCLUDES) $(MULTITHREADING_FLAG)
AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns
AM_CPPFLAGS += -I$(top_srcdir)/src/lib/nsas -I$(top_builddir)/src/lib/nsas
AM_CPPFLAGS += $(SQLITE_CFLAGS)
Modified: trunk/src/lib/nsas/nameserver_address_store.cc
==============================================================================
--- trunk/src/lib/nsas/nameserver_address_store.cc (original)
+++ trunk/src/lib/nsas/nameserver_address_store.cc Thu Dec 16 13:55:56 2010
@@ -33,7 +33,6 @@
using namespace isc::dns;
using namespace std;
-using namespace boost;
namespace isc {
namespace nsas {
@@ -44,7 +43,7 @@
// hash table, on the assumption that three elements is the longest linear
// search we want to do when looking up names in the hash table.
NameserverAddressStore::NameserverAddressStore(
- shared_ptr<ResolverInterface> resolver, uint32_t zonehashsize,
+ boost::shared_ptr<ResolverInterface> resolver, uint32_t zonehashsize,
uint32_t nshashsize) :
zone_hash_(new HashTable<ZoneEntry>(new NsasEntryCompare<ZoneEntry>,
zonehashsize)),
@@ -65,13 +64,13 @@
* no need to copy anything. In that case, the bind should not be
* called at all to create the object, just call the function.
*/
-shared_ptr<ZoneEntry>
-newZone(const shared_ptr<ResolverInterface>* resolver, const string* zone,
+boost::shared_ptr<ZoneEntry>
+newZone(const boost::shared_ptr<ResolverInterface>* resolver, const string* zone,
const RRClass* class_code,
- const shared_ptr<HashTable<NameserverEntry> >* ns_hash,
- const shared_ptr<LruList<NameserverEntry> >* ns_lru)
+ const boost::shared_ptr<HashTable<NameserverEntry> >* ns_hash,
+ const boost::shared_ptr<LruList<NameserverEntry> >* ns_lru)
{
- shared_ptr<ZoneEntry> result(new ZoneEntry(*resolver, *zone, *class_code,
+ boost::shared_ptr<ZoneEntry> result(new ZoneEntry(*resolver, *zone, *class_code,
*ns_hash, *ns_lru));
return (result);
}
@@ -80,9 +79,9 @@
void
NameserverAddressStore::lookup(const string& zone, const RRClass& class_code,
- shared_ptr<AddressRequestCallback> callback, AddressFamily family)
+ boost::shared_ptr<AddressRequestCallback> callback, AddressFamily family)
{
- pair<bool, shared_ptr<ZoneEntry> > zone_obj(zone_hash_->getOrAdd(HashKey(
+ pair<bool, boost::shared_ptr<ZoneEntry> > zone_obj(zone_hash_->getOrAdd(HashKey(
zone, class_code), boost::bind(newZone, &resolver_, &zone, &class_code,
&nameserver_hash_, &nameserver_lru_)));
if (zone_obj.first) {
Modified: trunk/src/lib/nsas/nameserver_entry.cc
==============================================================================
--- trunk/src/lib/nsas/nameserver_entry.cc (original)
+++ trunk/src/lib/nsas/nameserver_entry.cc Thu Dec 16 13:55:56 2010
@@ -41,7 +41,6 @@
using namespace isc::nsas;
using namespace isc::dns;
using namespace std;
-using namespace boost;
namespace isc {
namespace nsas {
@@ -49,7 +48,7 @@
namespace {
// Just shorter type alias
-typedef recursive_mutex::scoped_lock Lock;
+typedef boost::recursive_mutex::scoped_lock Lock;
}
@@ -100,7 +99,7 @@
return (getState());
}
- shared_ptr<NameserverEntry> self(shared_from_this());
+ boost::shared_ptr<NameserverEntry> self(shared_from_this());
// If any address is OK, just pass everything we have
if (family == ANY_OK) {
BOOST_FOREACH(const AddressEntry& entry, addresses_[V6_ONLY]) {
@@ -202,7 +201,7 @@
*/
class NameserverEntry::ResolverCallback : public ResolverInterface::Callback {
public:
- ResolverCallback(shared_ptr<NameserverEntry> entry,
+ ResolverCallback(boost::shared_ptr<NameserverEntry> entry,
AddressFamily family, const RRType& type) :
entry_(entry),
family_(family),
@@ -214,7 +213,7 @@
* This extracts the addresses out from the response and puts them
* inside the entry. It tries to reuse the address entries from before (if there were any), to keep their RTTs.
*/
- virtual void success(const shared_ptr<AbstractRRset>& response) {
+ virtual void success(const boost::shared_ptr<AbstractRRset>& response) {
time_t now = time(NULL);
Lock lock(entry_->mutex_);
@@ -295,7 +294,7 @@
failureInternal(lock);
}
private:
- shared_ptr<NameserverEntry> entry_;
+ boost::shared_ptr<NameserverEntry> entry_;
AddressFamily family_;
RRType type_;
@@ -309,7 +308,7 @@
!entry_->expect_address_[ANY_OK];
// Sort out the callbacks we want
vector<CallbackPair> keep;
- vector<shared_ptr<NameserverEntry::Callback> > dispatch;
+ vector<boost::shared_ptr<NameserverEntry::Callback> > dispatch;
BOOST_FOREACH(const CallbackPair &callback, entry_->callbacks_)
{
if (callback.first == family_ || (dispatch_any &&
@@ -331,7 +330,7 @@
* FIXME: This is not completely exception safe. If there's an
* exception in a callback, we lose the rest of them.
*/
- BOOST_FOREACH(const shared_ptr<NameserverEntry::Callback>&
+ BOOST_FOREACH(const boost::shared_ptr<NameserverEntry::Callback>&
callback, dispatch)
{
(*callback)(entry_);
@@ -364,19 +363,19 @@
};
void
-NameserverEntry::askIP(shared_ptr<ResolverInterface> resolver,
+NameserverEntry::askIP(boost::shared_ptr<ResolverInterface> resolver,
const RRType& type, AddressFamily family)
{
QuestionPtr question(new Question(Name(getName()), RRClass(getClass()),
type));
- shared_ptr<ResolverCallback> callback(new ResolverCallback(
+ boost::shared_ptr<ResolverCallback> callback(new ResolverCallback(
shared_from_this(), family, type));
resolver->resolve(question, callback);
}
void
-NameserverEntry::askIP(shared_ptr<ResolverInterface> resolver,
- shared_ptr<Callback> callback, AddressFamily family)
+NameserverEntry::askIP(boost::shared_ptr<ResolverInterface> resolver,
+ boost::shared_ptr<Callback> callback, AddressFamily family)
{
Lock lock(mutex_);
Modified: trunk/src/lib/nsas/tests/Makefile.am
==============================================================================
--- trunk/src/lib/nsas/tests/Makefile.am (original)
+++ trunk/src/lib/nsas/tests/Makefile.am Thu Dec 16 13:55:56 2010
@@ -1,12 +1,12 @@
SUBDIRS = .
AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
-AM_CPPFLAGS += $(BOOST_INCLUDES)
+AM_CPPFLAGS += $(BOOST_INCLUDES) $(MULTITHREADING_FLAG)
AM_CPPFLAGS += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns
AM_CPPFLAGS += -I$(top_srcdir)/src/lib/nsas -I$(top_builddir)/src/lib/nsas
AM_CXXFLAGS = $(B10_CXXFLAGS)
-AM_LDFLAGS =
+AM_LDFLAGS = $(PTHREAD_LDFLAGS)
if USE_STATIC_LINK
AM_LDFLAGS += -static
endif
Modified: trunk/src/lib/nsas/tests/nameserver_address_store_unittest.cc
==============================================================================
--- trunk/src/lib/nsas/tests/nameserver_address_store_unittest.cc (original)
+++ trunk/src/lib/nsas/tests/nameserver_address_store_unittest.cc Thu Dec 16 13:55:56 2010
@@ -41,7 +41,6 @@
using namespace isc::dns;
using namespace std;
-using namespace boost;
namespace isc {
namespace nsas {
@@ -57,7 +56,7 @@
///
/// \param hashsize Size of the zone hash table
/// \param lrusize Size of the zone hash table
- DerivedNsas(shared_ptr<TestResolver> resolver, uint32_t hashsize,
+ DerivedNsas(boost::shared_ptr<TestResolver> resolver, uint32_t hashsize,
uint32_t lrusize) :
NameserverAddressStore(resolver, hashsize, lrusize),
resolver_(resolver)
@@ -87,8 +86,8 @@
* if it is asked for by the resolver.
*/
void lookupAndAnswer(const string& name, const RRClass& class_code,
- shared_ptr<AbstractRRset> authority,
- shared_ptr<AddressRequestCallback> callback)
+ boost::shared_ptr<AbstractRRset> authority,
+ boost::shared_ptr<AddressRequestCallback> callback)
{
size_t size(resolver_->requests.size());
NameserverAddressStore::lookup(name, class_code, callback, ANY_OK);
@@ -102,7 +101,7 @@
}
}
private:
- shared_ptr<TestResolver> resolver_;
+ boost::shared_ptr<TestResolver> resolver_;
};
@@ -133,8 +132,8 @@
std::string name = "zone" + boost::lexical_cast<std::string>(i);
zones_.push_back(boost::shared_ptr<ZoneEntry>(new ZoneEntry(
resolver_, name, RRClass(40 + i),
- shared_ptr<HashTable<NameserverEntry> >(),
- shared_ptr<LruList<NameserverEntry> >())));
+ boost::shared_ptr<HashTable<NameserverEntry> >(),
+ boost::shared_ptr<LruList<NameserverEntry> >())));
}
// A nameserver serving data
@@ -151,7 +150,7 @@
RRsetPtr authority_, empty_authority_;
- shared_ptr<TestResolver> resolver_;
+ boost::shared_ptr<TestResolver> resolver_;
class NSASCallback : public AddressRequestCallback {
public:
Modified: trunk/src/lib/nsas/tests/nameserver_address_unittest.cc
==============================================================================
--- trunk/src/lib/nsas/tests/nameserver_address_unittest.cc (original)
+++ trunk/src/lib/nsas/tests/nameserver_address_unittest.cc Thu Dec 16 13:55:56 2010
@@ -31,7 +31,6 @@
using namespace dns;
using namespace rdata;
-using namespace boost;
#define TEST_ADDRESS_INDEX 1
@@ -48,8 +47,8 @@
rrv4_->addRdata(ConstRdataPtr(new RdataTest<A>("9.10.11.12")));
ns_.reset(new NameserverEntry(name_.toText(), RRClass::IN()));
- shared_ptr<TestResolver> resolver(new TestResolver);
- ns_->askIP(resolver, shared_ptr<Callback>(new Callback), ANY_OK);
+ boost::shared_ptr<TestResolver> resolver(new TestResolver);
+ ns_->askIP(resolver, boost::shared_ptr<Callback>(new Callback), ANY_OK);
resolver->asksIPs(name_, 0, 1);
resolver->requests[0].second->success(rrv4_);
}
@@ -74,12 +73,12 @@
private:
Name name_; ///< Name of the sample
- shared_ptr<BasicRRset> rrv4_; ///< Standard RRSet - IN, A, lowercase name
+ boost::shared_ptr<BasicRRset> rrv4_; ///< Standard RRSet - IN, A, lowercase name
boost::shared_ptr<NameserverEntry> ns_; ///< Shared_ptr that points to a NameserverEntry object
class Callback : public NameserverEntry::Callback {
public:
- virtual void operator()(shared_ptr<NameserverEntry>) { }
+ virtual void operator()(boost::shared_ptr<NameserverEntry>) { }
};
};
Modified: trunk/src/lib/nsas/tests/nameserver_entry_unittest.cc
==============================================================================
--- trunk/src/lib/nsas/tests/nameserver_entry_unittest.cc (original)
+++ trunk/src/lib/nsas/tests/nameserver_entry_unittest.cc Thu Dec 16 13:55:56 2010
@@ -43,7 +43,6 @@
using namespace std;
using namespace isc::dns;
using namespace rdata;
-using namespace boost;
namespace {
@@ -53,7 +52,7 @@
/// \short Just a really stupid callback counting times called
struct Callback : public NameserverEntry::Callback {
size_t count;
- virtual void operator()(shared_ptr<NameserverEntry>) {
+ virtual void operator()(boost::shared_ptr<NameserverEntry>) {
count ++;
}
Callback() : count(0) { }
@@ -69,8 +68,8 @@
* \param set The answer. If the pointer is empty, it is taken
* as a failure.
*/
- void fillSet(shared_ptr<TestResolver> resolver, size_t index,
- shared_ptr<BasicRRset> set)
+ void fillSet(boost::shared_ptr<TestResolver> resolver, size_t index,
+ boost::shared_ptr<BasicRRset> set)
{
if (set) {
resolver->requests[index].second->success(set);
@@ -80,12 +79,12 @@
}
protected:
/// Fills the nameserver entry with data trough ask IP
- void fillNSEntry(shared_ptr<NameserverEntry> entry,
- shared_ptr<BasicRRset> rrv4, shared_ptr<BasicRRset> rrv6)
+ void fillNSEntry(boost::shared_ptr<NameserverEntry> entry,
+ boost::shared_ptr<BasicRRset> rrv4, boost::shared_ptr<BasicRRset> rrv6)
{
// Prepare data to run askIP
- shared_ptr<TestResolver> resolver(new TestResolver);
- shared_ptr<Callback> callback(new Callback);
+ boost::shared_ptr<TestResolver> resolver(new TestResolver);
+ boost::shared_ptr<Callback> callback(new Callback);
// Let it ask for data
entry->askIP(resolver, callback, ANY_OK);
// Check it really asked and sort the queries
@@ -114,7 +113,7 @@
TEST_F(NameserverEntryTest, InitialRTT) {
// Get the RTT for the different addresses
- shared_ptr<NameserverEntry> alpha(new NameserverEntry(EXAMPLE_CO_UK,
+ boost::shared_ptr<NameserverEntry> alpha(new NameserverEntry(EXAMPLE_CO_UK,
RRClass::IN()));
fillNSEntry(alpha, rrv4_, rrv6_);
NameserverEntry::AddressVector vec;
@@ -133,7 +132,7 @@
TEST_F(NameserverEntryTest, SetRTT) {
// Get the RTT for the different addresses
- shared_ptr<NameserverEntry> alpha(new NameserverEntry(EXAMPLE_CO_UK,
+ boost::shared_ptr<NameserverEntry> alpha(new NameserverEntry(EXAMPLE_CO_UK,
RRClass::IN()));
fillNSEntry(alpha, rrv4_, rrv6_);
NameserverEntry::AddressVector vec;
@@ -168,7 +167,7 @@
TEST_F(NameserverEntryTest, Unreachable) {
// Get the RTT for the different addresses
- shared_ptr<NameserverEntry> alpha(new NameserverEntry(EXAMPLE_CO_UK,
+ boost::shared_ptr<NameserverEntry> alpha(new NameserverEntry(EXAMPLE_CO_UK,
RRClass::IN()));
fillNSEntry(alpha, rrv4_, rrv6_);
NameserverEntry::AddressVector vec;
@@ -211,21 +210,21 @@
time_t expiration = 0;
// Test where there is a single TTL
- shared_ptr<NameserverEntry> alpha(new NameserverEntry(EXAMPLE_CO_UK,
- RRClass::IN()));
- fillNSEntry(alpha, rrv4_, shared_ptr<BasicRRset>());
+ boost::shared_ptr<NameserverEntry> alpha(new NameserverEntry(EXAMPLE_CO_UK,
+ RRClass::IN()));
+ fillNSEntry(alpha, rrv4_, boost::shared_ptr<BasicRRset>());
expiration = alpha->getExpiration();
EXPECT_EQ(expiration, curtime + rrv4_->getTTL().getValue());
- shared_ptr<NameserverEntry> beta(new NameserverEntry(EXAMPLE_CO_UK,
- RRClass::IN()));
- fillNSEntry(beta, shared_ptr<BasicRRset>(), rrv6_);
+ boost::shared_ptr<NameserverEntry> beta(new NameserverEntry(EXAMPLE_CO_UK,
+ RRClass::IN()));
+ fillNSEntry(beta, boost::shared_ptr<BasicRRset>(), rrv6_);
expiration = beta->getExpiration();
EXPECT_EQ(expiration, curtime + rrv6_->getTTL().getValue());
// Test where there are two different TTLs
EXPECT_NE(rrv4_->getTTL().getValue(), rrv6_->getTTL().getValue());
- shared_ptr<NameserverEntry> gamma(new NameserverEntry(EXAMPLE_CO_UK,
+ boost::shared_ptr<NameserverEntry> gamma(new NameserverEntry(EXAMPLE_CO_UK,
RRClass::IN()));
fillNSEntry(gamma, rrv4_, rrv6_);
uint32_t minttl = min(rrv4_->getTTL().getValue(), rrv6_->getTTL().getValue());
@@ -236,9 +235,9 @@
// that the expiration time should be greater than the TTL (as the current
// time is greater than zero).
- shared_ptr<NameserverEntry> delta(new NameserverEntry(EXAMPLE_CO_UK,
- RRClass::IN()));
- fillNSEntry(delta, rrv4_, shared_ptr<BasicRRset>());
+ boost::shared_ptr<NameserverEntry> delta(new NameserverEntry(EXAMPLE_CO_UK,
+ RRClass::IN()));
+ fillNSEntry(delta, rrv4_, boost::shared_ptr<BasicRRset>());
EXPECT_GT(delta->getExpiration(), rrv4_->getTTL().getValue());
}
@@ -262,10 +261,10 @@
// Tests if it asks the IP addresses and calls callbacks when it comes
// including the right addresses are returned and that they expire
TEST_F(NameserverEntryTest, IPCallbacks) {
- shared_ptr<NameserverEntry> entry(new NameserverEntry(EXAMPLE_CO_UK,
- RRClass::IN()));
- shared_ptr<Callback> callback(new Callback);
- shared_ptr<TestResolver> resolver(new TestResolver);
+ boost::shared_ptr<NameserverEntry> entry(new NameserverEntry(EXAMPLE_CO_UK,
+ RRClass::IN()));
+ boost::shared_ptr<Callback> callback(new Callback);
+ boost::shared_ptr<TestResolver> resolver(new TestResolver);
entry->askIP(resolver, callback, ANY_OK);
// Ensure it becomes IN_PROGRESS
@@ -311,10 +310,10 @@
// Test the callback is called even when the address is unreachable
TEST_F(NameserverEntryTest, IPCallbacksUnreachable) {
- shared_ptr<NameserverEntry> entry(new NameserverEntry(EXAMPLE_CO_UK,
- RRClass::IN()));
- shared_ptr<Callback> callback(new Callback);
- shared_ptr<TestResolver> resolver(new TestResolver);
+ boost::shared_ptr<NameserverEntry> entry(new NameserverEntry(EXAMPLE_CO_UK,
+ RRClass::IN()));
+ boost::shared_ptr<Callback> callback(new Callback);
+ boost::shared_ptr<TestResolver> resolver(new TestResolver);
// Ask for its IP
entry->askIP(resolver, callback, ANY_OK);
@@ -339,18 +338,18 @@
* from resolve.
*/
TEST_F(NameserverEntryTest, DirectAnswer) {
- shared_ptr<NameserverEntry> entry(new NameserverEntry(EXAMPLE_CO_UK,
- RRClass::IN()));
- shared_ptr<Callback> callback(new Callback);
- shared_ptr<TestResolver> resolver(new TestResolver);
+ boost::shared_ptr<NameserverEntry> entry(new NameserverEntry(EXAMPLE_CO_UK,
+ RRClass::IN()));
+ boost::shared_ptr<Callback> callback(new Callback);
+ boost::shared_ptr<TestResolver> resolver(new TestResolver);
resolver->addPresetAnswer(Question(Name(EXAMPLE_CO_UK), RRClass::IN(),
RRType::A()), rrv4_);
resolver->addPresetAnswer(Question(Name(EXAMPLE_CO_UK), RRClass::IN(),
RRType::AAAA()), rrv6_);
resolver->addPresetAnswer(Question(Name(EXAMPLE_NET), RRClass::IN(),
- RRType::A()), shared_ptr<AbstractRRset>());
+ RRType::A()), boost::shared_ptr<AbstractRRset>());
resolver->addPresetAnswer(Question(Name(EXAMPLE_NET), RRClass::IN(),
- RRType::AAAA()), shared_ptr<AbstractRRset>());
+ RRType::AAAA()), boost::shared_ptr<AbstractRRset>());
// A successfull test first
entry->askIP(resolver, callback, ANY_OK);
@@ -376,10 +375,10 @@
* data is received the next time.
*/
TEST_F(NameserverEntryTest, ChangedExpired) {
- shared_ptr<NameserverEntry> entry(new NameserverEntry(EXAMPLE_CO_UK,
- RRClass::IN()));
- shared_ptr<Callback> callback(new Callback);
- shared_ptr<TestResolver> resolver(new TestResolver);
+ boost::shared_ptr<NameserverEntry> entry(new NameserverEntry(EXAMPLE_CO_UK,
+ RRClass::IN()));
+ boost::shared_ptr<Callback> callback(new Callback);
+ boost::shared_ptr<TestResolver> resolver(new TestResolver);
// Ask the first time
entry->askIP(resolver, callback, V4_ONLY);
@@ -426,10 +425,10 @@
* When the data expire and is asked again, the original RTT is kept.
*/
TEST_F(NameserverEntryTest, KeepRTT) {
- shared_ptr<NameserverEntry> entry(new NameserverEntry(EXAMPLE_CO_UK,
- RRClass::IN()));
- shared_ptr<Callback> callback(new Callback);
- shared_ptr<TestResolver> resolver(new TestResolver);
+ boost::shared_ptr<NameserverEntry> entry(new NameserverEntry(EXAMPLE_CO_UK,
+ RRClass::IN()));
+ boost::shared_ptr<Callback> callback(new Callback);
+ boost::shared_ptr<TestResolver> resolver(new TestResolver);
// Ask the first time
entry->askIP(resolver, callback, V4_ONLY);
@@ -482,7 +481,7 @@
// Test the RTT is updated smoothly
TEST_F(NameserverEntryTest, UpdateRTT) {
- shared_ptr<NameserverEntry> ns(new NameserverEntry(EXAMPLE_CO_UK,
+ boost::shared_ptr<NameserverEntry> ns(new NameserverEntry(EXAMPLE_CO_UK,
RRClass::IN()));
fillNSEntry(ns, rrv4_, rrv6_);
NameserverEntry::AddressVector vec;
Modified: trunk/src/lib/nsas/tests/zone_entry_unittest.cc
==============================================================================
--- trunk/src/lib/nsas/tests/zone_entry_unittest.cc (original)
+++ trunk/src/lib/nsas/tests/zone_entry_unittest.cc Thu Dec 16 13:55:56 2010
@@ -35,7 +35,6 @@
using namespace isc::nsas;
using namespace asiolink;
using namespace std;
-using namespace boost;
using namespace isc::dns;
namespace {
@@ -43,10 +42,10 @@
/// \brief Inherited version with access into its internals for tests
class InheritedZoneEntry : public ZoneEntry {
public:
- InheritedZoneEntry(shared_ptr<ResolverInterface> resolver,
+ InheritedZoneEntry(boost::shared_ptr<ResolverInterface> resolver,
const std::string& name, const RRClass& class_code,
- shared_ptr<HashTable<NameserverEntry> > nameserver_table,
- shared_ptr<LruList<NameserverEntry> > nameserver_lru) :
+ boost::shared_ptr<HashTable<NameserverEntry> > nameserver_table,
+ boost::shared_ptr<LruList<NameserverEntry> > nameserver_lru) :
ZoneEntry(resolver, name, class_code, nameserver_table,
nameserver_lru)
{ }
@@ -67,10 +66,10 @@
callback_(new Callback)
{ }
/// \brief Tables of nameservers to pass into zone entry constructor
- shared_ptr<HashTable<NameserverEntry> > nameserver_table_;
- shared_ptr<LruList<NameserverEntry> > nameserver_lru_;
+ boost::shared_ptr<HashTable<NameserverEntry> > nameserver_table_;
+ boost::shared_ptr<LruList<NameserverEntry> > nameserver_lru_;
/// \brief The resolver
- shared_ptr<TestResolver> resolver_;
+ boost::shared_ptr<TestResolver> resolver_;
/**
* \short A callback we use into the zone.
@@ -86,15 +85,15 @@
successes_.push_back(address);
}
};
- shared_ptr<Callback> callback_;
+ boost::shared_ptr<Callback> callback_;
// Empty callback to pass to nameserver entry, to do injection of them
struct NseCallback : public NameserverEntry::Callback {
- virtual void operator()(shared_ptr<NameserverEntry>) { }
+ virtual void operator()(boost::shared_ptr<NameserverEntry>) { }
};
- shared_ptr<NseCallback> nseCallback() {
- return (shared_ptr<NseCallback>(new NseCallback));
+ boost::shared_ptr<NseCallback> nseCallback() {
+ return (boost::shared_ptr<NseCallback>(new NseCallback));
}
/**
@@ -102,8 +101,8 @@
*
* Convenience funcion, just creating a new zone, to shorten the code.
*/
- shared_ptr<InheritedZoneEntry> getZone() {
- return (shared_ptr<InheritedZoneEntry>(new InheritedZoneEntry(
+ boost::shared_ptr<InheritedZoneEntry> getZone() {
+ return (boost::shared_ptr<InheritedZoneEntry>(new InheritedZoneEntry(
resolver_, EXAMPLE_CO_UK, RRClass::IN(), nameserver_table_,
nameserver_lru_)));
}
@@ -115,8 +114,8 @@
* hash table already contains the NameserverEntry. This function
* creates one and puts it into the hash table.
*/
- shared_ptr<NameserverEntry> injectEntry() {
- shared_ptr<NameserverEntry> nse(new NameserverEntry(ns_name_.toText(),
+ boost::shared_ptr<NameserverEntry> injectEntry() {
+ boost::shared_ptr<NameserverEntry> nse(new NameserverEntry(ns_name_.toText(),
RRClass::IN()));
nameserver_table_->add(nse, HashKey(ns_name_.toText(), RRClass::IN()));
EXPECT_EQ(Fetchable::NOT_ASKED, nse->getState());
@@ -148,7 +147,7 @@
size_t failure_count = 0)
{
// Create the zone and check it acts correctly
- shared_ptr<InheritedZoneEntry> zone(getZone());
+ boost::shared_ptr<InheritedZoneEntry> zone(getZone());
resolver_->addPresetAnswer(Question(Name(EXAMPLE_CO_UK), RRClass::IN(),
RRType::NS()), rr_single_);
zone->addCallback(callback_, ANY_OK);
@@ -192,7 +191,7 @@
* should be generated anywhere and the failure should be provided).
*/
TEST_F(ZoneEntryTest, CallbackNoNS) {
- shared_ptr<InheritedZoneEntry> zone(getZone());
+ boost::shared_ptr<InheritedZoneEntry> zone(getZone());
EXPECT_EQ(Fetchable::NOT_ASKED, zone->getState());
// feed it with a callback
zone->addCallback(callback_, ANY_OK);
@@ -220,7 +219,7 @@
TEST_F(ZoneEntryTest, ChangedNS) {
// Make it zero TTL, so it expires right away
rr_single_->setTTL(RRTTL(0));
- shared_ptr<InheritedZoneEntry> zone(getZone());
+ boost::shared_ptr<InheritedZoneEntry> zone(getZone());
EXPECT_EQ(Fetchable::NOT_ASKED, zone->getState());
// Feed it with callback
zone->addCallback(callback_, ANY_OK);
@@ -283,7 +282,7 @@
* provided.
*/
TEST_F(ZoneEntryTest, CallbacksAnswered) {
- shared_ptr<InheritedZoneEntry> zone(getZone());
+ boost::shared_ptr<InheritedZoneEntry> zone(getZone());
EXPECT_EQ(Fetchable::NOT_ASKED, zone->getState());
// Feed it with a callback
zone->addCallback(callback_, ANY_OK);
@@ -343,7 +342,7 @@
* fail.
*/
TEST_F(ZoneEntryTest, CallbacksAOnly) {
- shared_ptr<InheritedZoneEntry> zone(getZone());
+ boost::shared_ptr<InheritedZoneEntry> zone(getZone());
EXPECT_EQ(Fetchable::NOT_ASKED, zone->getState());
zone->addCallback(callback_, ANY_OK);
EXPECT_EQ(Fetchable::IN_PROGRESS, zone->getState());
@@ -396,14 +395,14 @@
* (successful) answers to us.
*/
TEST_F(ZoneEntryTest, CallbackTwoNS) {
- shared_ptr<InheritedZoneEntry> zone(getZone());
+ boost::shared_ptr<InheritedZoneEntry> zone(getZone());
EXPECT_EQ(Fetchable::NOT_ASKED, zone->getState());
zone->addCallback(callback_, V4_ONLY);
EXPECT_EQ(Fetchable::IN_PROGRESS, zone->getState());
EXPECT_NO_THROW(resolver_->provideNS(0, rrns_));
EXPECT_EQ(Fetchable::READY, zone->getState());
// It asks a question (we do not know which nameserver)
- shared_ptr<Name> name;
+ boost::shared_ptr<Name> name;
ASSERT_NO_THROW(name.reset(new Name((*resolver_)[1]->getName())));
ASSERT_TRUE(resolver_->asksIPs(*name, 1, 2));
resolver_->requests[1].second->failure();
@@ -455,12 +454,12 @@
* resolve). Tries checking both positive and negative answers.
*/
TEST_F(ZoneEntryTest, DirectAnswer) {
- shared_ptr<InheritedZoneEntry> zone(getZone());
+ boost::shared_ptr<InheritedZoneEntry> zone(getZone());
EXPECT_EQ(Fetchable::NOT_ASKED, zone->getState());
// One unsuccessfull attempt, nameservers fail
resolver_->addPresetAnswer(Question(Name(EXAMPLE_CO_UK), RRClass::IN(),
- RRType::NS()), shared_ptr<AbstractRRset>());
+ RRType::NS()), boost::shared_ptr<AbstractRRset>());
zone->addCallback(callback_, ANY_OK);
EXPECT_EQ(0, callback_->successes_.size());
EXPECT_EQ(1, callback_->unreachable_count_);
@@ -494,9 +493,9 @@
callback_->successes_.clear();
// Now, pretend we do not have IP addresses
resolver_->addPresetAnswer(Question(ns_name, RRClass::IN(), RRType::A()),
- shared_ptr<AbstractRRset>());
+ boost::shared_ptr<AbstractRRset>());
resolver_->addPresetAnswer(Question(ns_name, RRClass::IN(),
- RRType::AAAA()), shared_ptr<AbstractRRset>());
+ RRType::AAAA()), boost::shared_ptr<AbstractRRset>());
// Get another zone and ask it again. It should fail.
// Clean the table first, though, so it does not find the old nameserver
nameserver_table_->remove(HashKey(ns_name.toText(), RRClass::IN()));
@@ -518,7 +517,7 @@
* its addresses and must ask it again.
*/
TEST_F(ZoneEntryTest, AddressTimeout) {
- shared_ptr<InheritedZoneEntry> zone(getZone());
+ boost::shared_ptr<InheritedZoneEntry> zone(getZone());
EXPECT_EQ(Fetchable::NOT_ASKED, zone->getState());
zone->addCallback(callback_, ANY_OK);
EXPECT_EQ(Fetchable::IN_PROGRESS, zone->getState());
@@ -567,7 +566,7 @@
/// \short Test how the zone reacts to a nameserver entry in ready state
TEST_F(ZoneEntryTest, NameserverEntryReady) {
// Inject the entry
- shared_ptr<NameserverEntry> nse(injectEntry());
+ boost::shared_ptr<NameserverEntry> nse(injectEntry());
// Fill it with data
nse->askIP(resolver_, nseCallback(), ANY_OK);
EXPECT_EQ(Fetchable::IN_PROGRESS, nse->getState());
@@ -593,7 +592,7 @@
/// \short What if the zone finds a nameserver in progress?
TEST_F(ZoneEntryTest, NameserverEntryInProgress) {
// Prepare the nameserver entry
- shared_ptr<NameserverEntry> nse(injectEntry());
+ boost::shared_ptr<NameserverEntry> nse(injectEntry());
nse->askIP(resolver_, nseCallback(), ANY_OK);
EXPECT_EQ(Fetchable::IN_PROGRESS, nse->getState());
EXPECT_TRUE(resolver_->asksIPs(ns_name_, 0, 1));
@@ -603,7 +602,7 @@
/// \short Check Zone's reaction to found expired nameserver
TEST_F(ZoneEntryTest, NameserverEntryExpired) {
- shared_ptr<NameserverEntry> nse(injectEntry());
+ boost::shared_ptr<NameserverEntry> nse(injectEntry());
nse->askIP(resolver_, nseCallback(), ANY_OK);
EXPECT_EQ(Fetchable::IN_PROGRESS, nse->getState());
EXPECT_TRUE(resolver_->asksIPs(ns_name_, 0, 1));
@@ -622,7 +621,7 @@
/// \short Check how it reacts to an unreachable zone already in the table
TEST_F(ZoneEntryTest, NameserverEntryUnreachable) {
- shared_ptr<NameserverEntry> nse(injectEntry());
+ boost::shared_ptr<NameserverEntry> nse(injectEntry());
nse->askIP(resolver_, nseCallback(), ANY_OK);
ASSERT_EQ(2, resolver_->requests.size());
resolver_->requests[0].second->failure();
@@ -651,7 +650,7 @@
const size_t repeats = 100000;
// Create the zone, give it 2 nameservers and total of 3 addresses
// (one of them is ipv6)
- shared_ptr<ZoneEntry> zone(getZone());
+ boost::shared_ptr<ZoneEntry> zone(getZone());
zone->addCallback(callback_, ANY_OK);
EXPECT_NO_THROW(resolver_->provideNS(0, rrns_));
ASSERT_GT(resolver_->requests.size(), 1);
@@ -666,7 +665,7 @@
resolver_->answer(3, name2, RRType::A(), rdata::in::A("192.0.2.3"));
resolver_->requests[4].second->failure();
- shared_ptr<NameserverEntry> ns1(nameserver_table_->get(HashKey(
+ boost::shared_ptr<NameserverEntry> ns1(nameserver_table_->get(HashKey(
name1.toText(), RRClass::IN()))),
ns2(nameserver_table_->get(HashKey(name2.toText(), RRClass::IN())));
Modified: trunk/src/lib/nsas/zone_entry.cc
==============================================================================
--- trunk/src/lib/nsas/zone_entry.cc (original)
+++ trunk/src/lib/nsas/zone_entry.cc Thu Dec 16 13:55:56 2010
@@ -25,7 +25,6 @@
#include <dns/rdataclass.h>
using namespace std;
-using namespace boost;
namespace isc {
@@ -48,16 +47,16 @@
namespace {
// Shorter aliases for frequently used types
-typedef recursive_mutex::scoped_lock Lock; // Local lock, nameservers not locked
-typedef shared_ptr<AddressRequestCallback> CallbackPtr;
+typedef boost::recursive_mutex::scoped_lock Lock; // Local lock, nameservers not locked
+typedef boost::shared_ptr<AddressRequestCallback> CallbackPtr;
/*
* Create a nameserver.
* Called inside a mutex so it is filled in atomically.
*/
-shared_ptr<NameserverEntry>
+boost::shared_ptr<NameserverEntry>
newNs(const std::string* name, const RRClass* class_code) {
- return (shared_ptr<NameserverEntry>(new NameserverEntry(*name,
+ return (boost::shared_ptr<NameserverEntry>(new NameserverEntry(*name,
*class_code)));
}
@@ -77,7 +76,7 @@
class ZoneEntry::ResolverCallback : public ResolverInterface::Callback {
public:
/// \short Constructor. Pass "this" zone entry
- ResolverCallback(shared_ptr<ZoneEntry> entry) :
+ ResolverCallback(boost::shared_ptr<ZoneEntry> entry) :
entry_(entry)
{ }
/**
@@ -91,7 +90,7 @@
* examining them and seeing if some addresses are already there
* and to ask for the rest of them.
*/
- virtual void success(const shared_ptr<AbstractRRset>& answer) {
+ virtual void success(const boost::shared_ptr<AbstractRRset>& answer) {
Lock lock(entry_->mutex_);
RdataIteratorPtr iterator(answer->getRdataIterator());
// If there are no data
@@ -203,7 +202,7 @@
entry_->process(ADDR_REQ_MAX, NameserverPtr());
}
/// \short The entry we are callback of
- shared_ptr<ZoneEntry> entry_;
+ boost::shared_ptr<ZoneEntry> entry_;
};
void
@@ -237,7 +236,7 @@
// Our callback might be directly called from resolve, unlock now
QuestionPtr question(new Question(Name(name_), class_code_,
RRType::NS()));
- shared_ptr<ResolverCallback> resolver_callback(
+ boost::shared_ptr<ResolverCallback> resolver_callback(
new ResolverCallback(shared_from_this()));
resolver_->resolve(question, resolver_callback);
return;
@@ -337,7 +336,7 @@
* \param family For which address family this change is, so we
* do not process all the nameserves and callbacks there.
*/
- NameserverCallback(shared_ptr<ZoneEntry> entry, AddressFamily family) :
+ NameserverCallback(boost::shared_ptr<ZoneEntry> entry, AddressFamily family) :
entry_(entry),
family_(family)
{ }
@@ -352,7 +351,7 @@
entry_->process(family_, ns);
}
private:
- shared_ptr<ZoneEntry> entry_;
+ boost::shared_ptr<ZoneEntry> entry_;
AddressFamily family_;
};
@@ -373,7 +372,7 @@
void
ZoneEntry::process(AddressFamily family,
- const shared_ptr<NameserverEntry>& nameserver)
+ const boost::shared_ptr<NameserverEntry>& nameserver)
{
Lock lock(mutex_);
switch (getState()) {
@@ -516,7 +515,7 @@
insertCallback(ns, V4_ONLY);
insertCallback(ns, V6_ONLY);
} else {
- shared_ptr<NameserverCallback> callback(new NameserverCallback(
+ boost::shared_ptr<NameserverCallback> callback(new NameserverCallback(
shared_from_this(), family));
ns->askIP(resolver_, callback, family);
}
More information about the bind10-changes
mailing list