From: JINMEI Tatuya Date: Tue, 11 Dec 2012 03:22:01 +0000 (-0800) Subject: [2470] use MasterLoader instead of masterLoad for in-memory loading from text. X-Git-Tag: bind10-1.0.0-beta-release~15^2~12 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fe03e032e35e80420588b047a208b76016c3f440;p=thirdparty%2Fkea.git [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. --- diff --git a/src/bin/auth/tests/testdata/example.zone b/src/bin/auth/tests/testdata/example.zone index efbbaf23e9..af0b6188cc 100644 --- a/src/bin/auth/tests/testdata/example.zone +++ b/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. diff --git a/src/lib/datasrc/memory/zone_data_loader.cc b/src/lib/datasrc/memory/zone_data_loader.cc index 051acc30d5..36b2920b97 100644 --- a/src/lib/datasrc/memory/zone_data_loader.cc +++ b/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 #include #include #include #include #include +#include +#include #include #include -#include +#include #include #include @@ -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 to -// function (masterLoad() expects the latter). SunStudio +// function (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)));