Browse Source

[2219] move memory leak check from in-memory client destructor to client list.

now the memory segment is shared for multiple in-memory zones, we cannot check
it in each client.
JINMEI Tatuya 12 years ago
parent
commit
a16ecb53a5

+ 10 - 0
src/lib/datasrc/client_list.cc

@@ -69,6 +69,16 @@ ConfigurableClientList::ConfigurableClientList(const RRClass& rrclass) :
     allow_cache_(false)
     allow_cache_(false)
 {}
 {}
 
 
+ConfigurableClientList::~ConfigurableClientList() {
+    // Explicitly clear the contained data source clients, and check memory
+    // leak.  assert() (with abort on failure) may be too harsh, but
+    // it's probably better to find more leaks initially.  Once it's stabilized
+    // we should probably revisit it.
+
+    data_sources_.clear();
+    assert(mem_sgmt_->allMemoryDeallocated());
+}
+
 void
 void
 ConfigurableClientList::configure(const ConstElementPtr& config,
 ConfigurableClientList::configure(const ConstElementPtr& config,
                                   bool allow_cache)
                                   bool allow_cache)

+ 3 - 0
src/lib/datasrc/client_list.h

@@ -220,6 +220,9 @@ public:
     /// \param rrclass For which class the list should work.
     /// \param rrclass For which class the list should work.
     ConfigurableClientList(const isc::dns::RRClass& rrclass);
     ConfigurableClientList(const isc::dns::RRClass& rrclass);
 
 
+    /// \brief Destructor
+    virtual ~ConfigurableClientList();
+
     /// \brief Exception thrown when there's an error in configuration.
     /// \brief Exception thrown when there's an error in configuration.
     class ConfigurationError : public Exception {
     class ConfigurationError : public Exception {
     public:
     public:

+ 0 - 3
src/lib/datasrc/memory/memory_client.cc

@@ -101,9 +101,6 @@ public:
         FileNameTree::destroy(mem_sgmt_, file_name_tree_, deleter);
         FileNameTree::destroy(mem_sgmt_, file_name_tree_, deleter);
 
 
         ZoneTable::destroy(mem_sgmt_, zone_table_, rrclass_);
         ZoneTable::destroy(mem_sgmt_, zone_table_, rrclass_);
-
-        // see above for the assert().
-        assert(mem_sgmt_.allMemoryDeallocated());
     }
     }
 
 
     util::MemorySegment& mem_sgmt_;
     util::MemorySegment& mem_sgmt_;