Browse Source

[2470] use MasterLoader instead of masterLoad for in-memory loading from text.

there's one compatibility issus in unit tests in auth InMemoryQueryTest;
some owner names in the test zone file must be escaped.  It's fixed in this
commit, too.
JINMEI Tatuya 12 years ago
parent
commit
fe03e032e3

+ 3 - 3
src/bin/auth/tests/testdata/example.zone

@@ -55,11 +55,11 @@ t.example.com. 3600 IN NSEC b.*.t.example.com. A NSEC RRSIG
 ;; (.no.example.com. (qname, NXDOMAIN)
 ;; ).no.example.com. (exist)
 ;; *.no.example.com. (best possible wildcard, not exist)
-).no.example.com. 3600 IN AAAA 2001:db8::53
+\).no.example.com. 3600 IN AAAA 2001:db8::53
 ;; NSEC records.
 example.com. 3600 IN NSEC cname.example.com. NS SOA NSEC RRSIG
-mx.example.com. 3600 IN NSEC ).no.example.com. MX NSEC RRSIG
-).no.example.com. 3600 IN NSEC nz.no.example.com. AAAA NSEC RRSIG
+mx.example.com. 3600 IN NSEC \).no.example.com. MX NSEC RRSIG
+\).no.example.com. 3600 IN NSEC nz.no.example.com. AAAA NSEC RRSIG
 ;; We'll also test the case where a single NSEC proves both NXDOMAIN and the
 ;; non existence of wildcard.  The following records will be used for that
 ;; test.

+ 19 - 9
src/lib/datasrc/memory/zone_data_loader.cc

@@ -12,15 +12,18 @@
 // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 // PERFORMANCE OF THIS SOFTWARE.
 
+#include <datasrc/master_loader_callbacks.h>
 #include <datasrc/memory/zone_data_loader.h>
 #include <datasrc/memory/zone_data_updater.h>
 #include <datasrc/memory/logger.h>
 #include <datasrc/memory/segment_object_holder.h>
 #include <datasrc/memory/util_internal.h>
 
+#include <dns/master_loader.h>
+#include <dns/rrcollator.h>
 #include <dns/rdataclass.h>
 #include <dns/rrset.h>
-#include <dns/masterload.h>
+#include <dns/rrcollator.h>
 
 #include <boost/foreach.hpp>
 #include <boost/bind.hpp>
@@ -181,18 +184,25 @@ loadZoneDataInternal(util::MemorySegment& mem_sgmt,
     return (holder.release());
 }
 
-// A wrapper for dns::masterLoad used by loadZoneData() below.  Essentially it
-// converts the two callback types.  Note the mostly redundant wrapper of
+// A wrapper for dns::MasterLoader used by loadZoneData() below.  Essentially
+// it converts the two callback types.  Note the mostly redundant wrapper of
 // boost::bind.  It converts function<void(ConstRRsetPtr)> to
-// function<void(RRsetPtr)> (masterLoad() expects the latter).  SunStudio
+// function<void(RRsetPtr)> (MasterLoader expects the latter).  SunStudio
 // doesn't seem to do this conversion if we just pass 'callback'.
 void
-masterLoadWrapper(const char* const filename, const Name& origin,
-                  const RRClass& zone_class, LoadCallback callback)
+masterLoaderWrapper(const char* const filename, const Name& origin,
+                    const RRClass& zone_class, LoadCallback callback)
 {
+    bool load_ok = false;       // (we don't use it)
+    dns::RRCollator collator(boost::bind(callback, _1));
+
     try {
-        masterLoad(filename, origin, zone_class, boost::bind(callback, _1));
-    } catch (MasterLoadError& e) {
+        dns::MasterLoader(filename, origin, zone_class,
+                          createMasterLoaderCallbacks(origin, zone_class,
+                                                      &load_ok),
+                          collator.getCallback()).load();
+        collator.finish();
+    } catch (const dns::MasterLoaderError& e) {
         isc_throw(ZoneLoaderException, e.what());
     }
 }
@@ -215,7 +225,7 @@ loadZoneData(util::MemorySegment& mem_sgmt,
              const std::string& zone_file)
 {
      return (loadZoneDataInternal(mem_sgmt, rrclass, zone_name,
-                                 boost::bind(masterLoadWrapper,
+                                 boost::bind(masterLoaderWrapper,
                                              zone_file.c_str(),
                                              zone_name, rrclass,
                                              _1)));