]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Catch exceptions in destructors
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 16 Feb 2017 12:59:28 +0000 (13:59 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 16 Mar 2017 17:35:58 +0000 (18:35 +0100)
(cherry picked from commit 737a287f2d73b1e5f7f0378d9ccb2ddb389f9299)

modules/geoipbackend/geoipbackend.cc
modules/ldapbackend/ldapbackend.cc
modules/luabackend/minimal.cc
modules/remotebackend/unixconnector.cc
pdns/communicator.hh
pdns/dnsdist-cache.cc
pdns/packetcache.cc

index a0ec878eeb9a12ba6e9492f0feb5a7c1355280b7..2f8f587160a33495ce93168227ef9029e2a55c19 100644 (file)
@@ -293,11 +293,15 @@ void GeoIPBackend::initialize() {
 }
 
 GeoIPBackend::~GeoIPBackend() {
-  WriteLock wl(&s_state_lock);
-  s_rc--;
-  if (s_rc == 0) { // last instance gets to cleanup
-    s_geoip_files.clear();
-    s_domains.clear();
+  try {
+    WriteLock wl(&s_state_lock);
+    s_rc--;
+    if (s_rc == 0) { // last instance gets to cleanup
+      s_geoip_files.clear();
+      s_domains.clear();
+    }
+  }
+  catch(...) {
   }
 }
 
index 3ed7574f01fd96a5d30b4fb993867e4086bf0350..0cca7883805a032d6b3142654de673a7412e6b0d 100644 (file)
@@ -105,7 +105,11 @@ LdapBackend::LdapBackend( const string &suffix )
 LdapBackend::~LdapBackend()
 {
         if( m_pldap != NULL ) { delete( m_pldap ); }
-        L << Logger::Notice << m_myname << " Ldap connection closed" << endl;
+        try {
+                L << Logger::Notice << m_myname << " Ldap connection closed" << endl;
+        }
+        catch (...) {
+        }
 }
 
 
index 0f8e3df481be9d5822373a5020c91f05f3ee0d38..ad365e49d01d9e057e079fc68599ed01e0f518c6 100644 (file)
@@ -61,7 +61,11 @@ LUABackend::LUABackend(const string &suffix) {
 }
 
 LUABackend::~LUABackend() {
-    L<<Logger::Info<<backend_name<<"Closeing..." << endl;
+    try {
+        L<<Logger::Info<<backend_name<<"Closing..." << endl;
+    }
+    catch (...) {
+    }
 
     lua_close(lua);
 }
index e657984cd96f021377e5da3c8bf7eadfe5025fe6..2e19ed1c8c68d98fc42abb8b2906c617cbfd1467 100644 (file)
@@ -44,8 +44,12 @@ UnixsocketConnector::UnixsocketConnector(std::map<std::string,std::string> optio
 
 UnixsocketConnector::~UnixsocketConnector() {
   if (this->connected) {
-     L<<Logger::Info<<"closing socket connection"<<endl;
-     close(fd);
+    try {
+      L<<Logger::Info<<"closing socket connection"<<endl;
+    }
+    catch (...) {
+    }
+    close(fd);
   }
 }
 
index 065dae952ce62b838be504a9e6e80fe1c8355567..a2975def351210263df6f628cace2c120943a53b 100644 (file)
@@ -224,8 +224,12 @@ private:
     
     ~RemoveSentinel()
     {
-      Lock l(&d_cc->d_lock);
-      d_cc->d_inprogress.erase(d_dn);
+      try {
+        Lock l(&d_cc->d_lock);
+        d_cc->d_inprogress.erase(d_dn);
+      }
+      catch(...) {
+      }
     }
     DNSName d_dn;
     CommunicatorClass* d_cc;
index 180c18c6590999293b8903070632c9ca85f754f1..dfd08942b952be342c266051f06be7d26aa5ceb5 100644 (file)
@@ -34,7 +34,11 @@ DNSDistPacketCache::DNSDistPacketCache(size_t maxEntries, uint32_t maxTTL, uint3
 
 DNSDistPacketCache::~DNSDistPacketCache()
 {
-  WriteLock l(&d_lock);
+  try {
+    WriteLock l(&d_lock);
+  }
+  catch(const PDNSException& pe) {
+  }
 }
 
 bool DNSDistPacketCache::cachedValueMatches(const CacheValue& cachedValue, const DNSName& qname, uint16_t qtype, uint16_t qclass, bool tcp)
index 331332cf1696e8236cdf1bc608943dcc83862a45..e8c03d0ee9ca2a12c518f47172fea102348fb524 100644 (file)
@@ -61,13 +61,17 @@ PacketCache::PacketCache()
 
 PacketCache::~PacketCache()
 {
-  //  WriteLock l(&d_mut);
-  vector<WriteLock*> locks;
-  for(auto& mc : d_maps) {
-    locks.push_back(new WriteLock(&mc.d_mut));
+  try {
+    //  WriteLock l(&d_mut);
+    vector<WriteLock*> locks;
+    for(auto& mc : d_maps) {
+      locks.push_back(new WriteLock(&mc.d_mut));
+    }
+    for(auto wl : locks) {
+      delete wl;
+    }
   }
-  for(auto wl : locks) {
-    delete wl;
+  catch(...) {
   }
 }