1999-05-12 09:44:35 +00:00
|
|
|
/*
|
2000-02-03 23:08:31 +00:00
|
|
|
* Copyright (C) 1999, 2000 Internet Software Consortium.
|
2000-08-01 01:33:37 +00:00
|
|
|
*
|
1999-05-12 09:44:35 +00:00
|
|
|
* 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.
|
2000-08-01 01:33:37 +00:00
|
|
|
*
|
2000-07-27 09:55:03 +00:00
|
|
|
* 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.
|
1999-05-12 09:44:35 +00:00
|
|
|
*/
|
|
|
|
|
2000-08-26 01:31:56 +00:00
|
|
|
/* $Id: app.c,v 1.25 2000/08/26 01:31:53 bwelling Exp $ */
|
2000-06-22 22:00:42 +00:00
|
|
|
|
1999-05-12 09:44:35 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include <pthread.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <signal.h>
|
|
|
|
|
|
|
|
#include <isc/app.h>
|
|
|
|
#include <isc/boolean.h>
|
|
|
|
#include <isc/mutex.h>
|
1999-07-14 02:03:44 +00:00
|
|
|
#include <isc/event.h>
|
2000-05-08 14:38:29 +00:00
|
|
|
#include <isc/string.h>
|
2000-04-28 21:08:52 +00:00
|
|
|
#include <isc/task.h>
|
1999-12-16 22:24:22 +00:00
|
|
|
#include <isc/util.h>
|
1999-05-12 09:44:35 +00:00
|
|
|
|
|
|
|
static isc_eventlist_t on_run;
|
|
|
|
static isc_mutex_t lock;
|
|
|
|
static isc_boolean_t shutdown_requested = ISC_FALSE;
|
1999-07-14 02:03:44 +00:00
|
|
|
static isc_boolean_t running = ISC_FALSE;
|
2000-01-25 03:33:55 +00:00
|
|
|
/*
|
|
|
|
* We assume that 'want_shutdown' can be read and written atomically.
|
|
|
|
*/
|
|
|
|
static isc_boolean_t want_shutdown = ISC_FALSE;
|
2000-01-22 01:39:35 +00:00
|
|
|
/*
|
|
|
|
* We assume that 'want_reload' can be read and written atomically.
|
|
|
|
*/
|
|
|
|
static isc_boolean_t want_reload = ISC_FALSE;
|
1999-05-12 09:44:35 +00:00
|
|
|
|
1999-05-12 22:35:40 +00:00
|
|
|
#ifdef HAVE_LINUXTHREADS
|
2000-01-25 03:33:55 +00:00
|
|
|
/*
|
|
|
|
* Linux has sigwait(), but it appears to prevent signal handlers from
|
|
|
|
* running, even if they're not in the set being waited for. This makes
|
|
|
|
* it impossible to get the default actions for SIGILL, SIGSEGV, etc.
|
|
|
|
* Instead of messing with it, we just use sigsuspend() instead.
|
|
|
|
*/
|
|
|
|
#undef HAVE_SIGWAIT
|
|
|
|
/*
|
|
|
|
* We need to remember which thread is the main thread...
|
|
|
|
*/
|
1999-05-12 22:35:40 +00:00
|
|
|
static pthread_t main_thread;
|
|
|
|
#endif
|
|
|
|
|
1999-05-12 09:44:35 +00:00
|
|
|
#ifndef HAVE_SIGWAIT
|
|
|
|
static void
|
2000-01-25 03:33:55 +00:00
|
|
|
exit_action(int arg) {
|
2000-05-08 14:38:29 +00:00
|
|
|
UNUSED(arg);
|
2000-01-25 03:33:55 +00:00
|
|
|
want_shutdown = ISC_TRUE;
|
2000-01-22 01:39:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
reload_action(int arg) {
|
2000-05-08 14:38:29 +00:00
|
|
|
UNUSED(arg);
|
2000-01-22 01:39:35 +00:00
|
|
|
want_reload = ISC_TRUE;
|
1999-05-12 09:44:35 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1999-05-12 22:54:46 +00:00
|
|
|
static isc_result_t
|
|
|
|
handle_signal(int sig, void (*handler)(int)) {
|
|
|
|
struct sigaction sa;
|
|
|
|
|
|
|
|
memset(&sa, 0, sizeof sa);
|
|
|
|
sa.sa_handler = handler;
|
|
|
|
|
|
|
|
if (sigfillset(&sa.sa_mask) != 0 ||
|
|
|
|
sigaction(sig, &sa, NULL) < 0) {
|
|
|
|
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
|
|
|
"handle_signal() %d setup: %s", sig,
|
|
|
|
strerror(errno));
|
|
|
|
return (ISC_R_UNEXPECTED);
|
|
|
|
}
|
2000-08-01 01:33:37 +00:00
|
|
|
|
1999-05-12 22:54:46 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
1999-05-12 09:44:35 +00:00
|
|
|
isc_result_t
|
|
|
|
isc_app_start(void) {
|
|
|
|
isc_result_t result;
|
|
|
|
int presult;
|
|
|
|
sigset_t sset;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Start an ISC library application.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef NEED_PTHREAD_INIT
|
|
|
|
/*
|
|
|
|
* BSDI 3.1 seg faults in pthread_sigmask() if we don't do this.
|
|
|
|
*/
|
|
|
|
presult = pthread_init();
|
|
|
|
if (presult != 0) {
|
|
|
|
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
2000-08-01 01:33:37 +00:00
|
|
|
"isc_app_start() pthread_init: %s",
|
1999-05-12 09:44:35 +00:00
|
|
|
strerror(presult));
|
|
|
|
return (ISC_R_UNEXPECTED);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1999-05-12 22:35:40 +00:00
|
|
|
#ifdef HAVE_LINUXTHREADS
|
|
|
|
main_thread = pthread_self();
|
|
|
|
#endif
|
|
|
|
|
1999-05-12 09:44:35 +00:00
|
|
|
result = isc_mutex_init(&lock);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
|
|
|
|
|
|
|
#ifndef HAVE_SIGWAIT
|
|
|
|
/*
|
2000-03-18 01:29:48 +00:00
|
|
|
* Install do-nothing handlers for SIGINT and SIGTERM.
|
1999-05-12 09:44:35 +00:00
|
|
|
*
|
|
|
|
* We install them now because BSDI 3.1 won't block
|
|
|
|
* the default actions, regardless of what we do with
|
|
|
|
* pthread_sigmask().
|
|
|
|
*/
|
2000-01-25 03:33:55 +00:00
|
|
|
result = handle_signal(SIGINT, exit_action);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
|
|
|
result = handle_signal(SIGTERM, exit_action);
|
1999-05-12 22:54:46 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
1999-05-12 09:44:35 +00:00
|
|
|
#endif
|
|
|
|
|
1999-05-12 22:54:46 +00:00
|
|
|
/*
|
|
|
|
* Always ignore SIGPIPE.
|
|
|
|
*/
|
|
|
|
result = handle_signal(SIGPIPE, SIG_IGN);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
|
|
|
|
2000-06-27 18:49:14 +00:00
|
|
|
/*
|
2000-06-27 21:04:12 +00:00
|
|
|
* On Solaris 2, delivery of a signal whose action is SIG_IGN
|
|
|
|
* will not cause sigwait() to return. We may have inherited
|
2000-07-11 19:18:05 +00:00
|
|
|
* unexpected actions for SIGHUP, SIGINT, and SIGTERM from our parent
|
|
|
|
* process, * (e.g, Solaris cron). Set an action of SIG_DFL to make
|
2000-07-12 01:46:57 +00:00
|
|
|
* sure sigwait() works as expected. Only do this for SIGTERM and
|
|
|
|
* SIGINT if we don't have sigwait(), since a different handler is
|
|
|
|
* installed above.
|
2000-06-27 18:49:14 +00:00
|
|
|
*/
|
|
|
|
result = handle_signal(SIGHUP, SIG_DFL);
|
2000-07-11 19:18:05 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
2000-07-12 01:46:57 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_SIGWAIT
|
2000-07-11 19:18:05 +00:00
|
|
|
result = handle_signal(SIGTERM, SIG_DFL);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
|
|
|
result = handle_signal(SIGINT, SIG_DFL);
|
2000-06-27 18:49:14 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
2000-07-12 01:46:57 +00:00
|
|
|
#endif
|
2000-06-27 18:49:14 +00:00
|
|
|
|
1999-05-12 09:44:35 +00:00
|
|
|
/*
|
2000-01-22 01:39:35 +00:00
|
|
|
* Block SIGHUP, SIGINT, SIGTERM.
|
1999-05-12 09:44:35 +00:00
|
|
|
*
|
|
|
|
* If isc_app_start() is called from the main thread before any other
|
|
|
|
* threads have been created, then the pthread_sigmask() call below
|
2000-03-18 01:29:48 +00:00
|
|
|
* will result in all threads having SIGHUP, SIGINT and SIGTERM
|
|
|
|
* blocked by default, ensuring that only the thread that calls
|
|
|
|
* sigwait() for them will get those signals.
|
1999-05-12 09:44:35 +00:00
|
|
|
*/
|
|
|
|
if (sigemptyset(&sset) != 0 ||
|
2000-01-22 01:39:35 +00:00
|
|
|
sigaddset(&sset, SIGHUP) != 0 ||
|
1999-05-12 09:44:35 +00:00
|
|
|
sigaddset(&sset, SIGINT) != 0 ||
|
|
|
|
sigaddset(&sset, SIGTERM) != 0) {
|
|
|
|
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
2000-08-01 01:33:37 +00:00
|
|
|
"isc_app_start() sigsetops: %s",
|
1999-05-12 09:44:35 +00:00
|
|
|
strerror(errno));
|
|
|
|
return (ISC_R_UNEXPECTED);
|
|
|
|
}
|
|
|
|
presult = pthread_sigmask(SIG_BLOCK, &sset, NULL);
|
|
|
|
if (presult != 0) {
|
|
|
|
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
2000-08-01 01:33:37 +00:00
|
|
|
"isc_app_start() pthread_sigmask: %s",
|
1999-05-12 09:44:35 +00:00
|
|
|
strerror(presult));
|
|
|
|
return (ISC_R_UNEXPECTED);
|
|
|
|
}
|
|
|
|
|
|
|
|
ISC_LIST_INIT(on_run);
|
|
|
|
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
1999-07-14 02:03:44 +00:00
|
|
|
isc_result_t
|
|
|
|
isc_app_onrun(isc_mem_t *mctx, isc_task_t *task, isc_taskaction_t action,
|
|
|
|
void *arg)
|
|
|
|
{
|
|
|
|
isc_event_t *event;
|
|
|
|
isc_task_t *cloned_task = NULL;
|
|
|
|
isc_result_t result;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Request delivery of an event when the application is run.
|
|
|
|
*/
|
|
|
|
|
|
|
|
LOCK(&lock);
|
|
|
|
|
|
|
|
if (running) {
|
|
|
|
result = ISC_R_ALREADYRUNNING;
|
|
|
|
goto unlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note that we store the task to which we're going to send the event
|
|
|
|
* in the event's "sender" field.
|
|
|
|
*/
|
|
|
|
isc_task_attach(task, &cloned_task);
|
|
|
|
event = isc_event_allocate(mctx, cloned_task, ISC_APPEVENT_SHUTDOWN,
|
|
|
|
action, arg, sizeof *event);
|
|
|
|
if (event == NULL) {
|
|
|
|
result = ISC_R_NOMEMORY;
|
|
|
|
goto unlock;
|
|
|
|
}
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-04-17 19:22:44 +00:00
|
|
|
ISC_LIST_APPEND(on_run, event, ev_link);
|
1999-07-14 02:03:44 +00:00
|
|
|
|
|
|
|
result = ISC_R_SUCCESS;
|
|
|
|
|
|
|
|
unlock:
|
|
|
|
UNLOCK(&lock);
|
|
|
|
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
1999-05-12 09:44:35 +00:00
|
|
|
isc_result_t
|
|
|
|
isc_app_run(void) {
|
|
|
|
int result;
|
|
|
|
sigset_t sset;
|
|
|
|
isc_event_t *event, *next_event;
|
1999-07-14 02:03:44 +00:00
|
|
|
isc_task_t *task;
|
1999-05-12 09:44:35 +00:00
|
|
|
#ifdef HAVE_SIGWAIT
|
|
|
|
int sig;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Run an ISC library application.
|
|
|
|
*/
|
|
|
|
|
1999-05-12 22:35:40 +00:00
|
|
|
#ifdef HAVE_LINUXTHREADS
|
|
|
|
REQUIRE(main_thread == pthread_self());
|
|
|
|
#endif
|
|
|
|
|
1999-07-14 02:03:44 +00:00
|
|
|
LOCK(&lock);
|
|
|
|
|
2000-01-22 01:39:35 +00:00
|
|
|
if (!running) {
|
|
|
|
running = ISC_TRUE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Post any on-run events (in FIFO order).
|
|
|
|
*/
|
|
|
|
for (event = ISC_LIST_HEAD(on_run);
|
|
|
|
event != NULL;
|
|
|
|
event = next_event) {
|
2000-04-17 19:22:44 +00:00
|
|
|
next_event = ISC_LIST_NEXT(event, ev_link);
|
|
|
|
ISC_LIST_UNLINK(on_run, event, ev_link);
|
|
|
|
task = event->ev_sender;
|
2000-08-25 18:58:35 +00:00
|
|
|
event->ev_sender = NULL;
|
2000-01-22 01:39:35 +00:00
|
|
|
isc_task_sendanddetach(&task, &event);
|
|
|
|
}
|
1999-07-14 02:03:44 +00:00
|
|
|
|
1999-05-12 09:44:35 +00:00
|
|
|
}
|
2000-08-01 01:33:37 +00:00
|
|
|
|
1999-07-14 02:03:44 +00:00
|
|
|
UNLOCK(&lock);
|
|
|
|
|
2000-01-22 01:39:35 +00:00
|
|
|
#ifndef HAVE_SIGWAIT
|
|
|
|
/*
|
|
|
|
* Catch SIGHUP.
|
|
|
|
*
|
|
|
|
* We do this here to ensure that the signal handler is installed
|
|
|
|
* (i.e. that it wasn't a "one-shot" handler).
|
|
|
|
*/
|
|
|
|
result = handle_signal(SIGHUP, reload_action);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
#endif
|
|
|
|
|
1999-07-14 02:03:44 +00:00
|
|
|
/*
|
|
|
|
* There is no danger if isc_app_shutdown() is called before we wait
|
|
|
|
* for signals. Signals are blocked, so any such signal will simply
|
|
|
|
* be made pending and we will get it when we call sigwait().
|
|
|
|
*/
|
1999-05-12 09:44:35 +00:00
|
|
|
|
2000-01-25 03:33:55 +00:00
|
|
|
while (!want_shutdown) {
|
1999-05-12 09:44:35 +00:00
|
|
|
#ifdef HAVE_SIGWAIT
|
2000-01-25 03:33:55 +00:00
|
|
|
/*
|
|
|
|
* Wait for SIGHUP, SIGINT, or SIGTERM.
|
|
|
|
*/
|
|
|
|
if (sigemptyset(&sset) != 0 ||
|
|
|
|
sigaddset(&sset, SIGHUP) != 0 ||
|
|
|
|
sigaddset(&sset, SIGINT) != 0 ||
|
|
|
|
sigaddset(&sset, SIGTERM) != 0) {
|
|
|
|
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
2000-08-01 01:33:37 +00:00
|
|
|
"isc_app_run() sigsetops: %s",
|
2000-01-25 03:33:55 +00:00
|
|
|
strerror(errno));
|
|
|
|
return (ISC_R_UNEXPECTED);
|
|
|
|
}
|
2000-05-18 22:39:24 +00:00
|
|
|
|
|
|
|
#ifndef HAVE_UNIXWARE_SIGWAIT
|
2000-01-25 03:33:55 +00:00
|
|
|
result = sigwait(&sset, &sig);
|
|
|
|
if (result == 0) {
|
|
|
|
if (sig == SIGINT ||
|
|
|
|
sig == SIGTERM)
|
|
|
|
want_shutdown = ISC_TRUE;
|
|
|
|
else if (sig == SIGHUP)
|
|
|
|
want_reload = ISC_TRUE;
|
|
|
|
}
|
2000-05-18 22:39:24 +00:00
|
|
|
|
|
|
|
#else /* Using UnixWare sigwait semantics. */
|
|
|
|
sig = sigwait(&sset);
|
|
|
|
if (sig >= 0) {
|
|
|
|
if (sig == SIGINT ||
|
|
|
|
sig == SIGTERM)
|
|
|
|
want_shutdown = ISC_TRUE;
|
|
|
|
else if (sig == SIGHUP)
|
|
|
|
want_reload = ISC_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* HAVE_UNIXWARE_SIGWAIT */
|
|
|
|
#else /* Don't have sigwait(). */
|
2000-01-22 01:39:35 +00:00
|
|
|
/*
|
2000-01-25 03:33:55 +00:00
|
|
|
* Listen for all signals.
|
2000-01-22 01:39:35 +00:00
|
|
|
*/
|
2000-01-25 03:33:55 +00:00
|
|
|
if (sigemptyset(&sset) != 0) {
|
|
|
|
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
2000-08-01 01:33:37 +00:00
|
|
|
"isc_app_run() sigsetops: %s",
|
2000-01-25 03:33:55 +00:00
|
|
|
strerror(errno));
|
|
|
|
return (ISC_R_UNEXPECTED);
|
|
|
|
}
|
|
|
|
result = sigsuspend(&sset);
|
2000-05-18 22:39:24 +00:00
|
|
|
#endif /* HAVE_SIGWAIT */
|
2000-01-25 03:33:55 +00:00
|
|
|
|
|
|
|
if (want_reload) {
|
|
|
|
want_reload = ISC_FALSE;
|
|
|
|
return (ISC_R_RELOAD);
|
|
|
|
}
|
2000-01-22 01:39:35 +00:00
|
|
|
}
|
|
|
|
|
1999-05-12 09:44:35 +00:00
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
isc_result_t
|
|
|
|
isc_app_shutdown(void) {
|
|
|
|
isc_boolean_t want_kill = ISC_TRUE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Request application shutdown.
|
|
|
|
*/
|
|
|
|
|
|
|
|
LOCK(&lock);
|
2000-08-01 01:33:37 +00:00
|
|
|
|
1999-07-14 02:03:44 +00:00
|
|
|
REQUIRE(running);
|
|
|
|
|
1999-05-12 09:44:35 +00:00
|
|
|
if (shutdown_requested)
|
|
|
|
want_kill = ISC_FALSE;
|
|
|
|
else
|
|
|
|
shutdown_requested = ISC_TRUE;
|
|
|
|
|
|
|
|
UNLOCK(&lock);
|
|
|
|
|
1999-05-12 22:35:40 +00:00
|
|
|
if (want_kill) {
|
|
|
|
#ifdef HAVE_LINUXTHREADS
|
|
|
|
int result;
|
2000-08-01 01:33:37 +00:00
|
|
|
|
1999-05-12 22:35:40 +00:00
|
|
|
result = pthread_kill(main_thread, SIGTERM);
|
|
|
|
if (result != 0) {
|
|
|
|
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
|
|
|
"isc_app_shutdown() pthread_kill: %s",
|
|
|
|
strerror(result));
|
|
|
|
return (ISC_R_UNEXPECTED);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
if (kill(getpid(), SIGTERM) < 0) {
|
|
|
|
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
|
|
|
"isc_app_shutdown() kill: %s",
|
|
|
|
strerror(errno));
|
|
|
|
return (ISC_R_UNEXPECTED);
|
|
|
|
}
|
|
|
|
#endif
|
1999-05-12 09:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2000-01-22 01:39:35 +00:00
|
|
|
isc_result_t
|
|
|
|
isc_app_reload(void) {
|
|
|
|
isc_boolean_t want_kill = ISC_TRUE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Request application reload.
|
|
|
|
*/
|
|
|
|
|
|
|
|
LOCK(&lock);
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-01-22 01:39:35 +00:00
|
|
|
REQUIRE(running);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't send the reload signal if we're shutting down.
|
|
|
|
*/
|
|
|
|
if (shutdown_requested)
|
|
|
|
want_kill = ISC_FALSE;
|
|
|
|
|
|
|
|
UNLOCK(&lock);
|
|
|
|
|
|
|
|
if (want_kill) {
|
|
|
|
#ifdef HAVE_LINUXTHREADS
|
|
|
|
int result;
|
2000-08-01 01:33:37 +00:00
|
|
|
|
2000-01-22 01:39:35 +00:00
|
|
|
result = pthread_kill(main_thread, SIGHUP);
|
|
|
|
if (result != 0) {
|
|
|
|
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
2000-06-29 07:40:58 +00:00
|
|
|
"isc_app_reload() pthread_kill: %s",
|
2000-01-22 01:39:35 +00:00
|
|
|
strerror(result));
|
|
|
|
return (ISC_R_UNEXPECTED);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
if (kill(getpid(), SIGHUP) < 0) {
|
|
|
|
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
2000-06-29 07:40:58 +00:00
|
|
|
"isc_app_reload() kill: %s",
|
2000-01-22 01:39:35 +00:00
|
|
|
strerror(errno));
|
|
|
|
return (ISC_R_UNEXPECTED);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
}
|
|
|
|
|
1999-05-12 09:44:35 +00:00
|
|
|
void
|
|
|
|
isc_app_finish(void) {
|
|
|
|
/*
|
|
|
|
* Finish an ISC library application.
|
|
|
|
*/
|
|
|
|
|
2000-08-26 01:31:56 +00:00
|
|
|
DESTROYLOCK(&lock);
|
1999-05-12 09:44:35 +00:00
|
|
|
}
|