1 /* $NetBSD: managers.c,v 1.6 2025/07/17 19:01:46 christos Exp $ */ 2 3 /* 4 * Copyright (C) Internet Systems Consortium, Inc. ("ISC") 5 * 6 * SPDX-License-Identifier: MPL-2.0 7 * 8 * This Source Code Form is subject to the terms of the Mozilla Public 9 * License, v. 2.0. If a copy of the MPL was not distributed with this 10 * file, you can obtain one at https://mozilla.org/MPL/2.0/. 11 * 12 * See the COPYRIGHT file distributed with this work for additional 13 * information regarding copyright ownership. 14 */ 15 16 #include <isc/managers.h> 17 #include <isc/rwlock.h> 18 #include <isc/util.h> 19 #include <isc/uv.h> 20 21 void 22 isc_managers_create(isc_mem_t **mctxp, uint32_t workers, 23 isc_loopmgr_t **loopmgrp, isc_nm_t **netmgrp) { 24 REQUIRE(mctxp != NULL && *mctxp == NULL); 25 isc_mem_create(mctxp); 26 INSIST(*mctxp != NULL); 27 isc_mem_setname(*mctxp, "managers"); 28 29 REQUIRE(loopmgrp != NULL && *loopmgrp == NULL); 30 isc_loopmgr_create(*mctxp, workers, loopmgrp); 31 INSIST(*loopmgrp != NULL); 32 33 REQUIRE(netmgrp != NULL && *netmgrp == NULL); 34 isc_netmgr_create(*mctxp, *loopmgrp, netmgrp); 35 INSIST(*netmgrp != NULL); 36 37 isc_rwlock_setworkers(workers); 38 } 39 40 void 41 isc_managers_destroy(isc_mem_t **mctxp, isc_loopmgr_t **loopmgrp, 42 isc_nm_t **netmgrp) { 43 REQUIRE(mctxp != NULL && *mctxp != NULL); 44 REQUIRE(loopmgrp != NULL && *loopmgrp != NULL); 45 REQUIRE(netmgrp != NULL && *netmgrp != NULL); 46 47 /* 48 * The sequence of operations here is important: 49 */ 50 51 isc_netmgr_destroy(netmgrp); 52 isc_loopmgr_destroy(loopmgrp); 53 isc_mem_destroy(mctxp); 54 } 55