|
unbound
0.1
|
#include "config.h"#include <sys/time.h>#include "daemon/daemon.h"#include "daemon/worker.h"#include "daemon/remote.h"#include "daemon/acl_list.h"#include "util/log.h"#include "util/config_file.h"#include "util/data/msgreply.h"#include "util/shm_side/shm_main.h"#include "util/storage/lookup3.h"#include "util/storage/slabhash.h"#include "util/tcp_conn_limit.h"#include "services/listen_dnsport.h"#include "services/cache/rrset.h"#include "services/cache/infra.h"#include "services/localzone.h"#include "services/view.h"#include "services/modstack.h"#include "services/authzone.h"#include "util/module.h"#include "util/random.h"#include "util/tube.h"#include "util/net_help.h"#include "sldns/keyraw.h"#include "respip/respip.h"#include <signal.h>Functions | |
| int | ub_c_lex_destroy (void) |
| remove buffers for parsing and init | |
| static RETSIGTYPE | record_sigh (int sig) |
| used when no other sighandling happens, so we don't die when multiple signals in quick succession are sent to us. More... | |
| static void | signal_handling_record (void) |
| Signal handling during the time when netevent is disabled. More... | |
| static void | signal_handling_playback (struct worker *wrk) |
| Replay old signals. More... | |
| struct daemon * | daemon_init (void) |
| Initialize daemon structure. More... | |
| int | daemon_open_shared_ports (struct daemon *daemon) |
| Open shared listening ports (if needed). More... | |
| static void | daemon_setup_modules (struct daemon *daemon) |
| Setup modules. More... | |
| static int | daemon_get_shufport (struct daemon *daemon, int *shufport) |
| Obtain allowed port numbers, concatenate the list, and shuffle them (ready to be handed out to threads). More... | |
| static void | daemon_create_workers (struct daemon *daemon) |
| Allocate empty worker structures. More... | |
| static void * | thread_start (void *arg) |
| Function to start one thread. More... | |
| static void | daemon_start_others (struct daemon *daemon) |
| Fork and init the other threads. More... | |
| static void | daemon_stop_others (struct daemon *daemon) |
| Stop the other threads. More... | |
| void | daemon_fork (struct daemon *daemon) |
| Fork workers and start service. More... | |
| void | daemon_cleanup (struct daemon *daemon) |
| Close off the worker thread information. More... | |
| void | daemon_delete (struct daemon *daemon) |
| Delete workers, close listening ports. More... | |
| void | daemon_apply_cfg (struct daemon *daemon, struct config_file *cfg) |
| Apply config settings. More... | |
Variables | |
| static int | sig_record_quit = 0 |
| How many quit requests happened. | |
| static int | sig_record_reload = 0 |
| How many reload requests happened. | |
The daemon consists of global settings and a number of workers.
|
static |
used when no other sighandling happens, so we don't die when multiple signals in quick succession are sent to us.
| sig | signal number. |
References sig_record_quit, and sig_record_reload.
Referenced by signal_handling_record().
|
static |
Signal handling during the time when netevent is disabled.
Stores signals to replay later.
References log_err(), and record_sigh().
Referenced by daemon_cleanup().
|
static |
Replay old signals.
| wrk | worker that handles signals. |
References sig_record_quit, sig_record_reload, and worker_sighandler().
| struct daemon* daemon_init | ( | void | ) |
Initialize daemon structure.
Referenced by run_daemon().
| int daemon_open_shared_ports | ( | struct daemon * | daemon | ) |
Open shared listening ports (if needed).
The cfg member pointer must have been set for the daemon.
| daemon | the daemon. |
References daemon::cfg, config_file::control_port, daemon_remote_open_ports(), daemon::listening_port, listening_ports_free(), listening_ports_open(), log_assert, daemon::num_ports, config_file::num_threads, config_file::port, daemon::ports, daemon::rc_port, daemon::rc_ports, config_file::remote_control_enable, daemon::reuseport, and config_file::so_reuseport.
|
static |
Setup modules.
setup module stack.
| daemon | the daemon |
References module_env::alloc, daemon::cfg, module_env::cfg, daemon::env, daemon::mods, modstack_setup(), config_file::module_conf, module_env::need_to_validate, daemon::superalloc, and module_env::worker.
|
static |
Obtain allowed port numbers, concatenate the list, and shuffle them (ready to be handed out to threads).
| daemon | the daemon. Uses rand and cfg. |
| shufport | the portlist output. |
References daemon::cfg, and config_file::outgoing_avail_ports.
|
static |
Allocate empty worker structures.
With backptr and thread-number, from 0..numthread initialised. Used as user arguments to new threads. Creates the daemon random generator if it does not exist yet. The random generator stays existing between reloads with a unique state.
| daemon | the daemon with (new) config settings. |
References daemon::cfg, log_assert, daemon::rand, and ub_initstate().
|
static |
Function to start one thread.
| arg | user argument. |
References daemon::cfg, worker::cmd, worker::daemon, log_thread_set(), daemon::num_ports, daemon::ports, config_file::so_reuseport, worker::thread_num, tube_close_write(), ub_thread_blocksigs(), and worker_init().
Referenced by daemon_start_others().
|
static |
Fork and init the other threads.
Main thread returns for special handling.
| daemon | the daemon with other threads to fork. |
References worker::cmd, log_assert, daemon::num, worker::thr_id, thread_start(), tube_close_read(), VERB_ALGO, verbose(), and daemon::workers.
|
static |
Stop the other threads.
| daemon | the daemon with other threads. |
References log_assert, daemon::num, worker::thr_id, VERB_ALGO, verbose(), worker_cmd_quit, worker_send_cmd(), and daemon::workers.
| void daemon_fork | ( | struct daemon * | daemon | ) |
Fork workers and start service.
When the routine exits, it is no longer forked.
| daemon | the daemon. |
References log_assert, daemon::views, and views_create().
| void daemon_cleanup | ( | struct daemon * | daemon | ) |
Close off the worker thread information.
Bring the daemon back into state ready for daemon_fork again.
| daemon | the daemon. |
References alloc_clear_special(), module_env::auth_zones, auth_zones_cleanup(), daemon_remote_clear(), daemon::env, daemon::local_zones, local_zones_delete(), log_assert, log_thread_set(), module_env::msg_cache, daemon::num, daemon::rc, daemon::respip_set, respip_set_delete(), module_env::rrset_cache, signal_handling_record(), slabhash_clear(), daemon::superalloc, rrset_cache::table, daemon::views, views_delete(), worker_delete(), and daemon::workers.
Referenced by service_deinit().
| void daemon_delete | ( | struct daemon * | daemon | ) |
Delete workers, close listening ports.
| daemon | the daemon. |
References daemon::acl, acl_list_delete(), alloc_clear(), module_env::auth_zones, auth_zones_delete(), daemon::chroot, daemon_remote_delete(), edns_known_options_delete(), daemon::env, module_env::infra_cache, infra_delete(), daemon::listen_sslctx, listen_sslctx_delete_ticket_keys(), listening_ports_free(), log_err(), daemon::mods, modstack_desetup(), module_env::msg_cache, daemon::num_ports, daemon::pidfile, daemon::ports, daemon::rand, daemon::rc, daemon::rc_ports, module_env::rrset_cache, rrset_cache_delete(), slabhash_delete(), daemon::superalloc, daemon::tcl, tcl_list_delete(), ub_c_lex_destroy(), ub_openssl_lock_delete(), and ub_randfree().
Referenced by service_deinit().
| void daemon_apply_cfg | ( | struct daemon * | daemon, |
| struct config_file * | cfg | ||
| ) |
Apply config settings.
| daemon | the daemon. |
| cfg | new config settings. |
References daemon::cfg, config_apply(), daemon::env, HASH_DEFAULT_STARTARRAY, module_env::msg_cache, config_file::msg_cache_size, config_file::msg_cache_slabs, msgreply_sizefunc(), query_entry_delete(), query_info_compare(), reply_info_delete(), slabhash_create(), slabhash_delete(), and slabhash_is_size().
Referenced by apply_settings().
1.8.18