mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-01 06:55:30 +00:00
switch to using isc_loopmgr_pause() instead of task exclusive
change functions using isc_taskmgr_beginexclusive() to use isc_loopmgr_pause() instead. also, removed an unnecessary use of exclusive mode in named_server_tcptimeouts(). most functions that were implemented as task events because they needed to be running in a task to use exclusive mode have now been changed into loop callbacks instead. (the exception is catz, which is being changed in a separate commit because it's a particularly complex change.)
This commit is contained in:
@@ -16,9 +16,9 @@
|
|||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include <isc/async.h>
|
||||||
#include <isc/base64.h>
|
#include <isc/base64.h>
|
||||||
#include <isc/buffer.h>
|
#include <isc/buffer.h>
|
||||||
#include <isc/event.h>
|
|
||||||
#include <isc/file.h>
|
#include <isc/file.h>
|
||||||
#include <isc/mem.h>
|
#include <isc/mem.h>
|
||||||
#include <isc/mutex.h>
|
#include <isc/mutex.h>
|
||||||
@@ -30,13 +30,11 @@
|
|||||||
#include <isc/result.h>
|
#include <isc/result.h>
|
||||||
#include <isc/stdtime.h>
|
#include <isc/stdtime.h>
|
||||||
#include <isc/string.h>
|
#include <isc/string.h>
|
||||||
#include <isc/task.h>
|
|
||||||
#include <isc/util.h>
|
#include <isc/util.h>
|
||||||
|
|
||||||
#include <isccc/alist.h>
|
#include <isccc/alist.h>
|
||||||
#include <isccc/cc.h>
|
#include <isccc/cc.h>
|
||||||
#include <isccc/ccmsg.h>
|
#include <isccc/ccmsg.h>
|
||||||
#include <isccc/events.h>
|
|
||||||
#include <isccc/sexpr.h>
|
#include <isccc/sexpr.h>
|
||||||
#include <isccc/symtab.h>
|
#include <isccc/symtab.h>
|
||||||
#include <isccc/util.h>
|
#include <isccc/util.h>
|
||||||
@@ -375,24 +373,19 @@ cleanup:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
control_command(isc_task_t *task, isc_event_t *event) {
|
control_command(void *arg) {
|
||||||
controlconnection_t *conn = event->ev_arg;
|
controlconnection_t *conn = (controlconnection_t *)arg;
|
||||||
controllistener_t *listener = conn->listener;
|
controllistener_t *listener = conn->listener;
|
||||||
|
|
||||||
UNUSED(task);
|
|
||||||
|
|
||||||
if (atomic_load_acquire(&listener->controls->shuttingdown)) {
|
if (atomic_load_acquire(&listener->controls->shuttingdown)) {
|
||||||
conn_cleanup(conn);
|
conn_cleanup(conn);
|
||||||
isc_nmhandle_detach(&conn->cmdhandle);
|
isc_nmhandle_detach(&conn->cmdhandle);
|
||||||
goto done;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
conn->result = named_control_docommand(conn->request,
|
conn->result = named_control_docommand(conn->request,
|
||||||
listener->readonly, &conn->text);
|
listener->readonly, &conn->text);
|
||||||
control_respond(conn->cmdhandle, conn);
|
control_respond(conn->cmdhandle, conn);
|
||||||
|
|
||||||
done:
|
|
||||||
isc_event_free(&event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -400,7 +393,6 @@ control_recvmessage(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
|
|||||||
controlconnection_t *conn = (controlconnection_t *)arg;
|
controlconnection_t *conn = (controlconnection_t *)arg;
|
||||||
controllistener_t *listener = conn->listener;
|
controllistener_t *listener = conn->listener;
|
||||||
controlkey_t *key = NULL;
|
controlkey_t *key = NULL;
|
||||||
isc_event_t *event = NULL;
|
|
||||||
isccc_time_t sent;
|
isccc_time_t sent;
|
||||||
isccc_time_t exp;
|
isccc_time_t exp;
|
||||||
uint32_t nonce;
|
uint32_t nonce;
|
||||||
@@ -535,9 +527,7 @@ control_recvmessage(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
|
|||||||
* Trigger the command.
|
* Trigger the command.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
event = isc_event_allocate(listener->mctx, conn, NAMED_EVENT_COMMAND,
|
isc_async_run(named_g_mainloop, control_command, conn);
|
||||||
control_command, conn, sizeof(isc_event_t));
|
|
||||||
isc_task_send(named_g_server->task, &event);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@@ -139,12 +139,6 @@ named_server_destroy(named_server_t **serverp);
|
|||||||
* Destroy a server object, freeing its memory.
|
* Destroy a server object, freeing its memory.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
|
||||||
named_server_shutdown(named_server_t *server);
|
|
||||||
/*%<
|
|
||||||
* Initiate the server shutdown.
|
|
||||||
*/
|
|
||||||
|
|
||||||
void
|
void
|
||||||
named_server_reloadwanted(void *arg, int signum);
|
named_server_reloadwanted(void *arg, int signum);
|
||||||
/*%<
|
/*%<
|
||||||
|
@@ -401,7 +401,7 @@ noreturn static void
|
|||||||
fatal(named_server_t *server, const char *msg, isc_result_t result);
|
fatal(named_server_t *server, const char *msg, isc_result_t result);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
named_server_reload(isc_task_t *task, isc_event_t *event);
|
named_server_reload(void *arg);
|
||||||
|
|
||||||
#ifdef HAVE_LIBNGHTTP2
|
#ifdef HAVE_LIBNGHTTP2
|
||||||
static isc_result_t
|
static isc_result_t
|
||||||
@@ -2673,6 +2673,8 @@ catz_addmodzone_taskaction(isc_task_t *task, isc_event_t *event0) {
|
|||||||
ns_cfgctx_t *cfg;
|
ns_cfgctx_t *cfg;
|
||||||
dns_zone_t *zone = NULL;
|
dns_zone_t *zone = NULL;
|
||||||
|
|
||||||
|
UNUSED(task);
|
||||||
|
|
||||||
cfg = (ns_cfgctx_t *)ev->view->new_zone_config;
|
cfg = (ns_cfgctx_t *)ev->view->new_zone_config;
|
||||||
if (cfg == NULL) {
|
if (cfg == NULL) {
|
||||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||||
@@ -2821,14 +2823,14 @@ catz_addmodzone_taskaction(isc_task_t *task, isc_event_t *event0) {
|
|||||||
|
|
||||||
/* Mark view unfrozen so that zone can be added */
|
/* Mark view unfrozen so that zone can be added */
|
||||||
|
|
||||||
isc_task_beginexclusive(task);
|
isc_loopmgr_pause(named_g_loopmgr);
|
||||||
dns_view_thaw(ev->view);
|
dns_view_thaw(ev->view);
|
||||||
result = configure_zone(cfg->config, zoneobj, cfg->vconfig, ev->view,
|
result = configure_zone(cfg->config, zoneobj, cfg->vconfig, ev->view,
|
||||||
&ev->cbd->server->viewlist,
|
&ev->cbd->server->viewlist,
|
||||||
&ev->cbd->server->kasplist, cfg->actx, true,
|
&ev->cbd->server->kasplist, cfg->actx, true,
|
||||||
false, ev->mod);
|
false, ev->mod);
|
||||||
dns_view_freeze(ev->view);
|
dns_view_freeze(ev->view);
|
||||||
isc_task_endexclusive(task);
|
isc_loopmgr_resume(named_g_loopmgr);
|
||||||
|
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||||
@@ -2891,7 +2893,9 @@ catz_delzone_taskaction(isc_task_t *task, isc_event_t *event0) {
|
|||||||
char cname[DNS_NAME_FORMATSIZE];
|
char cname[DNS_NAME_FORMATSIZE];
|
||||||
const char *file;
|
const char *file;
|
||||||
|
|
||||||
isc_task_beginexclusive(task);
|
UNUSED(task);
|
||||||
|
|
||||||
|
isc_loopmgr_pause(named_g_loopmgr);
|
||||||
|
|
||||||
dns_name_format(dns_catz_entry_getname(ev->entry), cname,
|
dns_name_format(dns_catz_entry_getname(ev->entry), cname,
|
||||||
DNS_NAME_FORMATSIZE);
|
DNS_NAME_FORMATSIZE);
|
||||||
@@ -2946,7 +2950,7 @@ catz_delzone_taskaction(isc_task_t *task, isc_event_t *event0) {
|
|||||||
"zone '%s' deleted",
|
"zone '%s' deleted",
|
||||||
cname);
|
cname);
|
||||||
cleanup:
|
cleanup:
|
||||||
isc_task_endexclusive(task);
|
isc_loopmgr_resume(named_g_loopmgr);
|
||||||
if (zone != NULL) {
|
if (zone != NULL) {
|
||||||
dns_zone_detach(&zone);
|
dns_zone_detach(&zone);
|
||||||
}
|
}
|
||||||
@@ -3892,8 +3896,7 @@ configure_dnstap(const cfg_obj_t **maps, dns_view_t *view) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CHECKM(dns_dt_create(named_g_mctx, dmode, dpath, &fopt,
|
CHECKM(dns_dt_create(named_g_mctx, dmode, dpath, &fopt,
|
||||||
named_g_server->task,
|
named_g_mainloop, &named_g_server->dtenv),
|
||||||
&named_g_server->dtenv),
|
|
||||||
"unable to create dnstap environment");
|
"unable to create dnstap environment");
|
||||||
|
|
||||||
CHECKM(dns_dt_setupfile(named_g_server->dtenv, max_size, rolls,
|
CHECKM(dns_dt_setupfile(named_g_server->dtenv, max_size, rolls,
|
||||||
@@ -5648,7 +5651,6 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
|
|||||||
const void *hashinit = isc_hash_get_initializer();
|
const void *hashinit = isc_hash_get_initializer();
|
||||||
CHECK(dns_dyndb_createctx(mctx, hashinit, named_g_lctx,
|
CHECK(dns_dyndb_createctx(mctx, hashinit, named_g_lctx,
|
||||||
view, named_g_server->zonemgr,
|
view, named_g_server->zonemgr,
|
||||||
named_g_server->task,
|
|
||||||
named_g_loopmgr, &dctx));
|
named_g_loopmgr, &dctx));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8378,7 +8380,7 @@ load_configuration(const char *filename, named_server_t *server,
|
|||||||
ISC_LIST_INIT(altsecrets);
|
ISC_LIST_INIT(altsecrets);
|
||||||
|
|
||||||
/* Ensure exclusive access to configuration data. */
|
/* Ensure exclusive access to configuration data. */
|
||||||
isc_task_beginexclusive(server->task);
|
isc_loopmgr_pause(named_g_loopmgr);
|
||||||
|
|
||||||
/* Create the ACL configuration context */
|
/* Create the ACL configuration context */
|
||||||
if (named_g_aclconfctx != NULL) {
|
if (named_g_aclconfctx != NULL) {
|
||||||
@@ -8993,15 +8995,14 @@ load_configuration(const char *filename, named_server_t *server,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (first_time) {
|
if (first_time) {
|
||||||
isc_task_endexclusive(server->task);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Rescan the interface list to pick up changes in the
|
* Rescan the interface list to pick up changes in the
|
||||||
* listen-on option.
|
* listen-on option. This requires the loopmgr to be
|
||||||
|
* temporarily resumed.
|
||||||
*/
|
*/
|
||||||
|
isc_loopmgr_resume(named_g_loopmgr);
|
||||||
result = ns_interfacemgr_scan(server->interfacemgr, true, true);
|
result = ns_interfacemgr_scan(server->interfacemgr, true, true);
|
||||||
|
isc_loopmgr_pause(named_g_loopmgr);
|
||||||
isc_task_beginexclusive(server->task);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check that named is able to TCP listen on at least one
|
* Check that named is able to TCP listen on at least one
|
||||||
@@ -9722,7 +9723,7 @@ load_configuration(const char *filename, named_server_t *server,
|
|||||||
isc_result_totext(result));
|
isc_result_totext(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_task_endexclusive(server->task);
|
isc_loopmgr_resume(named_g_loopmgr);
|
||||||
exclusive = false;
|
exclusive = false;
|
||||||
|
|
||||||
/* Configure the statistics channel(s) */
|
/* Configure the statistics channel(s) */
|
||||||
@@ -9821,7 +9822,7 @@ cleanup_conf_parser:
|
|||||||
|
|
||||||
cleanup_exclusive:
|
cleanup_exclusive:
|
||||||
if (exclusive) {
|
if (exclusive) {
|
||||||
isc_task_endexclusive(server->task);
|
isc_loopmgr_resume(named_g_loopmgr);
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||||
@@ -9930,7 +9931,7 @@ load_zones(named_server_t *server, bool reconfig) {
|
|||||||
zl->server = server;
|
zl->server = server;
|
||||||
zl->reconfig = reconfig;
|
zl->reconfig = reconfig;
|
||||||
|
|
||||||
isc_task_beginexclusive(server->task);
|
isc_loopmgr_pause(named_g_loopmgr);
|
||||||
|
|
||||||
isc_refcount_init(&zl->refs, 1);
|
isc_refcount_init(&zl->refs, 1);
|
||||||
|
|
||||||
@@ -9977,21 +9978,17 @@ cleanup:
|
|||||||
isc_mem_put(server->mctx, zl, sizeof(*zl));
|
isc_mem_put(server->mctx, zl, sizeof(*zl));
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_task_endexclusive(server->task);
|
isc_loopmgr_resume(named_g_loopmgr);
|
||||||
|
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
run_server(isc_task_t *task, isc_event_t *event) {
|
run_server(void *arg) {
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
named_server_t *server = (named_server_t *)event->ev_arg;
|
named_server_t *server = (named_server_t *)arg;
|
||||||
dns_geoip_databases_t *geoip = NULL;
|
dns_geoip_databases_t *geoip = NULL;
|
||||||
|
|
||||||
INSIST(task == server->task);
|
|
||||||
|
|
||||||
isc_event_free(&event);
|
|
||||||
|
|
||||||
CHECKFATAL(dns_zonemgr_create(named_g_mctx, named_g_loopmgr,
|
CHECKFATAL(dns_zonemgr_create(named_g_mctx, named_g_loopmgr,
|
||||||
named_g_taskmgr, named_g_netmgr,
|
named_g_taskmgr, named_g_netmgr,
|
||||||
&server->zonemgr),
|
&server->zonemgr),
|
||||||
@@ -10058,15 +10055,6 @@ run_server(isc_task_t *task, isc_event_t *event) {
|
|||||||
#endif /* ifdef ENABLE_AFL */
|
#endif /* ifdef ENABLE_AFL */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
launch_server(void *arg) {
|
|
||||||
named_server_t *server = (named_server_t *)arg;
|
|
||||||
isc_event_t *event = isc_event_allocate(named_g_mctx, server->task,
|
|
||||||
NAMED_EVENT_RUN, run_server,
|
|
||||||
server, sizeof(*event));
|
|
||||||
isc_task_send(server->task, &event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
named_server_flushonshutdown(named_server_t *server, bool flush) {
|
named_server_flushonshutdown(named_server_t *server, bool flush) {
|
||||||
REQUIRE(NAMED_SERVER_VALID(server));
|
REQUIRE(NAMED_SERVER_VALID(server));
|
||||||
@@ -10075,21 +10063,20 @@ named_server_flushonshutdown(named_server_t *server, bool flush) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
shutdown_server(isc_task_t *task, isc_event_t *event) {
|
shutdown_server(void *arg) {
|
||||||
dns_view_t *view, *view_next = NULL;
|
named_server_t *server = (named_server_t *)arg;
|
||||||
dns_kasp_t *kasp, *kasp_next = NULL;
|
dns_view_t *view = NULL, *view_next = NULL;
|
||||||
named_server_t *server = (named_server_t *)event->ev_arg;
|
dns_kasp_t *kasp = NULL, *kasp_next = NULL;
|
||||||
bool flush = server->flushonshutdown;
|
bool flush = server->flushonshutdown;
|
||||||
named_cache_t *nsc;
|
named_cache_t *nsc = NULL;
|
||||||
|
|
||||||
INSIST(task == server->task);
|
|
||||||
|
|
||||||
isc_event_free(&event);
|
|
||||||
|
|
||||||
#if HAVE_LIBSYSTEMD
|
#if HAVE_LIBSYSTEMD
|
||||||
sd_notify(0, "STOPPING=1\n");
|
sd_notify(0, "STOPPING=1\n");
|
||||||
#endif /* HAVE_LIBSYSTEMD */
|
#endif /* HAVE_LIBSYSTEMD */
|
||||||
|
|
||||||
|
isc_signal_stop(server->sighup);
|
||||||
|
isc_signal_destroy(&server->sighup);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We need to shutdown the interface before going
|
* We need to shutdown the interface before going
|
||||||
* exclusive (which would pause the netmgr).
|
* exclusive (which would pause the netmgr).
|
||||||
@@ -10100,7 +10087,7 @@ shutdown_server(isc_task_t *task, isc_event_t *event) {
|
|||||||
|
|
||||||
named_statschannels_shutdown(server);
|
named_statschannels_shutdown(server);
|
||||||
|
|
||||||
isc_task_beginexclusive(server->task);
|
isc_loopmgr_pause(named_g_loopmgr);
|
||||||
|
|
||||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||||
NAMED_LOGMODULE_SERVER, ISC_LOG_INFO, "shutting down%s",
|
NAMED_LOGMODULE_SERVER, ISC_LOG_INFO, "shutting down%s",
|
||||||
@@ -10169,36 +10156,11 @@ shutdown_server(isc_task_t *task, isc_event_t *event) {
|
|||||||
|
|
||||||
dns_db_detach(&server->in_roothints);
|
dns_db_detach(&server->in_roothints);
|
||||||
|
|
||||||
isc_task_endexclusive(server->task);
|
isc_loopmgr_resume(named_g_loopmgr);
|
||||||
|
|
||||||
isc_task_detach(&server->task);
|
isc_task_detach(&server->task);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
close_server(void *arg) {
|
|
||||||
named_server_t *server = arg;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Cleanup loopmgr resources directly, because shuttingdown the server
|
|
||||||
* happens on async task
|
|
||||||
*/
|
|
||||||
isc_signal_stop(server->sighup);
|
|
||||||
isc_signal_destroy(&server->sighup);
|
|
||||||
|
|
||||||
isc_event_t *event = isc_event_allocate(
|
|
||||||
named_g_mctx, server->task, NAMED_EVENT_SHUTDOWN,
|
|
||||||
shutdown_server, server, sizeof(*event));
|
|
||||||
isc_task_send(server->task, &event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
named_server_shutdown(named_server_t *server) {
|
|
||||||
isc_event_t *event =
|
|
||||||
isc_event_allocate(named_g_mctx, server, NAMED_EVENT_SHUTDOWN,
|
|
||||||
shutdown_server, server, sizeof(*event));
|
|
||||||
isc_task_send(server->task, &event);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*%
|
/*%
|
||||||
* Find a view that matches the source and destination addresses of a query.
|
* Find a view that matches the source and destination addresses of a query.
|
||||||
*/
|
*/
|
||||||
@@ -10305,8 +10267,8 @@ named_server_create(isc_mem_t *mctx, named_server_t **serverp) {
|
|||||||
|
|
||||||
named_g_mainloop = isc_loop_main(named_g_loopmgr);
|
named_g_mainloop = isc_loop_main(named_g_loopmgr);
|
||||||
|
|
||||||
isc_loop_setup(named_g_mainloop, launch_server, server);
|
isc_loop_setup(named_g_mainloop, run_server, server);
|
||||||
isc_loop_teardown(named_g_mainloop, close_server, server);
|
isc_loop_teardown(named_g_mainloop, shutdown_server, server);
|
||||||
|
|
||||||
/* Add SIGHUP reload handler */
|
/* Add SIGHUP reload handler */
|
||||||
server->sighup = isc_signal_new(
|
server->sighup = isc_signal_new(
|
||||||
@@ -10412,7 +10374,7 @@ fatal(named_server_t *server, const char *msg, isc_result_t result) {
|
|||||||
* function and any other OpenSSL calls from other tasks
|
* function and any other OpenSSL calls from other tasks
|
||||||
* by requesting exclusive access to the task manager.
|
* by requesting exclusive access to the task manager.
|
||||||
*/
|
*/
|
||||||
isc_task_beginexclusive(server->task);
|
isc_loopmgr_pause(named_g_loopmgr);
|
||||||
}
|
}
|
||||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||||
NAMED_LOGMODULE_SERVER, ISC_LOG_CRITICAL, "%s: %s", msg,
|
NAMED_LOGMODULE_SERVER, ISC_LOG_CRITICAL, "%s: %s", msg,
|
||||||
@@ -10481,17 +10443,13 @@ cleanup:
|
|||||||
* Handle a reload event (from SIGHUP).
|
* Handle a reload event (from SIGHUP).
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
named_server_reload(isc_task_t *task, isc_event_t *event) {
|
named_server_reload(void *arg) {
|
||||||
named_server_t *server = (named_server_t *)event->ev_sender;
|
named_server_t *server = (named_server_t *)arg;
|
||||||
|
|
||||||
INSIST(task == server->task);
|
|
||||||
|
|
||||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||||
NAMED_LOGMODULE_SERVER, ISC_LOG_INFO,
|
NAMED_LOGMODULE_SERVER, ISC_LOG_INFO,
|
||||||
"received SIGHUP signal to reload zones");
|
"received SIGHUP signal to reload zones");
|
||||||
(void)reload(server);
|
(void)reload(server);
|
||||||
|
|
||||||
isc_event_free(&event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -10500,10 +10458,7 @@ named_server_reloadwanted(void *arg, int signum) {
|
|||||||
|
|
||||||
REQUIRE(signum == SIGHUP);
|
REQUIRE(signum == SIGHUP);
|
||||||
|
|
||||||
isc_event_t *event = isc_event_allocate(
|
isc_async_run(named_g_mainloop, named_server_reload, server);
|
||||||
named_g_mctx, server, NAMED_EVENT_RELOAD, named_server_reload,
|
|
||||||
NULL, sizeof(isc_event_t));
|
|
||||||
isc_task_send(server->task, &event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -11961,7 +11916,7 @@ named_server_validation(named_server_t *server, isc_lex_t *lex,
|
|||||||
/* Look for the view name. */
|
/* Look for the view name. */
|
||||||
ptr = next_token(lex, text);
|
ptr = next_token(lex, text);
|
||||||
|
|
||||||
isc_task_beginexclusive(server->task);
|
isc_loopmgr_pause(named_g_loopmgr);
|
||||||
for (view = ISC_LIST_HEAD(server->viewlist); view != NULL;
|
for (view = ISC_LIST_HEAD(server->viewlist); view != NULL;
|
||||||
view = ISC_LIST_NEXT(view, link))
|
view = ISC_LIST_NEXT(view, link))
|
||||||
{
|
{
|
||||||
@@ -11999,7 +11954,7 @@ named_server_validation(named_server_t *server, isc_lex_t *lex,
|
|||||||
result = ISC_R_FAILURE;
|
result = ISC_R_FAILURE;
|
||||||
}
|
}
|
||||||
cleanup:
|
cleanup:
|
||||||
isc_task_endexclusive(server->task);
|
isc_loopmgr_resume(named_g_loopmgr);
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -12021,7 +11976,7 @@ named_server_flushcache(named_server_t *server, isc_lex_t *lex) {
|
|||||||
/* Look for the view name. */
|
/* Look for the view name. */
|
||||||
ptr = next_token(lex, NULL);
|
ptr = next_token(lex, NULL);
|
||||||
|
|
||||||
isc_task_beginexclusive(server->task);
|
isc_loopmgr_pause(named_g_loopmgr);
|
||||||
flushed = true;
|
flushed = true;
|
||||||
found = false;
|
found = false;
|
||||||
|
|
||||||
@@ -12143,7 +12098,7 @@ named_server_flushcache(named_server_t *server, isc_lex_t *lex) {
|
|||||||
result = ISC_R_FAILURE;
|
result = ISC_R_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isc_task_endexclusive(server->task);
|
isc_loopmgr_resume(named_g_loopmgr);
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -12183,7 +12138,7 @@ named_server_flushnode(named_server_t *server, isc_lex_t *lex, bool tree) {
|
|||||||
/* Look for the view name. */
|
/* Look for the view name. */
|
||||||
viewname = next_token(lex, NULL);
|
viewname = next_token(lex, NULL);
|
||||||
|
|
||||||
isc_task_beginexclusive(server->task);
|
isc_loopmgr_pause(named_g_loopmgr);
|
||||||
flushed = true;
|
flushed = true;
|
||||||
found = false;
|
found = false;
|
||||||
for (view = ISC_LIST_HEAD(server->viewlist); view != NULL;
|
for (view = ISC_LIST_HEAD(server->viewlist); view != NULL;
|
||||||
@@ -12234,7 +12189,7 @@ named_server_flushnode(named_server_t *server, isc_lex_t *lex, bool tree) {
|
|||||||
}
|
}
|
||||||
result = ISC_R_FAILURE;
|
result = ISC_R_FAILURE;
|
||||||
}
|
}
|
||||||
isc_task_endexclusive(server->task);
|
isc_loopmgr_resume(named_g_loopmgr);
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -12486,7 +12441,7 @@ named_server_tsigdelete(named_server_t *server, isc_lex_t *lex,
|
|||||||
|
|
||||||
viewname = next_token(lex, text);
|
viewname = next_token(lex, text);
|
||||||
|
|
||||||
isc_task_beginexclusive(server->task);
|
isc_loopmgr_pause(named_g_loopmgr);
|
||||||
for (view = ISC_LIST_HEAD(server->viewlist); view != NULL;
|
for (view = ISC_LIST_HEAD(server->viewlist); view != NULL;
|
||||||
view = ISC_LIST_NEXT(view, link))
|
view = ISC_LIST_NEXT(view, link))
|
||||||
{
|
{
|
||||||
@@ -12498,11 +12453,12 @@ named_server_tsigdelete(named_server_t *server, isc_lex_t *lex,
|
|||||||
isc_rwlocktype_write);
|
isc_rwlocktype_write);
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
isc_task_endexclusive(server->task);
|
isc_task_endexclusive(server->task);
|
||||||
|
isc_loopmgr_resume(named_g_loopmgr);
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isc_task_endexclusive(server->task);
|
isc_loopmgr_resume(named_g_loopmgr);
|
||||||
|
|
||||||
snprintf(fbuf, sizeof(fbuf), "%u", foundkeys);
|
snprintf(fbuf, sizeof(fbuf), "%u", foundkeys);
|
||||||
|
|
||||||
@@ -12723,11 +12679,11 @@ synczone(dns_zone_t *zone, void *uap) {
|
|||||||
isc_result_t
|
isc_result_t
|
||||||
named_server_sync(named_server_t *server, isc_lex_t *lex, isc_buffer_t **text) {
|
named_server_sync(named_server_t *server, isc_lex_t *lex, isc_buffer_t **text) {
|
||||||
isc_result_t result, tresult;
|
isc_result_t result, tresult;
|
||||||
dns_view_t *view;
|
dns_view_t *view = NULL;
|
||||||
dns_zone_t *zone = NULL;
|
dns_zone_t *zone = NULL;
|
||||||
char classstr[DNS_RDATACLASS_FORMATSIZE];
|
char classstr[DNS_RDATACLASS_FORMATSIZE];
|
||||||
char zonename[DNS_NAME_FORMATSIZE];
|
char zonename[DNS_NAME_FORMATSIZE];
|
||||||
const char *vname, *sep, *arg;
|
const char *vname = NULL, *sep = NULL, *arg = NULL;
|
||||||
bool cleanup = false;
|
bool cleanup = false;
|
||||||
|
|
||||||
REQUIRE(text != NULL);
|
REQUIRE(text != NULL);
|
||||||
@@ -12750,7 +12706,7 @@ named_server_sync(named_server_t *server, isc_lex_t *lex, isc_buffer_t **text) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (zone == NULL) {
|
if (zone == NULL) {
|
||||||
isc_task_beginexclusive(server->task);
|
isc_loopmgr_pause(named_g_loopmgr);
|
||||||
tresult = ISC_R_SUCCESS;
|
tresult = ISC_R_SUCCESS;
|
||||||
for (view = ISC_LIST_HEAD(server->viewlist); view != NULL;
|
for (view = ISC_LIST_HEAD(server->viewlist); view != NULL;
|
||||||
view = ISC_LIST_NEXT(view, link))
|
view = ISC_LIST_NEXT(view, link))
|
||||||
@@ -12763,7 +12719,7 @@ named_server_sync(named_server_t *server, isc_lex_t *lex, isc_buffer_t **text) {
|
|||||||
tresult = result;
|
tresult = result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isc_task_endexclusive(server->task);
|
isc_loopmgr_resume(named_g_loopmgr);
|
||||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||||
NAMED_LOGMODULE_SERVER, ISC_LOG_INFO,
|
NAMED_LOGMODULE_SERVER, ISC_LOG_INFO,
|
||||||
"dumping all zones%s: %s",
|
"dumping all zones%s: %s",
|
||||||
@@ -12772,9 +12728,9 @@ named_server_sync(named_server_t *server, isc_lex_t *lex, isc_buffer_t **text) {
|
|||||||
return (tresult);
|
return (tresult);
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_task_beginexclusive(server->task);
|
isc_loopmgr_pause(named_g_loopmgr);
|
||||||
result = synczone(zone, &cleanup);
|
result = synczone(zone, &cleanup);
|
||||||
isc_task_endexclusive(server->task);
|
isc_loopmgr_resume(named_g_loopmgr);
|
||||||
|
|
||||||
view = dns_zone_getview(zone);
|
view = dns_zone_getview(zone);
|
||||||
if (strcmp(view->name, "_default") == 0 ||
|
if (strcmp(view->name, "_default") == 0 ||
|
||||||
@@ -12821,7 +12777,7 @@ named_server_freeze(named_server_t *server, bool freeze, isc_lex_t *lex,
|
|||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
if (mayberaw == NULL) {
|
if (mayberaw == NULL) {
|
||||||
isc_task_beginexclusive(server->task);
|
isc_loopmgr_pause(named_g_loopmgr);
|
||||||
tresult = ISC_R_SUCCESS;
|
tresult = ISC_R_SUCCESS;
|
||||||
for (view = ISC_LIST_HEAD(server->viewlist); view != NULL;
|
for (view = ISC_LIST_HEAD(server->viewlist); view != NULL;
|
||||||
view = ISC_LIST_NEXT(view, link))
|
view = ISC_LIST_NEXT(view, link))
|
||||||
@@ -12832,7 +12788,7 @@ named_server_freeze(named_server_t *server, bool freeze, isc_lex_t *lex,
|
|||||||
tresult = result;
|
tresult = result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isc_task_endexclusive(server->task);
|
isc_loopmgr_resume(named_g_loopmgr);
|
||||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||||
NAMED_LOGMODULE_SERVER, ISC_LOG_INFO,
|
NAMED_LOGMODULE_SERVER, ISC_LOG_INFO,
|
||||||
"%s all zones: %s",
|
"%s all zones: %s",
|
||||||
@@ -12857,7 +12813,7 @@ named_server_freeze(named_server_t *server, bool freeze, isc_lex_t *lex,
|
|||||||
return (DNS_R_NOTDYNAMIC);
|
return (DNS_R_NOTDYNAMIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_task_beginexclusive(server->task);
|
isc_loopmgr_pause(named_g_loopmgr);
|
||||||
frozen = dns_zone_getupdatedisabled(mayberaw);
|
frozen = dns_zone_getupdatedisabled(mayberaw);
|
||||||
if (freeze) {
|
if (freeze) {
|
||||||
if (frozen) {
|
if (frozen) {
|
||||||
@@ -12896,7 +12852,7 @@ named_server_freeze(named_server_t *server, bool freeze, isc_lex_t *lex,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isc_task_endexclusive(server->task);
|
isc_loopmgr_resume(named_g_loopmgr);
|
||||||
|
|
||||||
if (msg != NULL) {
|
if (msg != NULL) {
|
||||||
(void)putstr(text, msg);
|
(void)putstr(text, msg);
|
||||||
@@ -13800,7 +13756,7 @@ do_addzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_task_beginexclusive(server->task);
|
isc_loopmgr_pause(named_g_loopmgr);
|
||||||
|
|
||||||
#ifndef HAVE_LMDB
|
#ifndef HAVE_LMDB
|
||||||
/*
|
/*
|
||||||
@@ -13808,7 +13764,7 @@ do_addzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
|
|||||||
*/
|
*/
|
||||||
result = isc_stdio_open(view->new_zone_file, "a", &fp);
|
result = isc_stdio_open(view->new_zone_file, "a", &fp);
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
isc_task_endexclusive(server->task);
|
isc_loopmgr_resume(named_g_loopmgr);
|
||||||
TCHECK(putstr(text, "unable to create '"));
|
TCHECK(putstr(text, "unable to create '"));
|
||||||
TCHECK(putstr(text, view->new_zone_file));
|
TCHECK(putstr(text, view->new_zone_file));
|
||||||
TCHECK(putstr(text, "': "));
|
TCHECK(putstr(text, "': "));
|
||||||
@@ -13824,7 +13780,7 @@ do_addzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
|
|||||||
/* Make sure we can open the NZD database */
|
/* Make sure we can open the NZD database */
|
||||||
result = nzd_writable(view);
|
result = nzd_writable(view);
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
isc_task_endexclusive(server->task);
|
isc_loopmgr_resume(named_g_loopmgr);
|
||||||
TCHECK(putstr(text, "unable to open NZD database for '"));
|
TCHECK(putstr(text, "unable to open NZD database for '"));
|
||||||
TCHECK(putstr(text, view->new_zone_db));
|
TCHECK(putstr(text, view->new_zone_db));
|
||||||
TCHECK(putstr(text, "'"));
|
TCHECK(putstr(text, "'"));
|
||||||
@@ -13840,7 +13796,7 @@ do_addzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
|
|||||||
true, false, false);
|
true, false, false);
|
||||||
dns_view_freeze(view);
|
dns_view_freeze(view);
|
||||||
|
|
||||||
isc_task_endexclusive(server->task);
|
isc_loopmgr_resume(named_g_loopmgr);
|
||||||
|
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
TCHECK(putstr(text, "configure_zone failed: "));
|
TCHECK(putstr(text, "configure_zone failed: "));
|
||||||
@@ -13989,7 +13945,7 @@ do_modzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
|
|||||||
}
|
}
|
||||||
#endif /* ifndef HAVE_LMDB */
|
#endif /* ifndef HAVE_LMDB */
|
||||||
|
|
||||||
isc_task_beginexclusive(server->task);
|
isc_loopmgr_pause(named_g_loopmgr);
|
||||||
|
|
||||||
#ifndef HAVE_LMDB
|
#ifndef HAVE_LMDB
|
||||||
/* Make sure we can open the configuration save file */
|
/* Make sure we can open the configuration save file */
|
||||||
@@ -13999,7 +13955,7 @@ do_modzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
|
|||||||
TCHECK(putstr(text, view->new_zone_file));
|
TCHECK(putstr(text, view->new_zone_file));
|
||||||
TCHECK(putstr(text, "': "));
|
TCHECK(putstr(text, "': "));
|
||||||
TCHECK(putstr(text, isc_result_totext(result)));
|
TCHECK(putstr(text, isc_result_totext(result)));
|
||||||
isc_task_endexclusive(server->task);
|
isc_loopmgr_resume(named_g_loopmgr);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
(void)isc_stdio_close(fp);
|
(void)isc_stdio_close(fp);
|
||||||
@@ -14014,7 +13970,7 @@ do_modzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
|
|||||||
TCHECK(putstr(text, view->new_zone_db));
|
TCHECK(putstr(text, view->new_zone_db));
|
||||||
TCHECK(putstr(text, "'"));
|
TCHECK(putstr(text, "'"));
|
||||||
result = ISC_R_FAILURE;
|
result = ISC_R_FAILURE;
|
||||||
isc_task_endexclusive(server->task);
|
isc_loopmgr_resume(named_g_loopmgr);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_LMDB */
|
#endif /* HAVE_LMDB */
|
||||||
@@ -14026,7 +13982,7 @@ do_modzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
|
|||||||
true, false, true);
|
true, false, true);
|
||||||
dns_view_freeze(view);
|
dns_view_freeze(view);
|
||||||
|
|
||||||
isc_task_endexclusive(server->task);
|
isc_loopmgr_resume(named_g_loopmgr);
|
||||||
|
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
TCHECK(putstr(text, "configure_zone failed: "));
|
TCHECK(putstr(text, "configure_zone failed: "));
|
||||||
@@ -15808,7 +15764,7 @@ named_server_nta(named_server_t *server, isc_lex_t *lex, bool readonly,
|
|||||||
|
|
||||||
isc_stdtime_get(&now);
|
isc_stdtime_get(&now);
|
||||||
|
|
||||||
isc_task_beginexclusive(server->task);
|
isc_loopmgr_pause(named_g_loopmgr);
|
||||||
for (view = ISC_LIST_HEAD(server->viewlist); view != NULL;
|
for (view = ISC_LIST_HEAD(server->viewlist); view != NULL;
|
||||||
view = ISC_LIST_NEXT(view, link))
|
view = ISC_LIST_NEXT(view, link))
|
||||||
{
|
{
|
||||||
@@ -15920,7 +15876,7 @@ named_server_nta(named_server_t *server, isc_lex_t *lex, bool readonly,
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanup_exclusive:
|
cleanup_exclusive:
|
||||||
isc_task_endexclusive(server->task);
|
isc_loopmgr_resume(named_g_loopmgr);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
|
||||||
@@ -15995,7 +15951,7 @@ cleanup:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static isc_result_t
|
static isc_result_t
|
||||||
mkey_destroy(named_server_t *server, dns_view_t *view, isc_buffer_t **text) {
|
mkey_destroy(dns_view_t *view, isc_buffer_t **text) {
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
char msg[DNS_NAME_FORMATSIZE + 500] = "";
|
char msg[DNS_NAME_FORMATSIZE + 500] = "";
|
||||||
const char *file = NULL;
|
const char *file = NULL;
|
||||||
@@ -16011,7 +15967,7 @@ mkey_destroy(named_server_t *server, dns_view_t *view, isc_buffer_t **text) {
|
|||||||
view->name);
|
view->name);
|
||||||
CHECK(putstr(text, msg));
|
CHECK(putstr(text, msg));
|
||||||
|
|
||||||
isc_task_beginexclusive(server->task);
|
isc_loopmgr_pause(named_g_loopmgr);
|
||||||
|
|
||||||
/* Remove and clean up managed keys zone from view */
|
/* Remove and clean up managed keys zone from view */
|
||||||
mkzone = view->managed_keys;
|
mkzone = view->managed_keys;
|
||||||
@@ -16056,7 +16012,7 @@ mkey_destroy(named_server_t *server, dns_view_t *view, isc_buffer_t **text) {
|
|||||||
result = ISC_R_SUCCESS;
|
result = ISC_R_SUCCESS;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
isc_task_endexclusive(server->task);
|
isc_loopmgr_resume(named_g_loopmgr);
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -16304,7 +16260,7 @@ named_server_mkeys(named_server_t *server, isc_lex_t *lex,
|
|||||||
if (!first) {
|
if (!first) {
|
||||||
CHECK(putstr(text, "\n"));
|
CHECK(putstr(text, "\n"));
|
||||||
}
|
}
|
||||||
CHECK(mkey_destroy(server, view, text));
|
CHECK(mkey_destroy(view, text));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
@@ -16452,12 +16408,8 @@ named_server_tcptimeouts(isc_lex_t *lex, isc_buffer_t **text) {
|
|||||||
CHECK(ISC_R_RANGE);
|
CHECK(ISC_R_RANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_task_beginexclusive(named_g_server->task);
|
|
||||||
|
|
||||||
isc_nm_settimeouts(named_g_netmgr, initial, idle, keepalive,
|
isc_nm_settimeouts(named_g_netmgr, initial, idle, keepalive,
|
||||||
advertised);
|
advertised);
|
||||||
|
|
||||||
isc_task_endexclusive(named_g_server->task);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(msg, sizeof(msg), "tcp-initial-timeout=%u\n", initial / 100);
|
snprintf(msg, sizeof(msg), "tcp-initial-timeout=%u\n", initial / 100);
|
||||||
@@ -16547,7 +16499,7 @@ named_server_servestale(named_server_t *server, isc_lex_t *lex,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_task_beginexclusive(server->task);
|
isc_loopmgr_pause(named_g_loopmgr);
|
||||||
|
|
||||||
for (view = ISC_LIST_HEAD(server->viewlist); view != NULL;
|
for (view = ISC_LIST_HEAD(server->viewlist); view != NULL;
|
||||||
view = ISC_LIST_NEXT(view, link))
|
view = ISC_LIST_NEXT(view, link))
|
||||||
@@ -16636,7 +16588,7 @@ named_server_servestale(named_server_t *server, isc_lex_t *lex,
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
isc_task_endexclusive(named_g_server->task);
|
isc_loopmgr_resume(named_g_loopmgr);
|
||||||
|
|
||||||
if (isc_buffer_usedlength(*text) > 0) {
|
if (isc_buffer_usedlength(*text) > 0) {
|
||||||
(void)putnull(text);
|
(void)putnull(text);
|
||||||
|
@@ -136,7 +136,7 @@ new_sample_instance(isc_mem_t *mctx, const char *db_name, int argc, char **argv,
|
|||||||
|
|
||||||
dns_view_attach(dctx->view, &inst->view);
|
dns_view_attach(dctx->view, &inst->view);
|
||||||
dns_zonemgr_attach(dctx->zmgr, &inst->zmgr);
|
dns_zonemgr_attach(dctx->zmgr, &inst->zmgr);
|
||||||
isc_task_attach(dctx->task, &inst->task);
|
inst->loopmgr = dctx->loopmgr;
|
||||||
|
|
||||||
/* Register new DNS DB implementation. */
|
/* Register new DNS DB implementation. */
|
||||||
result = dns_db_register(db_name, create_db, inst, mctx, &inst->db_imp);
|
result = dns_db_register(db_name, create_db, inst, mctx, &inst->db_imp);
|
||||||
@@ -225,7 +225,6 @@ destroy_sample_instance(sample_instance_t **instp) {
|
|||||||
|
|
||||||
dns_view_detach(&inst->view);
|
dns_view_detach(&inst->view);
|
||||||
dns_zonemgr_detach(&inst->zmgr);
|
dns_zonemgr_detach(&inst->zmgr);
|
||||||
isc_task_detach(&inst->task);
|
|
||||||
|
|
||||||
MEM_PUT_AND_DETACH(inst);
|
MEM_PUT_AND_DETACH(inst);
|
||||||
}
|
}
|
||||||
|
@@ -47,7 +47,7 @@ struct sample_instance {
|
|||||||
/* These are needed for zone creation. */
|
/* These are needed for zone creation. */
|
||||||
dns_view_t *view;
|
dns_view_t *view;
|
||||||
dns_zonemgr_t *zmgr;
|
dns_zonemgr_t *zmgr;
|
||||||
isc_task_t *task;
|
isc_loopmgr_t *loopmgr;
|
||||||
bool exiting;
|
bool exiting;
|
||||||
|
|
||||||
dns_zone_t *zone1;
|
dns_zone_t *zone1;
|
||||||
|
@@ -171,7 +171,6 @@ publish_zone(sample_instance_t *inst, dns_zone_t *zone) {
|
|||||||
CLEANUP_WITH(ISC_R_UNEXPECTED);
|
CLEANUP_WITH(ISC_R_UNEXPECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_task_beginexclusive(inst->task);
|
|
||||||
if (inst->view->frozen) {
|
if (inst->view->frozen) {
|
||||||
freeze = true;
|
freeze = true;
|
||||||
dns_view_thaw(inst->view);
|
dns_view_thaw(inst->view);
|
||||||
@@ -193,7 +192,6 @@ cleanup:
|
|||||||
if (freeze) {
|
if (freeze) {
|
||||||
dns_view_freeze(inst->view);
|
dns_view_freeze(inst->view);
|
||||||
}
|
}
|
||||||
isc_task_endexclusive(inst->task);
|
|
||||||
|
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
@@ -54,6 +54,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <isc/async.h>
|
||||||
#include <isc/buffer.h>
|
#include <isc/buffer.h>
|
||||||
#include <isc/file.h>
|
#include <isc/file.h>
|
||||||
#include <isc/log.h>
|
#include <isc/log.h>
|
||||||
@@ -62,7 +63,6 @@
|
|||||||
#include <isc/once.h>
|
#include <isc/once.h>
|
||||||
#include <isc/result.h>
|
#include <isc/result.h>
|
||||||
#include <isc/sockaddr.h>
|
#include <isc/sockaddr.h>
|
||||||
#include <isc/task.h>
|
|
||||||
#include <isc/thread.h>
|
#include <isc/thread.h>
|
||||||
#include <isc/time.h>
|
#include <isc/time.h>
|
||||||
#include <isc/types.h>
|
#include <isc/types.h>
|
||||||
@@ -104,13 +104,12 @@ struct dns_dtenv {
|
|||||||
isc_refcount_t refcount;
|
isc_refcount_t refcount;
|
||||||
|
|
||||||
isc_mem_t *mctx;
|
isc_mem_t *mctx;
|
||||||
|
isc_loop_t *loop;
|
||||||
|
|
||||||
struct fstrm_iothr *iothr;
|
struct fstrm_iothr *iothr;
|
||||||
struct fstrm_iothr_options *fopt;
|
struct fstrm_iothr_options *fopt;
|
||||||
|
|
||||||
isc_task_t *reopen_task;
|
isc_mutex_t reopen_lock; /* locks 'reopen_queued' */
|
||||||
isc_mutex_t reopen_lock; /* locks 'reopen_queued'
|
|
||||||
* */
|
|
||||||
bool reopen_queued;
|
bool reopen_queued;
|
||||||
|
|
||||||
isc_region_t identity;
|
isc_region_t identity;
|
||||||
@@ -141,7 +140,7 @@ static atomic_uint_fast32_t global_generation;
|
|||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path,
|
dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path,
|
||||||
struct fstrm_iothr_options **foptp, isc_task_t *reopen_task,
|
struct fstrm_iothr_options **foptp, isc_loop_t *loop,
|
||||||
dns_dtenv_t **envp) {
|
dns_dtenv_t **envp) {
|
||||||
isc_result_t result = ISC_R_SUCCESS;
|
isc_result_t result = ISC_R_SUCCESS;
|
||||||
fstrm_res res;
|
fstrm_res res;
|
||||||
@@ -162,7 +161,7 @@ dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path,
|
|||||||
|
|
||||||
env = isc_mem_get(mctx, sizeof(*env));
|
env = isc_mem_get(mctx, sizeof(*env));
|
||||||
*env = (dns_dtenv_t){
|
*env = (dns_dtenv_t){
|
||||||
.reopen_task = reopen_task,
|
.loop = loop,
|
||||||
.reopen_queued = false,
|
.reopen_queued = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -281,13 +280,12 @@ dns_dt_reopen(dns_dtenv_t *env, int roll) {
|
|||||||
struct fstrm_file_options *ffwopt = NULL;
|
struct fstrm_file_options *ffwopt = NULL;
|
||||||
struct fstrm_writer_options *fwopt = NULL;
|
struct fstrm_writer_options *fwopt = NULL;
|
||||||
struct fstrm_writer *fw = NULL;
|
struct fstrm_writer *fw = NULL;
|
||||||
|
isc_loopmgr_t *loopmgr = NULL;
|
||||||
|
|
||||||
REQUIRE(VALID_DTENV(env));
|
REQUIRE(VALID_DTENV(env));
|
||||||
|
|
||||||
/*
|
loopmgr = isc_loop_getloopmgr(env->loop);
|
||||||
* Run in task-exclusive mode.
|
isc_loopmgr_pause(loopmgr);
|
||||||
*/
|
|
||||||
isc_task_beginexclusive(env->reopen_task);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check that we can create a new fw object.
|
* Check that we can create a new fw object.
|
||||||
@@ -383,7 +381,7 @@ cleanup:
|
|||||||
fstrm_writer_options_destroy(&fwopt);
|
fstrm_writer_options_destroy(&fwopt);
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_task_endexclusive(env->reopen_task);
|
isc_loopmgr_resume(loopmgr);
|
||||||
|
|
||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
@@ -680,36 +678,18 @@ setaddr(dns_dtmsg_t *dm, isc_sockaddr_t *sa, bool tcp,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*%
|
/*%
|
||||||
* Invoke dns_dt_reopen() and re-allow dnstap output file rolling. This
|
* Invoke dns_dt_reopen() and re-allow dnstap output file rolling.
|
||||||
* function is run in the context of the task stored in the 'reopen_task' field
|
|
||||||
* of the dnstap environment structure.
|
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
perform_reopen(isc_task_t *task, isc_event_t *event) {
|
perform_reopen(void *arg) {
|
||||||
dns_dtenv_t *env;
|
dns_dtenv_t *env = (dns_dtenv_t *)arg;
|
||||||
|
|
||||||
REQUIRE(event != NULL);
|
|
||||||
REQUIRE(event->ev_type == DNS_EVENT_FREESTORAGE);
|
|
||||||
|
|
||||||
env = (dns_dtenv_t *)event->ev_arg;
|
|
||||||
|
|
||||||
REQUIRE(VALID_DTENV(env));
|
REQUIRE(VALID_DTENV(env));
|
||||||
REQUIRE(task == env->reopen_task);
|
|
||||||
|
|
||||||
/*
|
/* Roll output file. */
|
||||||
* Roll output file in the context of env->reopen_task.
|
|
||||||
*/
|
|
||||||
dns_dt_reopen(env, env->rolls);
|
dns_dt_reopen(env, env->rolls);
|
||||||
|
|
||||||
/*
|
/* Re-allow output file rolling. */
|
||||||
* Clean up.
|
|
||||||
*/
|
|
||||||
isc_event_free(&event);
|
|
||||||
isc_task_detach(&task);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Re-allow output file rolling.
|
|
||||||
*/
|
|
||||||
LOCK(&env->reopen_lock);
|
LOCK(&env->reopen_lock);
|
||||||
env->reopen_queued = false;
|
env->reopen_queued = false;
|
||||||
UNLOCK(&env->reopen_lock);
|
UNLOCK(&env->reopen_lock);
|
||||||
@@ -721,15 +701,10 @@ perform_reopen(isc_task_t *task, isc_event_t *event) {
|
|||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
check_file_size_and_maybe_reopen(dns_dtenv_t *env) {
|
check_file_size_and_maybe_reopen(dns_dtenv_t *env) {
|
||||||
isc_task_t *reopen_task = NULL;
|
|
||||||
isc_event_t *event;
|
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
|
|
||||||
/*
|
/* If a loopmgr wasn't specified, abort. */
|
||||||
* If the task from which the output file should be reopened was not
|
if (env->loop == NULL) {
|
||||||
* specified, abort.
|
|
||||||
*/
|
|
||||||
if (env->reopen_task == NULL) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -746,15 +721,10 @@ check_file_size_and_maybe_reopen(dns_dtenv_t *env) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We need to roll the output file, but it needs to be done in the
|
* Send an event to roll the output file, then disallow output file
|
||||||
* context of env->reopen_task. Allocate and send an event to achieve
|
* rolling until the roll we queue is completed.
|
||||||
* that, then disallow output file rolling until the roll we queue is
|
|
||||||
* completed.
|
|
||||||
*/
|
*/
|
||||||
event = isc_event_allocate(env->mctx, NULL, DNS_EVENT_FREESTORAGE,
|
isc_async_run(env->loop, perform_reopen, env);
|
||||||
perform_reopen, env, sizeof(*event));
|
|
||||||
isc_task_attach(env->reopen_task, &reopen_task);
|
|
||||||
isc_task_send(reopen_task, &event);
|
|
||||||
env->reopen_queued = true;
|
env->reopen_queued = true;
|
||||||
|
|
||||||
unlock_and_return:
|
unlock_and_return:
|
||||||
|
@@ -19,7 +19,6 @@
|
|||||||
#include <isc/once.h>
|
#include <isc/once.h>
|
||||||
#include <isc/region.h>
|
#include <isc/region.h>
|
||||||
#include <isc/result.h>
|
#include <isc/result.h>
|
||||||
#include <isc/task.h>
|
|
||||||
#include <isc/types.h>
|
#include <isc/types.h>
|
||||||
#include <isc/util.h>
|
#include <isc/util.h>
|
||||||
#include <isc/uv.h>
|
#include <isc/uv.h>
|
||||||
@@ -268,7 +267,7 @@ dns_dyndb_cleanup(bool exiting) {
|
|||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
dns_dyndb_createctx(isc_mem_t *mctx, const void *hashinit, isc_log_t *lctx,
|
dns_dyndb_createctx(isc_mem_t *mctx, const void *hashinit, isc_log_t *lctx,
|
||||||
dns_view_t *view, dns_zonemgr_t *zmgr, isc_task_t *task,
|
dns_view_t *view, dns_zonemgr_t *zmgr,
|
||||||
isc_loopmgr_t *loopmgr, dns_dyndbctx_t **dctxp) {
|
isc_loopmgr_t *loopmgr, dns_dyndbctx_t **dctxp) {
|
||||||
dns_dyndbctx_t *dctx;
|
dns_dyndbctx_t *dctx;
|
||||||
|
|
||||||
@@ -287,9 +286,6 @@ dns_dyndb_createctx(isc_mem_t *mctx, const void *hashinit, isc_log_t *lctx,
|
|||||||
if (zmgr != NULL) {
|
if (zmgr != NULL) {
|
||||||
dns_zonemgr_attach(zmgr, &dctx->zmgr);
|
dns_zonemgr_attach(zmgr, &dctx->zmgr);
|
||||||
}
|
}
|
||||||
if (task != NULL) {
|
|
||||||
isc_task_attach(task, &dctx->task);
|
|
||||||
}
|
|
||||||
|
|
||||||
isc_mem_attach(mctx, &dctx->mctx);
|
isc_mem_attach(mctx, &dctx->mctx);
|
||||||
dctx->magic = DNS_DYNDBCTX_MAGIC;
|
dctx->magic = DNS_DYNDBCTX_MAGIC;
|
||||||
@@ -316,9 +312,6 @@ dns_dyndb_destroyctx(dns_dyndbctx_t **dctxp) {
|
|||||||
if (dctx->zmgr != NULL) {
|
if (dctx->zmgr != NULL) {
|
||||||
dns_zonemgr_detach(&dctx->zmgr);
|
dns_zonemgr_detach(&dctx->zmgr);
|
||||||
}
|
}
|
||||||
if (dctx->task != NULL) {
|
|
||||||
isc_task_detach(&dctx->task);
|
|
||||||
}
|
|
||||||
dctx->loopmgr = NULL;
|
dctx->loopmgr = NULL;
|
||||||
dctx->lctx = NULL;
|
dctx->lctx = NULL;
|
||||||
|
|
||||||
|
@@ -117,7 +117,7 @@ struct dns_dtdata {
|
|||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path,
|
dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path,
|
||||||
struct fstrm_iothr_options **foptp, isc_task_t *reopen_task,
|
struct fstrm_iothr_options **foptp, isc_loop_t *loop,
|
||||||
dns_dtenv_t **envp);
|
dns_dtenv_t **envp);
|
||||||
/*%<
|
/*%<
|
||||||
* Create and initialize the dnstap environment.
|
* Create and initialize the dnstap environment.
|
||||||
@@ -138,10 +138,10 @@ dns_dt_create(isc_mem_t *mctx, dns_dtmode_t mode, const char *path,
|
|||||||
* should also be set. Other options may be set if desired.
|
* should also be set. Other options may be set if desired.
|
||||||
* If dns_dt_create succeeds the *foptp is set to NULL.
|
* If dns_dt_create succeeds the *foptp is set to NULL.
|
||||||
*
|
*
|
||||||
*\li 'reopen_task' needs to be set to the task in the context of which
|
*\li 'loop' needs to be set to the loop in which
|
||||||
* dns_dt_reopen() will be called. This is not an optional parameter:
|
* dns_dt_reopen() will be called. This is not an optional parameter:
|
||||||
* using dns_dt_create() (which sets 'reopen_task' to NULL) is only
|
* using dns_dt_create() with 'loop' set to NULL is only allowed in
|
||||||
* allowed in unit tests.
|
* unit tests.
|
||||||
*
|
*
|
||||||
* Requires:
|
* Requires:
|
||||||
*
|
*
|
||||||
|
@@ -39,7 +39,6 @@ struct dns_dyndbctx {
|
|||||||
isc_log_t *lctx;
|
isc_log_t *lctx;
|
||||||
dns_view_t *view;
|
dns_view_t *view;
|
||||||
dns_zonemgr_t *zmgr;
|
dns_zonemgr_t *zmgr;
|
||||||
isc_task_t *task;
|
|
||||||
isc_loopmgr_t *loopmgr;
|
isc_loopmgr_t *loopmgr;
|
||||||
const bool *refvar; /* unused, but retained for API compatibility */
|
const bool *refvar; /* unused, but retained for API compatibility */
|
||||||
};
|
};
|
||||||
@@ -133,7 +132,7 @@ dns_dyndb_cleanup(bool exiting);
|
|||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
dns_dyndb_createctx(isc_mem_t *mctx, const void *hashinit, isc_log_t *lctx,
|
dns_dyndb_createctx(isc_mem_t *mctx, const void *hashinit, isc_log_t *lctx,
|
||||||
dns_view_t *view, dns_zonemgr_t *zmgr, isc_task_t *task,
|
dns_view_t *view, dns_zonemgr_t *zmgr,
|
||||||
isc_loopmgr_t *loopmgr, dns_dyndbctx_t **dctxp);
|
isc_loopmgr_t *loopmgr, dns_dyndbctx_t **dctxp);
|
||||||
/*%
|
/*%
|
||||||
* Create a dyndb initialization context structure, with
|
* Create a dyndb initialization context structure, with
|
||||||
|
@@ -192,7 +192,7 @@ void
|
|||||||
isc_loopmgr_blocking(isc_loopmgr_t *loopmgr);
|
isc_loopmgr_blocking(isc_loopmgr_t *loopmgr);
|
||||||
void
|
void
|
||||||
isc_loopmgr_nonblocking(isc_loopmgr_t *loopmgr);
|
isc_loopmgr_nonblocking(isc_loopmgr_t *loopmgr);
|
||||||
/*%
|
/*%<
|
||||||
* isc_loopmgr_blocking() stops the SIGINT and SIGTERM signal handlers
|
* isc_loopmgr_blocking() stops the SIGINT and SIGTERM signal handlers
|
||||||
* during blocking operations, for example while waiting for user
|
* during blocking operations, for example while waiting for user
|
||||||
* interaction; isc_loopmgr_nonblocking() restarts them.
|
* interaction; isc_loopmgr_nonblocking() restarts them.
|
||||||
@@ -200,4 +200,13 @@ isc_loopmgr_nonblocking(isc_loopmgr_t *loopmgr);
|
|||||||
* Requires:
|
* Requires:
|
||||||
*\li 'loopmgr' is a valid loop manager.
|
*\li 'loopmgr' is a valid loop manager.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
isc_loopmgr_t *
|
||||||
|
isc_loop_getloopmgr(isc_loop_t *loop);
|
||||||
|
/*%<
|
||||||
|
* Return the loopmgr associated with 'loop'.
|
||||||
|
*
|
||||||
|
* Requires:
|
||||||
|
*\li 'loop' is a valid loop.
|
||||||
|
*/
|
||||||
ISC_LANG_ENDDECLS
|
ISC_LANG_ENDDECLS
|
||||||
|
@@ -597,3 +597,10 @@ isc_loopmgr_nonblocking(isc_loopmgr_t *loopmgr) {
|
|||||||
isc_signal_start(loopmgr->sigint);
|
isc_signal_start(loopmgr->sigint);
|
||||||
isc_signal_start(loopmgr->sigterm);
|
isc_signal_start(loopmgr->sigterm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isc_loopmgr_t *
|
||||||
|
isc_loop_getloopmgr(isc_loop_t *loop) {
|
||||||
|
REQUIRE(VALID_LOOP(loop));
|
||||||
|
|
||||||
|
return (loop->loopmgr);
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user