2021-04-27 00:07:43 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
2021-06-03 08:37:05 +02:00
|
|
|
*
|
2021-04-27 00:07:43 +02:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* See the COPYRIGHT file distributed with this work for additional
|
|
|
|
* information regarding copyright ownership.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <isc/managers.h>
|
|
|
|
#include <isc/util.h>
|
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
void
|
|
|
|
isc_managers_create(isc_mem_t **mctxp, uint32_t workers,
|
2022-07-26 13:03:40 +02:00
|
|
|
isc_loopmgr_t **loopmgrp, isc_nm_t **netmgrp,
|
|
|
|
isc_taskmgr_t **taskmgrp) {
|
2022-07-26 13:03:45 +02:00
|
|
|
REQUIRE(mctxp != NULL && *mctxp == NULL);
|
|
|
|
isc_mem_create(mctxp);
|
|
|
|
INSIST(*mctxp != NULL);
|
2021-04-27 00:07:43 +02:00
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
REQUIRE(loopmgrp != NULL && *loopmgrp == NULL);
|
|
|
|
isc_loopmgr_create(*mctxp, workers, loopmgrp);
|
|
|
|
INSIST(*loopmgrp != NULL);
|
2021-04-27 00:07:43 +02:00
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
REQUIRE(netmgrp != NULL && *netmgrp == NULL);
|
|
|
|
isc_netmgr_create(*mctxp, *loopmgrp, netmgrp);
|
|
|
|
INSIST(*netmgrp != NULL);
|
2021-04-27 00:07:43 +02:00
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
REQUIRE(taskmgrp != NULL && *taskmgrp == NULL);
|
|
|
|
isc_taskmgr_create(*mctxp, *loopmgrp, taskmgrp);
|
|
|
|
INSIST(*taskmgrp != NULL);
|
2021-04-27 00:07:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2022-07-26 13:03:45 +02:00
|
|
|
isc_managers_destroy(isc_mem_t **mctxp, isc_loopmgr_t **loopmgrp,
|
|
|
|
isc_nm_t **netmgrp, isc_taskmgr_t **taskmgrp) {
|
|
|
|
REQUIRE(mctxp != NULL && *mctxp != NULL);
|
|
|
|
REQUIRE(loopmgrp != NULL && *loopmgrp != NULL);
|
|
|
|
REQUIRE(netmgrp != NULL && *netmgrp != NULL);
|
|
|
|
REQUIRE(taskmgrp != NULL && *taskmgrp != NULL);
|
2021-04-27 10:28:40 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The sequence of operations here is important:
|
|
|
|
*/
|
2021-04-27 00:07:43 +02:00
|
|
|
|
2022-07-26 13:03:45 +02:00
|
|
|
isc_taskmgr_destroy(taskmgrp);
|
|
|
|
isc_netmgr_destroy(netmgrp);
|
2022-07-26 13:03:40 +02:00
|
|
|
isc_loopmgr_destroy(loopmgrp);
|
2022-07-26 13:03:45 +02:00
|
|
|
isc_mem_destroy(mctxp);
|
2021-04-27 00:07:43 +02:00
|
|
|
}
|