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