boost::optional<ComboAddress> g_dns64Prefix{boost::none};
DNSName g_dns64PrefixReverse;
unsigned int g_maxChainLength;
-std::shared_ptr<SyncRes::domainmap_t> g_initialDomainMap; // new threads needs this to be setup
+LockGuarded<std::shared_ptr<SyncRes::domainmap_t>> g_initialDomainMap; // new threads needs this to be setup
std::shared_ptr<NetmaskGroup> g_initialAllowFrom; // new thread needs to be setup with this
std::shared_ptr<NetmaskGroup> g_initialAllowNotifyFrom; // new threads need this to be setup
std::shared_ptr<notifyset_t> g_initialAllowNotifyFor; // new threads need this to be setup
info.setHandler();
info.start(currentThreadId, "web+stat", cpusMap, log);
+ if (::arg().mustDo("webserver")) {
+ extern void serveRustWeb();
+ serveRustWeb();
+ }
+
for (auto& tInfo : RecThreadInfo::infos()) {
tInfo.thread.join();
if (tInfo.exitCode != 0) {
}
g_networkTimeoutMsec = ::arg().asNum("network-timeout");
- std::tie(g_initialDomainMap, g_initialAllowNotifyFor) = parseZoneConfiguration(g_yamlSettings);
+ std::tie(*g_initialDomainMap.lock(), g_initialAllowNotifyFor) = parseZoneConfiguration(g_yamlSettings);
g_latencyStatSize = ::arg().asNum("latency-statistic-size");
auto& threadInfo = RecThreadInfo::self();
{
SyncRes tmp(g_now); // make sure it allocates tsstorage before we do anything, like primeHints or so..
- SyncRes::setDomainMap(g_initialDomainMap);
+ SyncRes::setDomainMap(*g_initialDomainMap.lock());
t_allowFrom = g_initialAllowFrom;
t_allowNotifyFrom = g_initialAllowNotifyFrom;
t_allowNotifyFor = g_initialAllowNotifyFor;
g_packetCache = std::make_unique<RecursorPacketCache>(g_maxPacketCacheEntries, ::arg().asNum("packetcache-shards"));
}
- if (::arg().mustDo("webserver")) {
- extern void serveRustWeb();
- serveRustWeb();
- }
ret = serviceMain(startupLog);
}
catch (const PDNSException& ae) {
extern uint32_t g_disthashseed;
extern int g_argc;
extern char** g_argv;
-extern std::shared_ptr<SyncRes::domainmap_t> g_initialDomainMap; // new threads needs this to be setup
+extern LockGuarded<std::shared_ptr<SyncRes::domainmap_t>> g_initialDomainMap; // new threads needs this to be setup
extern std::shared_ptr<NetmaskGroup> g_initialAllowFrom; // new thread needs to be setup with this
extern std::shared_ptr<NetmaskGroup> g_initialAllowNotifyFrom; // new threads need this to be setup
extern std::shared_ptr<notifyset_t> g_initialAllowNotifyFor; // new threads need this to be setup
for (const auto& entry : oldAndNewDomains) {
wipeCaches(entry, true, 0xffff);
}
- extern std::shared_ptr<SyncRes::domainmap_t> g_initialDomainMap; // XXX
- g_initialDomainMap = newDomainMap;
+ extern LockGuarded<std::shared_ptr<SyncRes::domainmap_t>> g_initialDomainMap; // XXX
+ *g_initialDomainMap.lock() = newDomainMap;
return "ok\n";
}
catch (const std::exception& e) {
Json document = req->json();
DNSName zonename = apiNameToDNSName(stringFromJson(document, "name"));
-
- const auto& iter = g_initialDomainMap->find(zonename);
- if (iter != g_initialDomainMap->cend()) {
- throw ApiException("Zone already exists");
+ {
+ auto map = g_initialDomainMap.lock();
+ const auto& iter = (*map)->find(zonename);
+ if (iter != (*map)->cend()) {
+ throw ApiException("Zone already exists");
+ }
+ doCreateZone(document);
}
-
- doCreateZone(document);
reloadZoneConfiguration(g_yamlSettings);
fillZone(zonename, resp);
resp->status = 201;
static void apiServerZonesGET(HttpRequest* /* req */, HttpResponse* resp)
{
Json::array doc;
- for (const auto& val : *g_initialDomainMap) {
+ auto lock = g_initialDomainMap.lock();
+ for (const auto& val : **lock) {
const SyncRes::AuthDomain& zone = val.second;
Json::array servers;
for (const auto& server : zone.d_servers) {