Commit 1b32bc7d authored by Brian Wellington's avatar Brian Wellington
Browse files

417. [func] Add isc_app_block() and isc_app_unblock(), which

                        allow an application to handle signals while
                        blocking.
parent da41917c
417. [func] Add isc_app_block() and isc_app_unblock(), which
allow an application to handle signals while
blocking.
416. [bug] Slave zones with no master file tried to use a
NULL pointer for a journal file name when they
received an IXFR. [RT #273]
......
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: app.c,v 1.28 2000/08/30 23:47:16 bwelling Exp $ */
/* $Id: app.c,v 1.29 2000/09/01 21:31:51 bwelling Exp $ */
#include <config.h>
......@@ -58,6 +58,11 @@ static isc_boolean_t want_shutdown = ISC_FALSE;
*/
static isc_boolean_t want_reload = ISC_FALSE;
static isc_boolean_t blocked = ISC_FALSE;
#ifdef ISC_PLATFORM_USETHREADS
static pthread_t blockedthread;
#endif
#ifdef HAVE_LINUXTHREADS
/*
* Linux has sigwait(), but it appears to prevent signal handlers from
......@@ -521,3 +526,43 @@ isc_app_finish(void) {
DESTROYLOCK(&lock);
}
void
isc_app_block(void) {
#ifdef ISC_PLATFORM_USETHREADS
sigset_t sset;
#endif
REQUIRE(running);
REQUIRE(!blocked);
blocked = ISC_TRUE;
#ifdef ISC_PLATFORM_USETHREADS
blockedthread = pthread_self();
RUNTIME_CHECK(sigemptyset(&sset) == 0 &&
sigaddset(&sset, SIGINT) == 0 &&
sigaddset(&sset, SIGTERM) == 0);
RUNTIME_CHECK(pthread_sigmask(SIG_UNBLOCK, &sset, NULL) == 0);
#endif
}
void
isc_app_unblock(void) {
#ifdef ISC_PLATFORM_USETHREADS
sigset_t sset;
#endif
REQUIRE(running);
REQUIRE(blocked);
blocked = ISC_FALSE;
#ifdef ISC_PLATFORM_USETHREADS
REQUIRE(blockedthread == pthread_self());
RUNTIME_CHECK(sigemptyset(&sset) == 0 &&
sigaddset(&sset, SIGINT) == 0 &&
sigaddset(&sset, SIGTERM) == 0);
RUNTIME_CHECK(pthread_sigmask(SIG_BLOCK, &sset, NULL) == 0);
#endif
}
......@@ -15,7 +15,7 @@
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: app.h,v 1.8 2000/08/01 01:31:34 tale Exp $ */
/* $Id: app.h,v 1.9 2000/09/01 21:31:53 bwelling Exp $ */
#ifndef ISC_APP_H
#define ISC_APP_H 1
......@@ -176,6 +176,37 @@ isc_app_finish(void);
* Any resources allocated by isc_app_start() have been released.
*/
void
isc_app_block(void);
/*
* Indicate that a blocking operation will be performed.
*
* Notes:
* If a blocking operation is in process, a call to isc_app_shutdown()
* or an external signal will abort the program, rather than allowing
* clean shutdown. This is primarily useful for reading user input.
*
* Requires:
* isc_app_start() has been called.
* No other blocking operations are in progress.
*/
void
isc_app_unblock(void);
/*
* Indicate that a blocking operation is complete.
*
* Notes:
* When a blocking operation has completed, return the program to a
* state where a call to isc_app_shutdown() or an external signal will
* shutdown normally.
*
* Requires:
* isc_app_start() has been called.
* isc_app_block() has been called by the same thread.
*/
ISC_LANG_ENDDECLS
#endif /* ISC_APP_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment