[svn] commit: r3901 - in /branches/trac327: ./ src/bin/auth/ src/bin/auth/tests/ src/bin/bind10/ src/bin/stats/tests/isc/util/ src/lib/datasrc/ src/lib/datasrc/tests/ src/lib/dns/ src/lib/dns/tests/ src/lib/dns/tests/testdata/ src/lib/nsas/ src/lib/nsas/tests/

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Dec 20 20:53:10 UTC 2010


Author: jelte
Date: Mon Dec 20 20:53:09 2010
New Revision: 3901

Log:
sync with trunk

Added:
    branches/trac327/src/lib/datasrc/memory_datasrc.cc
      - copied unchanged from r3894, trunk/src/lib/datasrc/memory_datasrc.cc
    branches/trac327/src/lib/datasrc/memory_datasrc.h
      - copied unchanged from r3894, trunk/src/lib/datasrc/memory_datasrc.h
    branches/trac327/src/lib/datasrc/rbtree.h
      - copied unchanged from r3894, trunk/src/lib/datasrc/rbtree.h
    branches/trac327/src/lib/datasrc/tests/memory_datasrc_unittest.cc
      - copied unchanged from r3894, trunk/src/lib/datasrc/tests/memory_datasrc_unittest.cc
    branches/trac327/src/lib/datasrc/tests/rbtree_unittest.cc
      - copied unchanged from r3894, trunk/src/lib/datasrc/tests/rbtree_unittest.cc
    branches/trac327/src/lib/dns/masterload.cc
      - copied unchanged from r3894, trunk/src/lib/dns/masterload.cc
    branches/trac327/src/lib/dns/masterload.h
      - copied unchanged from r3894, trunk/src/lib/dns/masterload.h
    branches/trac327/src/lib/dns/tests/masterload_unittest.cc
      - copied unchanged from r3894, trunk/src/lib/dns/tests/masterload_unittest.cc
    branches/trac327/src/lib/dns/tests/testdata/masterload.txt
      - copied unchanged from r3894, trunk/src/lib/dns/tests/testdata/masterload.txt
Modified:
    branches/trac327/   (props changed)
    branches/trac327/ChangeLog
    branches/trac327/configure.ac
    branches/trac327/src/bin/auth/query.cc
    branches/trac327/src/bin/auth/tests/query_unittest.cc
    branches/trac327/src/bin/bind10/bind10.py.in   (props changed)
    branches/trac327/src/bin/stats/tests/isc/util/   (props changed)
    branches/trac327/src/lib/datasrc/Makefile.am
    branches/trac327/src/lib/datasrc/tests/Makefile.am
    branches/trac327/src/lib/datasrc/tests/zonetable_unittest.cc
    branches/trac327/src/lib/datasrc/zonetable.cc
    branches/trac327/src/lib/datasrc/zonetable.h
    branches/trac327/src/lib/dns/Makefile.am
    branches/trac327/src/lib/dns/tests/Makefile.am
    branches/trac327/src/lib/dns/tests/testdata/Makefile.am
    branches/trac327/src/lib/nsas/Makefile.am
    branches/trac327/src/lib/nsas/address_entry.cc
    branches/trac327/src/lib/nsas/hash_key.h
    branches/trac327/src/lib/nsas/hash_table.h
    branches/trac327/src/lib/nsas/lru_list.h
    branches/trac327/src/lib/nsas/nameserver_address.cc
    branches/trac327/src/lib/nsas/nameserver_address_store.cc
    branches/trac327/src/lib/nsas/nameserver_entry.cc
    branches/trac327/src/lib/nsas/nameserver_entry.h
    branches/trac327/src/lib/nsas/random_number_generator.h
    branches/trac327/src/lib/nsas/tests/Makefile.am
    branches/trac327/src/lib/nsas/tests/address_entry_unittest.cc
    branches/trac327/src/lib/nsas/tests/fetchable_unittest.cc
    branches/trac327/src/lib/nsas/tests/hash_deleter_unittest.cc
    branches/trac327/src/lib/nsas/tests/hash_key_unittest.cc
    branches/trac327/src/lib/nsas/tests/hash_table_unittest.cc
    branches/trac327/src/lib/nsas/tests/hash_unittest.cc
    branches/trac327/src/lib/nsas/tests/lru_list_unittest.cc
    branches/trac327/src/lib/nsas/tests/nameserver_address_store_unittest.cc
    branches/trac327/src/lib/nsas/tests/nameserver_address_unittest.cc
    branches/trac327/src/lib/nsas/tests/nameserver_entry_unittest.cc
    branches/trac327/src/lib/nsas/tests/nsas_entry_compare_unittest.cc
    branches/trac327/src/lib/nsas/tests/random_number_generator_unittest.cc
    branches/trac327/src/lib/nsas/tests/run_unittests.cc
    branches/trac327/src/lib/nsas/tests/zone_entry_unittest.cc
    branches/trac327/src/lib/nsas/zone_entry.cc
    branches/trac327/src/lib/nsas/zone_entry.h

Modified: branches/trac327/ChangeLog
==============================================================================
--- branches/trac327/ChangeLog (original)
+++ branches/trac327/ChangeLog Mon Dec 20 20:53:09 2010
@@ -12,6 +12,34 @@
 	It has "listen_on" and "forward_addresses" options.
 	(Trac #389, r3448)
 
+  131.  [func]    feng, jerry
+	src/lib/datasrc: Introduced two template classes RBTree and RBNode
+	to provide the generic map with domain name as key and anything as
+	the value. Because of some unresolved design issue, the new classes
+	are only intended to be used by memory zone and zone table.
+	(Trac #397, svn r3890)
+
+  130.	[func]		jerry
+	src/lib/datasrc: Introduced a new class MemoryDataSrc to provide
+	the general interface for memory data source.  For the initial
+	implementation, we don't make it a derived class of AbstractDataSrc
+	because the interface is so different(we'll eventually consider this
+	as part of the generalization work).
+	(Trac #422, svn r3866)
+
+  129.	[func]		jinmei
+	src/lib/dns: Added new functions masterLoad() for loading master
+	zone files.  The initial implementation can only parse a limited
+	form of master files, but BIND 9's named-compilezone can convert
+	any valid zone file into the acceptable form.
+	(Trac #423, svn r3857)
+
+  128.  [build]     vorner
+	Test for query name = '.', type = DS to authoritative nameserver
+	for root zone was added.
+	(Trac #85, svn r3836)
+
+>>>>>>> .merge-right.r3894
   127.  [bug]       stephen
 	During normal operation process termination and resurrection messages
 	are now output regardless of the state of the verbose flag.

Modified: branches/trac327/configure.ac
==============================================================================
--- branches/trac327/configure.ac (original)
+++ branches/trac327/configure.ac Mon Dec 20 20:53:09 2010
@@ -195,17 +195,50 @@
 # specify the default warning flags in CXXFLAGS and let specific modules
 # "override" the default.
 
+# This may be used to try linker flags.
+AC_DEFUN([BIND10_CXX_TRY_FLAG], [
+  AC_MSG_CHECKING([whether $CXX supports $1])
+
+  bind10_save_CXXFLAGS="$CXXFLAGS"
+  CXXFLAGS="$CXXFLAGS $1"
+
+  AC_LINK_IFELSE([int main(void){ return 0;} ],
+                 [bind10_cxx_flag=yes], [bind10_cxx_flag=no])
+  CXXFLAGS="$bind10_save_CXXFLAGS"
+
+  if test "x$bind10_cxx_flag" = "xyes"; then
+    ifelse([$2], , :, [$2])
+  else
+    ifelse([$3], , :, [$3])
+  fi
+
+  AC_MSG_RESULT([$bind10_cxx_flag])
+])
+
 werror_ok=0
 
 # SunStudio compiler requires special compiler options for boost
 # (http://blogs.sun.com/sga/entry/boost_mini_howto)
 if test "$SUNCXX" = "yes"; then
 CXXFLAGS="$CXXFLAGS -library=stlport4 -features=tmplife -features=tmplrefstatic"
-fi
+MULTITHREADING_FLAG="-mt"
+fi
+
+BIND10_CXX_TRY_FLAG(-Wno-missing-field-initializers,
+	[WARNING_NO_MISSING_FIELD_INITIALIZERS_CFLAG="-Wno-missing-field-initializers"])
+AC_SUBST(WARNING_NO_MISSING_FIELD_INITIALIZERS_CFLAG)
 
 # 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
@@ -323,6 +356,62 @@
 CPPFLAGS="$CPPFLAGS_SAVES"
 AC_SUBST(BOOST_INCLUDES)
 
+# Using boost::mutex can result in requiring libboost_thread with older
+# versions of Boost.  We'd like to avoid relying on a compiled Boost library
+# whenever possible, so we need to check for it step by step.
+#
+# NOTE: another fix of this problem is to simply require newer versions of
+# boost.  If we choose that solution we should simplify the following tricky
+# checks accordingly and all Makefile.am's that refer to NEED_LIBBOOST_THREAD.
+AC_MSG_CHECKING(for boost::mutex)
+CPPFLAGS_SAVES="$CPPFLAGS"
+LIBS_SAVES="$LIBS"
+CPPFLAGS="$BOOST_INCLUDES $CPPFLAGS $MULTITHREADING_FLAG"
+need_libboost_thread=0
+need_sunpro_workaround=0
+AC_TRY_LINK([
+#include <boost/thread.hpp>
+],[
+boost::mutex m;
+],
+	[ AC_MSG_RESULT(yes (without libboost_thread)) ],
+
+    # there is one specific problem with SunStudio 5.10
+    # where including boost/thread causes a compilation failure
+    # There is a workaround in boost but it checks the version not being 5.10
+    # This will probably be fixed in the future, in which case this
+    # is only a temporary workaround
+    [ AC_TRY_LINK([
+#if defined(__SUNPRO_CC) && __SUNPRO_CC == 0x5100
+#undef __SUNPRO_CC
+#define __SUNPRO_CC 0x5090
+#endif
+#include <boost/thread.hpp>
+],[
+boost::mutex m;
+],
+    [ AC_MSG_RESULT(yes (with SUNOS workaround))
+      need_sunpro_workaround=1 ],
+    	[ LIBS=" $LIBS -lboost_thread"
+	  AC_TRY_LINK([
+#include <boost/thread.hpp>
+],[
+boost::mutex m;
+],
+		  [ AC_MSG_RESULT(yes (with libboost_thread))
+		    need_libboost_thread=1 ],
+		  [ AC_MSG_RESULT(no)
+		    AC_MSG_ERROR([boost::mutex cannot be linked in this build environment.
+Perhaps you are using an older version of Boost that requires libboost_thread for the mutex support, which does not appear to be available.
+You may want to check the availability of the library or to upgrade Boost.])
+   		  ])])])
+CPPFLAGS="$CPPFLAGS_SAVES"
+LIBS="$LIBS_SAVES"
+AM_CONDITIONAL(NEED_LIBBOOST_THREAD, test $need_libboost_thread = 1)
+if test $need_sunpro_workaround = 1; then
+    AC_DEFINE([NEED_SUNPRO_WORKAROUND], [], [Need boost sunstudio workaround])
+fi
+
 #
 # Check availability of gtest, which will be used for unit tests.
 #
@@ -387,6 +476,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: branches/trac327/src/bin/auth/query.cc
==============================================================================
--- branches/trac327/src/bin/auth/query.cc (original)
+++ branches/trac327/src/bin/auth/query.cc Mon Dec 20 20:53:09 2010
@@ -26,10 +26,10 @@
 namespace auth {
 void
 Query::process() const {
-    const ZoneTable::FindResult result = zone_table_.find(qname_);
+    const ZoneTable::FindResult result = zone_table_.findZone(qname_);
 
-    if (result.code != ZoneTable::SUCCESS &&
-        result.code != ZoneTable::PARTIALMATCH) {
+    if (result.code != isc::datasrc::result::SUCCESS &&
+        result.code != isc::datasrc::result::PARTIALMATCH) {
         response_.setRcode(Rcode::SERVFAIL());
         return;
     }

Modified: branches/trac327/src/bin/auth/tests/query_unittest.cc
==============================================================================
--- branches/trac327/src/bin/auth/tests/query_unittest.cc (original)
+++ branches/trac327/src/bin/auth/tests/query_unittest.cc Mon Dec 20 20:53:09 2010
@@ -55,7 +55,7 @@
 TEST_F(QueryTest, matchZone) {
     // add a matching zone.  since the zone is empty right now, the response
     // should have NXDOMAIN.
-    zone_table.add(ZonePtr(new MemoryZone(qclass, Name("example.com"))));
+    zone_table.addZone(ZonePtr(new MemoryZone(qclass, Name("example.com"))));
     query.process();
     EXPECT_EQ(Rcode::NXDOMAIN(), response.getRcode());
 }
@@ -63,7 +63,7 @@
 TEST_F(QueryTest, noMatchZone) {
     // there's a zone in the table but it doesn't match the qname.  should
     // result in SERVFAIL.
-    zone_table.add(ZonePtr(new MemoryZone(qclass, Name("example.org"))));
+    zone_table.addZone(ZonePtr(new MemoryZone(qclass, Name("example.org"))));
     query.process();
     EXPECT_EQ(Rcode::SERVFAIL(), response.getRcode());
 }

Modified: branches/trac327/src/lib/datasrc/Makefile.am
==============================================================================
--- branches/trac327/src/lib/datasrc/Makefile.am (original)
+++ branches/trac327/src/lib/datasrc/Makefile.am Mon Dec 20 20:53:09 2010
@@ -15,4 +15,6 @@
 libdatasrc_la_SOURCES += sqlite3_datasrc.h sqlite3_datasrc.cc
 libdatasrc_la_SOURCES += query.h query.cc
 libdatasrc_la_SOURCES += cache.h cache.cc
+libdatasrc_la_SOURCES += rbtree.h 
 libdatasrc_la_SOURCES += zonetable.h zonetable.cc
+libdatasrc_la_SOURCES += memory_datasrc.h memory_datasrc.cc

Modified: branches/trac327/src/lib/datasrc/tests/Makefile.am
==============================================================================
--- branches/trac327/src/lib/datasrc/tests/Makefile.am (original)
+++ branches/trac327/src/lib/datasrc/tests/Makefile.am Mon Dec 20 20:53:09 2010
@@ -24,12 +24,14 @@
 run_unittests_SOURCES += query_unittest.cc
 run_unittests_SOURCES += cache_unittest.cc
 run_unittests_SOURCES += test_datasrc.h test_datasrc.cc
+run_unittests_SOURCES += rbtree_unittest.cc
 run_unittests_SOURCES += zonetable_unittest.cc
+run_unittests_SOURCES += memory_datasrc_unittest.cc
 run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
 run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS)
 run_unittests_LDADD = $(GTEST_LDADD)
 run_unittests_LDADD += $(SQLITE_LIBS)
-run_unittests_LDADD += $(top_builddir)/src/lib/datasrc/libdatasrc.la 
+run_unittests_LDADD += $(top_builddir)/src/lib/datasrc/libdatasrc.la
 run_unittests_LDADD += $(top_builddir)/src/lib/dns/libdns++.la
 run_unittests_LDADD += $(top_builddir)/src/lib/cc/libcc.la
 run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la

Modified: branches/trac327/src/lib/datasrc/tests/zonetable_unittest.cc
==============================================================================
--- branches/trac327/src/lib/datasrc/tests/zonetable_unittest.cc (original)
+++ branches/trac327/src/lib/datasrc/tests/zonetable_unittest.cc Mon Dec 20 20:53:09 2010
@@ -53,61 +53,61 @@
     ZonePtr zone1, zone2, zone3;
 };
 
-TEST_F(ZoneTableTest, add) {
-    EXPECT_EQ(ZoneTable::SUCCESS, zone_table.add(zone1));
-    EXPECT_EQ(ZoneTable::EXIST, zone_table.add(zone1));
+TEST_F(ZoneTableTest, addZone) {
+    EXPECT_EQ(result::SUCCESS, zone_table.addZone(zone1));
+    EXPECT_EQ(result::EXIST, zone_table.addZone(zone1));
     // names are compared in a case insensitive manner.
-    EXPECT_EQ(ZoneTable::EXIST, zone_table.add(
+    EXPECT_EQ(result::EXIST, zone_table.addZone(
                   ZonePtr(new MemoryZone(RRClass::IN(), Name("EXAMPLE.COM")))));
 
-    EXPECT_EQ(ZoneTable::SUCCESS, zone_table.add(zone2));
-    EXPECT_EQ(ZoneTable::SUCCESS, zone_table.add(zone3));
+    EXPECT_EQ(result::SUCCESS, zone_table.addZone(zone2));
+    EXPECT_EQ(result::SUCCESS, zone_table.addZone(zone3));
 
     // Zone table is indexed only by name.  Duplicate origin name with
     // different zone class isn't allowed.
-    EXPECT_EQ(ZoneTable::EXIST, zone_table.add(
+    EXPECT_EQ(result::EXIST, zone_table.addZone(
                   ZonePtr(new MemoryZone(RRClass::CH(),
                                          Name("example.com")))));
 
     /// Bogus zone (NULL)
-    EXPECT_THROW(zone_table.add(ZonePtr()), isc::InvalidParameter);
+    EXPECT_THROW(zone_table.addZone(ZonePtr()), isc::InvalidParameter);
 }
 
-TEST_F(ZoneTableTest, remove) {
-    EXPECT_EQ(ZoneTable::SUCCESS, zone_table.add(zone1));
-    EXPECT_EQ(ZoneTable::SUCCESS, zone_table.add(zone2));
-    EXPECT_EQ(ZoneTable::SUCCESS, zone_table.add(zone3));
+TEST_F(ZoneTableTest, removeZone) {
+    EXPECT_EQ(result::SUCCESS, zone_table.addZone(zone1));
+    EXPECT_EQ(result::SUCCESS, zone_table.addZone(zone2));
+    EXPECT_EQ(result::SUCCESS, zone_table.addZone(zone3));
 
-    EXPECT_EQ(ZoneTable::SUCCESS, zone_table.remove(Name("example.net")));
-    EXPECT_EQ(ZoneTable::NOTFOUND, zone_table.remove(Name("example.net")));
+    EXPECT_EQ(result::SUCCESS, zone_table.removeZone(Name("example.net")));
+    EXPECT_EQ(result::NOTFOUND, zone_table.removeZone(Name("example.net")));
 }
 
-TEST_F(ZoneTableTest, find) {
-    EXPECT_EQ(ZoneTable::SUCCESS, zone_table.add(zone1));
-    EXPECT_EQ(ZoneTable::SUCCESS, zone_table.add(zone2));
-    EXPECT_EQ(ZoneTable::SUCCESS, zone_table.add(zone3));
+TEST_F(ZoneTableTest, findZone) {
+    EXPECT_EQ(result::SUCCESS, zone_table.addZone(zone1));
+    EXPECT_EQ(result::SUCCESS, zone_table.addZone(zone2));
+    EXPECT_EQ(result::SUCCESS, zone_table.addZone(zone3));
 
-    EXPECT_EQ(ZoneTable::SUCCESS, zone_table.find(Name("example.com")).code);
+    EXPECT_EQ(result::SUCCESS, zone_table.findZone(Name("example.com")).code);
     EXPECT_EQ(Name("example.com"),
-              zone_table.find(Name("example.com")).zone->getOrigin());
+              zone_table.findZone(Name("example.com")).zone->getOrigin());
 
-    EXPECT_EQ(ZoneTable::NOTFOUND,
-              zone_table.find(Name("example.org")).code);
-    EXPECT_EQ(static_cast<const Zone*>(NULL),
-              zone_table.find(Name("example.org")).zone);
+    EXPECT_EQ(result::NOTFOUND,
+              zone_table.findZone(Name("example.org")).code);
+    EXPECT_EQ(ConstZonePtr(),
+              zone_table.findZone(Name("example.org")).zone);
 
     // there's no exact match.  the result should be the longest match,
     // and the code should be PARTIALMATCH.
-    EXPECT_EQ(ZoneTable::PARTIALMATCH,
-              zone_table.find(Name("www.example.com")).code);
+    EXPECT_EQ(result::PARTIALMATCH,
+              zone_table.findZone(Name("www.example.com")).code);
     EXPECT_EQ(Name("example.com"),
-              zone_table.find(Name("www.example.com")).zone->getOrigin());
+              zone_table.findZone(Name("www.example.com")).zone->getOrigin());
 
     // make sure the partial match is indeed the longest match by adding
     // a zone with a shorter origin and query again.
     ZonePtr zone_com(new MemoryZone(RRClass::IN(), Name("com")));
-    EXPECT_EQ(ZoneTable::SUCCESS, zone_table.add(zone_com));
+    EXPECT_EQ(result::SUCCESS, zone_table.addZone(zone_com));
     EXPECT_EQ(Name("example.com"),
-              zone_table.find(Name("www.example.com")).zone->getOrigin());
+              zone_table.findZone(Name("www.example.com")).zone->getOrigin());
 }
 }

Modified: branches/trac327/src/lib/datasrc/zonetable.cc
==============================================================================
--- branches/trac327/src/lib/datasrc/zonetable.cc (original)
+++ branches/trac327/src/lib/datasrc/zonetable.cc Mon Dec 20 20:53:09 2010
@@ -77,29 +77,30 @@
     delete impl_;
 }
 
-ZoneTable::Result
-ZoneTable::add(ZonePtr zone) {
+result::Result
+ZoneTable::addZone(ZonePtr zone) {
     if (!zone) {
         isc_throw(InvalidParameter,
-                  "Null pointer is passed to ZoneTable::add()");
+                  "Null pointer is passed to ZoneTable::addZone()");
     }
 
     if (impl_->zones.insert(
             ZoneTableImpl::NameAndZone(zone->getOrigin(), zone)).second
         == true) {
-        return (SUCCESS);
+        return (result::SUCCESS);
     } else {
-        return (EXIST);
+        return (result::EXIST);
     }
 }
 
-ZoneTable::Result
-ZoneTable::remove(const Name& origin) {
-    return (impl_->zones.erase(origin) == 1 ? SUCCESS : NOTFOUND);
+result::Result
+ZoneTable::removeZone(const Name& origin) {
+    return (impl_->zones.erase(origin) == 1 ? result::SUCCESS :
+                                              result::NOTFOUND);
 }
 
 ZoneTable::FindResult
-ZoneTable::find(const Name& name) const {
+ZoneTable::findZone(const Name& name) const {
     // Inefficient internal loop to find a longest match.
     // This will be replaced with a single call to more intelligent backend.
     for (int i = 0; i < name.getLabelCount(); ++i) {
@@ -107,11 +108,11 @@
         ZoneTableImpl::ZoneMap::const_iterator found =
             impl_->zones.find(matchname);
         if (found != impl_->zones.end()) {
-            return (FindResult(i == 0 ? SUCCESS : PARTIALMATCH,
-                               (*found).second.get()));
+            return (FindResult(i == 0 ? result::SUCCESS :
+                               result::PARTIALMATCH, (*found).second));
         }
     }
-    return (FindResult(NOTFOUND, NULL));
+    return (FindResult(result::NOTFOUND, ConstZonePtr()));
 }
 } // end of namespace datasrc
 } // end of namespace isc

Modified: branches/trac327/src/lib/datasrc/zonetable.h
==============================================================================
--- branches/trac327/src/lib/datasrc/zonetable.h (original)
+++ branches/trac327/src/lib/datasrc/zonetable.h Mon Dec 20 20:53:09 2010
@@ -26,6 +26,21 @@
 };
 
 namespace datasrc {
+namespace result {
+/// Result codes of various public methods of in memory data source
+///
+/// The detailed semantics may differ in different methods.
+/// See the description of specific methods for more details.
+///
+/// Note: this is intended to be used from other data sources eventually,
+/// but for now it's specific to in memory data source and its backend.
+enum Result {
+    SUCCESS,  ///< The operation is successful.
+    EXIST,    ///< The search key is already stored.
+    NOTFOUND, ///< The specified object is not found.
+    PARTIALMATCH ///< \c Only a partial match is found.
+};
+}
 
 /// \brief The base class for a single authoritative zone
 ///
@@ -223,81 +238,22 @@
 
 /// \brief A set of authoritative zones.
 ///
-/// The \c ZoneTable class represents a set of zones of the same RR class
-/// and provides a basic interface to help DNS lookup processing.
-/// For a given domain name, its \c find() method searches the set for a zone
-/// that gives a longest match against that name.
-///
-/// The set of zones are assumed to be of the same RR class, but the
-/// \c ZoneTable class does not enforce the assumption through its interface.
-/// For example, the \c add() method does not check if the new zone
-/// is of the same RR class as that of the others already in the table.
-/// It is caller's responsibility to ensure this assumption.
-///
-/// <b>Notes to developer:</b>
-///
-/// The add() method takes a (Boost) shared pointer because it would be
-/// inconvenient to require the caller to maintain the ownership of zones,
-/// while it wouldn't be safe to delete unnecessary zones inside the zone
-/// table.
-///
-/// On the other hand, the find() method returns a bare pointer, rather than
-/// the shared pointer, in order to minimize the dependency on Boost
-/// definitions in our public interfaces.  This means the caller can only
-/// refer to the returned object (via the pointer) for a short period.
-///  It should be okay for simple lookup purposes, but if we see the need
-/// for keeping a \c Zone object for a longer period of context, we may
-/// have to revisit this decision.
-///
-/// Currently, \c FindResult::zone is immutable for safety.
-/// In future versions we may want to make it changeable.  For example,
-/// we may want to allow configuration update on an existing zone.
-///
-/// In BIND 9's "zt" module, the equivalent of \c find() has an "option"
-/// parameter.  The only defined option is the one to specify the "no exact"
-/// mode, and the only purpose of that mode is to prefer a second longest match
-/// even if there is an exact match in order to deal with type DS query.
-/// This trick may help enhance performance, but it also seems to make the
-/// implementation complicated for a very limited, minor case.  So, for now,
-/// we don't introduce the special mode, and, since it was the only reason to
-/// have search options in BIND 9, our initial implementation doesn't provide
-/// a switch for options.
+/// \c ZoneTable class is primarily intended to be used as a backend for the
+/// \c MemoryDataSrc class, but is exposed as a separate class in case some
+/// application wants to use it directly (e.g. for a customized data source
+/// implementation).
+///
+/// For more descriptions about its struct and interfaces, please refer to the
+/// corresponding struct and interfaces of \c MemoryDataSrc.
 class ZoneTable {
 public:
-    /// Result codes of various public methods of \c ZoneTable.
-    ///
-    /// The detailed semantics may differ in different methods.
-    /// See the description of specific methods for more details.
-    enum Result {
-        SUCCESS,  ///< The operation is successful.
-        EXIST,    ///< A zone is already stored in \c ZoneTable.
-        NOTFOUND, ///< The specified zone is not found in \c ZoneTable.
-        PARTIALMATCH ///< \c Only a partial match is found in \c find(). 
-    };
-
-    /// \brief A helper structure to represent the search result of
-    /// <code>ZoneTable::find()</code>.
-    ///
-    /// This is a straightforward pair of the result code and a pointer
-    /// to the found zone to represent the result of \c find().
-    /// We use this in order to avoid overloading the return value for both
-    /// the result code ("success" or "not found") and the found object,
-    /// i.e., avoid using \c NULL to mean "not found", etc.
-    ///
-    /// This is a simple value class with no internal state, so for
-    /// convenience we allow the applications to refer to the members
-    /// directly.
-    ///
-    /// See the description of \c find() for the semantics of the member
-    /// variables.
     struct FindResult {
-        FindResult(Result param_code, const Zone* param_zone) :
+        FindResult(result::Result param_code, const ConstZonePtr param_zone) :
             code(param_code), zone(param_zone)
         {}
-        const Result code;
-        const Zone* const zone;
+        const result::Result code;
+        const ConstZonePtr zone;
     };
-
     ///
     /// \name Constructors and Destructor.
     ///
@@ -322,53 +278,25 @@
     //@}
 
     /// Add a \c Zone to the \c ZoneTable.
-    ///
-    /// \c zone must not be associated with a NULL pointer; otherwise
-    /// an exception of class \c InvalidParameter will be thrown.
-    /// If internal resource allocation fails, a corresponding standard
-    /// exception will be thrown.
-    /// This method never throws an exception otherwise.
-    ///
-    /// \param zone A \c Zone object to be added.
-    /// \return \c SUCCESS If the zone is successfully added to the zone table.
-    /// \return \c EXIST The zone table already stores a zone that has the
-    /// same origin.
-    Result add(ZonePtr zone);
+    /// See the description of <code>MemoryDataSrc::addZone()</code> for more
+    /// details.
+    result::Result addZone(ZonePtr zone);
 
     /// Remove a \c Zone of the given origin name from the \c ZoneTable.
     ///
     /// This method never throws an exception.
     ///
     /// \param origin The origin name of the zone to be removed.
-    /// \return \c SUCCESS If the zone is successfully removed from the
-    /// zone table.
-    /// \return \c NOTFOUND The zone table does not store the zone that matches
-    /// \c origin.
-    Result remove(const isc::dns::Name& origin);
+    /// \return \c result::SUCCESS If the zone is successfully
+    /// removed from the zone table.
+    /// \return \c result::NOTFOUND The zone table does not
+    /// store the zone that matches \c origin.
+    result::Result removeZone(const isc::dns::Name& origin);
 
     /// Find a \c Zone that best matches the given name in the \c ZoneTable.
-    ///
-    /// It searches the internal storage for a \c Zone that gives the
-    /// longest match against \c name, and returns the result in the
-    /// form of a \c FindResult object as follows:
-    /// - \c code: The result code of the operation.
-    ///   - \c SUCCESS: A zone that gives an exact match is found
-    ///   - \c PARTIALMATCH: A zone whose origin is a super domain of
-    ///     \c name is found (but there is no exact match)
-    ///   - \c NOTFOUND: For all other cases.
-    /// - \c zone: A pointer to the found \c Zone object if one is found;
-    /// otherwise \c NULL.
-    ///
-    /// The pointer returned in the \c FindResult object is only valid until
-    /// the corresponding zone is removed from the zone table.
-    /// The caller must ensure that the zone is held in the zone table while
-    /// it needs to refer to it.
-    ///
-    /// This method never throws an exception.
-    ///
-    /// \param name A domain name for which the search is performed.
-    /// \return A \c FindResult object enclosing the search result (see above).
-    FindResult find(const isc::dns::Name& name) const;
+    /// See the description of <code>MemoryDataSrc::findZone()</code> for more
+    /// details.
+    FindResult findZone(const isc::dns::Name& name) const;
 
 private:
     struct ZoneTableImpl;

Modified: branches/trac327/src/lib/dns/Makefile.am
==============================================================================
--- branches/trac327/src/lib/dns/Makefile.am (original)
+++ branches/trac327/src/lib/dns/Makefile.am Mon Dec 20 20:53:09 2010
@@ -69,6 +69,7 @@
 libdns___la_SOURCES += edns.h edns.cc
 libdns___la_SOURCES += exceptions.h exceptions.cc
 libdns___la_SOURCES += util/hex.h
+libdns___la_SOURCES += masterload.h masterload.cc
 libdns___la_SOURCES += message.h message.cc
 libdns___la_SOURCES += messagerenderer.h messagerenderer.cc
 libdns___la_SOURCES += name.h name.cc

Modified: branches/trac327/src/lib/dns/tests/Makefile.am
==============================================================================
--- branches/trac327/src/lib/dns/tests/Makefile.am (original)
+++ branches/trac327/src/lib/dns/tests/Makefile.am Mon Dec 20 20:53:09 2010
@@ -42,6 +42,7 @@
 run_unittests_SOURCES += rrset_unittest.cc rrsetlist_unittest.cc
 run_unittests_SOURCES += question_unittest.cc
 run_unittests_SOURCES += rrparamregistry_unittest.cc
+run_unittests_SOURCES += masterload_unittest.cc
 run_unittests_SOURCES += message_unittest.cc
 run_unittests_SOURCES += base32hex_unittest.cc
 run_unittests_SOURCES += base64_unittest.cc

Modified: branches/trac327/src/lib/dns/tests/testdata/Makefile.am
==============================================================================
--- branches/trac327/src/lib/dns/tests/testdata/Makefile.am (original)
+++ branches/trac327/src/lib/dns/tests/testdata/Makefile.am Mon Dec 20 20:53:09 2010
@@ -26,6 +26,7 @@
 EXTRA_DIST = gen-wiredata.py.in
 EXTRA_DIST += edns_toWire1.spec edns_toWire2.spec
 EXTRA_DIST += edns_toWire3.spec edns_toWire4.spec
+EXTRA_DIST += masterload.txt
 EXTRA_DIST += message_fromWire1 message_fromWire2
 EXTRA_DIST += message_fromWire3 message_fromWire4
 EXTRA_DIST += message_fromWire5 message_fromWire6

Modified: branches/trac327/src/lib/nsas/Makefile.am
==============================================================================
--- branches/trac327/src/lib/nsas/Makefile.am (original)
+++ branches/trac327/src/lib/nsas/Makefile.am Mon Dec 20 20:53:09 2010
@@ -1,17 +1,22 @@
 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)
 AM_CXXFLAGS = $(B10_CXXFLAGS)
 
-if USE_GXX
 # Some versions of GCC warn about some versions of Boost regarding
 # missing initializer for members in its posix_time.
 # https://svn.boost.org/trac/boost/ticket/3477
-AM_CXXFLAGS += -Wno-missing-field-initializers
+# But older GCC compilers don't have the flag.
+AM_CXXFLAGS += $(WARNING_NO_MISSING_FIELD_INITIALIZERS_CFLAG)
+
+if USE_CLANGPP
+# clang++ complains about unused function parameters in some boost header
+# files.
+AM_CXXFLAGS += -Wno-unused-parameter
 endif
 
 lib_LTLIBRARIES = libnsas.la

Modified: branches/trac327/src/lib/nsas/address_entry.cc
==============================================================================
--- branches/trac327/src/lib/nsas/address_entry.cc (original)
+++ branches/trac327/src/lib/nsas/address_entry.cc Mon Dec 20 20:53:09 2010
@@ -35,6 +35,8 @@
 #define __STDC_LIMIT_MACROS
 #include <stdint.h>
 
+#include <config.h>
+
 #include "address_entry.h"
 
 namespace isc {

Modified: branches/trac327/src/lib/nsas/hash_key.h
==============================================================================
--- branches/trac327/src/lib/nsas/hash_key.h (original)
+++ branches/trac327/src/lib/nsas/hash_key.h Mon Dec 20 20:53:09 2010
@@ -21,7 +21,6 @@
 
 #include <stdint.h>
 #include <string>
-#include <config.h>
 
 namespace isc {
 namespace nsas {

Modified: branches/trac327/src/lib/nsas/hash_table.h
==============================================================================
--- branches/trac327/src/lib/nsas/hash_table.h (original)
+++ branches/trac327/src/lib/nsas/hash_table.h Mon Dec 20 20:53:09 2010
@@ -17,14 +17,24 @@
 #ifndef __HASH_TABLE_H
 #define __HASH_TABLE_H
 
+// Workaround for a problem with boost and sunstudio 5.10
+// There is a version check in there that appears wrong,
+// which makes including boost/thread.hpp fail
+// This will probably be fixed in a future version of boost,
+// in which case this part can be removed then
+#ifdef NEED_SUNPRO_WORKAROUND
+#if defined(__SUNPRO_CC) && __SUNPRO_CC == 0x5100
+#undef __SUNPRO_CC
+#define __SUNPRO_CC 0x5090
+#endif
+#endif // NEED_SUNPRO_WORKAROUND
+
 #include <boost/shared_ptr.hpp>
 #include <boost/thread.hpp>
 #include <boost/interprocess/sync/sharable_lock.hpp>
 #include <boost/interprocess/sync/scoped_lock.hpp>
 #include <boost/interprocess/sync/interprocess_upgradable_mutex.hpp>
 #include <list>
-
-#include <config.h>
 
 #include "hash.h"
 #include "hash_key.h"

Modified: branches/trac327/src/lib/nsas/lru_list.h
==============================================================================
--- branches/trac327/src/lib/nsas/lru_list.h (original)
+++ branches/trac327/src/lib/nsas/lru_list.h Mon Dec 20 20:53:09 2010
@@ -20,12 +20,22 @@
 #include <list>
 #include <string>
 
+// Workaround for a problem with boost and sunstudio 5.10
+// There is a version check in there that appears wrong,
+// which makes including boost/thread.hpp fail
+// This will probably be fixed in a future version of boost,
+// in which case this part can be removed then
+#ifdef NEED_SUNPRO_WORKAROUND
+#if defined(__SUNPRO_CC) && __SUNPRO_CC == 0x5100
+#undef __SUNPRO_CC
+#define __SUNPRO_CC 0x5090
+#endif
+#endif // NEED_SUNPRO_WORKAROUND
+
 #include <boost/noncopyable.hpp>
 #include <boost/shared_ptr.hpp>
 #include <boost/thread.hpp>
 #include <boost/interprocess/sync/scoped_lock.hpp>
-
-#include <config.h>
 
 namespace isc {
 namespace nsas {

Modified: branches/trac327/src/lib/nsas/nameserver_address.cc
==============================================================================
--- branches/trac327/src/lib/nsas/nameserver_address.cc (original)
+++ branches/trac327/src/lib/nsas/nameserver_address.cc Mon Dec 20 20:53:09 2010
@@ -14,6 +14,8 @@
 
 // $id$
 
+#include <config.h>
+
 #include "nameserver_address.h"
 #include "nameserver_entry.h"
 

Modified: branches/trac327/src/lib/nsas/nameserver_address_store.cc
==============================================================================
--- branches/trac327/src/lib/nsas/nameserver_address_store.cc (original)
+++ branches/trac327/src/lib/nsas/nameserver_address_store.cc Mon Dec 20 20:53:09 2010
@@ -14,9 +14,25 @@
 
 // $Id$
 
+#include <config.h>
+
+// Workaround for a problem with boost and sunstudio 5.10
+// There is a version check in there that appears wrong,
+// which makes including boost/thread.hpp fail
+// This will probably be fixed in a future version of boost,
+// in which case this part can be removed then
+#ifdef NEED_SUNPRO_WORKAROUND
+#if defined(__SUNPRO_CC) && __SUNPRO_CC == 0x5100
+#undef __SUNPRO_CC
+#define __SUNPRO_CC 0x5090
+#endif
+#endif // NEED_SUNPRO_WORKAROUND
+
+
 #include <boost/thread.hpp>
 #include <boost/shared_ptr.hpp>
 #include <boost/foreach.hpp>
+#include <boost/bind.hpp>
 
 #include <config.h>
 #include <dns/rdataclass.h>
@@ -32,7 +48,6 @@
 
 using namespace isc::dns;
 using namespace std;
-using namespace boost;
 
 namespace isc {
 namespace nsas {
@@ -43,7 +58,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)),
@@ -64,13 +79,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);
 }
@@ -79,9 +94,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: branches/trac327/src/lib/nsas/nameserver_entry.cc
==============================================================================
--- branches/trac327/src/lib/nsas/nameserver_entry.cc (original)
+++ branches/trac327/src/lib/nsas/nameserver_entry.cc Mon Dec 20 20:53:09 2010
@@ -14,6 +14,8 @@
 
 // $Id$
 
+#include <config.h>
+
 #include <algorithm>
 #include <functional>
 #include <cassert>
@@ -41,7 +43,6 @@
 using namespace isc::nsas;
 using namespace isc::dns;
 using namespace std;
-using namespace boost;
 
 namespace isc {
 namespace nsas {
@@ -49,7 +50,7 @@
 namespace {
 
 // Just shorter type alias
-typedef recursive_mutex::scoped_lock Lock;
+typedef boost::recursive_mutex::scoped_lock Lock;
 
 }
 
@@ -100,7 +101,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 +203,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 +215,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 +296,7 @@
             failureInternal(lock);
         }
     private:
-        shared_ptr<NameserverEntry> entry_;
+        boost::shared_ptr<NameserverEntry> entry_;
         AddressFamily family_;
         RRType type_;
 
@@ -309,7 +310,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 +332,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 +365,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: branches/trac327/src/lib/nsas/nameserver_entry.h
==============================================================================
--- branches/trac327/src/lib/nsas/nameserver_entry.h (original)
+++ branches/trac327/src/lib/nsas/nameserver_entry.h Mon Dec 20 20:53:09 2010
@@ -16,6 +16,18 @@
 
 #ifndef __NAMESERVER_ENTRY_H
 #define __NAMESERVER_ENTRY_H
+
+// Workaround for a problem with boost and sunstudio 5.10
+// There is a version check in there that appears wrong,
+// which makes including boost/thread.hpp fail
+// This will probably be fixed in a future version of boost,
+// in which case this part can be removed then
+#ifdef NEED_SUNPRO_WORKAROUND
+#if defined(__SUNPRO_CC) && __SUNPRO_CC == 0x5100
+#undef __SUNPRO_CC
+#define __SUNPRO_CC 0x5090
+#endif
+#endif // NEED_SUNPRO_WORKAROUND
 
 #include <string>
 #include <vector>

Modified: branches/trac327/src/lib/nsas/random_number_generator.h
==============================================================================
--- branches/trac327/src/lib/nsas/random_number_generator.h (original)
+++ branches/trac327/src/lib/nsas/random_number_generator.h Mon Dec 20 20:53:09 2010
@@ -139,17 +139,20 @@
 
         double epsilon = 0.0001;
         // The sum must be equal to 1
-        return fabs(sum - 1.0) < epsilon;
+        return std::fabs(sum - 1.0) < epsilon;
     }
-
-    // Shortcut typedefs
-    typedef boost::variate_generator<boost::mt19937&, boost::uniform_real<> > UniformRealGenerator;
 
     std::vector<double> cumulative_;            ///< The partial sum of the probabilities
     boost::mt19937 rng_;                        ///< Mersenne Twister: A 623-dimensionally equidistributed uniform pseudo-random number generator 
     boost::uniform_real<> dist_;                ///< Uniformly distributed real numbers
+
+    // Shortcut typedef
+    // This typedef is placed directly before its use, as the sunstudio
+    // compiler could not handle it being anywhere else (don't know why)
+    typedef boost::variate_generator<boost::mt19937&, boost::uniform_real<> > UniformRealGenerator;
     UniformRealGenerator uniform_real_gen_;     ///< Uniformly distributed random real numbers generator
-    size_t min_;                                   ///< The minimum integer that will be generated
+
+    size_t min_;                                ///< The minimum integer that will be generated
 };
 
 }   // namespace dns

Modified: branches/trac327/src/lib/nsas/tests/Makefile.am
==============================================================================
--- branches/trac327/src/lib/nsas/tests/Makefile.am (original)
+++ branches/trac327/src/lib/nsas/tests/Makefile.am Mon Dec 20 20:53:09 2010
@@ -1,15 +1,26 @@
 SUBDIRS = .
 
 AM_CPPFLAGS  = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
+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
-AM_LDFLAGS += -lboost_thread
+
+# Some versions of GCC warn about some versions of Boost regarding
+# missing initializer for members in its posix_time.
+# https://svn.boost.org/trac/boost/ticket/3477
+# But older GCC compilers don't have the flag.     
+AM_CXXFLAGS += $(WARNING_NO_MISSING_FIELD_INITIALIZERS_CFLAG)
+
+if USE_CLANGPP
+# see ../Makefile.am
+AM_CXXFLAGS += -Wno-unused-parameter
+endif
 
 CLEANFILES = *.gcno *.gcda
 
@@ -36,6 +47,11 @@
 run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS)
 run_unittests_LDADD = $(GTEST_LDADD)
 
+# NOTE: we may have to clean up this hack later (see the note in configure.ac)
+if NEED_LIBBOOST_THREAD
+run_unittests_LDADD += -lboost_thread
+endif
+
 run_unittests_LDADD += $(top_builddir)/src/lib/nsas/libnsas.la
 run_unittests_LDADD += $(top_builddir)/src/lib/dns/libdns++.la
 run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libexceptions.la

Modified: branches/trac327/src/lib/nsas/tests/address_entry_unittest.cc
==============================================================================
--- branches/trac327/src/lib/nsas/tests/address_entry_unittest.cc (original)
+++ branches/trac327/src/lib/nsas/tests/address_entry_unittest.cc Mon Dec 20 20:53:09 2010
@@ -13,6 +13,7 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 // $Id$
+#include <config.h>
 
 #include <limits.h>
 #include <gtest/gtest.h>

Modified: branches/trac327/src/lib/nsas/tests/fetchable_unittest.cc
==============================================================================
--- branches/trac327/src/lib/nsas/tests/fetchable_unittest.cc (original)
+++ branches/trac327/src/lib/nsas/tests/fetchable_unittest.cc Mon Dec 20 20:53:09 2010
@@ -13,6 +13,7 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 // $id$
+#include <config.h>
 
 #include "../fetchable.h"
 

Modified: branches/trac327/src/lib/nsas/tests/hash_deleter_unittest.cc
==============================================================================
--- branches/trac327/src/lib/nsas/tests/hash_deleter_unittest.cc (original)
+++ branches/trac327/src/lib/nsas/tests/hash_deleter_unittest.cc Mon Dec 20 20:53:09 2010
@@ -13,6 +13,7 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 // $Id$
+#include <config.h>
 
 #include <algorithm>
 #include <string>

Modified: branches/trac327/src/lib/nsas/tests/hash_key_unittest.cc
==============================================================================
--- branches/trac327/src/lib/nsas/tests/hash_key_unittest.cc (original)
+++ branches/trac327/src/lib/nsas/tests/hash_key_unittest.cc Mon Dec 20 20:53:09 2010
@@ -13,6 +13,7 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 // $Id$
+#include <config.h>
 
 #include <algorithm>
 #include <string>

Modified: branches/trac327/src/lib/nsas/tests/hash_table_unittest.cc
==============================================================================
--- branches/trac327/src/lib/nsas/tests/hash_table_unittest.cc (original)
+++ branches/trac327/src/lib/nsas/tests/hash_table_unittest.cc Mon Dec 20 20:53:09 2010
@@ -13,6 +13,7 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 // $Id$
+#include <config.h>
 
 #include <gtest/gtest.h>
 #include <boost/shared_ptr.hpp>

Modified: branches/trac327/src/lib/nsas/tests/hash_unittest.cc
==============================================================================
--- branches/trac327/src/lib/nsas/tests/hash_unittest.cc (original)
+++ branches/trac327/src/lib/nsas/tests/hash_unittest.cc Mon Dec 20 20:53:09 2010
@@ -13,6 +13,7 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 // $Id$
+#include <config.h>
 
 #include <algorithm>
 #include <string>

Modified: branches/trac327/src/lib/nsas/tests/lru_list_unittest.cc
==============================================================================
--- branches/trac327/src/lib/nsas/tests/lru_list_unittest.cc (original)
+++ branches/trac327/src/lib/nsas/tests/lru_list_unittest.cc Mon Dec 20 20:53:09 2010
@@ -13,6 +13,7 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 // $Id$
+#include <config.h>
 
 #include <iostream>
 #include <algorithm>

Modified: branches/trac327/src/lib/nsas/tests/nameserver_address_store_unittest.cc
==============================================================================
--- branches/trac327/src/lib/nsas/tests/nameserver_address_store_unittest.cc (original)
+++ branches/trac327/src/lib/nsas/tests/nameserver_address_store_unittest.cc Mon Dec 20 20:53:09 2010
@@ -13,6 +13,7 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 // $Id$
+#include <config.h>
 
 /// \brief Test Deleter Objects
 ///
@@ -41,7 +42,6 @@
 
 using namespace isc::dns;
 using namespace std;
-using namespace boost;
 
 namespace isc {
 namespace nsas {
@@ -57,7 +57,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 +87,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 +102,7 @@
         }
     }
 private:
-    shared_ptr<TestResolver> resolver_;
+    boost::shared_ptr<TestResolver> resolver_;
 };
 
 
@@ -133,8 +133,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 +151,7 @@
 
     RRsetPtr authority_, empty_authority_;
 
-    shared_ptr<TestResolver> resolver_;
+    boost::shared_ptr<TestResolver> resolver_;
 
     class NSASCallback : public AddressRequestCallback {
         public:

Modified: branches/trac327/src/lib/nsas/tests/nameserver_address_unittest.cc
==============================================================================
--- branches/trac327/src/lib/nsas/tests/nameserver_address_unittest.cc (original)
+++ branches/trac327/src/lib/nsas/tests/nameserver_address_unittest.cc Mon Dec 20 20:53:09 2010
@@ -13,6 +13,7 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 // $Id$
+#include <config.h>
 
 #include <gtest/gtest.h>
 
@@ -31,7 +32,6 @@
 
 using namespace dns;
 using namespace rdata;
-using namespace boost;
 
 #define TEST_ADDRESS_INDEX 1
 
@@ -48,8 +48,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 +74,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: branches/trac327/src/lib/nsas/tests/nameserver_entry_unittest.cc
==============================================================================
--- branches/trac327/src/lib/nsas/tests/nameserver_entry_unittest.cc (original)
+++ branches/trac327/src/lib/nsas/tests/nameserver_entry_unittest.cc Mon Dec 20 20:53:09 2010
@@ -13,6 +13,7 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 // $Id$
+#include <config.h>
 
 #include <iostream>
 #include <algorithm>
@@ -43,7 +44,6 @@
 using namespace std;
 using namespace isc::dns;
 using namespace rdata;
-using namespace boost;
 
 namespace {
 
@@ -53,7 +53,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 +69,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 +80,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 +114,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 +133,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 +168,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 +211,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 +236,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 +262,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 +311,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 +339,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 +376,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 +426,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 +482,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: branches/trac327/src/lib/nsas/tests/nsas_entry_compare_unittest.cc
==============================================================================
--- branches/trac327/src/lib/nsas/tests/nsas_entry_compare_unittest.cc (original)
+++ branches/trac327/src/lib/nsas/tests/nsas_entry_compare_unittest.cc Mon Dec 20 20:53:09 2010
@@ -13,6 +13,7 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 // $Id$
+#include <config.h>
 
 #include <algorithm>
 #include <string>
@@ -37,16 +38,18 @@
 
 // Test of the comparison
 TEST_F(NsasEntryCompareTest, Compare) {
+    std::string name1("test1");
+    std::string name2("test2");
 
     // Construct a couple of different objects
-    TestEntry entry1("test1", RRClass(42));
-    TestEntry entry2("test1", RRClass(24));
-    TestEntry entry3("test2", RRClass(42));
+    TestEntry entry1(name1, RRClass(42));
+    TestEntry entry2(name1, RRClass(24));
+    TestEntry entry3(name2, RRClass(42));
 
     // Create corresponding hash key objects
-    HashKey key1(entry1.getName(), entry1.getClass());
-    HashKey key2(entry2.getName(), entry2.getClass());
-    HashKey key3(entry3.getName(), entry3.getClass());
+    HashKey key1(name1, entry1.getClass());
+    HashKey key2(name1, entry2.getClass());
+    HashKey key3(name2, entry3.getClass());
     
     // Perform the comparison
     NsasEntryCompare<TestEntry> compare;

Modified: branches/trac327/src/lib/nsas/tests/random_number_generator_unittest.cc
==============================================================================
--- branches/trac327/src/lib/nsas/tests/random_number_generator_unittest.cc (original)
+++ branches/trac327/src/lib/nsas/tests/random_number_generator_unittest.cc Mon Dec 20 20:53:09 2010
@@ -13,6 +13,7 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 // $Id$
+#include <config.h>
 
 #include <gtest/gtest.h>
 #include <boost/shared_ptr.hpp>
@@ -52,64 +53,64 @@
     const static int max_ = 10;
 };
 
+// Some validation tests will incur performance penalty, so the tests are
+// made only in "debug" version with assert(). But if NDEBUG is defined
+// the tests will be failed since assert() is non-op in non-debug version.
+// The "#ifndef NDEBUG" is added to make the tests be performed only in
+// non-debug environment.
+// Note: the death test is not supported by all platforms.  We need to
+// compile tests using it selectively.
+#if !defined(NDEBUG) && defined(GTEST_HAS_DEATH_TEST)
+// Test of the constructor
+TEST_F(UniformRandomIntegerGeneratorTest, Constructor) {
+    // The range must be min<=max
+    ASSERT_DEATH(UniformRandomIntegerGenerator(3, 2), "");
+}
+#endif
+
+// Test of the generated integers are in the range [min, max]
+TEST_F(UniformRandomIntegerGeneratorTest, IntegerRange) {
+    vector<int> numbers;
+
+    // Generate a lot of random integers
+    for (int i = 0; i < max()*10; ++i) {
+        numbers.push_back(gen());
+    }
+
+    // Remove the duplicated values
+    sort(numbers.begin(), numbers.end());
+    vector<int>::iterator it = unique(numbers.begin(), numbers.end());
+
+    // make sure the numbers are in range [min, max]
+    ASSERT_EQ(it - numbers.begin(), max() - min() + 1); 
+}
+
+/// \brief Test Fixture Class for weighted random number generator
+class WeightedRandomIntegerGeneratorTest : public ::testing::Test {
+public:
+    WeightedRandomIntegerGeneratorTest()
+    { }
+
+    virtual ~WeightedRandomIntegerGeneratorTest()
+    { }
+};
+
+// Test of the weighted random number generator constructor
+TEST_F(WeightedRandomIntegerGeneratorTest, Constructor) {
+    vector<double> probabilities;
+
+    // If no probabilities is provided, the smallest integer will always be generated
+    WeightedRandomIntegerGenerator gen(probabilities, 123);
+    for (int i = 0; i < 100; ++i) {
+        ASSERT_EQ(gen(), 123);
+    }
+
 /// Some validation tests will incur performance penalty, so the tests are
 /// made only in "debug" version with assert(). But if NDEBUG is defined
 /// the tests will be failed since assert() is non-op in non-debug version.
 /// The "#ifndef NDEBUG" is added to make the tests be performed only in
 /// non-debug environment.
-#ifndef NDEBUG
-// Test of the constructor
-TEST_F(UniformRandomIntegerGeneratorTest, Constructor) {
-    // The range must be min<=max
-    ASSERT_DEATH(UniformRandomIntegerGenerator(3, 2), "");
-}
-#endif
-
-// Test of the generated integers are in the range [min, max]
-TEST_F(UniformRandomIntegerGeneratorTest, IntegerRange) {
-    vector<int> numbers;
-
-    // Generate a lot of random integers
-    for(int i = 0; i < max()*10; ++i){
-        numbers.push_back(gen());
-    }
-
-    // Remove the duplicated values
-    sort(numbers.begin(), numbers.end());
-    vector<int>::iterator it = unique(numbers.begin(), numbers.end());
-
-    // make sure the numbers are in range [min, max]
-    ASSERT_EQ(it - numbers.begin(), max() - min() + 1); 
-}
-
-
-/// \brief Test Fixture Class for weighted random number generator
-class WeightedRandomIntegerGeneratorTest : public ::testing::Test {
-public:
-    WeightedRandomIntegerGeneratorTest()
-    { }
-
-    virtual ~WeightedRandomIntegerGeneratorTest()
-    { }
-};
-
-// Test of the weighted random number generator constructor
-TEST_F(WeightedRandomIntegerGeneratorTest, Constructor) 
-{
-    vector<double> probabilities;
-
-    // If no probabilities is provided, the smallest integer will always be generated
-    WeightedRandomIntegerGenerator gen(probabilities, 123);
-    for(int i = 0; i < 100; ++i){
-        ASSERT_EQ(gen(), 123);
-    }
-
-/// Some validation tests will incur performance penalty, so the tests are
-/// made only in "debug" version with assert(). But if NDEBUG is defined
-/// the tests will be failed since assert() is non-op in non-debug version.
-/// The "#ifndef NDEBUG" is added to make the tests be performed only in
-/// non-debug environment.
-#ifndef NDEBUG
+#if !defined(NDEBUG) && defined(GTEST_HAS_DEATH_TEST)
     //The probability must be >= 0
     probabilities.push_back(-0.1);
     probabilities.push_back(1.1);
@@ -137,8 +138,7 @@
 }
 
 // Test the randomization of the generator
-TEST_F(WeightedRandomIntegerGeneratorTest, WeightedRandomization) 
-{
+TEST_F(WeightedRandomIntegerGeneratorTest, WeightedRandomization) {
     const int repeats = 100000;
     // We repeat the simulation for N=repeats times
     // for each probability p, its average is mu = N*p
@@ -156,10 +156,13 @@
         WeightedRandomIntegerGenerator gen(probabilities);
         int c1 = 0;
         int c2 = 0;
-        for(int i = 0; i < repeats; ++i){
+        for (int i = 0; i < repeats; ++i){
             int n = gen();
-            if(n == 0) ++c1;
-            else if(n == 1) ++c2;
+            if (n == 0) {
+                ++c1;
+            } else if (n == 1) {
+                ++c2;
+            }
         }
         double mu = repeats * p;
         double sigma = sqrt(repeats * p * (1 - p));
@@ -176,10 +179,13 @@
         probabilities.push_back(p1);
         probabilities.push_back(p2);
         WeightedRandomIntegerGenerator gen(probabilities);
-        for(int i = 0; i < repeats; ++i){
+        for (int i = 0; i < repeats; ++i) {
             int n = gen();
-            if(n == 0) ++c1;
-            else if(n == 1) ++c2;
+            if (n == 0) {
+                ++c1;
+            } else if (n == 1) {
+                ++c2;
+            }
         }
         double mu1 = repeats * p1;
         double mu2 = repeats * p2;
@@ -198,10 +204,13 @@
         probabilities.push_back(p1);
         probabilities.push_back(p2);
         WeightedRandomIntegerGenerator gen(probabilities);
-        for(int i = 0; i < repeats; ++i){
+        for (int i = 0; i < repeats; ++i) {
             int n = gen();
-            if(n == 0) ++c1;
-            else if(n == 1) ++c2;
+            if (n == 0) {
+                ++c1;
+            } else if (n == 1) {
+                ++c2;
+            }
         }
         double mu1 = repeats * p1;
         double mu2 = repeats * p2;
@@ -223,11 +232,15 @@
         probabilities.push_back(p2);
         probabilities.push_back(p3);
         WeightedRandomIntegerGenerator gen(probabilities);
-        for(int i = 0; i < repeats; ++i){
+        for (int i = 0; i < repeats; ++i){
             int n = gen();
-            if(n == 0) ++c1;
-            else if(n == 1) ++c2;
-            else if(n == 2) ++c3;
+            if (n == 0) {
+                ++c1;
+            } else if (n == 1) {
+                ++c2;
+            } else if (n == 2) {
+                ++c3;
+            }
         }
         double mu1 = repeats * p1;
         double mu2 = repeats * p2;
@@ -242,8 +255,7 @@
 }
 
 // Test the reset function of generator
-TEST_F(WeightedRandomIntegerGeneratorTest, ResetProbabilities) 
-{
+TEST_F(WeightedRandomIntegerGeneratorTest, ResetProbabilities) {
     const int repeats = 100000;
     vector<double> probabilities;
     int c1 = 0;
@@ -253,10 +265,13 @@
     probabilities.push_back(p1);
     probabilities.push_back(p2);
     WeightedRandomIntegerGenerator gen(probabilities);
-    for(int i = 0; i < repeats; ++i){
+    for (int i = 0; i < repeats; ++i) {
         int n = gen();
-        if(n == 0) ++c1;
-        else if(n == 1) ++c2;
+        if (n == 0) {
+            ++c1;
+        } else if (n == 1) {
+            ++c2;
+        }
     }
     double mu1 = repeats * p1;
     double mu2 = repeats * p2;
@@ -273,10 +288,13 @@
     probabilities.push_back(p1);
     probabilities.push_back(p2);
     gen.reset(probabilities);
-    for(int i = 0; i < repeats; ++i){
+    for (int i = 0; i < repeats; ++i) {
         int n = gen();
-        if(n == 0) ++c1;
-        else if(n == 1) ++c2;
+        if (n == 0) {
+            ++c1;
+        } else if (n == 1) {
+            ++c2;
+        }
     }
     mu1 = repeats * p1;
     mu2 = repeats * p2;

Modified: branches/trac327/src/lib/nsas/tests/run_unittests.cc
==============================================================================
--- branches/trac327/src/lib/nsas/tests/run_unittests.cc (original)
+++ branches/trac327/src/lib/nsas/tests/run_unittests.cc Mon Dec 20 20:53:09 2010
@@ -13,6 +13,7 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 // $Id: run_unittests.cc 3020 2010-09-26 03:47:26Z jinmei $
+#include <config.h>
 
 #include <gtest/gtest.h>
 

Modified: branches/trac327/src/lib/nsas/tests/zone_entry_unittest.cc
==============================================================================
--- branches/trac327/src/lib/nsas/tests/zone_entry_unittest.cc (original)
+++ branches/trac327/src/lib/nsas/tests/zone_entry_unittest.cc Mon Dec 20 20:53:09 2010
@@ -13,6 +13,7 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 // $Id$
+#include <config.h>
 
 #include <gtest/gtest.h>
 #include <boost/shared_ptr.hpp>
@@ -35,7 +36,6 @@
 using namespace isc::nsas;
 using namespace asiolink;
 using namespace std;
-using namespace boost;
 using namespace isc::dns;
 
 namespace {
@@ -43,10 +43,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 +67,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 +86,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 +102,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 +115,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 +148,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 +192,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 +220,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 +283,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 +343,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 +396,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 +455,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 +494,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 +518,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 +567,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 +593,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 +603,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 +622,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 +651,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 +666,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())));
 
@@ -712,7 +712,7 @@
     for (size_t i(0); i < 3; ++ i) {
         double mu = repeats * ps[i];
         double sigma = sqrt(repeats * ps[i] * (1 - ps[i]));
-        ASSERT_TRUE(fabs(counts[i] - mu < 4 * sigma));
+        ASSERT_TRUE(fabs(counts[i] - mu) < 4 * sigma);
     }
 
     // reset the environment

Modified: branches/trac327/src/lib/nsas/zone_entry.cc
==============================================================================
--- branches/trac327/src/lib/nsas/zone_entry.cc (original)
+++ branches/trac327/src/lib/nsas/zone_entry.cc Mon Dec 20 20:53:09 2010
@@ -14,18 +14,19 @@
 
 // $id$
 
+#include <config.h>
+
 #include "zone_entry.h"
 #include "address_request_callback.h"
 #include "nameserver_entry.h"
 
 #include <algorithm>
 #include <boost/foreach.hpp>
-#include <boost/random.hpp>
+#include <boost/bind.hpp>
 #include <dns/rrttl.h>
 #include <dns/rdataclass.h>
 
 using namespace std;
-using namespace boost;
 
 namespace isc {
 
@@ -48,16 +49,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 +78,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 +92,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
@@ -137,7 +138,7 @@
                             string ns_name_str(ns_name.toText());
                             pair<bool, NameserverPtr> from_hash(
                                 entry_->nameserver_table_->getOrAdd(HashKey(
-                                ns_name_str, entry_->class_code_), bind(
+                                ns_name_str, entry_->class_code_), boost::bind(
                                 newNs, &ns_name_str, &entry_->class_code_)));
                             // Make it at the front of the list
                             if (from_hash.first) {
@@ -203,7 +204,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 +238,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 +338,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 +353,7 @@
             entry_->process(family_, ns);
         }
     private:
-        shared_ptr<ZoneEntry> entry_;
+        boost::shared_ptr<ZoneEntry> entry_;
         AddressFamily family_;
 };
 
@@ -373,7 +374,7 @@
 
 void
 ZoneEntry::process(AddressFamily family,
-    const shared_ptr<NameserverEntry>& nameserver)
+    const boost::shared_ptr<NameserverEntry>& nameserver)
 {
     Lock lock(mutex_);
     switch (getState()) {
@@ -516,7 +517,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);
     }

Modified: branches/trac327/src/lib/nsas/zone_entry.h
==============================================================================
--- branches/trac327/src/lib/nsas/zone_entry.h (original)
+++ branches/trac327/src/lib/nsas/zone_entry.h Mon Dec 20 20:53:09 2010
@@ -16,6 +16,18 @@
 
 #ifndef __ZONE_ENTRY_H
 #define __ZONE_ENTRY_H
+
+// Workaround for a problem with boost and sunstudio 5.10
+// There is a version check in there that appears wrong,
+// which makes including boost/thread.hpp fail
+// This will probably be fixed in a future version of boost,
+// in which case this part can be removed then
+#ifdef NEED_SUNPRO_WORKAROUND
+#if defined(__SUNPRO_CC) && __SUNPRO_CC == 0x5100
+#undef __SUNPRO_CC
+#define __SUNPRO_CC 0x5090
+#endif
+#endif // NEED_SUNPRO_WORKAROUND
 
 #include <string>
 #include <vector>




More information about the bind10-changes mailing list