Blame SOURCES/bind-9.11-rh1790879.patch

57726f
From f9a37643528dc83b981156d0a1cf52e3d9a38322 Mon Sep 17 00:00:00 2001
57726f
From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= <michal@isc.org>
57726f
Date: Mon, 2 Dec 2019 15:15:06 +0100
57726f
Subject: [PATCH] Fix GeoIP2 memory leak upon reconfiguration
57726f
57726f
Loaded GeoIP2 databases are only released when named is shut down, but
57726f
not during server reconfiguration.  This causes memory to be leaked
57726f
every time "rndc reconfig" or "rndc reload" is used, as long as any
57726f
GeoIP2 database is in use.  Fix by releasing any loaded GeoIP2 databases
57726f
before reloading them.  Do not call dns_geoip_shutdown() until server
57726f
shutdown as that function releases the memory context used for caching
57726f
GeoIP2 lookup results.
57726f
57726f
(cherry picked from commit 670afbe84a87e202fa795079d9d6d1639bcf391d)
57726f
(cherry picked from commit 95a5589fa2ac3956fecfef780158a2745718c860)
57726f
---
57726f
 bin/named/geoip.c  | 2 --
57726f
 bin/named/server.c | 6 ++++++
57726f
 2 files changed, 6 insertions(+), 2 deletions(-)
57726f
57726f
diff --git a/bin/named/geoip.c b/bin/named/geoip.c
57726f
index d560f8fbcf..0b11f6b803 100644
57726f
--- a/bin/named/geoip.c
57726f
+++ b/bin/named/geoip.c
57726f
@@ -243,6 +243,4 @@ ns_geoip_shutdown(void) {
57726f
 		ns_g_geoip->domain = NULL;
57726f
 	}
57726f
 #endif /* HAVE_GEOIP2 */
57726f
-
57726f
-	dns_geoip_shutdown();
57726f
 }
57726f
diff --git a/bin/named/server.c b/bin/named/server.c
57726f
index ebe7ad4702..4d7d2210ff 100644
57726f
--- a/bin/named/server.c
57726f
+++ b/bin/named/server.c
57726f
@@ -72,6 +72,7 @@
57726f
 #include <dns/events.h>
57726f
 #include <dns/forward.h>
57726f
 #include <dns/fixedname.h>
57726f
+#include <dns/geoip.h>
57726f
 #include <dns/journal.h>
57726f
 #include <dns/keytable.h>
57726f
 #include <dns/keyvalues.h>
57726f
@@ -7684,6 +7685,10 @@ load_configuration(const char *filename, ns_server_t *server,
57726f
 	isc__socketmgr_setreserved(ns_g_socketmgr, reserved);
57726f
 
57726f
 #if defined(HAVE_GEOIP) || defined(HAVE_GEOIP2)
57726f
+	/*
57726f
+	 * Release any previously opened GeoIP2 databases.
57726f
+	 */
57726f
+	ns_geoip_shutdown();
57726f
 	/*
57726f
 	 * Initialize GeoIP databases from the configured location.
57726f
 	 * This should happen before configuring any ACLs, so that we
57726f
@@ -9030,6 +9035,7 @@ shutdown_server(isc_task_t *task, isc_event_t *event) {
57726f
 #endif
57726f
 #if defined(HAVE_GEOIP) || defined(HAVE_GEOIP2)
57726f
 	ns_geoip_shutdown();
57726f
+	dns_geoip_shutdown();
57726f
 #endif /* HAVE_GEOIP || HAVE_GEOIP2 */
57726f
 
57726f
 	dns_db_detach(&server->in_roothints);
57726f
-- 
57726f
2.21.1
57726f