app.c File Reference

#include <config.h>
#include <sys/param.h>
#include <sys/types.h>
#include <stddef.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <signal.h>
#include <sys/time.h>
#include <isc/app.h>
#include <isc/boolean.h>
#include <isc/condition.h>
#include <isc/mem.h>
#include <isc/msgs.h>
#include <isc/mutex.h>
#include <isc/event.h>
#include <isc/platform.h>
#include <isc/strerror.h>
#include <isc/string.h>
#include <isc/task.h>
#include <isc/time.h>
#include <isc/util.h>
#include "../timer_p.h"
#include "../task_p.h"
#include "socket_p.h"
#include "../app_api.c"

Go to the source code of this file.

Data Structures

struct  isc__appctx

Defines

#define APPCTX_MAGIC   ISC_MAGIC('A', 'p', 'c', 'x')
#define VALID_APPCTX(c)   ISC_MAGIC_VALID(c, APPCTX_MAGIC)

Typedefs

typedef struct isc__appctx isc__appctx_t

Functions

isc_result_t isc__app_start (void)
 For BIND9 internal applications built with threads, we use a single app context and let multiple worker, I/O, timer threads do actual jobs. For other cases (including BIND9 built without threads) an app context acts as an event loop dispatching various events.
isc_result_t isc__app_ctxstart (isc_appctx_t *ctx)
isc_result_t isc__app_onrun (isc_mem_t *mctx, isc_task_t *task, isc_taskaction_t action, void *arg)
isc_result_t isc__app_ctxrun (isc_appctx_t *ctx)
isc_result_t isc__app_run (void)
isc_result_t isc__app_ctxshutdown (isc_appctx_t *ctx)
isc_result_t isc__app_shutdown (void)
isc_result_t isc__app_reload (void)
isc_result_t isc__app_ctxsuspend (isc_appctx_t *ctx)
void isc__app_ctxfinish (isc_appctx_t *ctx)
void isc__app_finish (void)
void isc__app_block (void)
void isc__app_unblock (void)
isc_result_t isc__appctx_create (isc_mem_t *mctx, isc_appctx_t **ctxp)
void isc__appctx_destroy (isc_appctx_t **ctxp)
void isc__appctx_settaskmgr (isc_appctx_t *ctx, isc_taskmgr_t *taskmgr)
void isc__appctx_setsocketmgr (isc_appctx_t *ctx, isc_socketmgr_t *socketmgr)
void isc__appctx_settimermgr (isc_appctx_t *ctx, isc_timermgr_t *timermgr)
isc_result_t isc__app_ctxonrun (isc_appctx_t *ctx, isc_mem_t *mctx, isc_task_t *task, isc_taskaction_t action, void *arg)
static void exit_action (int arg)
static void reload_action (int arg)
static isc_result_t handle_signal (int sig, void(*handler)(int))
static isc_result_t evloop (isc__appctx_t *ctx)
isc_result_t isc__nothread_wait_hack (isc_condition_t *cp, isc_mutex_t *mp)
isc_result_t isc__nothread_signal_hack (isc_condition_t *cp)
isc_result_t isc__app_register (void)
 A short cut function that specifies the application module in the ISC library for isc_app_register(). An application that uses the ISC library usually do not have to care about this function: it would call isc_lib_register(), which internally calls this function.

Variables

static isc__appctx_t isc_g_appctx
struct {
   isc_appmethods_t   methods
   void *   run
 The following are defined just for avoiding unused static functions.
   void *   shutdown
   void *   start
   void *   reload
   void *   finish
   void *   block
   void *   unblock
appmethods
static isc_boolean_t in_recursive_evloop = ISC_FALSE
 True if we are currently executing in the recursive event loop.
static isc_boolean_t signalled = ISC_FALSE
 True if we are exiting the event loop as the result of a call to isc_condition_signal() rather than a shutdown or reload.


Detailed Description

Definition in file app.c.


Define Documentation

#define APPCTX_MAGIC   ISC_MAGIC('A', 'p', 'c', 'x')

Definition at line 101 of file app.c.

Referenced by isc__app_start().

#define VALID_APPCTX (  )     ISC_MAGIC_VALID(c, APPCTX_MAGIC)

Definition at line 102 of file app.c.

Referenced by isc__app_ctxrun(), and isc__app_ctxstart().


Typedef Documentation

typedef struct isc__appctx isc__appctx_t


Function Documentation

isc_result_t isc__app_start ( void   ) 

For BIND9 internal applications built with threads, we use a single app context and let multiple worker, I/O, timer threads do actual jobs. For other cases (including BIND9 built without threads) an app context acts as an event loop dispatching various events.

The following are intended for internal use (indicated by "isc__" prefix) but are not declared as static, allowing direct access from unit tests etc.

Definition at line 384 of file app.c.

References APPCTX_MAGIC, appmethods, isc__appctx::common, isc_appctx::impmagic, isc__app_ctxstart(), ISCAPI_APPCTX_MAGIC, isc_appctx::magic, isc__appctx::mctx, and isc_appctx::methods.

Referenced by isc_app_start().

isc_result_t isc__app_ctxstart ( isc_appctx_t ctx  ) 

Definition at line 212 of file app.c.

References isc__appctx::blocked, cleanup(), exit_action(), handle_signal(), isc__strerror(), isc_condition_destroy, isc_condition_init, ISC_FALSE, ISC_LIST_INIT, isc_mutex_destroy, isc_mutex_init, ISC_R_SUCCESS, ISC_R_UNEXPECTED, ISC_STRERRORSIZE, isc__appctx::lock, isc__appctx::on_run, REQUIRE, isc__appctx::running, isc__appctx::shutdown_requested, UNEXPECTED_ERROR, VALID_APPCTX, isc__appctx::want_reload, and isc__appctx::want_shutdown.

Referenced by isc__app_start(), and isc_app_ctxstart().

isc_result_t isc__app_onrun ( isc_mem_t mctx,
isc_task_t task,
isc_taskaction_t  action,
void *  arg 
)

Definition at line 395 of file app.c.

References isc__app_ctxonrun().

Referenced by isc_app_onrun().

isc_result_t isc__app_ctxrun ( isc_appctx_t ctx  ) 

Definition at line 581 of file app.c.

References isc__appctx::blocked, evloop(), handle_signal(), isc__strerror(), isc__taskmgr_dispatch(), isc_bind9, ISC_FALSE, ISC_LIST_HEAD, ISC_LIST_NEXT, ISC_LIST_UNLINK, ISC_R_RELOAD, ISC_R_SUCCESS, ISC_R_UNEXPECTED, ISC_STRERRORSIZE, isc_task_sendanddetach(), ISC_TRUE, isc__appctx::lock, LOCK, isc__appctx::on_run, reload_action(), REQUIRE, isc__appctx::running, isc__appctx::taskmgr, UNEXPECTED_ERROR, UNLOCK, VALID_APPCTX, WAIT, isc__appctx::want_reload, and isc__appctx::want_shutdown.

Referenced by isc_app_ctxrun().

isc_result_t isc__app_run ( void   ) 

Definition at line 755 of file app.c.

Referenced by isc_app_run().

isc_result_t isc__app_ctxshutdown ( isc_appctx_t ctx  ) 

Definition at line 760 of file app.c.

Referenced by isc_app_ctxshutdown().

isc_result_t isc__app_shutdown ( void   ) 

Definition at line 831 of file app.c.

Referenced by isc_app_shutdown().

isc_result_t isc__app_reload ( void   ) 

Definition at line 908 of file app.c.

Referenced by isc_app_reload().

isc_result_t isc__app_ctxsuspend ( isc_appctx_t ctx  ) 

Definition at line 836 of file app.c.

Referenced by isc__app_ctxfinish(), and isc_app_ctxsuspend().

void isc__app_ctxfinish ( isc_appctx_t ctx  ) 

Definition at line 913 of file app.c.

References isc__app_ctxsuspend().

Referenced by isc__app_block(), and isc_app_ctxfinish().

void isc__app_finish ( void   ) 

Definition at line 922 of file app.c.

Referenced by isc_app_finish().

void isc__app_block ( void   ) 

Definition at line 927 of file app.c.

References isc__app_ctxfinish().

Referenced by isc_app_block().

void isc__app_unblock ( void   ) 

Definition at line 945 of file app.c.

Referenced by isc_app_unblock().

isc_result_t isc__appctx_create ( isc_mem_t mctx,
isc_appctx_t **  ctxp 
)

Definition at line 966 of file app.c.

Referenced by isc_appctx_create().

void isc__appctx_destroy ( isc_appctx_t **  ctxp  ) 

Definition at line 993 of file app.c.

Referenced by isc_appctx_destroy().

void isc__appctx_settaskmgr ( isc_appctx_t ctx,
isc_taskmgr_t taskmgr 
)

Definition at line 1006 of file app.c.

Referenced by isc_appctx_settaskmgr().

void isc__appctx_setsocketmgr ( isc_appctx_t ctx,
isc_socketmgr_t socketmgr 
)

Definition at line 1015 of file app.c.

Referenced by isc_appctx_setsocketmgr().

void isc__appctx_settimermgr ( isc_appctx_t ctx,
isc_timermgr_t timermgr 
)

Definition at line 1024 of file app.c.

Referenced by isc_appctx_settimermgr().

isc_result_t isc__app_ctxonrun ( isc_appctx_t ctx,
isc_mem_t mctx,
isc_task_t task,
isc_taskaction_t  action,
void *  arg 
)

Definition at line 403 of file app.c.

References ISC_APPEVENT_SHUTDOWN, isc_event_allocate(), ISC_LIST_APPEND, ISC_R_ALREADYRUNNING, ISC_R_NOMEMORY, ISC_R_SUCCESS, isc_task_attach(), isc__appctx::lock, LOCK, isc__appctx::on_run, isc__appctx::running, and UNLOCK.

Referenced by isc__app_onrun(), and isc_app_ctxonrun().

static void exit_action ( int  arg  )  [static]

Definition at line 177 of file app.c.

References ISC_TRUE, UNUSED, and isc__appctx::want_shutdown.

Referenced by isc__app_ctxstart().

static void reload_action ( int  arg  )  [static]

Definition at line 183 of file app.c.

References ISC_TRUE, UNUSED, and isc__appctx::want_reload.

Referenced by isc__app_ctxrun().

static isc_result_t handle_signal ( int  sig,
void(*)(int)  handler 
) [static]

Definition at line 190 of file app.c.

References isc__strerror(), ISC_MSG_SIGNALSETUP, isc_msgcat_get(), ISC_MSGSET_APP, ISC_R_SUCCESS, ISC_R_UNEXPECTED, ISC_STRERRORSIZE, and UNEXPECTED_ERROR.

Referenced by isc__app_ctxrun(), and isc__app_ctxstart().

static isc_result_t evloop ( isc__appctx_t ctx  )  [static]

Event loop for nonthreaded programs.

Definition at line 445 of file app.c.

References isc__socketmgr_dispatch(), isc__socketmgr_waitevents(), isc__taskmgr_dispatch(), isc__taskmgr_ready(), isc__timermgr_dispatch(), isc__timermgr_nextevent(), ISC_FALSE, ISC_R_RELOAD, ISC_R_SUCCESS, isc_time_microdiff(), ISC_TRUE, now, isc__appctx::socketmgr, isc__appctx::taskmgr, TIME_NOW, isc__appctx::timermgr, isc__appctx::want_reload, and isc__appctx::want_shutdown.

Referenced by isc__app_ctxrun(), and isc__nothread_wait_hack().

isc_result_t isc__nothread_wait_hack ( isc_condition_t cp,
isc_mutex_t mp 
)

Definition at line 542 of file app.c.

References evloop(), INSIST, ISC_FALSE, ISC_R_RELOAD, ISC_R_SUCCESS, ISC_TRUE, UNUSED, isc__appctx::want_reload, and isc__appctx::want_shutdown.

isc_result_t isc__nothread_signal_hack ( isc_condition_t cp  ) 

Definition at line 568 of file app.c.

References INSIST, ISC_R_SUCCESS, ISC_TRUE, UNUSED, and isc__appctx::want_shutdown.

isc_result_t isc__app_register ( void   ) 

A short cut function that specifies the application module in the ISC library for isc_app_register(). An application that uses the ISC library usually do not have to care about this function: it would call isc_lib_register(), which internally calls this function.

Definition at line 1033 of file app.c.

Referenced by do_register().


Variable Documentation

isc__appctx_t isc_g_appctx [static]

Definition at line 132 of file app.c.

isc_appmethods_t methods

Definition at line 135 of file app.c.

Referenced by dns_name_towire().

void* run

The following are defined just for avoiding unused static functions.

Definition at line 140 of file app.c.

Referenced by isc__taskmgr_create(), and isc__timermgr_create().

void * shutdown

Definition at line 140 of file app.c.

void * start

Definition at line 140 of file app.c.

Referenced by dns_compress_add(), dns_nsec_compressbitmap(), dns_time64_from32(), dumptostreaminc(), free_rbtdb(), fromtext_hip(), generate(), incremental_cleaning_action(), and receive_secure_serial().

void * reload

Definition at line 140 of file app.c.

Referenced by ns_server_reload(), and ns_server_reloadcommand().

void * finish

Definition at line 140 of file app.c.

Referenced by dns_keytable_deletekeynode(), dns_view_findzonecut2(), and resquery_response().

void * block

Definition at line 140 of file app.c.

Referenced by msgblock_allocate(), and transform().

void * unblock

Definition at line 140 of file app.c.

struct { ... } appmethods [static]

Referenced by isc__app_start().

isc_boolean_t in_recursive_evloop = ISC_FALSE [static]

True if we are currently executing in the recursive event loop.

Definition at line 532 of file app.c.

isc_boolean_t signalled = ISC_FALSE [static]

True if we are exiting the event loop as the result of a call to isc_condition_signal() rather than a shutdown or reload.

Definition at line 539 of file app.c.


Generated on Tue Apr 28 17:41:18 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha