2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 21:47:59 +00:00

[rt36341]

3905.   [bug]           Address deadlock between view.c and adb.c. [RT #36341]
This commit is contained in:
Mark Andrews 2014-07-31 11:38:11 +10:00
parent 3a55d43527
commit b04839cfe2
2 changed files with 43 additions and 16 deletions

View File

@ -1,3 +1,5 @@
3905. [bug] Address deadlock between view.c and adb.c. [RT #36341]
3904. [func] Add the RPZ SOA to the additional section. [RT36507] 3904. [func] Add the RPZ SOA to the additional section. [RT36507]
3903. [bug] Improve the accuracy of DiG's reported round trip 3903. [bug] Improve the accuracy of DiG's reported round trip

View File

@ -15,8 +15,6 @@
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
*/ */
/* $Id: adb.c,v 1.264.16.1 2011/12/22 07:48:27 marka Exp $ */
/*! \file /*! \file
* *
* \note * \note
@ -157,7 +155,7 @@ struct dns_adb {
unsigned int *entry_refcnt; unsigned int *entry_refcnt;
isc_event_t cevent; isc_event_t cevent;
isc_boolean_t cevent_sent; isc_boolean_t cevent_out;
isc_boolean_t shutting_down; isc_boolean_t shutting_down;
isc_eventlist_t whenshutdown; isc_eventlist_t whenshutdown;
isc_event_t growentries; isc_event_t growentries;
@ -337,6 +335,7 @@ static void water(void *, int);
static void dump_entry(FILE *, dns_adbentry_t *, isc_boolean_t, isc_stdtime_t); static void dump_entry(FILE *, dns_adbentry_t *, isc_boolean_t, isc_stdtime_t);
static void adjustsrtt(dns_adbaddrinfo_t *addr, unsigned int rtt, static void adjustsrtt(dns_adbaddrinfo_t *addr, unsigned int rtt,
unsigned int factor, isc_stdtime_t now); unsigned int factor, isc_stdtime_t now);
static void shutdown_task(isc_task_t *task, isc_event_t *ev);
/* /*
* MUST NOT overlap DNS_ADBFIND_* flags! * MUST NOT overlap DNS_ADBFIND_* flags!
@ -1541,10 +1540,13 @@ check_exit(dns_adb_t *adb) {
* If there aren't any external references either, we're * If there aren't any external references either, we're
* done. Send the control event to initiate shutdown. * done. Send the control event to initiate shutdown.
*/ */
INSIST(!adb->cevent_sent); /* Sanity check. */ INSIST(!adb->cevent_out); /* Sanity check. */
ISC_EVENT_INIT(&adb->cevent, sizeof(adb->cevent), 0, NULL,
DNS_EVENT_ADBCONTROL, shutdown_task, adb,
adb, NULL, NULL);
event = &adb->cevent; event = &adb->cevent;
isc_task_send(adb->task, &event); isc_task_send(adb->task, &event);
adb->cevent_sent = ISC_TRUE; adb->cevent_out = ISC_TRUE;
} }
} }
@ -2493,10 +2495,9 @@ dns_adb_create(isc_mem_t *mem, dns_view_t *view, isc_timermgr_t *timermgr,
adb->view = view; adb->view = view;
adb->taskmgr = taskmgr; adb->taskmgr = taskmgr;
adb->next_cleanbucket = 0; adb->next_cleanbucket = 0;
ISC_EVENT_INIT(&adb->cevent, sizeof(adb->cevent), 0, NULL, ISC_EVENT_INIT(&adb->cevent, sizeof(adb->cevent),
DNS_EVENT_ADBCONTROL, shutdown_task, adb, 0, NULL, 0, NULL, NULL, NULL, NULL, NULL);
adb, NULL, NULL); adb->cevent_out = ISC_FALSE;
adb->cevent_sent = ISC_FALSE;
adb->shutting_down = ISC_FALSE; adb->shutting_down = ISC_FALSE;
ISC_LIST_INIT(adb->whenshutdown); ISC_LIST_INIT(adb->whenshutdown);
@ -2530,7 +2531,7 @@ dns_adb_create(isc_mem_t *mem, dns_view_t *view, isc_timermgr_t *timermgr,
"intializing table sizes to %u\n", "intializing table sizes to %u\n",
nbuckets[11]); nbuckets[11]);
adb->nentries = nbuckets[11]; adb->nentries = nbuckets[11];
adb->nnames= nbuckets[11]; adb->nnames = nbuckets[11];
} }
@ -2810,9 +2811,28 @@ dns_adb_whenshutdown(dns_adb_t *adb, isc_task_t *task, isc_event_t **eventp) {
UNLOCK(&adb->lock); UNLOCK(&adb->lock);
} }
static void
shutdown_stage2(isc_task_t *task, isc_event_t *event) {
dns_adb_t *adb;
UNUSED(task);
adb = event->ev_arg;
INSIST(DNS_ADB_VALID(adb));
LOCK(&adb->lock);
INSIST(adb->shutting_down);
adb->cevent_out = ISC_FALSE;
(void)shutdown_names(adb);
(void)shutdown_entries(adb);
if (dec_adb_irefcnt(adb))
check_exit(adb);
UNLOCK(&adb->lock);
}
void void
dns_adb_shutdown(dns_adb_t *adb) { dns_adb_shutdown(dns_adb_t *adb) {
isc_boolean_t need_check_exit; isc_event_t *event;
/* /*
* Shutdown 'adb'. * Shutdown 'adb'.
@ -2823,11 +2843,16 @@ dns_adb_shutdown(dns_adb_t *adb) {
if (!adb->shutting_down) { if (!adb->shutting_down) {
adb->shutting_down = ISC_TRUE; adb->shutting_down = ISC_TRUE;
isc_mem_setwater(adb->mctx, water, adb, 0, 0); isc_mem_setwater(adb->mctx, water, adb, 0, 0);
need_check_exit = shutdown_names(adb); /*
if (!need_check_exit) * Isolate shutdown_names and shutdown_entries calls.
need_check_exit = shutdown_entries(adb); */
if (need_check_exit) inc_adb_irefcnt(adb);
check_exit(adb); ISC_EVENT_INIT(&adb->cevent, sizeof(adb->cevent), 0, NULL,
DNS_EVENT_ADBCONTROL, shutdown_stage2, adb,
adb, NULL, NULL);
adb->cevent_out = ISC_TRUE;
event = &adb->cevent;
isc_task_send(adb->task, &event);
} }
UNLOCK(&adb->lock); UNLOCK(&adb->lock);