BIND 10 trac2432, updated. bdf19add5fca40dbc91c6ce4c0d87d8bb6080bde [2432] Return status in removeRRset()
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Jan 3 10:42:33 UTC 2013
The branch, trac2432 has been updated
via bdf19add5fca40dbc91c6ce4c0d87d8bb6080bde (commit)
from cfbb9eada0a6e0ff8a2faead73f870d3ca3400fc (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit bdf19add5fca40dbc91c6ce4c0d87d8bb6080bde
Author: Mukund Sivaraman <muks at isc.org>
Date: Thu Jan 3 16:07:56 2013 +0530
[2432] Return status in removeRRset()
-----------------------------------------------------------------------
Summary of changes:
src/lib/dns/rrset_collection.cc | 11 +++++++++--
src/lib/dns/rrset_collection.h | 5 ++++-
src/lib/dns/tests/rrset_collection_unittest.cc | 11 +++++++++--
3 files changed, 22 insertions(+), 5 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/lib/dns/rrset_collection.cc b/src/lib/dns/rrset_collection.cc
index 53f9702..8ee85be 100644
--- a/src/lib/dns/rrset_collection.cc
+++ b/src/lib/dns/rrset_collection.cc
@@ -115,12 +115,19 @@ RRsetCollection::find(const Name& name, const RRClass& rrclass,
return (ConstRRsetPtr());
}
-void
+bool
RRsetCollection::removeRRset(const Name& name, const RRClass& rrclass,
const RRType& rrtype)
{
const CollectionKey key(rrclass, rrtype, name);
- rrsets_.erase(key);
+
+ CollectionMap::iterator it = rrsets_.find(key);
+ if (it == rrsets_.end()) {
+ return (false);
+ }
+
+ rrsets_.erase(it);
+ return (true);
}
RRsetCollectionBase::IterPtr
diff --git a/src/lib/dns/rrset_collection.h b/src/lib/dns/rrset_collection.h
index fe9152c..b44faab 100644
--- a/src/lib/dns/rrset_collection.h
+++ b/src/lib/dns/rrset_collection.h
@@ -87,7 +87,10 @@ public:
///
/// RRset(s) matching the \c name, \c rrclass and \c rrtype are
/// removed from the collection.
- void removeRRset(const isc::dns::Name& name,
+ ///
+ /// \returns \c true if a matching RRset was deleted, \c false if no
+ /// such RRset exists.
+ bool removeRRset(const isc::dns::Name& name,
const isc::dns::RRClass& rrclass,
const isc::dns::RRType& rrtype);
diff --git a/src/lib/dns/tests/rrset_collection_unittest.cc b/src/lib/dns/tests/rrset_collection_unittest.cc
index a4834e9..5c0caed 100644
--- a/src/lib/dns/tests/rrset_collection_unittest.cc
+++ b/src/lib/dns/tests/rrset_collection_unittest.cc
@@ -152,13 +152,20 @@ doAddAndRemove(RRsetCollection& collection, const RRClass& rrclass) {
collection.addRRset(rrset);
}, isc::InvalidParameter);
- // Remove foo.example.org/A
- collection.removeRRset(Name("foo.example.org"), rrclass, RRType::A());
+ // Remove foo.example.org/A, which should pass
+ bool exists = collection.removeRRset(Name("foo.example.org"),
+ rrclass, RRType::A());
+ EXPECT_TRUE(exists);
// foo.example.org/A should not exist now
rrset_found = collection.find(Name("foo.example.org"), rrclass,
RRType::A());
EXPECT_FALSE(rrset_found);
+
+ // Removing foo.example.org/A should fail now
+ exists = collection.removeRRset(Name("foo.example.org"),
+ rrclass, RRType::A());
+ EXPECT_FALSE(exists);
}
TEST_F(RRsetCollectionTest, addAndRemove) {
More information about the bind10-changes
mailing list