Blame SOURCES/bind-9.11-rh1790879.patch

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