app.c revision 91cd0f93ad34d23e8b09dca337120f64fbe8f0a1
/*
* Copyright (C) 1999-2001 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: app.c,v 1.4 2001/11/27 01:56:20 gson 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>
static isc_eventlist_t on_run;
static isc_mutex_t lock;
/*
* We assume that 'want_shutdown' can be read and written atomically.
*/
/*
* We assume that 'want_reload' can be read and written atomically.
*/
static isc_thread_t blockedthread;
/* Events to wait for */
#define NUM_EVENTS 2
enum {
};
/*
* We need to remember which thread is the main thread...
*/
static isc_thread_t main_thread;
isc_app_start(void) {
/*
* 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);
}
void *arg) {
if (running) {
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);
}
isc_app_run(void) {
if (!running) {
/*
* 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 (!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 (want_reload) {
return (ISC_R_RELOAD);
}
if (want_shutdown && blocked)
exit(-1);
}
return (ISC_R_SUCCESS);
}
isc_app_shutdown(void) {
if (shutdown_requested)
else
if (want_kill)
return (ISC_R_SUCCESS);
}
isc_app_reload(void) {
/*
* Don't send the reload signal if we're shutting down.
*/
if (shutdown_requested)
if (want_reload)
return (ISC_R_SUCCESS);
}
void
isc_app_finish(void) {
DESTROYLOCK(&lock);
}
void
isc_app_block(void) {
}
void
isc_app_unblock(void) {
}