File: managers.c

package info (click to toggle)
bind9 1%3A9.20.19-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 43,408 kB
  • sloc: ansic: 316,115; sh: 50,056; python: 23,954; perl: 3,062; makefile: 2,247
file content (52 lines) | stat: -rw-r--r-- 1,443 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
 * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
 *
 * SPDX-License-Identifier: MPL-2.0
 *
 * 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/rwlock.h>
#include <isc/util.h>
#include <isc/uv.h>

void
isc_managers_create(isc_mem_t **mctxp, uint32_t workers,
		    isc_loopmgr_t **loopmgrp, isc_nm_t **netmgrp) {
	REQUIRE(mctxp != NULL && *mctxp == NULL);
	isc_mem_create(mctxp);
	INSIST(*mctxp != NULL);
	isc_mem_setname(*mctxp, "managers");

	REQUIRE(loopmgrp != NULL && *loopmgrp == NULL);
	isc_loopmgr_create(*mctxp, workers, loopmgrp);
	INSIST(*loopmgrp != NULL);

	REQUIRE(netmgrp != NULL && *netmgrp == NULL);
	isc_netmgr_create(*mctxp, *loopmgrp, netmgrp);
	INSIST(*netmgrp != NULL);

	isc_rwlock_setworkers(workers);
}

void
isc_managers_destroy(isc_mem_t **mctxp, isc_loopmgr_t **loopmgrp,
		     isc_nm_t **netmgrp) {
	REQUIRE(mctxp != NULL && *mctxp != NULL);
	REQUIRE(loopmgrp != NULL && *loopmgrp != NULL);
	REQUIRE(netmgrp != NULL && *netmgrp != NULL);

	/*
	 * The sequence of operations here is important:
	 */

	isc_netmgr_destroy(netmgrp);
	isc_loopmgr_destroy(loopmgrp);
	isc_mem_destroy(mctxp);
}