2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 13:38:26 +00:00

Delay kserver cleanup until all tasks finishes

It might be possible some pending task would run when kserver is already
cleaned up. Postpone gsstsig structures cleanup after task and timer
managers are destroyed. No pending threads are possible after it.

Make action in maybeshutdown only if doshutdown was not already called.
Might be called from getinput event.
This commit is contained in:
Petr Mensik 2020-03-27 21:03:40 +01:00 committed by Ondřej Surý
parent 970db5691d
commit 2685e69be8

View File

@ -759,6 +759,10 @@ doshutdown(void) {
static void
maybeshutdown(void) {
/* when called from getinput, doshutdown might be already finished */
if (requestmgr == NULL)
return;
ddebug("Shutting down request manager");
dns_requestmgr_shutdown(requestmgr);
@ -3036,6 +3040,8 @@ send_gssrequest(isc_sockaddr_t *destaddr, dns_message_t *msg,
isc_sockaddr_t *srcaddr;
debug("send_gssrequest");
REQUIRE(destaddr != NULL);
reqinfo = isc_mem_get(gmctx, sizeof(nsu_gssinfo_t));
reqinfo->msg = msg;
reqinfo->addr = destaddr;
@ -3327,21 +3333,7 @@ cleanup(void) {
ddebug("Detaching GSS-TSIG keyring");
dns_tsigkeyring_detach(&gssring);
}
if (kserver != NULL) {
isc_mem_put(gmctx, kserver, sizeof(isc_sockaddr_t));
kserver = NULL;
}
if (realm != NULL) {
isc_mem_free(gmctx, realm);
realm = NULL;
}
if (dns_name_dynamic(&tmpzonename)) {
dns_name_free(&tmpzonename, gmctx);
}
if (dns_name_dynamic(&restart_master)) {
dns_name_free(&restart_master, gmctx);
}
#endif /* HAVE_GSSAPI */
#endif /* ifdef HAVE_GSSAPI */
if (sig0key != NULL) {
dst_key_free(&sig0key);
@ -3359,6 +3351,26 @@ cleanup(void) {
ddebug("Shutting down timer manager");
isc_timermgr_destroy(&timermgr);
#ifdef HAVE_GSSAPI
/*
* Cleanup GSSAPI resources after taskmgr has been destroyed.
*/
if (kserver != NULL) {
isc_mem_put(gmctx, kserver, sizeof(isc_sockaddr_t));
kserver = NULL;
}
if (realm != NULL) {
isc_mem_free(gmctx, realm);
realm = NULL;
}
if (dns_name_dynamic(&tmpzonename)) {
dns_name_free(&tmpzonename, gmctx);
}
if (dns_name_dynamic(&restart_master)) {
dns_name_free(&restart_master, gmctx);
}
#endif /* ifdef HAVE_GSSAPI */
ddebug("Removing log context");
isc_log_destroy(&glctx);