mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 13:38:26 +00:00
417. [func] Add isc_app_block() and isc_app_unblock(), which
allow an application to handle signals while blocking.
This commit is contained in:
parent
da41917c3f
commit
1b32bc7da1
4
CHANGES
4
CHANGES
@ -1,4 +1,8 @@
|
|||||||
|
|
||||||
|
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
|
416. [bug] Slave zones with no master file tried to use a
|
||||||
NULL pointer for a journal file name when they
|
NULL pointer for a journal file name when they
|
||||||
received an IXFR. [RT #273]
|
received an IXFR. [RT #273]
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* 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>
|
#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 want_reload = ISC_FALSE;
|
||||||
|
|
||||||
|
static isc_boolean_t blocked = ISC_FALSE;
|
||||||
|
#ifdef ISC_PLATFORM_USETHREADS
|
||||||
|
static pthread_t blockedthread;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_LINUXTHREADS
|
#ifdef HAVE_LINUXTHREADS
|
||||||
/*
|
/*
|
||||||
* Linux has sigwait(), but it appears to prevent signal handlers from
|
* Linux has sigwait(), but it appears to prevent signal handlers from
|
||||||
@ -521,3 +526,43 @@ isc_app_finish(void) {
|
|||||||
|
|
||||||
DESTROYLOCK(&lock);
|
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.
|
* 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
|
#ifndef ISC_APP_H
|
||||||
#define ISC_APP_H 1
|
#define ISC_APP_H 1
|
||||||
@ -176,6 +176,37 @@ isc_app_finish(void);
|
|||||||
* Any resources allocated by isc_app_start() have been released.
|
* 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
|
ISC_LANG_ENDDECLS
|
||||||
|
|
||||||
#endif /* ISC_APP_H */
|
#endif /* ISC_APP_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user