Copilot commented on code in PR #13042:
URL: https://github.com/apache/trafficserver/pull/13042#discussion_r3012597641
##########
plugins/header_rewrite/conditions_geo_maxmind.cc:
##########
@@ -23,17 +23,25 @@
#include <unistd.h>
#include <arpa/inet.h>
+#include <map>
+#include <mutex>
+#include <string>
#include "ts/ts.h"
#include "conditions_geo.h"
#include <maxminddb.h>
-MMDB_s *gMaxMindDB = nullptr;
-
enum class MmdbSchema { NESTED, FLAT };
-static MmdbSchema gMmdbSchema = MmdbSchema::NESTED;
+
+struct MmdbHandle {
+ MMDB_s db;
+ MmdbSchema schema = MmdbSchema::NESTED;
+};
+
+static std::map<std::string, MmdbHandle *> gMmdbCache;
+static std::mutex gMmdbCacheMutex;
Review Comment:
The new MaxMind handle cache stores heap-allocated MmdbHandle instances (and
their MMDB_s mmaps) for the lifetime of the process, but there is no
corresponding MMDB_close()/delete path. This can lead to unbounded growth in
mapped memory / open files if remap instances are recreated over time with
different --geo-db-path values. Consider adding reference counting and cleanup
(e.g., close+erase when the last RulesConfig using a path is deleted), or a
bounded/evicting cache with explicit teardown on shutdown/reload.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]