From: Evan Hunt Date: Wed, 11 May 2022 20:55:01 +0000 (-0700) Subject: remove requestmgr whenshutdown events X-Git-Tag: v9.19.2~36^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d7ffd897ef61542a1d2e6763a61171b102b83639;p=thirdparty%2Fbind9.git remove requestmgr whenshutdown events the request manager has no direct dependency on the view, so there's no need for a weak reference. remove the dns_requestmgr_whenshutdown() mechanism since it is no longer used. --- diff --git a/lib/dns/include/dns/events.h b/lib/dns/include/dns/events.h index 9be2f705cb6..7a514af5300 100644 --- a/lib/dns/include/dns/events.h +++ b/lib/dns/include/dns/events.h @@ -42,44 +42,44 @@ #define DNS_EVENT_VALIDATORDONE (ISC_EVENTCLASS_DNS + 19) #define DNS_EVENT_REQUESTDONE (ISC_EVENTCLASS_DNS + 20) #define DNS_EVENT_VALIDATORSTART (ISC_EVENTCLASS_DNS + 21) -#define DNS_EVENT_VIEWREQSHUTDOWN (ISC_EVENTCLASS_DNS + 22) -#define DNS_EVENT_NOTIFYSENDTOADDR (ISC_EVENTCLASS_DNS + 23) -#define DNS_EVENT_ZONE (ISC_EVENTCLASS_DNS + 24) -#define DNS_EVENT_ZONESTARTXFRIN (ISC_EVENTCLASS_DNS + 25) -#define DNS_EVENT_MASTERQUANTUM (ISC_EVENTCLASS_DNS + 26) -#define DNS_EVENT_CACHEOVERMEM (ISC_EVENTCLASS_DNS + 27) -#define DNS_EVENT_MASTERNEXTZONE (ISC_EVENTCLASS_DNS + 28) -#define DNS_EVENT_IOREADY (ISC_EVENTCLASS_DNS + 29) -#define DNS_EVENT_LOOKUPDONE (ISC_EVENTCLASS_DNS + 30) -#define DNS_EVENT_RBTDEADNODES (ISC_EVENTCLASS_DNS + 31) -#define DNS_EVENT_DISPATCHCONTROL (ISC_EVENTCLASS_DNS + 32) -#define DNS_EVENT_REQUESTCONTROL (ISC_EVENTCLASS_DNS + 33) -#define DNS_EVENT_DUMPQUANTUM (ISC_EVENTCLASS_DNS + 34) +/* #define DNS_EVENT_VIEWREQSHUTDOWN (ISC_EVENTCLASS_DNS + 22) */ +#define DNS_EVENT_NOTIFYSENDTOADDR (ISC_EVENTCLASS_DNS + 23) +#define DNS_EVENT_ZONE (ISC_EVENTCLASS_DNS + 24) +#define DNS_EVENT_ZONESTARTXFRIN (ISC_EVENTCLASS_DNS + 25) +#define DNS_EVENT_MASTERQUANTUM (ISC_EVENTCLASS_DNS + 26) +#define DNS_EVENT_CACHEOVERMEM (ISC_EVENTCLASS_DNS + 27) +#define DNS_EVENT_MASTERNEXTZONE (ISC_EVENTCLASS_DNS + 28) +#define DNS_EVENT_IOREADY (ISC_EVENTCLASS_DNS + 29) +#define DNS_EVENT_LOOKUPDONE (ISC_EVENTCLASS_DNS + 30) +#define DNS_EVENT_RBTDEADNODES (ISC_EVENTCLASS_DNS + 31) +#define DNS_EVENT_DISPATCHCONTROL (ISC_EVENTCLASS_DNS + 32) +#define DNS_EVENT_REQUESTCONTROL (ISC_EVENTCLASS_DNS + 33) +#define DNS_EVENT_DUMPQUANTUM (ISC_EVENTCLASS_DNS + 34) /* #define DNS_EVENT_IMPORTRECVDONE (ISC_EVENTCLASS_DNS + 35) */ -#define DNS_EVENT_FREESTORAGE (ISC_EVENTCLASS_DNS + 36) -#define DNS_EVENT_VIEWACACHESHUTDOWN (ISC_EVENTCLASS_DNS + 37) -#define DNS_EVENT_ACACHECONTROL (ISC_EVENTCLASS_DNS + 38) -#define DNS_EVENT_ACACHECLEAN (ISC_EVENTCLASS_DNS + 39) -#define DNS_EVENT_ACACHEOVERMEM (ISC_EVENTCLASS_DNS + 40) -#define DNS_EVENT_RBTPRUNE (ISC_EVENTCLASS_DNS + 41) -#define DNS_EVENT_MANAGEKEYS (ISC_EVENTCLASS_DNS + 42) -#define DNS_EVENT_CLIENTRESDONE (ISC_EVENTCLASS_DNS + 43) -#define DNS_EVENT_CLIENTREQDONE (ISC_EVENTCLASS_DNS + 44) -#define DNS_EVENT_ADBGROWENTRIES (ISC_EVENTCLASS_DNS + 45) -#define DNS_EVENT_ADBGROWNAMES (ISC_EVENTCLASS_DNS + 46) -#define DNS_EVENT_ZONESECURESERIAL (ISC_EVENTCLASS_DNS + 47) -#define DNS_EVENT_ZONESECUREDB (ISC_EVENTCLASS_DNS + 48) -#define DNS_EVENT_ZONELOAD (ISC_EVENTCLASS_DNS + 49) -#define DNS_EVENT_KEYDONE (ISC_EVENTCLASS_DNS + 50) -#define DNS_EVENT_SETNSEC3PARAM (ISC_EVENTCLASS_DNS + 51) -#define DNS_EVENT_SETSERIAL (ISC_EVENTCLASS_DNS + 52) -#define DNS_EVENT_CATZUPDATED (ISC_EVENTCLASS_DNS + 53) -#define DNS_EVENT_CATZADDZONE (ISC_EVENTCLASS_DNS + 54) -#define DNS_EVENT_CATZMODZONE (ISC_EVENTCLASS_DNS + 55) -#define DNS_EVENT_CATZDELZONE (ISC_EVENTCLASS_DNS + 56) -#define DNS_EVENT_RPZUPDATED (ISC_EVENTCLASS_DNS + 57) -#define DNS_EVENT_STARTUPDATE (ISC_EVENTCLASS_DNS + 58) -#define DNS_EVENT_TRYSTALE (ISC_EVENTCLASS_DNS + 59) -#define DNS_EVENT_ZONEFLUSH (ISC_EVENTCLASS_DNS + 60) -#define DNS_EVENT_CHECKDSSENDTOADDR (ISC_EVENTCLASS_DNS + 61) -#define DNS_EVENT_CACHESHUTDOWN (ISC_EVENTCLASS_DNS + 62) +#define DNS_EVENT_FREESTORAGE (ISC_EVENTCLASS_DNS + 36) +/* #define DNS_EVENT_VIEWACACHESHUTDOWN (ISC_EVENTCLASS_DNS + 37) */ +#define DNS_EVENT_ACACHECONTROL (ISC_EVENTCLASS_DNS + 38) +#define DNS_EVENT_ACACHECLEAN (ISC_EVENTCLASS_DNS + 39) +#define DNS_EVENT_ACACHEOVERMEM (ISC_EVENTCLASS_DNS + 40) +#define DNS_EVENT_RBTPRUNE (ISC_EVENTCLASS_DNS + 41) +#define DNS_EVENT_MANAGEKEYS (ISC_EVENTCLASS_DNS + 42) +#define DNS_EVENT_CLIENTRESDONE (ISC_EVENTCLASS_DNS + 43) +#define DNS_EVENT_CLIENTREQDONE (ISC_EVENTCLASS_DNS + 44) +#define DNS_EVENT_ADBGROWENTRIES (ISC_EVENTCLASS_DNS + 45) +#define DNS_EVENT_ADBGROWNAMES (ISC_EVENTCLASS_DNS + 46) +#define DNS_EVENT_ZONESECURESERIAL (ISC_EVENTCLASS_DNS + 47) +#define DNS_EVENT_ZONESECUREDB (ISC_EVENTCLASS_DNS + 48) +#define DNS_EVENT_ZONELOAD (ISC_EVENTCLASS_DNS + 49) +#define DNS_EVENT_KEYDONE (ISC_EVENTCLASS_DNS + 50) +#define DNS_EVENT_SETNSEC3PARAM (ISC_EVENTCLASS_DNS + 51) +#define DNS_EVENT_SETSERIAL (ISC_EVENTCLASS_DNS + 52) +#define DNS_EVENT_CATZUPDATED (ISC_EVENTCLASS_DNS + 53) +#define DNS_EVENT_CATZADDZONE (ISC_EVENTCLASS_DNS + 54) +#define DNS_EVENT_CATZMODZONE (ISC_EVENTCLASS_DNS + 55) +#define DNS_EVENT_CATZDELZONE (ISC_EVENTCLASS_DNS + 56) +#define DNS_EVENT_RPZUPDATED (ISC_EVENTCLASS_DNS + 57) +#define DNS_EVENT_STARTUPDATE (ISC_EVENTCLASS_DNS + 58) +#define DNS_EVENT_TRYSTALE (ISC_EVENTCLASS_DNS + 59) +#define DNS_EVENT_ZONEFLUSH (ISC_EVENTCLASS_DNS + 60) +#define DNS_EVENT_CHECKDSSENDTOADDR (ISC_EVENTCLASS_DNS + 61) +#define DNS_EVENT_CACHESHUTDOWN (ISC_EVENTCLASS_DNS + 62) diff --git a/lib/dns/include/dns/request.h b/lib/dns/include/dns/request.h index 8dbee8c9ffa..342277c9f22 100644 --- a/lib/dns/include/dns/request.h +++ b/lib/dns/include/dns/request.h @@ -84,30 +84,6 @@ dns_requestmgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr, *\li Any other result indicates failure. */ -void -dns_requestmgr_whenshutdown(dns_requestmgr_t *requestmgr, isc_task_t *task, - isc_event_t **eventp); -/*%< - * Send '*eventp' to 'task' when 'requestmgr' has completed shutdown. - * - * Notes: - * - *\li It is not safe to detach the last reference to 'requestmgr' until - * shutdown is complete. - * - * Requires: - * - *\li 'requestmgr' is a valid request manager. - * - *\li 'task' is a valid task. - * - *\li *eventp is a valid event. - * - * Ensures: - * - *\li *eventp == NULL. - */ - void dns_requestmgr_shutdown(dns_requestmgr_t *requestmgr); /*%< diff --git a/lib/dns/include/dns/view.h b/lib/dns/include/dns/view.h index 1a620468b26..b09230ba0a2 100644 --- a/lib/dns/include/dns/view.h +++ b/lib/dns/include/dns/view.h @@ -104,7 +104,6 @@ struct dns_view { isc_mutex_t lock; bool frozen; isc_task_t *task; - isc_event_t reqevent; bool cacheshared; /* Configurable data. */ diff --git a/lib/dns/request.c b/lib/dns/request.c index 5a70ad6d890..54db3308332 100644 --- a/lib/dns/request.c +++ b/lib/dns/request.c @@ -58,7 +58,6 @@ struct dns_requestmgr { dns_dispatch_t *dispatchv4; dns_dispatch_t *dispatchv6; atomic_bool exiting; - isc_eventlist_t whenshutdown; unsigned int hash; isc_mutex_t locks[DNS_REQUEST_NLOCKS]; dns_requestlist_t requests; @@ -103,9 +102,6 @@ static void mgr_destroy(dns_requestmgr_t *requestmgr); static unsigned int mgr_gethash(dns_requestmgr_t *requestmgr); -static void -send_shutdown_events(dns_requestmgr_t *requestmgr); - static isc_result_t req_render(dns_message_t *message, isc_buffer_t **buffer, unsigned int options, isc_mem_t *mctx); @@ -166,7 +162,6 @@ dns_requestmgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr, isc_refcount_init(&requestmgr->references, 1); - ISC_LIST_INIT(requestmgr->whenshutdown); ISC_LIST_INIT(requestmgr->requests); atomic_init(&requestmgr->exiting, false); @@ -179,37 +174,6 @@ dns_requestmgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr, return (ISC_R_SUCCESS); } -void -dns_requestmgr_whenshutdown(dns_requestmgr_t *requestmgr, isc_task_t *task, - isc_event_t **eventp) { - isc_task_t *tclone; - isc_event_t *event; - - req_log(ISC_LOG_DEBUG(3), "dns_requestmgr_whenshutdown"); - - REQUIRE(VALID_REQUESTMGR(requestmgr)); - REQUIRE(eventp != NULL); - - event = *eventp; - *eventp = NULL; - - LOCK(&requestmgr->lock); - - if (atomic_load_acquire(&requestmgr->exiting)) { - /* - * We're already shutdown. Send the event. - */ - event->ev_sender = requestmgr; - isc_task_send(task, &event); - } else { - tclone = NULL; - isc_task_attach(task, &tclone); - event->ev_sender = tclone; - ISC_LIST_APPEND(requestmgr->whenshutdown, event, ev_link); - } - UNLOCK(&requestmgr->lock); -} - void dns_requestmgr_shutdown(dns_requestmgr_t *requestmgr) { dns_request_t *request; @@ -230,11 +194,6 @@ dns_requestmgr_shutdown(dns_requestmgr_t *requestmgr) { { dns_request_cancel(request); } - - if (ISC_LIST_EMPTY(requestmgr->requests)) { - send_shutdown_events(requestmgr); - } - UNLOCK(&requestmgr->lock); } @@ -278,28 +237,6 @@ dns_requestmgr_detach(dns_requestmgr_t **requestmgrp) { } } -/* FIXME */ -static void -send_shutdown_events(dns_requestmgr_t *requestmgr) { - isc_event_t *event, *next_event; - isc_task_t *etask; - - req_log(ISC_LOG_DEBUG(3), "send_shutdown_events: %p", requestmgr); - - /* - * Caller must be holding the manager lock. - */ - for (event = ISC_LIST_HEAD(requestmgr->whenshutdown); event != NULL; - event = next_event) - { - next_event = ISC_LIST_NEXT(event, ev_link); - ISC_LIST_UNLINK(requestmgr->whenshutdown, event, ev_link); - etask = event->ev_sender; - event->ev_sender = requestmgr; - isc_task_sendanddetach(&etask, &event); - } -} - static void mgr_destroy(dns_requestmgr_t *requestmgr) { int i; @@ -1163,27 +1100,13 @@ req_attach(dns_request_t *source, dns_request_t **targetp) { static void req_detach(dns_request_t **requestp) { dns_request_t *request = NULL; - uint_fast32_t ref; REQUIRE(requestp != NULL && VALID_REQUEST(*requestp)); request = *requestp; *requestp = NULL; - ref = isc_refcount_decrement(&request->references); - - if (request->requestmgr != NULL && - atomic_load_acquire(&request->requestmgr->exiting)) - { - /* We are shutting down and this was last request */ - LOCK(&request->requestmgr->lock); - if (ISC_LIST_EMPTY(request->requestmgr->requests)) { - send_shutdown_events(request->requestmgr); - } - UNLOCK(&request->requestmgr->lock); - } - - if (ref == 1) { + if (isc_refcount_decrement(&request->references) == 1) { req_destroy(request); } } diff --git a/lib/dns/view.c b/lib/dns/view.c index 8e15efeff99..75516bae28b 100644 --- a/lib/dns/view.c +++ b/lib/dns/view.c @@ -75,9 +75,6 @@ #define DNS_VIEW_DELONLYHASH 111 #define DNS_VIEW_FAILCACHESIZE 1021 -static void -req_shutdown(isc_task_t *task, isc_event_t *event); - isc_result_t dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, const char *name, dns_view_t **viewp) { @@ -126,10 +123,6 @@ dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, const char *name, ISC_LINK_INIT(view, link); - ISC_EVENT_INIT(&view->reqevent, sizeof(view->reqevent), 0, NULL, - DNS_EVENT_VIEWREQSHUTDOWN, req_shutdown, view, NULL, - NULL, NULL); - isc_mem_attach(mctx, &view->mctx); isc_mutex_init(&view->lock); @@ -520,6 +513,7 @@ dns_view_detach(dns_view_t **viewp) { } if (view->requestmgr != NULL) { dns_requestmgr_shutdown(view->requestmgr); + dns_requestmgr_detach(&view->requestmgr); } LOCK(&view->lock); @@ -612,21 +606,6 @@ dns_view_weakdetach(dns_view_t **viewp) { } } -static void -req_shutdown(isc_task_t *task, isc_event_t *event) { - dns_view_t *view = event->ev_arg; - - REQUIRE(event->ev_type == DNS_EVENT_VIEWREQSHUTDOWN); - REQUIRE(DNS_VIEW_VALID(view)); - REQUIRE(view->task == task); - - UNUSED(task); - - isc_event_free(&event); - - dns_view_weakdetach(&view); -} - isc_result_t dns_view_createzonetable(dns_view_t *view) { REQUIRE(DNS_VIEW_VALID(view)); @@ -644,7 +623,6 @@ dns_view_createresolver(dns_view_t *view, isc_taskmgr_t *taskmgr, dns_dispatch_t *dispatchv4, dns_dispatch_t *dispatchv6) { isc_result_t result; - isc_event_t *event = NULL; isc_mem_t *mctx = NULL; REQUIRE(DNS_VIEW_VALID(view)); @@ -681,10 +659,6 @@ dns_view_createresolver(dns_view_t *view, isc_taskmgr_t *taskmgr, goto cleanup_adb; } - dns_view_weakattach(view, &(dns_view_t *){ NULL }); - event = &view->reqevent; - dns_requestmgr_whenshutdown(view->requestmgr, view->task, &event); - return (ISC_R_SUCCESS); cleanup_adb: