daemon.h File Reference

The daemon consists of global settings and a number of workers. More...

#include "util/locks.h"
#include "util/alloc.h"
#include "services/modstack.h"
#include "dnstap/dnstap_config.h"
#include "dnscrypt/dnscrypt_config.h"

Data Structures

struct  daemon
 Structure holding worker list. More...
 

Functions

struct daemondaemon_init (void)
 Initialize daemon structure. More...
 
int daemon_open_shared_ports (struct daemon *daemon)
 Open shared listening ports (if needed). More...
 
int daemon_privileged (struct daemon *daemon)
 Do daemon setup that needs privileges like opening privileged ports or opening device files. 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...
 

Detailed Description

The daemon consists of global settings and a number of workers.

Function Documentation

◆ daemon_init()

struct daemon* daemon_init ( void  )

Initialize daemon structure.

Returns
: The daemon structure, or NULL on error.

Referenced by run_daemon().

◆ daemon_open_shared_ports()

int daemon_open_shared_ports ( struct daemon daemon)

◆ daemon_privileged()

int daemon_privileged ( struct daemon daemon)

Do daemon setup that needs privileges like opening privileged ports or opening device files.

The cfg member pointer must have been set for the daemon.

Parameters
daemonthe daemon.
Returns
: false on error.

References module_env::alloc, daemon::cfg, module_env::cfg, daemon::env, daemon::mods, modstack_call_startup(), config_file::module_conf, daemon::superalloc, and module_env::worker.

Referenced by perform_setup().

◆ daemon_fork()

void daemon_fork ( struct daemon daemon)

Fork workers and start service.

When the routine exits, it is no longer forked.

Parameters
daemonthe daemon.

References log_assert, daemon::views, and views_create().

◆ daemon_cleanup()

◆ daemon_delete()

◆ daemon_apply_cfg()