nxt_runtime.h (1182:325b315e48c4) nxt_runtime.h (1254:aae6699f4eee)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) Valentin V. Bartenev
5 * Copyright (C) NGINX, Inc.
6 */
7
8#ifndef _NXT_RUNTIME_H_INCLUDED_
9#define _NXT_RUNTIME_H_INCLUDED_
10
11
12typedef void (*nxt_runtime_cont_t)(nxt_task_t *task, nxt_uint_t status);
13
14
15struct nxt_runtime_s {
16 nxt_mp_t *mem_pool;
17
18 nxt_array_t *inherited_sockets; /* of nxt_listen_socket_t */
19 nxt_array_t *listen_sockets; /* of nxt_listen_socket_t */
20
21 nxt_array_t *services; /* of nxt_service_t */
22 nxt_array_t *languages; /* of nxt_app_lang_module_t */
23 void *data;
24
25 nxt_runtime_cont_t start;
26
27 nxt_str_t hostname;
28
29 nxt_file_name_t *pid_file;
30
31#if (NXT_TLS)
32 const nxt_tls_lib_t *tls;
33#endif
34
35 nxt_array_t *thread_pools; /* of nxt_thread_pool_t */
36 nxt_runtime_cont_t continuation;
37
38 nxt_process_t *mprocess;
39 size_t nprocesses;
40 nxt_thread_mutex_t processes_mutex;
41 nxt_lvlhsh_t processes; /* of nxt_process_t */
42
43 nxt_port_t *port_by_type[NXT_PROCESS_MAX];
44 nxt_lvlhsh_t ports; /* of nxt_port_t */
45
46 nxt_list_t *log_files; /* of nxt_file_t */
47
48 uint32_t last_engine_id;
49
50 nxt_process_type_t type;
51
52 nxt_timer_t timer;
53
54 uint8_t daemon;
55 uint8_t batch;
56 uint8_t status;
57
58 const char *engine;
59 uint32_t engine_connections;
60 uint32_t auxiliary_threads;
61 nxt_user_cred_t user_cred;
62 nxt_capabilities_t capabilities;
63 const char *group;
64 const char *pid;
65 const char *log;
66 const char *modules;
67 const char *state;
68 const char *conf;
69 const char *conf_tmp;
70 const char *control;
71
72 nxt_str_t certs;
73
74 nxt_queue_t engines; /* of nxt_event_engine_t */
75
76 nxt_sockaddr_t *controller_listen;
77 nxt_listen_socket_t *controller_socket;
78};
79
80
81
82typedef nxt_int_t (*nxt_module_init_t)(nxt_thread_t *thr, nxt_runtime_t *rt);
83
84
85nxt_int_t nxt_runtime_create(nxt_task_t *task);
86void nxt_runtime_quit(nxt_task_t *task, nxt_uint_t status);
87
88void nxt_runtime_event_engine_free(nxt_runtime_t *rt);
89
90nxt_int_t nxt_runtime_thread_pool_create(nxt_thread_t *thr, nxt_runtime_t *rt,
91 nxt_uint_t max_threads, nxt_nsec_t timeout);
92
93
94nxt_process_t *nxt_runtime_process_new(nxt_runtime_t *rt);
95
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) Valentin V. Bartenev
5 * Copyright (C) NGINX, Inc.
6 */
7
8#ifndef _NXT_RUNTIME_H_INCLUDED_
9#define _NXT_RUNTIME_H_INCLUDED_
10
11
12typedef void (*nxt_runtime_cont_t)(nxt_task_t *task, nxt_uint_t status);
13
14
15struct nxt_runtime_s {
16 nxt_mp_t *mem_pool;
17
18 nxt_array_t *inherited_sockets; /* of nxt_listen_socket_t */
19 nxt_array_t *listen_sockets; /* of nxt_listen_socket_t */
20
21 nxt_array_t *services; /* of nxt_service_t */
22 nxt_array_t *languages; /* of nxt_app_lang_module_t */
23 void *data;
24
25 nxt_runtime_cont_t start;
26
27 nxt_str_t hostname;
28
29 nxt_file_name_t *pid_file;
30
31#if (NXT_TLS)
32 const nxt_tls_lib_t *tls;
33#endif
34
35 nxt_array_t *thread_pools; /* of nxt_thread_pool_t */
36 nxt_runtime_cont_t continuation;
37
38 nxt_process_t *mprocess;
39 size_t nprocesses;
40 nxt_thread_mutex_t processes_mutex;
41 nxt_lvlhsh_t processes; /* of nxt_process_t */
42
43 nxt_port_t *port_by_type[NXT_PROCESS_MAX];
44 nxt_lvlhsh_t ports; /* of nxt_port_t */
45
46 nxt_list_t *log_files; /* of nxt_file_t */
47
48 uint32_t last_engine_id;
49
50 nxt_process_type_t type;
51
52 nxt_timer_t timer;
53
54 uint8_t daemon;
55 uint8_t batch;
56 uint8_t status;
57
58 const char *engine;
59 uint32_t engine_connections;
60 uint32_t auxiliary_threads;
61 nxt_user_cred_t user_cred;
62 nxt_capabilities_t capabilities;
63 const char *group;
64 const char *pid;
65 const char *log;
66 const char *modules;
67 const char *state;
68 const char *conf;
69 const char *conf_tmp;
70 const char *control;
71
72 nxt_str_t certs;
73
74 nxt_queue_t engines; /* of nxt_event_engine_t */
75
76 nxt_sockaddr_t *controller_listen;
77 nxt_listen_socket_t *controller_socket;
78};
79
80
81
82typedef nxt_int_t (*nxt_module_init_t)(nxt_thread_t *thr, nxt_runtime_t *rt);
83
84
85nxt_int_t nxt_runtime_create(nxt_task_t *task);
86void nxt_runtime_quit(nxt_task_t *task, nxt_uint_t status);
87
88void nxt_runtime_event_engine_free(nxt_runtime_t *rt);
89
90nxt_int_t nxt_runtime_thread_pool_create(nxt_thread_t *thr, nxt_runtime_t *rt,
91 nxt_uint_t max_threads, nxt_nsec_t timeout);
92
93
94nxt_process_t *nxt_runtime_process_new(nxt_runtime_t *rt);
95
96nxt_process_t *nxt_runtime_process_get(nxt_runtime_t *rt, nxt_pid_t pid);
97
98void nxt_runtime_process_add(nxt_task_t *task, nxt_process_t *process);
99
100nxt_process_t *nxt_runtime_process_find(nxt_runtime_t *rt, nxt_pid_t pid);
101
96void nxt_runtime_process_add(nxt_task_t *task, nxt_process_t *process);
97
98nxt_process_t *nxt_runtime_process_find(nxt_runtime_t *rt, nxt_pid_t pid);
99
102void nxt_process_use(nxt_task_t *task, nxt_process_t *process, int i);
103
104nxt_process_t *nxt_runtime_process_first(nxt_runtime_t *rt,
105 nxt_lvlhsh_each_t *lhe);
106
100nxt_process_t *nxt_runtime_process_first(nxt_runtime_t *rt,
101 nxt_lvlhsh_each_t *lhe);
102
103void nxt_runtime_process_release(nxt_runtime_t *rt, nxt_process_t *process);
104
107#define nxt_runtime_process_next(rt, lhe) \
108 nxt_lvlhsh_each(&rt->processes, lhe)
109
105#define nxt_runtime_process_next(rt, lhe) \
106 nxt_lvlhsh_each(&rt->processes, lhe)
107
108nxt_port_t *nxt_runtime_process_port_create(nxt_task_t *task, nxt_runtime_t *rt,
109 nxt_pid_t pid, nxt_port_id_t id, nxt_process_type_t type);
110
110
111void nxt_runtime_port_add(nxt_task_t *task, nxt_port_t *port);
112
113void nxt_runtime_port_remove(nxt_task_t *task, nxt_port_t *port);
114
115NXT_EXPORT nxt_port_t *nxt_runtime_port_find(nxt_runtime_t *rt, nxt_pid_t pid,
116 nxt_port_id_t port_id);
117
118
119/* STUB */
120nxt_int_t nxt_runtime_controller_socket(nxt_task_t *task, nxt_runtime_t *rt);
121
122nxt_str_t *nxt_current_directory(nxt_mp_t *mp);
123
124nxt_listen_socket_t *nxt_runtime_listen_socket_add(nxt_runtime_t *rt,
125 nxt_sockaddr_t *sa);
126nxt_int_t nxt_runtime_listen_sockets_create(nxt_task_t *task,
127 nxt_runtime_t *rt);
128nxt_int_t nxt_runtime_listen_sockets_enable(nxt_task_t *task,
129 nxt_runtime_t *rt);
130nxt_file_t *nxt_runtime_log_file_add(nxt_runtime_t *rt, nxt_str_t *name);
131
132/* STUB */
133void nxt_cdecl nxt_log_time_handler(nxt_uint_t level, nxt_log_t *log,
134 const char *fmt, ...);
135
136void nxt_stream_connection_init(nxt_task_t *task, void *obj, void *data);
137
138
139#define nxt_runtime_process_each(rt, process) \
140 do { \
141 nxt_lvlhsh_each_t _lhe; \
142 nxt_process_t *_nxt; \
143 \
144 for (process = nxt_runtime_process_first(rt, &_lhe); \
145 process != NULL; \
146 process = _nxt) { \
147 \
148 _nxt = nxt_runtime_process_next(rt, &_lhe); \
149
150#define nxt_runtime_process_loop \
151 } \
152 } while(0)
153
154
155extern nxt_module_init_t nxt_init_modules[];
156extern nxt_uint_t nxt_init_modules_n;
157
158
159#endif /* _NXT_RUNTIME_H_INCLIDED_ */
111void nxt_runtime_port_remove(nxt_task_t *task, nxt_port_t *port);
112
113NXT_EXPORT nxt_port_t *nxt_runtime_port_find(nxt_runtime_t *rt, nxt_pid_t pid,
114 nxt_port_id_t port_id);
115
116
117/* STUB */
118nxt_int_t nxt_runtime_controller_socket(nxt_task_t *task, nxt_runtime_t *rt);
119
120nxt_str_t *nxt_current_directory(nxt_mp_t *mp);
121
122nxt_listen_socket_t *nxt_runtime_listen_socket_add(nxt_runtime_t *rt,
123 nxt_sockaddr_t *sa);
124nxt_int_t nxt_runtime_listen_sockets_create(nxt_task_t *task,
125 nxt_runtime_t *rt);
126nxt_int_t nxt_runtime_listen_sockets_enable(nxt_task_t *task,
127 nxt_runtime_t *rt);
128nxt_file_t *nxt_runtime_log_file_add(nxt_runtime_t *rt, nxt_str_t *name);
129
130/* STUB */
131void nxt_cdecl nxt_log_time_handler(nxt_uint_t level, nxt_log_t *log,
132 const char *fmt, ...);
133
134void nxt_stream_connection_init(nxt_task_t *task, void *obj, void *data);
135
136
137#define nxt_runtime_process_each(rt, process) \
138 do { \
139 nxt_lvlhsh_each_t _lhe; \
140 nxt_process_t *_nxt; \
141 \
142 for (process = nxt_runtime_process_first(rt, &_lhe); \
143 process != NULL; \
144 process = _nxt) { \
145 \
146 _nxt = nxt_runtime_process_next(rt, &_lhe); \
147
148#define nxt_runtime_process_loop \
149 } \
150 } while(0)
151
152
153extern nxt_module_init_t nxt_init_modules[];
154extern nxt_uint_t nxt_init_modules_n;
155
156
157#endif /* _NXT_RUNTIME_H_INCLIDED_ */