[svn] commit: r1395 - in /trunk/src/lib/auth: data_source.cc query.h tests/Makefile.am tests/query_unittest.cc

BIND 10 source code commits bind10-changes at lists.isc.org
Sun Mar 14 06:31:58 UTC 2010


Author: jinmei
Date: Sun Mar 14 06:31:57 2010
New Revision: 1395

Log:
changed the types of QueryTask::qclass/qtype/section from reference to real
object so that they'll be valid regardless of how the QueryTask is constructed.

In the current usage patter the previous behavior is probably safe, but
since this object is passed beyond a scope of a single function, there's
always a risk of retaining a stale reference to a temporary object.  This fix
solves that potential problem.

Note that copy of these member objects should be cheap because in this sense
they are mostly native integer types.

Added:
    trunk/src/lib/auth/tests/query_unittest.cc   (with props)
Modified:
    trunk/src/lib/auth/data_source.cc
    trunk/src/lib/auth/query.h
    trunk/src/lib/auth/tests/Makefile.am

Modified: trunk/src/lib/auth/data_source.cc
==============================================================================
--- trunk/src/lib/auth/data_source.cc (original)
+++ trunk/src/lib/auth/data_source.cc Sun Mar 14 06:31:57 2010
@@ -418,14 +418,14 @@
         return (DataSrc::SUCCESS);
     }
 
-    int nlen = task->qname.getLabelCount();
-    int diff = nlen - zonename->getLabelCount();
+    const int nlen = task->qname.getLabelCount();
+    const int diff = nlen - zonename->getLabelCount();
     if (diff < 1) {
         return (DataSrc::SUCCESS);
     }
 
     RRsetList wild;
-    Name star("*");
+    const Name star("*");
     uint32_t rflags = 0;
 
     for (int i = 1; i <= diff; ++i) {

Modified: trunk/src/lib/auth/query.h
==============================================================================
--- trunk/src/lib/auth/query.h (original)
+++ trunk/src/lib/auth/query.h Sun Mar 14 06:31:57 2010
@@ -19,17 +19,14 @@
 
 #include <boost/shared_ptr.hpp>
 
+#include <dns/name.h>
+#include <dns/message.h>
+#include <dns/rrtype.h>
+#include <dns/rrclass.h>
+
 #include <queue>
 
 namespace isc {
-
-namespace dns {
-class Name;
-class Message;
-class Section;
-class RRClass;
-class RRType;
-}
 
 namespace auth {
 
@@ -47,12 +44,12 @@
     // The standard query tuple: qname/qclass/qtype.
     // Note that qtype is ignored in the GLUE_QUERY/NOGLUE_QUERY case.
     const isc::dns::Name qname;
-    const isc::dns::RRClass& qclass;
-    const isc::dns::RRType& qtype;
+    const isc::dns::RRClass qclass;
+    const isc::dns::RRType qtype;
 
     // The section of the reply into which the data should be
     // written after it has been fetched from the data source.
-    const isc::dns::Section& section;
+    const isc::dns::Section section;
 
     // The op field indicates the operation to be carried out by
     // this query task:

Modified: trunk/src/lib/auth/tests/Makefile.am
==============================================================================
--- trunk/src/lib/auth/tests/Makefile.am (original)
+++ trunk/src/lib/auth/tests/Makefile.am Sun Mar 14 06:31:57 2010
@@ -10,6 +10,7 @@
 run_unittests_SOURCES += datasrc_unittest.cc
 run_unittests_SOURCES += sqlite3_unittest.cc
 run_unittests_SOURCES += static_unittest.cc
+run_unittests_SOURCES += query_unittest.cc
 run_unittests_SOURCES += test_datasrc.h test_datasrc.cc
 run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
 run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS)




More information about the bind10-changes mailing list