/* * Close the sockets, shutdown the server and exit. * Does not return. * */ static void server_shutdown(struct nsd *nsd) { size_t i; close_all_sockets(nsd->udp, nsd->ifs); close_all_sockets(nsd->tcp, nsd->ifs); /* CHILD: close command channel to parent */ if(nsd->this_child && nsd->this_child->parent_fd != -1) { close(nsd->this_child->parent_fd); nsd->this_child->parent_fd = -1; } /* SERVER: close command channels to children */ if(!nsd->this_child) { for(i=0; i < nsd->child_count; ++i) if(nsd->children[i].child_fd != -1) { close(nsd->children[i].child_fd); nsd->children[i].child_fd = -1; } } log_finalize(); tsig_finalize(); nsd_options_destroy(nsd->options); region_destroy(nsd->region); exit(0); }
void dnscore_finalize() { /* * No need to "finalize" format, dnsformat and rfc */ if(dnscore_finalizing) { /* OOPS : ALREADY BUSY SHUTTING DOWN */ /* DO NOT USE LOGGER HERE ! */ return; } dnscore_finalizing = TRUE; dnscore_shutdown(); #ifndef NDEBUG log_debug("exit: destroying the thread pool"); #endif logger_flush(); thread_pool_destroy(); #ifdef DEBUG log_debug("exit: bye (pid=%hd)", getpid()); logger_flush(); #endif scheduler_finalize(); logger_flush(); logger_finalize(); /** @note does a logger_stop */ logger_handle_finalize(); #ifndef NDEBUG /* * It may not be required right now, but in case the stdstream are filtered/buffered * this will flush them. */ #if HAS_TSIG_SUPPORT tsig_finalize(); #endif stdstream_flush_both_terms(); error_unregister_all(); rfc_finalize(); format_class_finalize(); #endif #ifndef NDEBUG #if ZDB_DEBUG_MALLOC != 0 debug_stat(TRUE); #endif #endif stdstream_flush_both_terms(); output_stream_close(&__termerr__); output_stream_close(&__termout__); }