/*
* Copyright (C) 1999-2001, 2004, 2007, 2009, 2013, 2014, 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* $Id: app.c,v 1.9 2009/09/02 23:48:03 tbox Exp $ */
#include <config.h>
#include <stddef.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <process.h>
#include <isc/condition.h>
#include <isc/platform.h>
/*%
* For BIND9 internal applications built with threads, we use a single app
* context and let multiple worker, I/O, timer threads do actual jobs.
*/
/*%
* The following are intended for internal use (indicated by "isc__"
* prefix) but are not declared as static, allowing direct access from
* unit tests etc.
*/
isc_result_t isc__app_start(void);
isc_result_t isc__app_run(void);
isc_result_t isc__app_shutdown(void);
isc_result_t isc__app_reload(void);
void isc__app_finish(void);
void isc__app_block(void);
void isc__app_unblock(void);
void *arg);
/*
* The application context of this module. This implementation actually
* doesn't use it. (This may change in the future).
*/
/* Events to wait for */
enum {
};
typedef struct isc__appctx {
/*
* We assume that 'want_shutdown' can be read and written atomically.
*/
/*
* We assume that 'want_reload' can be read and written atomically.
*/
static struct {
/*%
* The following are defined just for avoiding unused static functions.
*/
} appmethods = {
{
},
(void *)isc__app_run,
(void *)isc__app_shutdown,
(void *)isc__app_start,
(void *)isc__app_reload,
(void *)isc__app_finish,
(void *)isc__app_block,
(void *)isc__app_unblock
};
/*
* We need to remember which thread is the main thread...
*/
/*
* Start an ISC library application.
*/
if (result != ISC_R_SUCCESS)
return (result);
/* Create the reload event in a non-signaled state */
/* Create the shutdown event in a non-signaled state */
return (ISC_R_SUCCESS);
}
isc__app_start(void) {
/* The remaining members will be initialized in ctxstart() */
}
void *arg)
{
}
{
goto unlock;
}
/*
* Note that we store the task to which we're going to send the event
* in the event's "sender" field.
*/
goto unlock;
}
return (result);
}
/*
* Post any on-run events (in FIFO order).
*/
event = next_event) {
}
}
/*
* There is no danger if isc_app_shutdown() is called before we wait
* for events.
*/
while (!ctx->want_shutdown) {
/* See why we returned */
/*
* The return was due to one of the events
* being signaled
*/
switch (WaitSucceededIndex(dwWaitResult)) {
case RELOAD_EVENT:
break;
case SHUTDOWN_EVENT:
break;
}
}
if (ctx->want_reload) {
return (ISC_R_RELOAD);
}
exit(-1);
}
return (ISC_R_SUCCESS);
}
isc__app_run(void) {
}
if (ctx->shutdown_requested)
else
if (want_kill)
return (ISC_R_SUCCESS);
}
isc__app_shutdown(void) {
}
/*
* Don't send the reload signal if we're shutting down.
*/
if (ctx->shutdown_requested)
if (want_kill)
return (ISC_R_SUCCESS);
}
isc__app_reload(void) {
}
void
}
void
isc__app_finish(void) {
}
void
isc__app_block(void) {
}
void
isc__app_unblock(void) {
}
return (ISC_R_NOMEMORY);
return (ISC_R_SUCCESS);
}
void
}
void
}
void
}
void
}
isc__app_register(void) {
return (isc_app_register(isc__appctx_create));
}
#include "../app_api.c"