MCPcopy Create free account
hub / github.com/apache/trafficserver / initLibrary

Method initLibrary

plugins/header_rewrite/conditions_geo_maxmind.cc:35–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33MMDB_s *gMaxMindDB = nullptr;
34
35void
36MMConditionGeo::initLibrary(const std::string &path)
37{
38 if (path.empty()) {
39 Dbg(pi_dbg_ctl, "Empty MaxMind db path specified. Not initializing!");
40 return;
41 }
42
43 if (gMaxMindDB != nullptr) {
44 Dbg(pi_dbg_ctl, "Maxmind library already initialized");
45 return;
46 }
47
48 gMaxMindDB = new MMDB_s;
49
50 int status = MMDB_open(path.c_str(), MMDB_MODE_MMAP, gMaxMindDB);
51 if (MMDB_SUCCESS != status) {
52 Dbg(pi_dbg_ctl, "Cannot open %s - %s", path.c_str(), MMDB_strerror(status));
53 delete gMaxMindDB;
54 return;
55 }
56 Dbg(pi_dbg_ctl, "Loaded %s", path.c_str());
57}
58
59std::string
60MMConditionGeo::get_geo_string(const sockaddr *addr) const

Callers

nothing calls this directly

Calls 2

emptyMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected