xref: /netbsd-src/external/bsd/unbound/dist/util/shm_side/shm_main.h (revision 0cd9f4ecf44538bbdd5619b5b2081449960ab3e6)
1*0cd9f4ecSchristos /*
2*0cd9f4ecSchristos  * util/shm_side/shm_main.h - control the shared memory for unbound.
3*0cd9f4ecSchristos  *
4*0cd9f4ecSchristos  * Copyright (c) 2007, NLnet Labs. All rights reserved.
5*0cd9f4ecSchristos  *
6*0cd9f4ecSchristos  * This software is open source.
7*0cd9f4ecSchristos  *
8*0cd9f4ecSchristos  * Redistribution and use in source and binary forms, with or without
9*0cd9f4ecSchristos  * modification, are permitted provided that the following conditions
10*0cd9f4ecSchristos  * are met:
11*0cd9f4ecSchristos  *
12*0cd9f4ecSchristos  * Redistributions of source code must retain the above copyright notice,
13*0cd9f4ecSchristos  * this list of conditions and the following disclaimer.
14*0cd9f4ecSchristos  *
15*0cd9f4ecSchristos  * Redistributions in binary form must reproduce the above copyright notice,
16*0cd9f4ecSchristos  * this list of conditions and the following disclaimer in the documentation
17*0cd9f4ecSchristos  * and/or other materials provided with the distribution.
18*0cd9f4ecSchristos  *
19*0cd9f4ecSchristos  * Neither the name of the NLNET LABS nor the names of its contributors may
20*0cd9f4ecSchristos  * be used to endorse or promote products derived from this software without
21*0cd9f4ecSchristos  * specific prior written permission.
22*0cd9f4ecSchristos  *
23*0cd9f4ecSchristos  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24*0cd9f4ecSchristos  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25*0cd9f4ecSchristos  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26*0cd9f4ecSchristos  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27*0cd9f4ecSchristos  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28*0cd9f4ecSchristos  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29*0cd9f4ecSchristos  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30*0cd9f4ecSchristos  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31*0cd9f4ecSchristos  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32*0cd9f4ecSchristos  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33*0cd9f4ecSchristos  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34*0cd9f4ecSchristos  */
35*0cd9f4ecSchristos 
36*0cd9f4ecSchristos /**
37*0cd9f4ecSchristos  * \file
38*0cd9f4ecSchristos  *
39*0cd9f4ecSchristos  * This file contains functions for the SHM side.
40*0cd9f4ecSchristos  */
41*0cd9f4ecSchristos 
42*0cd9f4ecSchristos #ifndef UTIL_SHM_SIDE_MAIN_H
43*0cd9f4ecSchristos #define UTIL_SHM_SIDE_MAIN_H
44*0cd9f4ecSchristos struct daemon;
45*0cd9f4ecSchristos struct worker;
46*0cd9f4ecSchristos 
47*0cd9f4ecSchristos /* get struct ub_shm_stat_info */
48*0cd9f4ecSchristos #include "libunbound/unbound.h"
49*0cd9f4ecSchristos 
50*0cd9f4ecSchristos /**
51*0cd9f4ecSchristos  * The SHM info.
52*0cd9f4ecSchristos  */
53*0cd9f4ecSchristos struct shm_main_info {
54*0cd9f4ecSchristos 	/** stats_info array, shared memory segment.
55*0cd9f4ecSchristos 	 * [0] is totals, [1..thread_num] are per-thread stats */
56*0cd9f4ecSchristos 	struct ub_stats_info* ptr_arr;
57*0cd9f4ecSchristos 	/** the global stats block, shared memory segment */
58*0cd9f4ecSchristos 	struct ub_shm_stat_info* ptr_ctl;
59*0cd9f4ecSchristos 	int key;
60*0cd9f4ecSchristos 	int id_ctl;
61*0cd9f4ecSchristos 	int id_arr;
62*0cd9f4ecSchristos };
63*0cd9f4ecSchristos 
64*0cd9f4ecSchristos int shm_main_init(struct daemon* daemon);
65*0cd9f4ecSchristos void shm_main_shutdown(struct daemon* daemon);
66*0cd9f4ecSchristos void shm_main_run(struct worker *worker);
67*0cd9f4ecSchristos 
68*0cd9f4ecSchristos #endif /* UTIL_SHM_SIDE_MAIN_H */
69