mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-16 03:18:52 -04:00
dont run isc__trampoline_initialize() in dlopen library
when built without libtool, the sample driver in the dyndb system test runs library intializers that have already been run, causing the value for isc__trampoline_min to be reset. wrap the trampoline initialize and shutdown routines under isc_once_do() to ensure that they are only run once.
This commit is contained in:
parent
7a1ae6255a
commit
adeddfa8ff
1 changed files with 16 additions and 3 deletions
|
|
@ -66,6 +66,9 @@ __declspec(thread) size_t isc_tid_v = SIZE_MAX;
|
|||
static size_t isc__trampoline_min = 1;
|
||||
static size_t isc__trampoline_max = 65;
|
||||
|
||||
static isc_once_t start_once = ISC_ONCE_INIT;
|
||||
static isc_once_t stop_once = ISC_ONCE_INIT;
|
||||
|
||||
static isc__trampoline_t *
|
||||
isc__trampoline_new(int tid, isc_threadfunc_t start, isc_threadarg_t arg) {
|
||||
isc__trampoline_t *trampoline = calloc(1, sizeof(*trampoline));
|
||||
|
|
@ -81,8 +84,8 @@ isc__trampoline_new(int tid, isc_threadfunc_t start, isc_threadarg_t arg) {
|
|||
return (trampoline);
|
||||
}
|
||||
|
||||
void
|
||||
isc__trampoline_initialize(void) {
|
||||
static void
|
||||
do_init(void) {
|
||||
uv_mutex_init(&isc__trampoline_lock);
|
||||
|
||||
trampolines = calloc(isc__trampoline_max, sizeof(trampolines[0]));
|
||||
|
|
@ -101,7 +104,12 @@ isc__trampoline_initialize(void) {
|
|||
}
|
||||
|
||||
void
|
||||
isc__trampoline_shutdown(void) {
|
||||
isc__trampoline_initialize(void) {
|
||||
isc_once_do(&start_once, do_init);
|
||||
}
|
||||
|
||||
static void
|
||||
do_shutdown(void) {
|
||||
/*
|
||||
* When the program using the library exits abruptly and the library
|
||||
* gets unloaded, there might be some existing trampolines from unjoined
|
||||
|
|
@ -112,6 +120,11 @@ isc__trampoline_shutdown(void) {
|
|||
free(trampolines[0]);
|
||||
}
|
||||
|
||||
void
|
||||
isc__trampoline_shutdown(void) {
|
||||
isc_once_do(&stop_once, do_shutdown);
|
||||
}
|
||||
|
||||
isc__trampoline_t *
|
||||
isc__trampoline_get(isc_threadfunc_t start, isc_threadarg_t arg) {
|
||||
isc__trampoline_t **tmp = NULL;
|
||||
|
|
|
|||
Loading…
Reference in a new issue