]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix GeoIP2 memory leak upon reconfiguration
authorMichał Kępień <michal@isc.org>
Mon, 2 Dec 2019 14:15:06 +0000 (15:15 +0100)
committerMichał Kępień <michal@isc.org>
Mon, 2 Dec 2019 14:27:00 +0000 (15:27 +0100)
Loaded GeoIP2 databases are only released when named is shut down, but
not during server reconfiguration.  This causes memory to be leaked
every time "rndc reconfig" or "rndc reload" is used, as long as any
GeoIP2 database is in use.  Fix by releasing any loaded GeoIP2 databases
before reloading them.  Do not call dns_geoip_shutdown() until server
shutdown as that function releases the memory context used for caching
GeoIP2 lookup results.

(cherry picked from commit 670afbe84a87e202fa795079d9d6d1639bcf391d)

bin/named/geoip.c
bin/named/server.c

index d560f8fbcfa2c39af6b7e8f1fa15d9ab4c8f5bcd..0b11f6b80387e29b531e1a8eda608e70d79b48c1 100644 (file)
@@ -243,6 +243,4 @@ ns_geoip_shutdown(void) {
                ns_g_geoip->domain = NULL;
        }
 #endif /* HAVE_GEOIP2 */
-
-       dns_geoip_shutdown();
 }
index 0e7b3b083e253582d2d9106c95202d47417100b0..5a860e4288ad7622f3ab56020839844f0c1297a6 100644 (file)
@@ -71,6 +71,7 @@
 #include <dns/events.h>
 #include <dns/forward.h>
 #include <dns/fixedname.h>
+#include <dns/geoip.h>
 #include <dns/journal.h>
 #include <dns/keytable.h>
 #include <dns/keyvalues.h>
@@ -7636,6 +7637,10 @@ load_configuration(const char *filename, ns_server_t *server,
        isc__socketmgr_setreserved(ns_g_socketmgr, reserved);
 
 #if defined(HAVE_GEOIP) || defined(HAVE_GEOIP2)
+       /*
+        * Release any previously opened GeoIP2 databases.
+        */
+       ns_geoip_shutdown();
        /*
         * Initialize GeoIP databases from the configured location.
         * This should happen before configuring any ACLs, so that we
@@ -8967,6 +8972,7 @@ shutdown_server(isc_task_t *task, isc_event_t *event) {
 #endif
 #if defined(HAVE_GEOIP) || defined(HAVE_GEOIP2)
        ns_geoip_shutdown();
+       dns_geoip_shutdown();
 #endif /* HAVE_GEOIP || HAVE_GEOIP2 */
 
        dns_db_detach(&server->in_roothints);