xref: /unit/src/nxt_main_process.c (revision 2078:0996dd223cdd)
1240Sigor@sysoev.ru 
2240Sigor@sysoev.ru /*
3240Sigor@sysoev.ru  * Copyright (C) Igor Sysoev
4240Sigor@sysoev.ru  * Copyright (C) NGINX, Inc.
5240Sigor@sysoev.ru  */
6240Sigor@sysoev.ru 
7240Sigor@sysoev.ru #include <nxt_main.h>
8240Sigor@sysoev.ru #include <nxt_runtime.h>
9240Sigor@sysoev.ru #include <nxt_port.h>
10240Sigor@sysoev.ru #include <nxt_main_process.h>
11240Sigor@sysoev.ru #include <nxt_conf.h>
12444Sigor@sysoev.ru #include <nxt_router.h>
131998St.nateldemoura@f5.com #include <nxt_port_queue.h>
14774Svbart@nginx.com #if (NXT_TLS)
15774Svbart@nginx.com #include <nxt_cert.h>
16774Svbart@nginx.com #endif
17240Sigor@sysoev.ru 
181489St.nateldemoura@f5.com #include <sys/mount.h>
191489St.nateldemoura@f5.com 
20240Sigor@sysoev.ru 
21240Sigor@sysoev.ru typedef struct {
22240Sigor@sysoev.ru     nxt_socket_t        socket;
23240Sigor@sysoev.ru     nxt_socket_error_t  error;
24240Sigor@sysoev.ru     u_char              *start;
25240Sigor@sysoev.ru     u_char              *end;
26240Sigor@sysoev.ru } nxt_listening_socket_t;
27240Sigor@sysoev.ru 
28240Sigor@sysoev.ru 
29510Salexander.borisov@nginx.com typedef struct {
30536Svbart@nginx.com     nxt_uint_t          size;
31536Svbart@nginx.com     nxt_conf_map_t      *map;
32546Smax.romanov@nginx.com } nxt_conf_app_map_t;
33510Salexander.borisov@nginx.com 
34510Salexander.borisov@nginx.com 
35240Sigor@sysoev.ru static nxt_int_t nxt_main_process_port_create(nxt_task_t *task,
36240Sigor@sysoev.ru     nxt_runtime_t *rt);
37240Sigor@sysoev.ru static void nxt_main_process_title(nxt_task_t *task);
38240Sigor@sysoev.ru static void nxt_main_process_sigterm_handler(nxt_task_t *task, void *obj,
39240Sigor@sysoev.ru     void *data);
40240Sigor@sysoev.ru static void nxt_main_process_sigquit_handler(nxt_task_t *task, void *obj,
41240Sigor@sysoev.ru     void *data);
42240Sigor@sysoev.ru static void nxt_main_process_sigusr1_handler(nxt_task_t *task, void *obj,
43240Sigor@sysoev.ru     void *data);
44240Sigor@sysoev.ru static void nxt_main_process_sigchld_handler(nxt_task_t *task, void *obj,
45240Sigor@sysoev.ru     void *data);
46944Sigor@sysoev.ru static void nxt_main_process_signal_handler(nxt_task_t *task, void *obj,
47944Sigor@sysoev.ru     void *data);
481997St.nateldemoura@f5.com static void nxt_main_process_cleanup(nxt_task_t *task, nxt_process_t *process);
49240Sigor@sysoev.ru static void nxt_main_port_socket_handler(nxt_task_t *task,
50240Sigor@sysoev.ru     nxt_port_recv_msg_t *msg);
51240Sigor@sysoev.ru static nxt_int_t nxt_main_listening_socket(nxt_sockaddr_t *sa,
52240Sigor@sysoev.ru     nxt_listening_socket_t *ls);
53240Sigor@sysoev.ru static void nxt_main_port_modules_handler(nxt_task_t *task,
54240Sigor@sysoev.ru     nxt_port_recv_msg_t *msg);
55240Sigor@sysoev.ru static int nxt_cdecl nxt_app_lang_compare(const void *v1, const void *v2);
561998St.nateldemoura@f5.com static void nxt_main_process_whoami_handler(nxt_task_t *task,
571998St.nateldemoura@f5.com     nxt_port_recv_msg_t *msg);
58314Svbart@nginx.com static void nxt_main_port_conf_store_handler(nxt_task_t *task,
59314Svbart@nginx.com     nxt_port_recv_msg_t *msg);
601969Sz.hong@f5.com static nxt_int_t nxt_main_file_store(nxt_task_t *task, const char *tmp_name,
611969Sz.hong@f5.com     const char *name, u_char *buf, size_t size);
62630Svbart@nginx.com static void nxt_main_port_access_log_handler(nxt_task_t *task,
63630Svbart@nginx.com     nxt_port_recv_msg_t *msg);
64240Sigor@sysoev.ru 
65240Sigor@sysoev.ru const nxt_sig_event_t  nxt_main_process_signals[] = {
66944Sigor@sysoev.ru     nxt_event_signal(SIGHUP,  nxt_main_process_signal_handler),
67240Sigor@sysoev.ru     nxt_event_signal(SIGINT,  nxt_main_process_sigterm_handler),
68240Sigor@sysoev.ru     nxt_event_signal(SIGQUIT, nxt_main_process_sigquit_handler),
69240Sigor@sysoev.ru     nxt_event_signal(SIGTERM, nxt_main_process_sigterm_handler),
70240Sigor@sysoev.ru     nxt_event_signal(SIGCHLD, nxt_main_process_sigchld_handler),
71240Sigor@sysoev.ru     nxt_event_signal(SIGUSR1, nxt_main_process_sigusr1_handler),
72240Sigor@sysoev.ru     nxt_event_signal_end,
73240Sigor@sysoev.ru };
74240Sigor@sysoev.ru 
75240Sigor@sysoev.ru 
761969Sz.hong@f5.com nxt_uint_t  nxt_conf_ver;
771969Sz.hong@f5.com 
78240Sigor@sysoev.ru static nxt_bool_t  nxt_exiting;
79240Sigor@sysoev.ru 
80240Sigor@sysoev.ru 
81240Sigor@sysoev.ru nxt_int_t
nxt_main_process_start(nxt_thread_t * thr,nxt_task_t * task,nxt_runtime_t * rt)82240Sigor@sysoev.ru nxt_main_process_start(nxt_thread_t *thr, nxt_task_t *task,
83240Sigor@sysoev.ru     nxt_runtime_t *rt)
84240Sigor@sysoev.ru {
85696Sigor@sysoev.ru     rt->type = NXT_PROCESS_MAIN;
86240Sigor@sysoev.ru 
87240Sigor@sysoev.ru     if (nxt_main_process_port_create(task, rt) != NXT_OK) {
88240Sigor@sysoev.ru         return NXT_ERROR;
89240Sigor@sysoev.ru     }
90240Sigor@sysoev.ru 
91240Sigor@sysoev.ru     nxt_main_process_title(task);
92240Sigor@sysoev.ru 
93240Sigor@sysoev.ru     /*
941488St.nateldemoura@f5.com      * The discovery process will send a message processed by
95240Sigor@sysoev.ru      * nxt_main_port_modules_handler() which starts the controller
96240Sigor@sysoev.ru      * and router processes.
97240Sigor@sysoev.ru      */
981997St.nateldemoura@f5.com     return nxt_process_init_start(task, nxt_discovery_process);
99240Sigor@sysoev.ru }
100240Sigor@sysoev.ru 
101240Sigor@sysoev.ru 
102240Sigor@sysoev.ru static nxt_conf_map_t  nxt_common_app_conf[] = {
103240Sigor@sysoev.ru     {
104240Sigor@sysoev.ru         nxt_string("type"),
105240Sigor@sysoev.ru         NXT_CONF_MAP_STR,
106240Sigor@sysoev.ru         offsetof(nxt_common_app_conf_t, type),
107240Sigor@sysoev.ru     },
108240Sigor@sysoev.ru 
109240Sigor@sysoev.ru     {
110240Sigor@sysoev.ru         nxt_string("user"),
111240Sigor@sysoev.ru         NXT_CONF_MAP_STR,
112240Sigor@sysoev.ru         offsetof(nxt_common_app_conf_t, user),
113240Sigor@sysoev.ru     },
114240Sigor@sysoev.ru 
115240Sigor@sysoev.ru     {
116240Sigor@sysoev.ru         nxt_string("group"),
117240Sigor@sysoev.ru         NXT_CONF_MAP_STR,
118240Sigor@sysoev.ru         offsetof(nxt_common_app_conf_t, group),
119240Sigor@sysoev.ru     },
120240Sigor@sysoev.ru 
121240Sigor@sysoev.ru     {
122271Smax.romanov@nginx.com         nxt_string("working_directory"),
123271Smax.romanov@nginx.com         NXT_CONF_MAP_CSTRZ,
124271Smax.romanov@nginx.com         offsetof(nxt_common_app_conf_t, working_directory),
125271Smax.romanov@nginx.com     },
126678Svbart@nginx.com 
127678Svbart@nginx.com     {
128678Svbart@nginx.com         nxt_string("environment"),
129678Svbart@nginx.com         NXT_CONF_MAP_PTR,
130678Svbart@nginx.com         offsetof(nxt_common_app_conf_t, environment),
131678Svbart@nginx.com     },
1321182St.nateldemoura@f5.com 
1331182St.nateldemoura@f5.com     {
1341182St.nateldemoura@f5.com         nxt_string("isolation"),
1351182St.nateldemoura@f5.com         NXT_CONF_MAP_PTR,
1361182St.nateldemoura@f5.com         offsetof(nxt_common_app_conf_t, isolation),
1371320Smax.romanov@nginx.com     },
1381320Smax.romanov@nginx.com 
1391320Smax.romanov@nginx.com     {
1401320Smax.romanov@nginx.com         nxt_string("limits"),
1411320Smax.romanov@nginx.com         NXT_CONF_MAP_PTR,
1421320Smax.romanov@nginx.com         offsetof(nxt_common_app_conf_t, limits),
1431320Smax.romanov@nginx.com     },
1441320Smax.romanov@nginx.com 
1451320Smax.romanov@nginx.com };
1461320Smax.romanov@nginx.com 
1471320Smax.romanov@nginx.com 
1481320Smax.romanov@nginx.com static nxt_conf_map_t  nxt_common_app_limits_conf[] = {
1491320Smax.romanov@nginx.com     {
1501320Smax.romanov@nginx.com         nxt_string("shm"),
1511320Smax.romanov@nginx.com         NXT_CONF_MAP_SIZE,
1521320Smax.romanov@nginx.com         offsetof(nxt_common_app_conf_t, shm_limit),
1531320Smax.romanov@nginx.com     },
1541320Smax.romanov@nginx.com 
1551980Smax.romanov@nginx.com     {
1561980Smax.romanov@nginx.com         nxt_string("requests"),
1571980Smax.romanov@nginx.com         NXT_CONF_MAP_INT32,
1581980Smax.romanov@nginx.com         offsetof(nxt_common_app_conf_t, request_limit),
1591980Smax.romanov@nginx.com     },
1601980Smax.romanov@nginx.com 
161510Salexander.borisov@nginx.com };
162271Smax.romanov@nginx.com 
163510Salexander.borisov@nginx.com 
164804Svbart@nginx.com static nxt_conf_map_t  nxt_external_app_conf[] = {
165804Svbart@nginx.com     {
166804Svbart@nginx.com         nxt_string("executable"),
167804Svbart@nginx.com         NXT_CONF_MAP_CSTRZ,
168804Svbart@nginx.com         offsetof(nxt_common_app_conf_t, u.external.executable),
169804Svbart@nginx.com     },
170804Svbart@nginx.com 
171804Svbart@nginx.com     {
172804Svbart@nginx.com         nxt_string("arguments"),
173804Svbart@nginx.com         NXT_CONF_MAP_PTR,
174804Svbart@nginx.com         offsetof(nxt_common_app_conf_t, u.external.arguments),
175804Svbart@nginx.com     },
176804Svbart@nginx.com 
177804Svbart@nginx.com };
178804Svbart@nginx.com 
179804Svbart@nginx.com 
180546Smax.romanov@nginx.com static nxt_conf_map_t  nxt_python_app_conf[] = {
181271Smax.romanov@nginx.com     {
182394Smax.romanov@nginx.com         nxt_string("home"),
183394Smax.romanov@nginx.com         NXT_CONF_MAP_CSTRZ,
184394Smax.romanov@nginx.com         offsetof(nxt_common_app_conf_t, u.python.home),
185394Smax.romanov@nginx.com     },
186394Smax.romanov@nginx.com 
187394Smax.romanov@nginx.com     {
188240Sigor@sysoev.ru         nxt_string("path"),
1891759Svbart@nginx.com         NXT_CONF_MAP_PTR,
190240Sigor@sysoev.ru         offsetof(nxt_common_app_conf_t, u.python.path),
191240Sigor@sysoev.ru     },
192240Sigor@sysoev.ru 
193240Sigor@sysoev.ru     {
194240Sigor@sysoev.ru         nxt_string("module"),
195240Sigor@sysoev.ru         NXT_CONF_MAP_STR,
196240Sigor@sysoev.ru         offsetof(nxt_common_app_conf_t, u.python.module),
197240Sigor@sysoev.ru     },
1981601Smax.romanov@nginx.com 
1991601Smax.romanov@nginx.com     {
2001601Smax.romanov@nginx.com         nxt_string("callable"),
2011601Smax.romanov@nginx.com         NXT_CONF_MAP_CSTRZ,
2021601Smax.romanov@nginx.com         offsetof(nxt_common_app_conf_t, u.python.callable),
2031601Smax.romanov@nginx.com     },
2041681Smax.romanov@nginx.com 
2051681Smax.romanov@nginx.com     {
2061697Smax.romanov@nginx.com         nxt_string("protocol"),
2071697Smax.romanov@nginx.com         NXT_CONF_MAP_STR,
2081697Smax.romanov@nginx.com         offsetof(nxt_common_app_conf_t, u.python.protocol),
2091697Smax.romanov@nginx.com     },
2101697Smax.romanov@nginx.com 
2111697Smax.romanov@nginx.com     {
2121681Smax.romanov@nginx.com         nxt_string("threads"),
2131681Smax.romanov@nginx.com         NXT_CONF_MAP_INT32,
2141681Smax.romanov@nginx.com         offsetof(nxt_common_app_conf_t, u.python.threads),
2151681Smax.romanov@nginx.com     },
2161681Smax.romanov@nginx.com 
2171681Smax.romanov@nginx.com     {
2181872So.canty@f5.com         nxt_string("targets"),
2191872So.canty@f5.com         NXT_CONF_MAP_PTR,
2201872So.canty@f5.com         offsetof(nxt_common_app_conf_t, u.python.targets),
2211872So.canty@f5.com     },
2221872So.canty@f5.com 
2231872So.canty@f5.com     {
2241681Smax.romanov@nginx.com         nxt_string("thread_stack_size"),
2251681Smax.romanov@nginx.com         NXT_CONF_MAP_INT32,
2261681Smax.romanov@nginx.com         offsetof(nxt_common_app_conf_t, u.python.thread_stack_size),
2271681Smax.romanov@nginx.com     },
228510Salexander.borisov@nginx.com };
229240Sigor@sysoev.ru 
230510Salexander.borisov@nginx.com 
231546Smax.romanov@nginx.com static nxt_conf_map_t  nxt_php_app_conf[] = {
232240Sigor@sysoev.ru     {
2331473Svbart@nginx.com         nxt_string("targets"),
2341473Svbart@nginx.com         NXT_CONF_MAP_PTR,
2351473Svbart@nginx.com         offsetof(nxt_common_app_conf_t, u.php.targets),
236240Sigor@sysoev.ru     },
237687Svbart@nginx.com 
238687Svbart@nginx.com     {
239687Svbart@nginx.com         nxt_string("options"),
240687Svbart@nginx.com         NXT_CONF_MAP_PTR,
241687Svbart@nginx.com         offsetof(nxt_common_app_conf_t, u.php.options),
242687Svbart@nginx.com     },
243510Salexander.borisov@nginx.com };
244240Sigor@sysoev.ru 
245510Salexander.borisov@nginx.com 
246546Smax.romanov@nginx.com static nxt_conf_map_t  nxt_perl_app_conf[] = {
247510Salexander.borisov@nginx.com     {
248510Salexander.borisov@nginx.com         nxt_string("script"),
249510Salexander.borisov@nginx.com         NXT_CONF_MAP_CSTRZ,
250510Salexander.borisov@nginx.com         offsetof(nxt_common_app_conf_t, u.perl.script),
251510Salexander.borisov@nginx.com     },
2521689Smax.romanov@nginx.com 
2531689Smax.romanov@nginx.com     {
2541689Smax.romanov@nginx.com         nxt_string("threads"),
2551689Smax.romanov@nginx.com         NXT_CONF_MAP_INT32,
2561689Smax.romanov@nginx.com         offsetof(nxt_common_app_conf_t, u.perl.threads),
2571689Smax.romanov@nginx.com     },
2581689Smax.romanov@nginx.com 
2591689Smax.romanov@nginx.com     {
2601689Smax.romanov@nginx.com         nxt_string("thread_stack_size"),
2611689Smax.romanov@nginx.com         NXT_CONF_MAP_INT32,
2621689Smax.romanov@nginx.com         offsetof(nxt_common_app_conf_t, u.perl.thread_stack_size),
2631689Smax.romanov@nginx.com     },
264510Salexander.borisov@nginx.com };
265510Salexander.borisov@nginx.com 
266510Salexander.borisov@nginx.com 
267584Salexander.borisov@nginx.com static nxt_conf_map_t  nxt_ruby_app_conf[] = {
268584Salexander.borisov@nginx.com     {
269584Salexander.borisov@nginx.com         nxt_string("script"),
270584Salexander.borisov@nginx.com         NXT_CONF_MAP_STR,
271584Salexander.borisov@nginx.com         offsetof(nxt_common_app_conf_t, u.ruby.script),
272584Salexander.borisov@nginx.com     },
2731687Smax.romanov@nginx.com     {
2741687Smax.romanov@nginx.com         nxt_string("threads"),
2751687Smax.romanov@nginx.com         NXT_CONF_MAP_INT32,
2761687Smax.romanov@nginx.com         offsetof(nxt_common_app_conf_t, u.ruby.threads),
2771687Smax.romanov@nginx.com     },
2781910So.canty@f5.com     {
2791910So.canty@f5.com         nxt_string("hooks"),
2801910So.canty@f5.com         NXT_CONF_MAP_STR,
2811910So.canty@f5.com         offsetof(nxt_common_app_conf_t, u.ruby.hooks),
2821910So.canty@f5.com     }
283584Salexander.borisov@nginx.com };
284584Salexander.borisov@nginx.com 
285584Salexander.borisov@nginx.com 
286977Smax.romanov@gmail.com static nxt_conf_map_t  nxt_java_app_conf[] = {
287977Smax.romanov@gmail.com     {
288977Smax.romanov@gmail.com         nxt_string("classpath"),
289977Smax.romanov@gmail.com         NXT_CONF_MAP_PTR,
290977Smax.romanov@gmail.com         offsetof(nxt_common_app_conf_t, u.java.classpath),
291977Smax.romanov@gmail.com     },
292977Smax.romanov@gmail.com     {
293977Smax.romanov@gmail.com         nxt_string("webapp"),
294977Smax.romanov@gmail.com         NXT_CONF_MAP_CSTRZ,
295977Smax.romanov@gmail.com         offsetof(nxt_common_app_conf_t, u.java.webapp),
296977Smax.romanov@gmail.com     },
297977Smax.romanov@gmail.com     {
298977Smax.romanov@gmail.com         nxt_string("options"),
299977Smax.romanov@gmail.com         NXT_CONF_MAP_PTR,
300977Smax.romanov@gmail.com         offsetof(nxt_common_app_conf_t, u.java.options),
301977Smax.romanov@gmail.com     },
302977Smax.romanov@gmail.com     {
303977Smax.romanov@gmail.com         nxt_string("unit_jars"),
304977Smax.romanov@gmail.com         NXT_CONF_MAP_CSTRZ,
305977Smax.romanov@gmail.com         offsetof(nxt_common_app_conf_t, u.java.unit_jars),
306977Smax.romanov@gmail.com     },
3071684Smax.romanov@nginx.com     {
3081684Smax.romanov@nginx.com         nxt_string("threads"),
3091684Smax.romanov@nginx.com         NXT_CONF_MAP_INT32,
3101684Smax.romanov@nginx.com         offsetof(nxt_common_app_conf_t, u.java.threads),
3111684Smax.romanov@nginx.com     },
3121684Smax.romanov@nginx.com     {
3131684Smax.romanov@nginx.com         nxt_string("thread_stack_size"),
3141684Smax.romanov@nginx.com         NXT_CONF_MAP_INT32,
3151684Smax.romanov@nginx.com         offsetof(nxt_common_app_conf_t, u.java.thread_stack_size),
3161684Smax.romanov@nginx.com     },
317977Smax.romanov@gmail.com 
318977Smax.romanov@gmail.com };
319977Smax.romanov@gmail.com 
320977Smax.romanov@gmail.com 
321546Smax.romanov@nginx.com static nxt_conf_app_map_t  nxt_app_maps[] = {
322804Svbart@nginx.com     { nxt_nitems(nxt_external_app_conf),  nxt_external_app_conf },
323804Svbart@nginx.com     { nxt_nitems(nxt_python_app_conf),    nxt_python_app_conf },
324804Svbart@nginx.com     { nxt_nitems(nxt_php_app_conf),       nxt_php_app_conf },
325804Svbart@nginx.com     { nxt_nitems(nxt_perl_app_conf),      nxt_perl_app_conf },
326804Svbart@nginx.com     { nxt_nitems(nxt_ruby_app_conf),      nxt_ruby_app_conf },
327977Smax.romanov@gmail.com     { nxt_nitems(nxt_java_app_conf),      nxt_java_app_conf },
328510Salexander.borisov@nginx.com };
329510Salexander.borisov@nginx.com 
330510Salexander.borisov@nginx.com 
331240Sigor@sysoev.ru static void
nxt_main_data_handler(nxt_task_t * task,nxt_port_recv_msg_t * msg)3321998St.nateldemoura@f5.com nxt_main_data_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
333240Sigor@sysoev.ru {
334240Sigor@sysoev.ru     nxt_debug(task, "main data: %*s",
335240Sigor@sysoev.ru               nxt_buf_mem_used_size(&msg->buf->mem), msg->buf->mem.pos);
336240Sigor@sysoev.ru }
337240Sigor@sysoev.ru 
338240Sigor@sysoev.ru 
339240Sigor@sysoev.ru static void
nxt_main_new_port_handler(nxt_task_t * task,nxt_port_recv_msg_t * msg)3401998St.nateldemoura@f5.com nxt_main_new_port_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
3411998St.nateldemoura@f5.com {
3421998St.nateldemoura@f5.com     void        *mem;
3431998St.nateldemoura@f5.com     nxt_port_t  *port;
3441998St.nateldemoura@f5.com 
3451998St.nateldemoura@f5.com     nxt_port_new_port_handler(task, msg);
3461998St.nateldemoura@f5.com 
3471998St.nateldemoura@f5.com     port = msg->u.new_port;
3481998St.nateldemoura@f5.com 
3491998St.nateldemoura@f5.com     if (port != NULL
3501998St.nateldemoura@f5.com         && port->type == NXT_PROCESS_APP
3511998St.nateldemoura@f5.com         && msg->fd[1] != -1)
3521998St.nateldemoura@f5.com     {
3531998St.nateldemoura@f5.com         mem = nxt_mem_mmap(NULL, sizeof(nxt_port_queue_t),
3541998St.nateldemoura@f5.com                            PROT_READ | PROT_WRITE, MAP_SHARED, msg->fd[1], 0);
3551998St.nateldemoura@f5.com         if (nxt_fast_path(mem != MAP_FAILED)) {
3561998St.nateldemoura@f5.com             port->queue = mem;
3571998St.nateldemoura@f5.com         }
3581998St.nateldemoura@f5.com 
3591998St.nateldemoura@f5.com         nxt_fd_close(msg->fd[1]);
3601998St.nateldemoura@f5.com         msg->fd[1] = -1;
3611998St.nateldemoura@f5.com     }
3621998St.nateldemoura@f5.com }
3631998St.nateldemoura@f5.com 
3641998St.nateldemoura@f5.com 
3651998St.nateldemoura@f5.com static void
nxt_main_start_process_handler(nxt_task_t * task,nxt_port_recv_msg_t * msg)3661998St.nateldemoura@f5.com nxt_main_start_process_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
367240Sigor@sysoev.ru {
3681488St.nateldemoura@f5.com     u_char                 *start, *p, ch;
369536Svbart@nginx.com     size_t                 type_len;
370536Svbart@nginx.com     nxt_int_t              ret;
371240Sigor@sysoev.ru     nxt_buf_t              *b;
372318Smax.romanov@nginx.com     nxt_port_t             *port;
3731182St.nateldemoura@f5.com     nxt_runtime_t          *rt;
3741488St.nateldemoura@f5.com     nxt_process_t          *process;
375536Svbart@nginx.com     nxt_app_type_t         idx;
376240Sigor@sysoev.ru     nxt_conf_value_t       *conf;
3771488St.nateldemoura@f5.com     nxt_process_init_t     *init;
3781488St.nateldemoura@f5.com     nxt_common_app_conf_t  *app_conf;
379240Sigor@sysoev.ru 
3801488St.nateldemoura@f5.com     rt = task->thread->runtime;
381352Smax.romanov@nginx.com 
3821996St.nateldemoura@f5.com     port = rt->port_by_type[NXT_PROCESS_ROUTER];
3831996St.nateldemoura@f5.com     if (nxt_slow_path(port == NULL)) {
3841996St.nateldemoura@f5.com         nxt_alert(task, "router port not found");
3852014Smax.romanov@nginx.com         goto close_fds;
3861996St.nateldemoura@f5.com     }
3871996St.nateldemoura@f5.com 
3881996St.nateldemoura@f5.com     if (nxt_slow_path(port->pid != nxt_recv_msg_cmsg_pid(msg))) {
3891996St.nateldemoura@f5.com         nxt_alert(task, "process %PI cannot start processes",
3901996St.nateldemoura@f5.com                   nxt_recv_msg_cmsg_pid(msg));
3911996St.nateldemoura@f5.com 
3922014Smax.romanov@nginx.com         goto close_fds;
3931996St.nateldemoura@f5.com     }
3941996St.nateldemoura@f5.com 
3951997St.nateldemoura@f5.com     process = nxt_process_new(rt);
3961488St.nateldemoura@f5.com     if (nxt_slow_path(process == NULL)) {
3972014Smax.romanov@nginx.com         goto close_fds;
398352Smax.romanov@nginx.com     }
399352Smax.romanov@nginx.com 
4001997St.nateldemoura@f5.com     process->mem_pool = nxt_mp_create(1024, 128, 256, 32);
4011997St.nateldemoura@f5.com     if (process->mem_pool == NULL) {
4021997St.nateldemoura@f5.com         nxt_process_use(task, process, -1);
4032014Smax.romanov@nginx.com         goto close_fds;
4041997St.nateldemoura@f5.com     }
4051997St.nateldemoura@f5.com 
4061998St.nateldemoura@f5.com     process->parent_port = rt->port_by_type[NXT_PROCESS_MAIN];
4071998St.nateldemoura@f5.com 
4081488St.nateldemoura@f5.com     init = nxt_process_init(process);
4091488St.nateldemoura@f5.com 
4101998St.nateldemoura@f5.com     *init = nxt_proto_process;
411352Smax.romanov@nginx.com 
4121488St.nateldemoura@f5.com     b = nxt_buf_chk_make_plain(process->mem_pool, msg->buf, msg->size);
413352Smax.romanov@nginx.com     if (b == NULL) {
4141488St.nateldemoura@f5.com         goto failed;
415352Smax.romanov@nginx.com     }
416240Sigor@sysoev.ru 
4171998St.nateldemoura@f5.com     nxt_debug(task, "main start prototype: %*s", b->mem.free - b->mem.pos,
418240Sigor@sysoev.ru               b->mem.pos);
419240Sigor@sysoev.ru 
4201488St.nateldemoura@f5.com     app_conf = nxt_mp_zalloc(process->mem_pool, sizeof(nxt_common_app_conf_t));
4211488St.nateldemoura@f5.com     if (nxt_slow_path(app_conf == NULL)) {
4221488St.nateldemoura@f5.com         goto failed;
4231488St.nateldemoura@f5.com     }
424240Sigor@sysoev.ru 
4252014Smax.romanov@nginx.com     app_conf->shared_port_fd = msg->fd[0];
4262014Smax.romanov@nginx.com     app_conf->shared_queue_fd = msg->fd[1];
4272014Smax.romanov@nginx.com 
428240Sigor@sysoev.ru     start = b->mem.pos;
429240Sigor@sysoev.ru 
4301488St.nateldemoura@f5.com     app_conf->name.start = start;
4311488St.nateldemoura@f5.com     app_conf->name.length = nxt_strlen(start);
4321488St.nateldemoura@f5.com 
4331488St.nateldemoura@f5.com     init->name = (const char *) start;
4341488St.nateldemoura@f5.com 
4351488St.nateldemoura@f5.com     process->name = nxt_mp_alloc(process->mem_pool, app_conf->name.length
4361998St.nateldemoura@f5.com                                  + sizeof("\"\" prototype") + 1);
4371488St.nateldemoura@f5.com 
4381488St.nateldemoura@f5.com     if (nxt_slow_path(process->name == NULL)) {
4391488St.nateldemoura@f5.com         goto failed;
4401488St.nateldemoura@f5.com     }
441240Sigor@sysoev.ru 
4421488St.nateldemoura@f5.com     p = (u_char *) process->name;
4431488St.nateldemoura@f5.com     *p++ = '"';
4441488St.nateldemoura@f5.com     p = nxt_cpymem(p, init->name, app_conf->name.length);
4451998St.nateldemoura@f5.com     p = nxt_cpymem(p, "\" prototype", 11);
4461488St.nateldemoura@f5.com     *p = '\0';
447240Sigor@sysoev.ru 
4481488St.nateldemoura@f5.com     app_conf->shm_limit = 100 * 1024 * 1024;
4491980Smax.romanov@nginx.com     app_conf->request_limit = 0;
450240Sigor@sysoev.ru 
4511488St.nateldemoura@f5.com     start += app_conf->name.length + 1;
4521488St.nateldemoura@f5.com 
4531488St.nateldemoura@f5.com     conf = nxt_conf_json_parse(process->mem_pool, start, b->mem.free, NULL);
454240Sigor@sysoev.ru     if (conf == NULL) {
455564Svbart@nginx.com         nxt_alert(task, "router app configuration parsing error");
456318Smax.romanov@nginx.com 
457318Smax.romanov@nginx.com         goto failed;
458240Sigor@sysoev.ru     }
459240Sigor@sysoev.ru 
4601182St.nateldemoura@f5.com     rt = task->thread->runtime;
4611182St.nateldemoura@f5.com 
4621488St.nateldemoura@f5.com     app_conf->user.start  = (u_char*)rt->user_cred.user;
4631488St.nateldemoura@f5.com     app_conf->user.length = nxt_strlen(rt->user_cred.user);
464240Sigor@sysoev.ru 
4651488St.nateldemoura@f5.com     ret = nxt_conf_map_object(process->mem_pool, conf, nxt_common_app_conf,
4661488St.nateldemoura@f5.com                               nxt_nitems(nxt_common_app_conf), app_conf);
4671488St.nateldemoura@f5.com 
468240Sigor@sysoev.ru     if (ret != NXT_OK) {
469564Svbart@nginx.com         nxt_alert(task, "failed to map common app conf received from router");
470318Smax.romanov@nginx.com         goto failed;
471240Sigor@sysoev.ru     }
472240Sigor@sysoev.ru 
4731488St.nateldemoura@f5.com     for (type_len = 0; type_len != app_conf->type.length; type_len++) {
4741488St.nateldemoura@f5.com         ch = app_conf->type.start[type_len];
475536Svbart@nginx.com 
476536Svbart@nginx.com         if (ch == ' ' || nxt_isdigit(ch)) {
477536Svbart@nginx.com             break;
478536Svbart@nginx.com         }
479536Svbart@nginx.com     }
480536Svbart@nginx.com 
4811488St.nateldemoura@f5.com     idx = nxt_app_parse_type(app_conf->type.start, type_len);
482510Salexander.borisov@nginx.com 
483546Smax.romanov@nginx.com     if (nxt_slow_path(idx >= nxt_nitems(nxt_app_maps))) {
484564Svbart@nginx.com         nxt_alert(task, "invalid app type %d received from router", (int) idx);
485546Smax.romanov@nginx.com         goto failed;
486546Smax.romanov@nginx.com     }
487510Salexander.borisov@nginx.com 
4881488St.nateldemoura@f5.com     ret = nxt_conf_map_object(process->mem_pool, conf, nxt_app_maps[idx].map,
4891488St.nateldemoura@f5.com                               nxt_app_maps[idx].size, app_conf);
490510Salexander.borisov@nginx.com 
491546Smax.romanov@nginx.com     if (nxt_slow_path(ret != NXT_OK)) {
492564Svbart@nginx.com         nxt_alert(task, "failed to map app conf received from router");
493546Smax.romanov@nginx.com         goto failed;
494546Smax.romanov@nginx.com     }
495510Salexander.borisov@nginx.com 
4961488St.nateldemoura@f5.com     if (app_conf->limits != NULL) {
4971488St.nateldemoura@f5.com         ret = nxt_conf_map_object(process->mem_pool, app_conf->limits,
4981320Smax.romanov@nginx.com                                   nxt_common_app_limits_conf,
4991320Smax.romanov@nginx.com                                   nxt_nitems(nxt_common_app_limits_conf),
5001488St.nateldemoura@f5.com                                   app_conf);
5011320Smax.romanov@nginx.com 
5021320Smax.romanov@nginx.com         if (nxt_slow_path(ret != NXT_OK)) {
5031320Smax.romanov@nginx.com             nxt_alert(task, "failed to map app limits received from router");
5041320Smax.romanov@nginx.com             goto failed;
5051320Smax.romanov@nginx.com         }
5061320Smax.romanov@nginx.com     }
5071320Smax.romanov@nginx.com 
5081488St.nateldemoura@f5.com     app_conf->self = conf;
5091488St.nateldemoura@f5.com 
5101488St.nateldemoura@f5.com     process->stream = msg->port_msg.stream;
5111488St.nateldemoura@f5.com     process->data.app = app_conf;
5121473Svbart@nginx.com 
5131997St.nateldemoura@f5.com     ret = nxt_process_start(task, process);
5141488St.nateldemoura@f5.com     if (nxt_fast_path(ret == NXT_OK || ret == NXT_AGAIN)) {
5152014Smax.romanov@nginx.com 
5162014Smax.romanov@nginx.com         /* Close shared port fds only in main process. */
5172014Smax.romanov@nginx.com         if (ret == NXT_OK) {
5182014Smax.romanov@nginx.com             nxt_fd_close(app_conf->shared_port_fd);
5192014Smax.romanov@nginx.com             nxt_fd_close(app_conf->shared_queue_fd);
5202014Smax.romanov@nginx.com         }
5212014Smax.romanov@nginx.com 
5222014Smax.romanov@nginx.com         /* Avoid fds close in caller. */
5232014Smax.romanov@nginx.com         msg->fd[0] = -1;
5242014Smax.romanov@nginx.com         msg->fd[1] = -1;
5252014Smax.romanov@nginx.com 
5261488St.nateldemoura@f5.com         return;
5271488St.nateldemoura@f5.com     }
528240Sigor@sysoev.ru 
529318Smax.romanov@nginx.com failed:
530318Smax.romanov@nginx.com 
5311488St.nateldemoura@f5.com     nxt_process_use(task, process, -1);
5321488St.nateldemoura@f5.com 
5331488St.nateldemoura@f5.com     port = nxt_runtime_port_find(rt, msg->port_msg.pid,
5341488St.nateldemoura@f5.com                                  msg->port_msg.reply_port);
5351488St.nateldemoura@f5.com 
5361488St.nateldemoura@f5.com     if (nxt_fast_path(port != NULL)) {
5371488St.nateldemoura@f5.com         nxt_port_socket_write(task, port, NXT_PORT_MSG_RPC_ERROR,
5381488St.nateldemoura@f5.com                               -1, msg->port_msg.stream, 0, NULL);
5391488St.nateldemoura@f5.com     }
5402014Smax.romanov@nginx.com 
5412014Smax.romanov@nginx.com close_fds:
5422014Smax.romanov@nginx.com 
5432014Smax.romanov@nginx.com     nxt_fd_close(msg->fd[0]);
5442014Smax.romanov@nginx.com     msg->fd[0] = -1;
5452014Smax.romanov@nginx.com 
5462014Smax.romanov@nginx.com     nxt_fd_close(msg->fd[1]);
5472014Smax.romanov@nginx.com     msg->fd[1] = -1;
5481488St.nateldemoura@f5.com }
5491488St.nateldemoura@f5.com 
5501488St.nateldemoura@f5.com 
5511488St.nateldemoura@f5.com static void
nxt_main_process_created_handler(nxt_task_t * task,nxt_port_recv_msg_t * msg)5521488St.nateldemoura@f5.com nxt_main_process_created_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
5531488St.nateldemoura@f5.com {
5541488St.nateldemoura@f5.com     nxt_port_t     *port;
5551488St.nateldemoura@f5.com     nxt_process_t  *process;
5561488St.nateldemoura@f5.com     nxt_runtime_t  *rt;
5571488St.nateldemoura@f5.com 
5581488St.nateldemoura@f5.com     rt = task->thread->runtime;
5591488St.nateldemoura@f5.com 
5601998St.nateldemoura@f5.com     port = nxt_runtime_port_find(rt, msg->port_msg.pid,
5611998St.nateldemoura@f5.com                                  msg->port_msg.reply_port);
5621998St.nateldemoura@f5.com     if (nxt_slow_path(port == NULL)) {
5631488St.nateldemoura@f5.com         return;
564318Smax.romanov@nginx.com     }
565318Smax.romanov@nginx.com 
5661998St.nateldemoura@f5.com     process = port->process;
5671488St.nateldemoura@f5.com 
5681998St.nateldemoura@f5.com     nxt_assert(process != NULL);
5691998St.nateldemoura@f5.com     nxt_assert(process->state == NXT_PROCESS_STATE_CREATING);
5701488St.nateldemoura@f5.com 
5711488St.nateldemoura@f5.com #if (NXT_HAVE_CLONE && NXT_HAVE_CLONE_NEWUSER)
5721488St.nateldemoura@f5.com     if (nxt_is_clone_flag_set(process->isolation.clone.flags, NEWUSER)) {
5731488St.nateldemoura@f5.com         if (nxt_slow_path(nxt_clone_credential_map(task, process->pid,
5741488St.nateldemoura@f5.com                                                    process->user_cred,
5751488St.nateldemoura@f5.com                                                    &process->isolation.clone)
5761488St.nateldemoura@f5.com                           != NXT_OK))
5771488St.nateldemoura@f5.com         {
5781488St.nateldemoura@f5.com             (void) nxt_port_socket_write(task, port, NXT_PORT_MSG_RPC_ERROR,
5791488St.nateldemoura@f5.com                                          -1, msg->port_msg.stream, 0, NULL);
5801488St.nateldemoura@f5.com             return;
5811488St.nateldemoura@f5.com         }
582*2078Salx.manpages@gmail.com     }
5831488St.nateldemoura@f5.com 
5841488St.nateldemoura@f5.com #endif
5851488St.nateldemoura@f5.com 
5861488St.nateldemoura@f5.com     process->state = NXT_PROCESS_STATE_CREATED;
5871488St.nateldemoura@f5.com 
5881488St.nateldemoura@f5.com     (void) nxt_port_socket_write(task, port, NXT_PORT_MSG_RPC_READY_LAST,
5891488St.nateldemoura@f5.com                                  -1, msg->port_msg.stream, 0, NULL);
590240Sigor@sysoev.ru }
591240Sigor@sysoev.ru 
592240Sigor@sysoev.ru 
593320Smax.romanov@nginx.com static nxt_port_handlers_t  nxt_main_process_port_handlers = {
5941998St.nateldemoura@f5.com     .data             = nxt_main_data_handler,
5951998St.nateldemoura@f5.com     .new_port         = nxt_main_new_port_handler,
5961488St.nateldemoura@f5.com     .process_created  = nxt_main_process_created_handler,
5971488St.nateldemoura@f5.com     .process_ready    = nxt_port_process_ready_handler,
5981998St.nateldemoura@f5.com     .whoami           = nxt_main_process_whoami_handler,
5991998St.nateldemoura@f5.com     .remove_pid       = nxt_port_remove_pid_handler,
6001998St.nateldemoura@f5.com     .start_process    = nxt_main_start_process_handler,
6011488St.nateldemoura@f5.com     .socket           = nxt_main_port_socket_handler,
6021488St.nateldemoura@f5.com     .modules          = nxt_main_port_modules_handler,
6031488St.nateldemoura@f5.com     .conf_store       = nxt_main_port_conf_store_handler,
604774Svbart@nginx.com #if (NXT_TLS)
6051488St.nateldemoura@f5.com     .cert_get         = nxt_cert_store_get_handler,
6061488St.nateldemoura@f5.com     .cert_delete      = nxt_cert_store_delete_handler,
607774Svbart@nginx.com #endif
6081488St.nateldemoura@f5.com     .access_log       = nxt_main_port_access_log_handler,
6091488St.nateldemoura@f5.com     .rpc_ready        = nxt_port_rpc_handler,
6101488St.nateldemoura@f5.com     .rpc_error        = nxt_port_rpc_handler,
611240Sigor@sysoev.ru };
612240Sigor@sysoev.ru 
613240Sigor@sysoev.ru 
6141998St.nateldemoura@f5.com static void
nxt_main_process_whoami_handler(nxt_task_t * task,nxt_port_recv_msg_t * msg)6151998St.nateldemoura@f5.com nxt_main_process_whoami_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
6161998St.nateldemoura@f5.com {
6171998St.nateldemoura@f5.com     nxt_buf_t      *buf;
6181998St.nateldemoura@f5.com     nxt_pid_t      pid, ppid;
6191998St.nateldemoura@f5.com     nxt_port_t     *port;
6201998St.nateldemoura@f5.com     nxt_runtime_t  *rt;
6211998St.nateldemoura@f5.com     nxt_process_t  *pprocess;
6221998St.nateldemoura@f5.com 
6231998St.nateldemoura@f5.com     nxt_assert(msg->port_msg.reply_port == 0);
6241998St.nateldemoura@f5.com 
6251998St.nateldemoura@f5.com     if (nxt_slow_path(msg->buf == NULL
6261998St.nateldemoura@f5.com         || nxt_buf_used_size(msg->buf) != sizeof(nxt_pid_t)))
6271998St.nateldemoura@f5.com     {
6281998St.nateldemoura@f5.com         nxt_alert(task, "whoami: buffer is NULL or unexpected size");
6291998St.nateldemoura@f5.com         goto fail;
6301998St.nateldemoura@f5.com     }
6311998St.nateldemoura@f5.com 
6321998St.nateldemoura@f5.com     nxt_memcpy(&ppid, msg->buf->mem.pos, sizeof(nxt_pid_t));
6331998St.nateldemoura@f5.com 
6341998St.nateldemoura@f5.com     rt = task->thread->runtime;
6351998St.nateldemoura@f5.com 
6361998St.nateldemoura@f5.com     pprocess = nxt_runtime_process_find(rt, ppid);
6371998St.nateldemoura@f5.com     if (nxt_slow_path(pprocess == NULL)) {
6381998St.nateldemoura@f5.com         nxt_alert(task, "whoami: parent process %PI not found", ppid);
6391998St.nateldemoura@f5.com         goto fail;
6401998St.nateldemoura@f5.com     }
6411998St.nateldemoura@f5.com 
6421998St.nateldemoura@f5.com     pid = nxt_recv_msg_cmsg_pid(msg);
6431998St.nateldemoura@f5.com 
6441998St.nateldemoura@f5.com     nxt_debug(task, "whoami: from %PI, parent %PI, fd %d", pid, ppid,
6451998St.nateldemoura@f5.com               msg->fd[0]);
6461998St.nateldemoura@f5.com 
6471998St.nateldemoura@f5.com     if (msg->fd[0] != -1) {
6481998St.nateldemoura@f5.com         port = nxt_runtime_process_port_create(task, rt, pid, 0,
6491998St.nateldemoura@f5.com                                                NXT_PROCESS_APP);
6501998St.nateldemoura@f5.com         if (nxt_slow_path(port == NULL)) {
6511998St.nateldemoura@f5.com             goto fail;
6521998St.nateldemoura@f5.com         }
6531998St.nateldemoura@f5.com 
6541998St.nateldemoura@f5.com         nxt_fd_nonblocking(task, msg->fd[0]);
6551998St.nateldemoura@f5.com 
6561998St.nateldemoura@f5.com         port->pair[0] = -1;
6571998St.nateldemoura@f5.com         port->pair[1] = msg->fd[0];
6581998St.nateldemoura@f5.com         msg->fd[0] = -1;
6591998St.nateldemoura@f5.com 
6601998St.nateldemoura@f5.com         port->max_size = 16 * 1024;
6611998St.nateldemoura@f5.com         port->max_share = 64 * 1024;
6621998St.nateldemoura@f5.com         port->socket.task = task;
6631998St.nateldemoura@f5.com 
6641998St.nateldemoura@f5.com         nxt_port_write_enable(task, port);
6651998St.nateldemoura@f5.com 
6661998St.nateldemoura@f5.com     } else {
6671998St.nateldemoura@f5.com         port = nxt_runtime_port_find(rt, pid, 0);
6681998St.nateldemoura@f5.com         if (nxt_slow_path(port == NULL)) {
6691998St.nateldemoura@f5.com             goto fail;
6701998St.nateldemoura@f5.com         }
6711998St.nateldemoura@f5.com     }
6721998St.nateldemoura@f5.com 
6731998St.nateldemoura@f5.com     if (ppid != nxt_pid) {
6741998St.nateldemoura@f5.com         nxt_queue_insert_tail(&pprocess->children, &port->process->link);
6751998St.nateldemoura@f5.com     }
6761998St.nateldemoura@f5.com 
6771998St.nateldemoura@f5.com     buf = nxt_buf_mem_alloc(task->thread->engine->mem_pool,
6781998St.nateldemoura@f5.com                             sizeof(nxt_pid_t), 0);
6791998St.nateldemoura@f5.com     if (nxt_slow_path(buf == NULL)) {
6801998St.nateldemoura@f5.com         goto fail;
6811998St.nateldemoura@f5.com     }
6821998St.nateldemoura@f5.com 
6831998St.nateldemoura@f5.com     buf->mem.free = nxt_cpymem(buf->mem.free, &pid, sizeof(nxt_pid_t));
6841998St.nateldemoura@f5.com 
6851998St.nateldemoura@f5.com     (void) nxt_port_socket_write(task, port, NXT_PORT_MSG_RPC_READY_LAST, -1,
6861998St.nateldemoura@f5.com                                  msg->port_msg.stream, 0, buf);
6871998St.nateldemoura@f5.com 
6881998St.nateldemoura@f5.com fail:
6891998St.nateldemoura@f5.com 
6901998St.nateldemoura@f5.com     if (msg->fd[0] != -1) {
6911998St.nateldemoura@f5.com         nxt_fd_close(msg->fd[0]);
6921998St.nateldemoura@f5.com     }
6931998St.nateldemoura@f5.com }
6941998St.nateldemoura@f5.com 
6951998St.nateldemoura@f5.com 
696240Sigor@sysoev.ru static nxt_int_t
nxt_main_process_port_create(nxt_task_t * task,nxt_runtime_t * rt)697240Sigor@sysoev.ru nxt_main_process_port_create(nxt_task_t *task, nxt_runtime_t *rt)
698240Sigor@sysoev.ru {
699240Sigor@sysoev.ru     nxt_int_t      ret;
700240Sigor@sysoev.ru     nxt_port_t     *port;
701240Sigor@sysoev.ru     nxt_process_t  *process;
702240Sigor@sysoev.ru 
7031254Shongzhidao@gmail.com     port = nxt_runtime_process_port_create(task, rt, nxt_pid, 0,
7041254Shongzhidao@gmail.com                                            NXT_PROCESS_MAIN);
705240Sigor@sysoev.ru     if (nxt_slow_path(port == NULL)) {
706240Sigor@sysoev.ru         return NXT_ERROR;
707240Sigor@sysoev.ru     }
708240Sigor@sysoev.ru 
7091254Shongzhidao@gmail.com     process = port->process;
710349Smax.romanov@nginx.com 
711240Sigor@sysoev.ru     ret = nxt_port_socket_init(task, port, 0);
712240Sigor@sysoev.ru     if (nxt_slow_path(ret != NXT_OK)) {
7131488St.nateldemoura@f5.com         nxt_port_use(task, port, -1);
714240Sigor@sysoev.ru         return ret;
715240Sigor@sysoev.ru     }
716240Sigor@sysoev.ru 
717240Sigor@sysoev.ru     /*
718240Sigor@sysoev.ru      * A main process port.  A write port is not closed
7191488St.nateldemoura@f5.com      * since it should be inherited by processes.
720240Sigor@sysoev.ru      */
721320Smax.romanov@nginx.com     nxt_port_enable(task, port, &nxt_main_process_port_handlers);
722240Sigor@sysoev.ru 
7231488St.nateldemoura@f5.com     process->state = NXT_PROCESS_STATE_READY;
724