Electroneum
worker.h
Go to the documentation of this file.
1 /*
2  * daemon/worker.h - worker that handles a pending list of requests.
3  *
4  * Copyright (c) 2007, NLnet Labs. All rights reserved.
5  *
6  * This software is open source.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  *
19  * Neither the name of the NLNET LABS nor the names of its contributors may
20  * be used to endorse or promote products derived from this software without
21  * specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 
43 #ifndef DAEMON_WORKER_H
44 #define DAEMON_WORKER_H
45 
46 #include "libunbound/worker.h"
47 #include "util/netevent.h"
48 #include "util/locks.h"
49 #include "util/alloc.h"
50 #include "util/data/msgreply.h"
51 #include "util/data/msgparse.h"
52 #include "daemon/stats.h"
53 #include "util/module.h"
54 #include "dnstap/dnstap.h"
55 struct listen_dnsport;
56 struct outside_network;
57 struct config_file;
58 struct daemon;
59 struct listen_port;
60 struct ub_randstate;
61 struct regional;
62 struct tube;
63 struct daemon_remote;
64 struct query_info;
65 
76 };
77 
82 struct worker {
86  struct daemon* daemon;
90  struct tube* cmd;
92  struct comm_base* base;
98  int* ports;
100  int numports;
110  unsigned int err_limit_count;
111 
113  struct ub_randstate* rndstate;
122 
124  struct module_env env;
125 
126 #ifdef USE_DNSTAP
127 
128  struct dt_env dtenv;
129 #endif
130 };
131 
141 struct worker* worker_create(struct daemon* daemon, int id, int* ports, int n);
142 
152 int worker_init(struct worker* worker, struct config_file *cfg,
153  struct listen_port* ports, int do_sigs);
154 
158 void worker_work(struct worker* worker);
159 
163 void worker_delete(struct worker* worker);
164 
170 void worker_send_cmd(struct worker* worker, enum worker_commands cmd);
171 
176 void worker_stats_clear(struct worker* worker);
177 
178 #endif /* DAEMON_WORKER_H */
Definition: daemon.h:76
struct alloc_cache alloc
Definition: worker.h:117
void worker_stats_clear(struct worker *worker)
int * ports
Definition: worker.h:98
struct comm_signal * comsig
Definition: worker.h:102
struct comm_base * base
Definition: worker.h:92
int numports
Definition: worker.h:100
struct regional * scratchpad
Definition: worker.h:121
void worker_send_cmd(struct worker *worker, enum worker_commands cmd)
struct tube * cmd
Definition: worker.h:90
struct worker * worker_create(struct daemon *daemon, int id, int *ports, int n)
struct daemon * daemon
Definition: worker.h:86
struct ub_server_stats stats
Definition: worker.h:119
int thread_num
Definition: worker.h:84
pid_t ub_thread_type
Definition: locks.h:283
struct module_env env
Definition: worker.h:124
struct listen_dnsport * front
Definition: worker.h:94
time_t err_limit_time
Definition: worker.h:108
struct outside_network * back
Definition: worker.h:96
unsigned int err_limit_count
Definition: worker.h:110
int need_to_exit
Definition: worker.h:115
Definition: tube.h:63
Definition: worker.h:82
struct ub_randstate * rndstate
Definition: worker.h:113
worker_commands
Definition: worker.h:67
ub_thread_type thr_id
Definition: worker.h:88
struct comm_point * cmd_com
Definition: worker.h:104
void worker_delete(struct worker *worker)
void worker_work(struct worker *worker)
struct comm_timer * stat_timer
Definition: worker.h:106
int worker_init(struct worker *worker, struct config_file *cfg, struct listen_port *ports, int do_sigs)